Skip to content

Commit f27fe52

Browse files
committed
Adding creation o plc8 log
Former-commit-id: 52acae2
1 parent 5b599e9 commit f27fe52

File tree

9 files changed

+1673
-156
lines changed

9 files changed

+1673
-156
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5612b836670ff87b06c0728d4d0ad6a29e8a55f7
1+
6ac18184a496f7d29fa6a347e598c9bc22d2b89d

ICS_topologies/enhanced_ctown_topology/automatic_plant.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@ def start_simulation(self):
5050
wntr_environment_path = home_path + str("/wntr-experiments/bin/python")
5151
print "Launching simulation for week index: " + str(sys.argv[2])
5252

53-
cmd_string = wntr_environment_path + " physical_process.py " + sys.argv[1] + " " + sys.argv[2]
54-
#cmd_string = wntr_environment_path + " physical_process_epynet.py " + sys.argv[1] + " " + sys.argv[2]
53+
#cmd_string = wntr_environment_path + " physical_process.py " + sys.argv[1] + " " + sys.argv[2]
54+
cmd_string = wntr_environment_path + " physical_process_epynet.py " + sys.argv[1] + " " + sys.argv[2]
5555
if len(sys.argv) >= 4:
56-
#cmd_string = wntr_environment_path + " physical_process_epynet.py " + sys.argv[1] + " " + sys.argv[2] + \
57-
# " " + sys.argv[3]
58-
59-
cmd_string = wntr_environment_path + " physical_process.py " + sys.argv[1] + " " + sys.argv[2] + \
56+
cmd_string = wntr_environment_path + " physical_process_epynet.py " + sys.argv[1] + " " + sys.argv[2] + \
6057
" " + sys.argv[3]
6158

59+
#cmd_string = wntr_environment_path + " physical_process.py " + sys.argv[1] + " " + sys.argv[2] + \
60+
# " " + sys.argv[3]
61+
6262
cmd = shlex.split(cmd_string)
6363
simulation = subprocess.Popen(cmd)
6464
return simulation

ICS_topologies/enhanced_ctown_topology/c_town_config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# Simulation initialization parameters.
33
initial_custom_flag: "True"
4-
week_index: 25
4+
week_index: 0
55
demand_patterns_path: "../../Demand_patterns/three_year_demands_ctown.csv" # that file was this one. the total demand pattern csv
66
starting_demand_path: "../../Demand_patterns/starting_demand_points.csv" # that would be this file
77
initial_tank_levels_path: "../../Demand_patterns/tank_initial_conditions.csv" #
@@ -18,7 +18,7 @@ epanet_cpa_path: "../../Demand_patterns/ctown.cpa"
1818
# General simulation parameters
1919
db_path: "ctown_db.sqlite"
2020
output_ground_truth_path: "physical_process.csv"
21-
duration_days: 10
21+
duration_days: 1
2222
inp_file: "ctown_map.inp"
2323
simulator: "pdd"
2424

@@ -47,6 +47,6 @@ simulation_type: "Single"
4747
# This flag indicates if the experiment will have an attack in the network
4848
# Using this flag also requires setting the value of attacks_path and attack_name.
4949
# The attack_name should be present in the attacks_path file
50-
run_attack: "True"
50+
run_attack: "False"
5151
attacks_path: "../../attack_repository/attack_description.yaml"
5252
attack_name: "network_empty_tank_1"

ICS_topologies/enhanced_ctown_topology/create_log_files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
files=(plc1 plc2 plc3 plc4 plc5 plc6 plc7 plc9 physical attacker arp_poison scada client server)
3+
files=(plc1 plc2 plc3 plc4 plc5 plc6 plc7 plc8 plc9 physical attacker arp_poison scada client server)
44

55
rm -rf output/*
66

ICS_topologies/enhanced_ctown_topology/physical_process_epynet.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,20 @@
44
import os
55
import pandas as pd
66
import yaml
7+
import traceback
78
from decimal import Decimal
89
from datetime import datetime
910
from utils import T1, T2, T3, T4, T5, T6, T7, PU1, PU2, PU1F, PU2F
1011
from utils import V2, PU3, PU4, PU5, PU6, PU7, PU8, PU9, PU10, PU11
1112
from utils import V2F, PU3F, PU4F, PU5F, PU6F, PU7F, PU8F, PU9F, PU10F, PU11F
1213
from utils import J280, J269, J300, J256, J289, J415, J14, J422, J302, J306, J307, J317, ATT_1, ATT_2
1314

14-
sys.path.insert(1, sys.path[0] + '/epynet/scripts')
15+
sys.path.insert(1, sys.path[0] + '/DHALSIM-epynet')
1516

1617
print(sys.path)
1718

1819
import network
19-
import epynet_utils
20+
import epynetUtils
2021

2122
class PhysicalPlant:
2223

@@ -188,16 +189,15 @@ def load_config(self, config_path):
188189
options = yaml.load(config_file, Loader=yaml.FullLoader)
189190
return options
190191

191-
192192
def configure_demand_patterns(self, patterns_path, starting_demand):
193193
limit = (self.simulation_days * 24) - 1
194-
total_demands = pd.read_csv(patterns_path, index_col=0)
194+
total_demands = pd.read_csv(patterns_path)
195195
demand_starting_points = pd.read_csv(starting_demand, index_col=0)
196196

197197
week_start = demand_starting_points.iloc[self.week_index][0]
198198
week_demands = total_demands.loc[week_start:week_start + limit, :]
199199

200-
for pattern in list(self.wn.patterns.keys()):
200+
for pattern in self.wn.patterns.uid:
201201
self.wn.set_demand_pattern(pattern, week_demands[pattern].values.tolist())
202202

203203
def configure_initial_tank_levels(self, tank_levels_path):
@@ -368,35 +368,28 @@ def main(self):
368368
internal_epynet_step = 1
369369
simulation_time = 0
370370

371-
# FOR DEBUG
372-
#status = [1.0, 0.0]
373-
#actuators_status_dict = {uid: status for uid in self.wn.pumps.uid.append(self.wn.valves.uid)}
374-
375371
while internal_epynet_step > 0:
376372

377373
self.update_actuators()
378-
#print("Simulating with actuators: " + str(self.actuator_list))
379-
internal_epynet_step, network_state = self.wn.simulate_step(simulation_time, self.actuator_list)
374+
375+
try:
376+
internal_epynet_step, network_state = self.wn.simulate_step(simulation_time, self.actuator_list)
377+
except IndexError as i_error:
378+
print("ERROR: ", i_error)
379+
traceback.print_exc()
380+
break
380381

381382
if internal_epynet_step == simluation_step:
382383
master_time += 1
383384

384385
print("Internal epynet step: " + str(internal_epynet_step))
385386
print("ITERATION %d ------------- " % master_time)
386387

387-
#print("Network State")
388-
#print(network_state)
389-
390388
step_results = self.register_results(network_state)
391389

392-
#print("Step Results")
393-
#print(step_results)
394-
395390
self.results_list.append(step_results)
396391

397392
simulation_time = simulation_time + internal_epynet_step
398-
#continue
399-
400393

401394
try:
402395
# Update tank pressure

ICS_topologies/enhanced_ctown_topology/towns/ctown_pd.inp renamed to ICS_topologies/enhanced_ctown_topology/towns/ctown.inp

File renamed without changes.

ICS_topologies/enhanced_ctown_topology/towns/ctown_map.inp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,42 +1089,6 @@
10891089
11 40 10
10901090

10911091
[CONTROLS]
1092-
; ----------- Tank 1 ---------------
1093-
;LINK PU1 OPEN IF NODE T1 BELOW 4
1094-
;LINK PU1 CLOSED IF NODE T1 ABOVE 6.3
1095-
1096-
;LINK PU2 OPEN IF NODE T1 BELOW 1
1097-
;LINK PU2 CLOSED IF NODE T1 ABOVE 4.5
1098-
1099-
; ----------- Valve to T2 ---
1100-
;LINK V2 OPEN IF NODE T2 BELOW .5
1101-
;LINK V2 CLOSED IF NODE T2 ABOVE 5.5
1102-
1103-
; ----------- T3 ---
1104-
;LINK PU4 OPEN IF NODE T3 BELOW 3
1105-
;LINK PU4 CLOSED IF NODE T3 ABOVE 5.3
1106-
1107-
;LINK PU5 OPEN IF NODE T3 BELOW 1
1108-
;LINK PU5 CLOSED IF NODE T3 ABOVE 3.5
1109-
1110-
; ----------- T4 ---
1111-
;LINK PU6 OPEN IF NODE T4 BELOW 2
1112-
;LINK PU6 CLOSED IF NODE T4 ABOVE 3.5
1113-
1114-
;LINK PU7 OPEN IF NODE T4 BELOW 3
1115-
;LINK PU7 CLOSED IF NODE T4 ABOVE 4.5
1116-
1117-
; ----------- T5 ---
1118-
;LINK PU8 OPEN IF NODE T5 BELOW 1.5
1119-
;LINK PU8 CLOSED IF NODE T5 ABOVE 4.5
1120-
1121-
; ----------- T7 ---
1122-
;LINK PU10 OPEN IF NODE T7 BELOW 2.5
1123-
;LINK PU10 CLOSED IF NODE T7 ABOVE 4.8
1124-
1125-
;LINK PU11 OPEN IF NODE T7 BELOW 1
1126-
;LINK PU11 CLOSED IF NODE T7 ABOVE 3
1127-
11281092

11291093
[RULES]
11301094

@@ -1221,7 +1185,6 @@
12211185
REQUIRED PRESSURE 20
12221186
PRESSURE EXPONENT 0.5
12231187

1224-
12251188
[COORDINATES]
12261189
;Node X-Coord Y-Coord
12271190
J511 -246643.52 150768.11

ICS_topologies/enhanced_ctown_topology/towns/ctown_map.rpt

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)