summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-09-11 14:48:59 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-09-11 14:48:59 +0200
commita8281ebfd3f3a3c67e4a022ce59450146c90fb6e (patch)
tree3d47894f8397aff012f2f22b08652f4d92c6e96a
parentf4f1d975043223b6a5fb512946f6d7c0e3ee791f (diff)
Minor changes
-rw-r--r--esds/helpers/platform.py11
-rw-r--r--example/platform.yaml2
-rw-r--r--example/platform_callback.py6
-rwxr-xr-xexample/platform_test.py3
4 files changed, 19 insertions, 3 deletions
diff --git a/esds/helpers/platform.py b/esds/helpers/platform.py
index 341baed..a811398 100644
--- a/esds/helpers/platform.py
+++ b/esds/helpers/platform.py
@@ -1,5 +1,5 @@
-import yaml, os
+import yaml, os, importlib
import numpy as np
class UnitsParser:
@@ -195,3 +195,12 @@ class YAMLPlatformFile:
if type(general["interferences"]) != bool:
self.parsing_error("interferences should be on or off")
self.default["interferences"]=general["interferences"]
+
+ def run(self):
+ callback=None
+ ##### First load callback from file if any
+ 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
diff --git a/example/platform.yaml b/example/platform.yaml
index 45c6685..1f9eae5 100644
--- a/example/platform.yaml
+++ b/example/platform.yaml
@@ -7,7 +7,7 @@ general:
breakpoints_every: 0
# Define the callback to call when the simulator reach a breakpoint
breakpoints_callback:
- file: "platform_test.py"
+ file: "platform_callback.py"
callback: "callback"
# Turn on/off the debugging of esds
debug: off
diff --git a/example/platform_callback.py b/example/platform_callback.py
new file mode 100644
index 0000000..b8a87d0
--- /dev/null
+++ b/example/platform_callback.py
@@ -0,0 +1,6 @@
+
+
+
+
+def callback(simulator):
+ print("Called :)") \ No newline at end of file
diff --git a/example/platform_test.py b/example/platform_test.py
index ccc9a98..2573b32 100755
--- a/example/platform_test.py
+++ b/example/platform_test.py
@@ -4,4 +4,5 @@ from esds.helpers.platform import YAMLPlatformFile
-simulator=YAMLPlatformFile("platform.yaml") \ No newline at end of file
+s=YAMLPlatformFile("platform.yaml")
+s.run() \ No newline at end of file