From aec4b1f0bc62fa86beffb4ce269fdb2d0f10adf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Artelt?= Date: Thu, 23 Jan 2025 08:39:49 +0100 Subject: [PATCH] Test MSX scenarios: Add sensor reading events --- tests/test_advancedquality.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_advancedquality.py b/tests/test_advancedquality.py index dd48a74..2c9ebe2 100644 --- a/tests/test_advancedquality.py +++ b/tests/test_advancedquality.py @@ -1,7 +1,10 @@ """ Module provides tests to test the advanced quality analysis. """ -from epyt_flow.simulation import ScenarioSimulator +import random +from epyt_flow.simulation import ScenarioSimulator, SENSOR_TYPE_NODE_BULK_SPECIES, \ + SENSOR_TYPE_LINK_BULK_SPECIES +from epyt_flow.simulation.events import SensorFaultStuckZero from epyt_flow.utils import to_seconds @@ -14,6 +17,13 @@ def test_msx_net2cl2(): # Monitor "CL2" bulk species at every node sim.set_bulk_species_node_sensors(sensor_info={"CL2": sim.sensor_config.nodes}) + # Add sensor fault + node_id = random.choice(sim.sensor_config.nodes) + sim.add_sensor_fault(SensorFaultStuckZero(sensor_id=node_id, + sensor_type=SENSOR_TYPE_NODE_BULK_SPECIES, + start_time=to_seconds(days=1), + end_time=to_seconds(days=3))) + # Run entire simulation res = sim.run_simulation(verbose=True) @@ -31,6 +41,13 @@ def test_msx_net2cl2_place_sensors_everywhere(): sim.place_bulk_species_node_sensors_everywhere() sim.place_bulk_species_link_sensors_everywhere() + # Place sensor faults + link_id = random.choice(sim.sensor_config.links) + sim.add_sensor_fault(SensorFaultStuckZero(sensor_id=link_id, + sensor_type=SENSOR_TYPE_LINK_BULK_SPECIES, + start_time=to_seconds(days=4), + end_time=to_seconds(days=5))) + # Run entire simulation res = sim.run_simulation(verbose=True)