summaryrefslogtreecommitdiff
path: root/esds/simulator.py
diff options
context:
space:
mode:
Diffstat (limited to 'esds/simulator.py')
-rw-r--r--esds/simulator.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/esds/simulator.py b/esds/simulator.py
index 219c1d9..f103cf6 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -204,11 +204,11 @@ class Simulator:
else:
selector_wireless.append(False)
selector_wired.append(False)
- # Informed senders of wired events to cancel send
+ # Build the set of senders to notify (only in wired connections,
+ # indeed IRL, in wireless communications sender would send all its data)
+ senders_to_notify=set()
for event in self.events[selector_wired]:
- sender=self.nodes[int(event[2][0])]
- sender["state"]="running"
- sender.rqueue.put(("send_cancel",2))
+ senders_to_notify.add(int(event[2][0]))
# Remove communications from the event list
if(len(self.events) != 0):
self.events=self.events[~(np.array(selector_wireless)|np.array(selector_wired))]
@@ -219,6 +219,14 @@ class Simulator:
node["state"]="running"
node.rqueue.put(("turn_off",0))
self.log("Turned off",node=node.node_id)
+ # Informed senders of wired events that communication ended
+ for sender_id in senders_to_notify:
+ sender_node=self.nodes[sender_id]
+ sender_node["state"]="running"
+ sender_node.rqueue.put(("send_cancel",2))
+ # The node should resume at current self.time. So, sync the sender now:
+ self.sync_node_non_blocking(sender_node)
+ self.sync_node_blocking(sender_node)
elif node["request"] == "send_cancel":
selector=list()
for event in self.events:
@@ -436,7 +444,7 @@ class Simulator:
src["state"]="running"
src.rqueue.put(("send",0))
self.sync_node_non_blocking(src,timeout_remove_only=True)
- elif event_type == 1:
+ elif event_type == 1: # Timeout
node=self.nodes[int(event)]
node["state"]="running"
node.rqueue.put(("timeout",0))