summaryrefslogtreecommitdiff
path: root/esds
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-09-11 15:16:30 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-09-11 15:16:30 +0200
commitcb02cc0e0208a0d056a5216f73eb8fef346aad89 (patch)
treef6de58a3fe04735c070847d3696a6677781a405a /esds
parent918cc9a4481149912027485ea10cc45f55334d1b (diff)
Improve platform file
Diffstat (limited to 'esds')
-rw-r--r--esds/helpers/platform.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py
index a811398..99b6986 100644
--- a/esds/helpers/platform.py
+++ b/esds/helpers/platform.py
@@ -1,6 +1,7 @@
import yaml, os, importlib
import numpy as np
+from esds import Simulator
class UnitsParser:
def node_range(r,limit):
@@ -55,6 +56,7 @@ class YAMLPlatformFile:
"interferences": True,
"node_count": 0,
"implementations": [],
+ "arguments": [],
"interfaces": dict()
}
@@ -156,13 +158,19 @@ class YAMLPlatformFile:
if extension != ".py":
self.parsing_error("File "+file+" must be a python file")
for node in r:
- self.default["implementations"][node]=file
+ self.default["implementations"][node]=path
count = len(nodes["implementations"])
if count > 1 and count != self.default["node_count"]:
self.parsing_error("If more than one implementation is specified, each node implementation should be provided ("+str(self.default["node_count"])+" in total)")
else:
self.parsing_error("node implementation not provided")
-
+ ##### Nodes arguments
+ self.default["arguments"]=[None]*self.default["node_count"]
+ if "arguments" in nodes:
+ args=nodes["arguments"]
+ for r in args:
+ for node_id in UnitsParser.node_range(r,self.default["node_count"]):
+ self.default["arguments"][node_id]=args[r]
def parse_general(self):
general=self.platform["general"]
@@ -197,10 +205,15 @@ class YAMLPlatformFile:
self.default["interferences"]=general["interferences"]
def run(self):
- callback=None
##### First load callback from file if any
+ callback=None
if self.default["breakpoints_file"] != None:
module, ext=os.path.splitext(self.default["breakpoints_file"])
imported=importlib.import_module(module)
callback=getattr(imported, self.default["breakpoints_callback"])
- pass
+ ##### Create simulator
+ simulator=Simulator(self.default["interfaces"])
+ for node_id in range(0,self.default["node_count"]):
+ simulator.create_node(self.default["implementations"][node_id], args=self.default["arguments"][node_id])
+ simulator.run()
+ \ No newline at end of file