summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--esds/helpers/platform.py15
-rw-r--r--example/platform.yaml20
-rw-r--r--example/platform_callback.py5
3 files changed, 22 insertions, 18 deletions
diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py
index 99b6986..c236e60 100644
--- a/esds/helpers/platform.py
+++ b/esds/helpers/platform.py
@@ -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"])
\ No newline at end of file
diff --git a/example/platform.yaml b/example/platform.yaml
index 911daa1..723b4b8 100644
--- a/example/platform.yaml
+++ b/example/platform.yaml
@@ -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
diff --git a/example/platform_callback.py b/example/platform_callback.py
index b8a87d0..d3d5dab 100644
--- a/example/platform_callback.py
+++ b/example/platform_callback.py
@@ -1,6 +1,3 @@
-
-
-
def callback(simulator):
- print("Called :)") \ No newline at end of file
+ print("Callback called at {}s".format(simulator.time)) \ No newline at end of file