From 95838c19e71bd2d2d94b3f6f73fba5c2877f1beb Mon Sep 17 00:00:00 2001 From: OscarFdezS Date: Thu, 27 Jun 2024 18:14:52 +0200 Subject: [PATCH] Renamed json example --- xdevs/examples/json/README.md | 2 +- xdevs/examples/json/json2xdevs_example.py | 21 +++++++++++++++++++++ xdevs/examples/json/main.py | 12 ------------ 3 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 xdevs/examples/json/json2xdevs_example.py delete mode 100644 xdevs/examples/json/main.py diff --git a/xdevs/examples/json/README.md b/xdevs/examples/json/README.md index 815b9ae..8b94e12 100644 --- a/xdevs/examples/json/README.md +++ b/xdevs/examples/json/README.md @@ -87,5 +87,5 @@ Couplings define connections between components: ```bash $ cd xdevs/examples/json -$ python3 main.py +$ python3 json2xdevs_example.py ``` diff --git a/xdevs/examples/json/json2xdevs_example.py b/xdevs/examples/json/json2xdevs_example.py new file mode 100644 index 0000000..a637e40 --- /dev/null +++ b/xdevs/examples/json/json2xdevs_example.py @@ -0,0 +1,21 @@ +import sys + +from xdevs.rt import RealTimeCoordinator, RealTimeManager +from xdevs.factory import Components + + +if __name__ == '__main__': + file_path = sys.argv[1] if len(sys.argv) > 1 else 'gpt.json' + + model = Components.from_json(file_path) + """ + # Virtual simulation + coord_v_sim = Coordinator(model) + coord_v_sim.initialize() + coord_v_sim.simulate() + """ + # Wall-clock simulation + m_rt = RealTimeManager(0.2,1) + coord_rt_sim = RealTimeCoordinator(model, m_rt) + coord_rt_sim.simulate_rt() + diff --git a/xdevs/examples/json/main.py b/xdevs/examples/json/main.py deleted file mode 100644 index f713acf..0000000 --- a/xdevs/examples/json/main.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys -from xdevs.sim import Coordinator -from xdevs.factory import Components - - -if __name__ == '__main__': - file_path = sys.argv[1] if len(sys.argv) > 1 else 'gpt.json' - - component = Components.from_json(file_path) - coord = Coordinator(component) - coord.initialize() - coord.simulate_iters()