diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-30 17:50:34 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-30 17:50:34 +0200 |
| commit | f4db71e833f7adc862d2c6707b441006053adf33 (patch) | |
| tree | e0d2e3f17c9810acc96148dd35fa55eb8c317ff6 /esds | |
| parent | d0ae9f329685a19136cfd9a890b305db3bc384b9 (diff) | |
Debug turn off for wired communications
Diffstat (limited to 'esds')
| -rw-r--r-- | esds/simulator.py | 18 |
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)) |
