Skip to content

Commit

Permalink
merge next_release
Browse files Browse the repository at this point in the history
  • Loading branch information
jalazawa committed Dec 20, 2017
1 parent 7263e4b commit 6a77efb
Show file tree
Hide file tree
Showing 42 changed files with 2,506 additions and 52 deletions.
Binary file added inst/AntaresViz.xlsx
Binary file not shown.
58 changes: 29 additions & 29 deletions inst/GraphicalCharter.csv
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name red green blue formula
pumpedStorage 17 71 185 PSP
"import/export" 150 150 150 -(BALANCE + `ROW BAL.`)
mustRunTotal 120 136 194 mustRunTotal
mustRunPartial 120 236 194 mustRunPartial
mustRun 220 236 94 mustRun
bioenergy 22 106 87 `MISC. NDG`
wind 116 205 185 WIND
solar 242 116 6 SOLAR
nuclear 245 179 0 NUCLEAR
hydraulic 39 114 178 `H. ROR`+`H. STOR`
gas 243 10 10 GAS
coal 172 140 53 COAL
other 173 255 47 `MISC. DTG` + `MIX. FUEL`
load 135 86 39 LOAD
renewable 0 255 0 WIND+SOLAR+`H. ROR`+`H. STOR`+`MISC. NDG`
renewableNoDispatchable 0 255 0 WIND+SOLAR+`H. ROR`+`MISC. NDG`
thermal 77 77 77 NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`
thermalDispatchable 100 100 100 NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`
hydraulicDispatchable 39 114 178 `H. STOR`
lignite 180 130 43 LIGNITE
oil 131 86 162 OIL
mixFuel 127 84 156 `MIX. FUEL`
"misc. DTG" 173 255 47 `MISC. DTG`
hydraulicRor 61 96 125 `H. ROR`
hydraulicStor 84 151 208 `H. STOR`
totalProduction 235 155 166 NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`+WIND+SOLAR+`H. ROR`+`H. STOR`+`MISC. NDG` + pmax(0, PSP)
netLoad 101 180 197 netLoad
thermalAvailability 1 1 1 `AVL DTG`
name;red;green;blue;formula;Needed_Col
pumpedStorage;17;71;185;PSP;PSP
import/export;150;150;150;-(BALANCE + `ROW BAL.`);BALANCE,ROW BAL.
mustRunTotal;120;136;194;mustRunTotal;mustRunTotal
mustRunPartial;120;236;194;mustRunPartial;mustRunPartial
mustRun;220;236;94;mustRun;mustRun
bioenergy;22;106;87;`MISC. NDG`;MISC. NDG
wind;116;205;185;WIND;WIND
solar;242;116;6;SOLAR;SOLAR
nuclear;245;179;0;NUCLEAR;NUCLEAR
hydraulic;39;114;178;`H. ROR`+`H. STOR`;H. ROR,H. STOR
gas;243;10;10;GAS;GAS
coal;172;140;53;COAL;COAL
other;173;255;47;`MISC. DTG` + `MIX. FUEL`;MISC. DTG,MIX. FUEL
load;135;86;39;LOAD;LOAD
renewable;0;255;0;WIND+SOLAR+`H. ROR`+`H. STOR`+`MISC. NDG`;WIND,SOLAR,H. ROR,H. STOR,MISC. NDG
renewableNoDispatchable;0;255;0;WIND+SOLAR+`H. ROR`+`MISC. NDG`;WIND,SOLAR,H. ROR,MISC. NDG
thermal;77;77;77;NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`;NUCLEAR,LIGNITE,COAL,GAS,OIL,MIX. FUEL,MISC. DTG
thermalDispatchable;100;100;100;NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`;NUCLEAR,LIGNITE,COAL,GAS,OIL,MIX. FUEL,MISC. DTG
hydraulicDispatchable;39;114;178;`H. STOR`;H. STOR
lignite;180;130;43;LIGNITE;LIGNITE
oil;131;86;162;OIL;OIL
mixFuel;127;84;156;`MIX. FUEL`;MIX. FUEL
misc. DTG;173;255;47;`MISC. DTG`;MISC. DTG
hydraulicRor;61;96;125;`H. ROR`;H. ROR
hydraulicStor;84;151;208;`H. STOR`;H. STOR
totalProduction;235;155;166;NUCLEAR+LIGNITE+COAL+GAS+OIL+`MIX. FUEL`+`MISC. DTG`+WIND+SOLAR+`H. ROR`+`H. STOR`+`MISC. NDG` + pmax(0, PSP);NUCLEAR,LIGNITE,COAL,GAS,OIL,MIX. FUEL,MISC. DTG,WIND,SOLAR,H. ROR,H. STOR,MISC. NDG,PSP
netLoad;101;180;197;netLoad;netLoad
thermalAvailability;1;1;1;`AVL DTG`;AVL DTG
79 changes: 79 additions & 0 deletions inst/application/global.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require(shiny)
require(antaresRead)
require(antaresViz)
require(manipulateWidget)
require(data.table)


# choose a directory
source("src/scripts/directoryInput.R")

# shared inputs
.global_shared_prodStack <- data.frame(
module = "prodStack",
panel = "prodStack",
input = c("dateRange", "unit", "mcYear", "mcYearh", "timeSteph5", "legend", "drawPoints", "stepPlot"),
type = c("dateRangeInput", "selectInput", "selectInput", "selectInput", "selectInput",
"checkboxInput", "checkboxInput", "checkboxInput"), stringsAsFactors = FALSE)

.global_shared_plotts <- data.frame(
module = "plotts",
panel = "tsPlot",
input = c("dateRange", "mcYear", "mcYearh", "timeSteph5", "legend", "drawPoints", "stepPlot"),
type = c("dateRangeInput", "selectInput", "selectInput", "selectInput",
"checkboxInput", "checkboxInput", "checkboxInput"), stringsAsFactors = FALSE)


.global_shared_plotMap <- data.frame(
module = "plotMap",
panel = "Map",
input = c("dateRange", "mcYear", "mcYearh", "timeSteph5"),
type = c("dateRangeInput", "selectInput", "selectInput", "selectInput"), stringsAsFactors = FALSE)

.global_shared_exchangesStack <- data.frame(
module = "exchangesStack",
panel = "exchangesStack",
input = c("dateRange", "unit", "mcYear", "mcYearh", "timeSteph5", "legend", "drawPoints", "stepPlot"),
type = c("dateRangeInput", "selectInput", "selectInput", "selectInput", "selectInput",
"checkboxInput", "checkboxInput", "checkboxInput"), stringsAsFactors = FALSE)

.global_shared_input <- rbind(.global_shared_prodStack, .global_shared_plotts, .global_shared_plotMap, .global_shared_exchangesStack)


.global_build_input_data <- function(data){
data$input_id <- paste0(data$module, "-shared_", data$input)
data$last_update <- NA
data$update_call <- ""
class(data$last_update) <- c("character")
data <- data.table(data)
data
}

#------------
# compare
#-----------

.global_compare_prodstack <- c("mcYear", "main", "unit", "areas", "legend",
"stack", "stepPlot", "drawPoints")

.global_compare_exchangesStack <- c("mcYear", "main", "unit", "area",
"legend", "stepPlot", "drawPoints")

.global_compare_tsPlot <- c("mcYear", "main", "variable", "type", "confInt", "elements",
"aggregate", "legend", "highlight", "stepPlot", "drawPoints", "secondAxis")

.global_compare_plotMap <- c("mcYear", "type", "colAreaVar", "sizeAreaVars", "areaChartType", "showLabels",
"popupAreaVars", "labelAreaVar","colLinkVar", "sizeLinkVar", "popupLinkVars")


#----- generate help for antaresRead function
# library(tools)
# add.html.help <- function(package, func, tempsave = paste0(getwd(), "/temp.html")) {
# pkgRdDB = tools:::fetchRdDB(file.path(find.package(package), "help", package))
# topics = names(pkgRdDB)
# rdfunc <- pkgRdDB[[func]]
# tools::Rd2HTML(pkgRdDB[[func]], out = tempsave)
# }
# add.html.help("antaresRead", "readAntares", "inst/application/www/readAntares.html")
# add.html.help("antaresRead", "removeVirtualAreas", "inst/application/www/removeVirtualAreas.html")
# add.html.help("antaresRead", "writeAntaresH5", "inst/application/www/writeAntaresH5.html")
169 changes: 169 additions & 0 deletions inst/application/src/scripts/directoryInput.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#' Choose a Folder Interactively (Mac OS X)
#'
#' Display a folder selection dialog under Mac OS X
#'
#' @param default which folder to show initially
#' @param caption the caption on the selection dialog
#'
#' @details
#' Uses an Apple Script to display a folder selection dialog. With \code{default = NA},
#' the initial folder selection is determined by default behavior of the
#' "choose folder" Apple Script command. Otherwise, paths are expanded with
#' \link{path.expand}.
#'
#' @return
#' A length one character vector, character NA if 'Cancel' was selected.
#'
if (Sys.info()['sysname'] == 'Darwin') {
choose.dir = function(default = NA, caption = NA) {
command = 'osascript'
args = '-e "POSIX path of (choose folder{{prompt}}{{default}})"'

if (!is.null(caption) && !is.na(caption) && nzchar(caption)) {
prompt = sprintf(' with prompt \\"%s\\"', caption)
} else {
prompt = ''
}
args = sub('{{prompt}}', prompt, args, fixed = T)

if (!is.null(default) && !is.na(default) && nzchar(default)) {
default = sprintf(' default location \\"%s\\"', path.expand(default))
} else {
default = ''
}
args = sub('{{default}}', default, args, fixed = T)

suppressWarnings({
path = system2(command, args = args, stderr = TRUE)
})
if (!is.null(attr(path, 'status')) && attr(path, 'status')) {
# user canceled
path = NA
}

return(path)
}
} else if (Sys.info()['sysname'] == 'Linux') {
choose.dir = function(default = NA, caption = NA) {
command = 'zenity'
args = '--file-selection --directory --title="Choose a folder"'

suppressWarnings({
path = system2(command, args = args, stderr = TRUE)
})

#Return NA if user hits cancel
if (!is.null(attr(path, 'status')) && attr(path, 'status')) {
# user canceled
return(default)
}

#Error: Gtk-Message: GtkDialog mapped without a transient parent
if(length(path) == 2){
path = path[2]
}

return(path)
}
}

#' Directory Selection Control
#'
#' Create a directory selection control to select a directory on the server
#'
#' @param inputId The \code{input} slot that will be used to access the value
#' @param label Display label for the control, or NULL for no label
#' @param value Initial value. Paths are exapnded via \code{\link{path.expand}}.
#'
#' @details
#' This widget relies on \link{\code{choose.dir}} to present an interactive
#' dialog to users for selecting a directory on the local filesystem. Therefore,
#' this widget is intended for shiny apps that are run locally - i.e. on the
#' same system that files/directories are to be accessed - and not from hosted
#' applications (e.g. from shinyapps.io).
#'
#' @return
#' A directory input control that can be added to a UI definition.
#'
#' @seealso
#' \link{updateDirectoryInput}, \link{readDirectoryInput}, \link[utils]{choose.dir}
directoryInput = function(inputId, label, value = NULL) {
if (!is.null(value) && !is.na(value)) {
value = path.expand(value)
}

tagList(
singleton(
tags$head(
tags$script(src = 'js/directory_input_binding.js')
)
),

div(
class = 'form-group directory-input-container',
shiny:::`%AND%`(label, tags$label(label)),
div(
span(
class = 'col-xs-9 col-md-11',
style = 'padding-left: 0; padding-right: 5px;',
div(
class = 'input-group shiny-input-container',
style = 'width:100%;',
div(class = 'input-group-addon', icon('folder-o')),
tags$input(
id = sprintf('%s__chosen_dir', inputId),
value = value,
type = 'text',
class = 'form-control directory-input-chosen-dir',
readonly = 'readonly'
)
)
),
span(
class = 'shiny-input-container',
tags$button(
id = inputId,
class = 'btn btn-default directory-input',
'...'
)
)
)
)

)

}

#' Change the value of a directoryInput on the client
#'
#' @param session The \code{session} object passed to function given to \code{shinyServer}.
#' @param inputId The id of the input object.
#' @param value A directory path to set
#' @param ... Additional arguments passed to \link{\code{choose.dir}}. Only used
#' if \code{value} is \code{NULL}.
#'
#' @details
#' Sends a message to the client, telling it to change the value of the input
#' object. For \code{directoryInput} objects, this changes the value displayed
#' in the text-field and triggers a client-side change event. A directory
#' selection dialog is not displayed.
#'
updateDirectoryInput = function(session, inputId, value = NULL, ...) {
if (is.null(value)) {
value = choose.dir(...)
}
session$sendInputMessage(inputId, list(chosen_dir = value))
}

#' Read the value of a directoryInput
#'
#' @param session The \code{session} object passed to function given to \code{shinyServer}.
#' @param inputId The id of the input object
#'
#' @details
#' Reads the value of the text field associated with a \code{directoryInput}
#' object that stores the user selected directory path.
#'
readDirectoryInput = function(session, inputId) {
session$input[[sprintf('%s__chosen_dir', inputId)]]
}
Loading

0 comments on commit 6a77efb

Please sign in to comment.