From c63ae59a81c8ace0c243bfa2ab265eff61ea6cfe Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Wed, 31 Aug 2022 11:25:48 +0200 Subject: Add manual and improve node plugins system --- esds/simulator.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'esds/simulator.py') diff --git a/esds/simulator.py b/esds/simulator.py index fee9331..57dda4e 100644 --- a/esds/simulator.py +++ b/esds/simulator.py @@ -123,7 +123,10 @@ class Simulator: """ sorted_indexes=np.lexsort((self.events[:,3],self.events[:,1])) self.events=self.events[sorted_indexes] - + + def notify_node_plugin(self,node,function,args): + self.nodes[node]["plugin_notify"][function]=args + def sync_node_non_blocking(self,node, timeout_remove_only=False): """ Process all call request and wait for Node.sync() to return @@ -196,11 +199,14 @@ 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)) else: selector_wired.append(False) event[2][8]=False # So set delivery to False!! + # TODO: notify receiver plugins else: selector_wireless.append(True) + # TODO: notify receiver plugins selector_wired.append(False) else: selector_wireless.append(False) @@ -234,6 +240,7 @@ class Simulator: selector.append(True) if self.netmat[event[2][2]]["is_wired"]: sharing_to_update.append((int(event[2][1]),event[2][2])) + # TODO: notify sender plugins else: selector.append(False) self.events=self.events[~np.array(selector)] @@ -427,11 +434,13 @@ class Simulator: dst["state"]="running" dst.rqueue.put(("receive",0)) self.sync_node_non_blocking(dst,timeout_remove_only=True) + # TODO: notify receiver plugins self.update_sharing(dst.node_id,-1,interface) src["state"]="running" code=0 if perform_delivery else 1 src.rqueue.put(("send",code)) self.sync_node_non_blocking(src,timeout_remove_only=True) + # TODO: notify sender plugins else: if src.node_id != dst.node_id: if perform_delivery: @@ -444,10 +453,12 @@ class Simulator: dst["state"]="running" dst.rqueue.put(("receive",0)) self.sync_node_non_blocking(dst,timeout_remove_only=True) + # TODO: notify receiver plugins else: src["state"]="running" src.rqueue.put(("send",0)) self.sync_node_non_blocking(src,timeout_remove_only=True) + # TODO: notify sender plugins elif event_type == 1: # Timeout node=self.nodes[int(event)] node["state"]="running" -- cgit v1.2.3