-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
165 lines (112 loc) · 4.36 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
function(input, output,session) {
#close session and windows
#log out when close the windows
session$onSessionEnded(function() {
print(c$close_session())
print(c$logout())
stopApp()
})
# # INPUT FILE TO NIS ----
# INPUT FGS XLSX for faster testing ----
# NisOutput<- reactive({
# df <- pandas$read_csv('flow_graph_solution.csv')
# df$Period<-as.character(df$Period)
# list(df1 = df, df2 = df)
# })
NisOutput<-callModule(NisOutput,'input')
output$FGS<- renderDataTable({
df <- NisOutput()[['df1']]
DT::datatable(df)
})
output$issues<- renderDataTable({
df <- NisOutput()[['df2']]
DT::datatable(df)
})
# Reactive FGS Absolute values ------
dfAbs<-reactive({
df<-NisOutput()[['df1']]
#Cleaning
df<-df %>% replace_na(list(Level = 'Subsystem'))
df[is.na(df)] <- "Subsystem"
# Select only useful data for analysis
df<- filter(df, Conflict_Partof != 'Dismissed', Conflict_Itype != 'Dismissed')
cols<- c('Scenario','Period','Scope','Processor','Interface','Orientation','RoegenType','Value','Unit','Level','System','Subsystem','Sphere')
df<-subset(df,select = cols)
#Spreading Value by orientation
data_spread<-df%>%spread(Orientation,value = Value)
data_spread<-data_spread %>% replace_na(list(Input = 0, Output = 0))
data_spread['Value'] <- abs(data_spread['Input']-data_spread['Output'])
data_spread
})
# Reactive FGS Negative Output ------
dfIO <- reactive({
data_spread<-dfAbs()
data_spread['Output']<- data_spread['Output']*-1
data_gather<-data_spread%>%gather(key = "Orientation", value= "Value", Input, Output, na.rm = TRUE)
})
df<-callModule(choosedf,'bars',dfAbs,dfIO)
# BAR PLOT SCOPES stacked Interface grouped ---------------------
callModule(ChoicesSPL, "Scope", df)
callModule(ChoicesMultiInterface,'Scope',df)
callModule(MultibarPlotServerScope,"Scope",df)
# BAR CHART BY SYSTEM stacked subsystems ----
callModule(ScenarioTimeChoice,'System',df)
callModule(ChoicesInterface,'System',df)
callModule(barPlotSubsystemServer,'System',df)
# BAR CHART BY PROCESSOR AND INTERFACE choice ------
callModule(ScenarioTimeChoice, "processor", df)
callModule(ChoicesScope,"processor",df)
callModule(ChoicesMultiInterface,'processor',df)
callModule(ChoicesMultiProcessor,'processor',df)
callModule(barPlotProcessorInterfaceSertver,'processor',df)
# new Reactive EUM ----
callModule(ChoicesScenario,'EUM',dfAbs)
callModule(ChoicesPeriod,'EUM',dfAbs)
callModule(ChoicesSystem,'EUM',dfAbs)
callModule(ChoicesScope,'EUM',dfAbs)
callModule(ChoicesFlow,'EUM',dfAbs)
callModule(ChoicesFund,'EUM',dfAbs)
# reactive dataframes for indicators ------
totalEUM<-callModule(matrixEUM,'EUM',dfAbs)
ShortEUM<-callModule(IndicatorsEUM,'EUM',totalEUM)
#EUM output en formato excel ----
output$eum<-renderExcel({
excelTable(data = ShortEUM())
})
#PLOT Indicators ----
callModule(ChoicesIndicator,'EUMplot',totalEUM)
callModule(ChoicesLevel,'EUMplot',totalEUM)
callModule(ChoicesPeriod,'EUMplot',totalEUM)
callModule(batPlotEUMScope,'EUMplot',totalEUM)
# Gauge Plot ---
callModule(ChoicesIndicator,'gauge',totalEUM)
callModule(ChoicesLevel,'gauge',totalEUM)
callModule(ChoicesPeriod,'gauge',totalEUM)
callModule(ChoicesScope,'gauge',totalEUM)
callModule(gaugePlotServer,'gauge',totalEUM)
#Create command -----
ScalarBenchmarks<-callModule(Benchmarks,'gauge')
ScalarIndicators<-callModule(Indicators,'gauge')
# Add command
observeEvent(input$addCommands,{
c = NisOutput()[['c']]
c$check_backend_available()
c$append_command(paste0('ScalarIndicators'," ",toString(input$addCommands)),
ScalarIndicators())
c$append_command(paste0('ScalarBenchmarks',' ',toString(input$addCommands)),
ScalarBenchmarks())
})
# download Commands xlsx
output$dl <- downloadHandler(
filename = function() {"Indicators.xlsx"},
content = function(file) {write_xlsx(list(
ScalarIndicators = ScalarIndicators(),
ScalarBenchmarks = ScalarBenchmarks()), path = file)}
)
# TREE ----
callModule(ChoicesScope,'tree',dfAbs)
callModule(ChoicesPeriod,'tree',dfAbs)
callModule(ChoicesInterface,'tree',dfAbs)
callModule(TreeServer,'tree',dfAbs)
callModule(unit,'tree',dfAbs)
} #END