#' GPV curves APP shiny server function
#' @return shiny UI
#' @export
app_gpv <- function() {
# UI
ui <- shiny::fluidPage(
## Application title
shiny::titlePanel("RIKO Control Valve"),
## Sidebar
shiny::sidebarLayout(
shiny::sidebarPanel(
select_cylinder("cylinder", "VAG"),
select_diameter("diameter"),
shiny::hr(style = "border-top: 1px solid #000000;"),
shiny::sliderInput("masl",
label = "Localization above sea level (m):",
value = 0, min = 0, max = 4000),
shiny::sliderInput("temperature",
label = "Water Temperature (Celcius):",
value = 20, min = 5, max = 30),
shiny::hr(style = "border-top: 1px solid #000000;"),
op_data_input_ui("operation_datatable"),
shiny::actionButton("go",label = "Plot Data")
),
## Show plot
shiny::mainPanel(
shiny::tabsetPanel(
shiny::tabPanel("Table", DT::DTOutput("table"),
hr(),
helpText("NOTE: The table only shows the values
of operation that the Kv <= Kvs.")),
shiny::tabPanel("Kv Plot", plotOutput("kv_plot")),
shiny::tabPanel("Zeta Plot", plotOutput("z_plot")),
shiny::tabPanel("Sigma Plot", plotOutput("s_plot")),
)
)
)
)
# SERVER
server <- function(input, output, session) {
## Initialize a blank data-frame
v <- shiny::reactiveValues(data = {
initialize_df(6) # insert the number of observations data
})
## Module for Interact with the input of Operations data
op_data_input_server("operation_datatable", op_data = v)
## Cylinder parameter
gpv_data <- shiny::reactive({
cylinder_parameter("VAG") # insert the Band
})
## Calculation of the Operations point Table
op_points <- shiny::reactive({
operation_points(v$data, "VAG", input$cylinder,
as.numeric(input$diameter),
as.numeric(input$masl),
as.numeric(input$temperature))
})
output$table <- DT::renderDT({
## Require the input button to be non-0
shiny::req(input$go)
## print the Operations point Table
tab_op_points(op_points())
})
## Render plot Kv Value
output$kv_plot <- renderPlot({
shiny::req(input$go)
plot_curves("kv", "VAG",
input$cylinder,
as.numeric(input$diameter),
op_points())
})
## Render plot Zeta Values
output$z_plot <- renderPlot({
shiny::req(input$go)
plot_curves("zv", "VAG",
input$cylinder,
as.numeric(input$diameter),
op_points())
})
## Render plot Sigma Values
output$s_plot <- renderPlot({
shiny::req(input$go)
plot_curves("sigma", "VAG",
input$cylinder,
as.numeric(input$diameter),
op_points())
})
}
# SHINY
shiny::shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.