mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-05 17:46:29 +02:00
Update platform parser
This commit is contained in:
parent
cb02cc0e02
commit
1563817f1f
3 changed files with 22 additions and 18 deletions
|
@ -50,7 +50,7 @@ class YAMLPlatformFile:
|
|||
"breakpoints": [],
|
||||
"breakpoints_every": None,
|
||||
"breakpoints_file": None,
|
||||
"breakpoints_callback": None,
|
||||
"breakpoints_callback": lambda s:None,
|
||||
"debug": False,
|
||||
"debug_file": "./esds.debug",
|
||||
"interferences": True,
|
||||
|
@ -198,7 +198,7 @@ class YAMLPlatformFile:
|
|||
self.parsing_error("debug should be on or off")
|
||||
self.default["debug"]=general["debug"]
|
||||
if "debug_file" in general:
|
||||
self.default["debug_file"]=general["debug"]
|
||||
self.default["debug_file"]=general["debug_file"]
|
||||
if "interferences" in general:
|
||||
if type(general["interferences"]) != bool:
|
||||
self.parsing_error("interferences should be on or off")
|
||||
|
@ -206,14 +206,21 @@ class YAMLPlatformFile:
|
|||
|
||||
def run(self):
|
||||
##### 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"])
|
||||
self.default["breakpoints_callback"]=callback
|
||||
##### 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()
|
||||
##### Run simulation
|
||||
simulator.run(
|
||||
breakpoints=self.default["breakpoints"],
|
||||
breakpoints_every=self.default["breakpoints_every"],
|
||||
breakpoint_callback=self.default["breakpoints_callback"],
|
||||
debug=self.default["debug"],
|
||||
debug_file_path=self.default["debug_file"],
|
||||
interferences=self.default["interferences"])
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
##### General Section #####
|
||||
general:
|
||||
# List of timestamps where the simulator will break
|
||||
# and call the callback function (cf breakpoints_callback entry)
|
||||
# List of timestamps at which the simulator should break
|
||||
# and call the callback function (cf. the breakpoints_callback entry)
|
||||
breakpoints: []
|
||||
# Same as breakpoints but simulator will break every x second(s)
|
||||
breakpoints_every: 0
|
||||
breakpoints_every: 1000
|
||||
# Define the callback to call when the simulator reach a breakpoint
|
||||
breakpoints_callback:
|
||||
file: "platform_callback.py"
|
||||
callback: "callback"
|
||||
# Turn on/off the debugging of esds
|
||||
# Turn on/off the debugging mode of esds
|
||||
debug: off
|
||||
# Debug output file (default is ./esds.debug)
|
||||
debug_file: "./esds.debug"
|
||||
|
@ -20,17 +20,17 @@ general:
|
|||
nodes:
|
||||
# Number of nodes to simulate
|
||||
count: 5
|
||||
# List of files used has implementation for each node
|
||||
# List of files used as implementation for each node
|
||||
# Example:
|
||||
# - 0,1,2 sender.py
|
||||
# - 3-4 receiver.py
|
||||
# Note that @ will be replaced by the last node id ex:
|
||||
# Note that @ will be replaced by the last node id example for 5 nodes:
|
||||
# 0-@ receiver.py is equivalent to 0-4 receiver.py
|
||||
implementations:
|
||||
- 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
|
||||
# Node implementation arguments
|
||||
# arguments is a dictionary where key are ranges of node and values are the arguments for
|
||||
# these specific node ranges
|
||||
arguments: {
|
||||
"all": 2
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ interfaces:
|
|||
wlan0:
|
||||
# Interface type (wired/wireless)
|
||||
type: "wireless"
|
||||
# List of links between nodes in this interface
|
||||
# List of links between nodes on this interface
|
||||
# Syntax infos:
|
||||
# 1MBps = 1 megaBYTE per seconds
|
||||
# 1Mbps = 1 megabit per seconds
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
|
||||
|
||||
|
||||
def callback(simulator):
|
||||
print("Called :)")
|
||||
print("Callback called at {}s".format(simulator.time))
|
Loading…
Add table
Reference in a new issue