summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-09-06 15:34:48 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-09-06 15:34:48 +0200
commit721801012ad7ae440b8f53d082cc0eefa3b37fca (patch)
treecd55735f6b70fb86199a7ddbb91e233d0043be40
parent0db52b3e8393f22ce62728729bd78aa379fc8282 (diff)
Debug plugins system
-rw-r--r--esds/node.py38
-rw-r--r--esds/plugins/node_plugin.py2
-rw-r--r--esds/simulator.py2
3 files changed, 21 insertions, 21 deletions
diff --git a/esds/node.py b/esds/node.py
index 59b6f96..aa3cf22 100644
--- a/esds/node.py
+++ b/esds/node.py
@@ -22,11 +22,6 @@ class Node:
def plugin_register(self,plugin):
self.plugins.append(plugin)
- def plugin_handle_requests(self):
- # Take plugins notification into account
- for key in list(self["plugin_notify"]):
- self.plugin_notify(key,self["plugin_notify"].pop(key))
-
def plugin_notify(self,reason,args):
"""
This function strives to avoid using Python specific features
@@ -145,15 +140,17 @@ class Node:
self["request"]="send"
self["state"]="call_blocking"
ack=self.wait_ack(["send","timeout","send_cancel"])
+ status=-1
if ack[0] == "timeout":
self["request"]="send_cancel"
self["state"]="call_non_blocking"
self.wait_ack(["send_cancel"])
- return -1
- self["request"]="timeout_remove"
- self["state"]="call_non_blocking"
- self.wait_ack(["timeout_remove"])
- return ack[1]
+ else:
+ self["request"]="timeout_remove"
+ self["state"]="call_non_blocking"
+ self.wait_ack(["timeout_remove"])
+ status=ack[1]
+ return status
def receive(self,interface):
if interface not in self["interfaces"]:
@@ -185,14 +182,15 @@ class Node:
self.rargs=interface
self["state"]="call_blocking"
ack=self.wait_ack(["receive","timeout"])
- if ack[0] == "timeout":
- return (-1,None)
- self["request"]="timeout_remove"
- self["state"]="call_non_blocking"
- self.wait_ack(["timeout_remove"])
- data,start_at,end_at=self["interfaces"][interface].get()
- self.plugin_notify("receivet_return",(interface,data,start_at,end_at))
- return (0,data)
+ result=(-1,None)
+ if ack[0] != "timeout":
+ self["request"]="timeout_remove"
+ self["state"]="call_non_blocking"
+ self.wait_ack(["timeout_remove"])
+ data,start_at,end_at=self["interfaces"][interface].get()
+ self.plugin_notify("receivet_return",(interface,data,start_at,end_at))
+ result=(0,data)
+ return result
def wait_ack(self, ack_types):
"""
@@ -202,7 +200,9 @@ class Node:
ack=None
while True:
ack=self.rqueue.get() # Wait for simulator acknowledgments
- if ack[0] not in ack_types:
+ if ack[0] == "plugin_notify":
+ self.plugin_notify(ack[1],ack[2]) # TODO: what is ack_types received before "plugin_notify" ?
+ elif ack[0] not in ack_types:
ack_buffer.append(ack)
else:
break
diff --git a/esds/plugins/node_plugin.py b/esds/plugins/node_plugin.py
index dc9302f..5972c95 100644
--- a/esds/plugins/node_plugin.py
+++ b/esds/plugins/node_plugin.py
@@ -25,7 +25,7 @@ class NodePlugin:
pass
def on_communication_end(self,interface,data,start_at,end_at,aborted_at):
- self.log("hello world")
+ pass
def log(self,msg):
self.api.log(self.plugin_name+"(NP) "+msg)
diff --git a/esds/simulator.py b/esds/simulator.py
index 5032713..960d87f 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -199,7 +199,7 @@ class Simulator:
selector_wireless.append(False)
if event[2][9]: # Check if should be cancel on turn_off (receiver_required)
selector_wired.append(True)
- self.notify_node_plugin(event[2][1],"on_communication_end",("eth0",0,0,0,0))
+ self.nodes[int(event[2][1])].rqueue.put(("plugin_notify","on_communication_end",("eth0",0,0,0,0)))
else:
selector_wired.append(False)
event[2][8]=False # So set delivery to False!!