You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
repairable_count["nw"] =Dict{String,Any}(nw =>sum(length(comp_ids) for (comp_type,comp_ids) in repariable_network) for (nw, repariable_network) in repairable_set["nw"] )
11
+
repairable_count["nw"] =Dict{String,Any}(nw =>sum(length(comp_ids) for (comp_name,comp_ids) in repariable_network) for (nw, repariable_network) in repairable_set["nw"] )
6
12
else
7
13
repairable_set =get_repairable_items(network)
8
-
return repairable_count =sum(length(comp_ids) for (comp_type,comp_ids) in repairable_set)
14
+
return repairable_count =sum(length(comp_ids) for (comp_name,comp_ids) in repairable_set)
damaged_count["nw"] =Dict{String,Any}(nw =>sum(length(comp_ids) for (comp_type,comp_ids) in damage_network) for (nw, damage_network) in damaged_set["nw"] )
71
+
damaged_count["nw"] =Dict{String,Any}(nw =>sum(length(comp_ids) for (comp_name,comp_ids) in damage_network) for (nw, damage_network) in damaged_set["nw"] )
65
72
else
66
73
damaged_set =get_damaged_items(network)
67
-
damaged_count =sum(length(comp_ids) for (comp_type,comp_ids) in damaged_set)
74
+
damaged_count =sum(length(comp_ids) for (comp_name,comp_ids) in damaged_set)
" Update damage status for each time period based on whether the device has already been repaired"
176
-
functionupdate_damage_status!(mn_data)
177
-
if _IM.ismultinetwork(mn_data)
178
-
for (nw_id, network) in mn_data["nw"]
179
-
for (comp_type, comp_status) in _PM.pm_component_status
180
-
for (comp_id, comp) in network[comp_type]
181
-
if nw_id !="0"#not items are repaired in "0", do not check in previous network for a change
182
-
if comp[comp_status] != _PM.pm_component_status_inactive[comp_type] &&# if comp is active
183
-
mn_data["nw"]["$(parse(Int,nw_id)-1)"][comp_type][comp_id][comp_status] != _PM.pm_component_status_inactive[comp_type] # if comp was previously active
184
-
ifhaskey(comp,"damaged") && comp["damaged"] ==1
185
-
# therefore the comp was repaired in a former time_step, should be considered undamaged
186
-
Memento.info(_PM._LOGGER, "$(comp_type)$(comp_id) was repaired before step $(nw_id). Setting damged state to 0.")
187
-
comp["damaged"] =0
188
-
end
189
-
end
244
+
repairs =Dict{String,Array{Tuple{String,String},1}}(nw=>[] for nw inkeys(mn_data["nw"]))
245
+
for (nw_id, network) in mn_data["nw"]
246
+
for comp_name in restoration_comps
247
+
status_key = _PM.pm_component_status[comp_name]
248
+
for (comp_id, comp) in network[comp_name]
249
+
if nw_id !="0"#not items are repaired in "0", do not check in previous network for a change
250
+
if comp[status_key] != _PM.pm_component_status_inactive[comp_name] &&# if comp is active
251
+
mn_data["nw"]["$(parse(Int,nw_id)-1)"][comp_name][comp_id][status_key] == _PM.pm_component_status_inactive[comp_name] # if comp was previously inactive
252
+
push!(repairs[nw_id], (comp_name,comp_id))
190
253
end
191
254
end
192
255
end
193
256
end
194
-
else
195
-
Memento.error(_PM._LOGGER, "update_damage_status required multinetwork to identify is a device has been previously repaired.")
196
257
end
258
+
259
+
return repairs
197
260
end
198
261
262
+
263
+
"Remove damage status if a device has already been repaired"
0 commit comments