mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-06 01:56:27 +02:00
Now no ref to eth0 and wlan0 anymore. Each node can have an arbitrary number of wired and wireless interfaces
This commit is contained in:
parent
4a11e56d28
commit
0f0d08caba
1 changed files with 16 additions and 13 deletions
29
esds.py
29
esds.py
|
@ -334,29 +334,32 @@ class Simulator:
|
|||
node.rqueue.put(("turn_on",0))
|
||||
self.log("Turned on",node=node.node_id)
|
||||
elif node["request"] == "turn_off":
|
||||
selector_wlan0=list()
|
||||
selector_other=list()
|
||||
# Create communications selectors (True/False arrays)
|
||||
selector_wireless=list() # Select all wireless events where node is involved
|
||||
selector_wired=list() # Select all wired events where node is involved
|
||||
for event in self.events:
|
||||
if event[0]==0 and int(event[2][1])==node.node_id:
|
||||
if event[2][2] == "wlan0":
|
||||
selector_wlan0.append(True)
|
||||
selector_other.append(False)
|
||||
if self.netmat[event[2][2]]["is_wired"]:
|
||||
selector_wireless.append(False)
|
||||
selector_wired.append(True)
|
||||
else:
|
||||
selector_wlan0.append(False)
|
||||
selector_other.append(True)
|
||||
selector_wireless.append(True)
|
||||
selector_wired.append(False)
|
||||
else:
|
||||
selector_wlan0.append(False)
|
||||
selector_other.append(False)
|
||||
# Informed sender to cancel send
|
||||
for event in self.events[selector_other]:
|
||||
selector_wireless.append(False)
|
||||
selector_wired.append(False)
|
||||
# Informed senders of wired events to cancel send
|
||||
for event in self.events[selector_wired]:
|
||||
sender=self.nodes[int(event[2][0])]
|
||||
sender["state"]="running"
|
||||
sender.rqueue.put(("send_cancel",2))
|
||||
# Remove communications
|
||||
# Remove communications from the event list
|
||||
if(len(self.events) != 0):
|
||||
self.events=self.events[~(np.array(selector_wlan0)|np.array(selector_other))]
|
||||
self.events=self.events[~(np.array(selector_wireless)|np.array(selector_wired))]
|
||||
# Refresh wired sharing
|
||||
for interface in self.sharing.keys():
|
||||
self.sharing[interface][node.node_id]=0 # Sharing goes back to zero
|
||||
# Update node state after turning off
|
||||
node["state"]="running"
|
||||
node.rqueue.put(("turn_off",0))
|
||||
self.log("Turned off",node=node.node_id)
|
||||
|
|
Loading…
Add table
Reference in a new issue