Skip to content

Commit

Permalink
update pilot gui and install/setup instructions #46
Browse files Browse the repository at this point in the history
  • Loading branch information
bstabler committed Feb 24, 2017
1 parent 3e5d038 commit cdc4825
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -46,6 +46,7 @@ source("run_model.R")

```
library("shiny")
library("shinyFiles")
runGitHub( "gregorbj/VisionEval", subdir="sources/VEGUI")
```

Expand Down
13 changes: 13 additions & 0 deletions sources/VEGUI/README.md
Expand Up @@ -8,6 +8,7 @@ VisionEval R Shiny GUI and Scenario Viewer (Visualizer)

```
install.packages("shiny")
install.packages("shinyFiles")
```

# Running VE GUI
Expand All @@ -16,5 +17,17 @@ install.packages("shiny")

```
library("shiny")
library("shinyFiles")
runGitHub( "gregorbj/VisionEval", subdir="sources/VEGUI")
```

3. Or run it from within R with:

```
library("shiny")
library("shinyFiles")
full_path_to_VEGUI = "C:/projects/development/VisionEval/sources/VEGUI"
setwd(full_path_to_VEGUI)
runApp('../VEGUI')
```
39 changes: 25 additions & 14 deletions sources/VEGUI/server.R
@@ -1,20 +1,31 @@
library(shiny)
library(shinyFiles)
library(visioneval)

# Define server logic required to draw a histogram
# Define server logic
shinyServer(function(input, output) {

#file picker
shinyFileChoose(input, 'file', root=getVolumes(''), filetypes=c('', 'R'))

#run model on file name change
observeEvent(input$file, {

#parse script name
inFile = parseFilePaths(roots=getVolumes(''), input$file)
scriptName = as.character(inFile$datapath)
output$filepath = renderPrint( { scriptName } )

#run model
setwd(dirname(scriptName))
output$scriptprint = renderPrint( {
capture.output(source(scriptName, local=FALSE)) #sourced in global environment
} )

#read resulting datastore
datastorePrint = capture.output(getModelState("Datastore"))
output$datastorelist = renderPrint( { datastorePrint } )

# Expression that generates a histogram. The expression is
# wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should re-execute automatically
# when inputs change
# 2) Its output type is a plot
})

output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)

# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})
43 changes: 26 additions & 17 deletions sources/VEGUI/ui.R
@@ -1,24 +1,33 @@
library(shiny)
library(shinyFiles)

# Define UI for application that draws a histogram
# Define UI for application
shinyUI(fluidPage(

# Application title
titlePanel("VisionEval"),
titlePanel("Pilot Model Runner and Scenario Viewer"),

# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),

# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot")
sidebarLayout(

sidebarPanel(

img(src="visioneval_logo.png", height=100, width=100, style="margin:10px 10px"),

shinyFilesButton('file', label='Select Model Run Script',
title='Please select model run script', multiple=FALSE)

),

mainPanel(

h3("Script Name"),
verbatimTextOutput('filepath', TRUE),
h3("Script Output"),
verbatimTextOutput('scriptprint', TRUE),
h3("Datastore List"),
verbatimTextOutput('datastorelist', TRUE)

)

)
)

))
Binary file added sources/VEGUI/www/visioneval_logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cdc4825

Please sign in to comment.