mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-07 02:26:28 +02:00
Improve platform file
This commit is contained in:
parent
918cc9a448
commit
cb02cc0e02
2 changed files with 23 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import yaml, os, importlib
|
import yaml, os, importlib
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from esds import Simulator
|
||||||
|
|
||||||
class UnitsParser:
|
class UnitsParser:
|
||||||
def node_range(r,limit):
|
def node_range(r,limit):
|
||||||
|
@ -55,6 +56,7 @@ class YAMLPlatformFile:
|
||||||
"interferences": True,
|
"interferences": True,
|
||||||
"node_count": 0,
|
"node_count": 0,
|
||||||
"implementations": [],
|
"implementations": [],
|
||||||
|
"arguments": [],
|
||||||
"interfaces": dict()
|
"interfaces": dict()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,13 +158,19 @@ class YAMLPlatformFile:
|
||||||
if extension != ".py":
|
if extension != ".py":
|
||||||
self.parsing_error("File "+file+" must be a python file")
|
self.parsing_error("File "+file+" must be a python file")
|
||||||
for node in r:
|
for node in r:
|
||||||
self.default["implementations"][node]=file
|
self.default["implementations"][node]=path
|
||||||
count = len(nodes["implementations"])
|
count = len(nodes["implementations"])
|
||||||
if count > 1 and count != self.default["node_count"]:
|
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)")
|
self.parsing_error("If more than one implementation is specified, each node implementation should be provided ("+str(self.default["node_count"])+" in total)")
|
||||||
else:
|
else:
|
||||||
self.parsing_error("node implementation not provided")
|
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):
|
def parse_general(self):
|
||||||
general=self.platform["general"]
|
general=self.platform["general"]
|
||||||
|
@ -197,10 +205,15 @@ class YAMLPlatformFile:
|
||||||
self.default["interferences"]=general["interferences"]
|
self.default["interferences"]=general["interferences"]
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
callback=None
|
|
||||||
##### First load callback from file if any
|
##### First load callback from file if any
|
||||||
|
callback=None
|
||||||
if self.default["breakpoints_file"] != None:
|
if self.default["breakpoints_file"] != None:
|
||||||
module, ext=os.path.splitext(self.default["breakpoints_file"])
|
module, ext=os.path.splitext(self.default["breakpoints_file"])
|
||||||
imported=importlib.import_module(module)
|
imported=importlib.import_module(module)
|
||||||
callback=getattr(imported, self.default["breakpoints_callback"])
|
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()
|
||||||
|
|
|
@ -28,6 +28,12 @@ nodes:
|
||||||
# 0-@ receiver.py is equivalent to 0-4 receiver.py
|
# 0-@ receiver.py is equivalent to 0-4 receiver.py
|
||||||
implementations:
|
implementations:
|
||||||
- all sender.py
|
- all sender.py
|
||||||
|
# Node implementations arguments
|
||||||
|
# arguments is a dictionary where key isrange of node the value is the arguments for
|
||||||
|
# this specific node range
|
||||||
|
arguments: {
|
||||||
|
"all": 2
|
||||||
|
}
|
||||||
|
|
||||||
##### Interfaces Section #####
|
##### Interfaces Section #####
|
||||||
interfaces:
|
interfaces:
|
||||||
|
|
Loading…
Add table
Reference in a new issue