From b75498604a20ec7a15b0271ecffa19ff72a9e996 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sat, 11 Jun 2022 10:32:23 +0200 Subject: [PATCH] Remove interface name from registers --- esds.py | 20 +++++++++---------- tests/simple_read_eth0_ncom_2s1r/receiver.py | 8 ++++---- tests/simple_read_wlan0_ncom_2s1r/receiver.py | 8 ++++---- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/esds.py b/esds.py index 7ecf790..a26de97 100644 --- a/esds.py +++ b/esds.py @@ -252,8 +252,12 @@ class Simulator: for node in self.nodes: s=node["state"] states[s]=states[s]+1 if s in states else 1 - if self.sharing["eth0"][node.node_id] > 0: - sharing["n"+str(node.node_id)]=str(int(self.sharing["eth0"][node.node_id])) + node_key="n"+str(node.node_id) + for interface in self.sharing.keys(): + if self.sharing[interface][node.node_id] > 0: + if node_key not in sharing: + sharing[node_key] = "" + sharing[node_key]+=str(int(self.sharing[interface][node.node_id])) print("Node number per state: ",end="") for key in states: print(key+"="+str(states[key]), end=" ") @@ -315,18 +319,12 @@ class Simulator: node["state"]="running" if node.rargs == "clock": node.rqueue.put(("read",self.time)) - elif node.rargs == "wlan0_ncom": + elif node.rargs[0:5] == "ncom_": # ncom_ register + interface=node.rargs[5:] count=0 # Count number of communication on wlan0 for event in self.events: - if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == "wlan0": - count+=1 - node.rqueue.put(("read",count)) - elif node.rargs == "eth0_ncom": - count=0 - # Count number of communication on eth0 - for event in self.events: - if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == "eth0": + if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == interface: count+=1 node.rqueue.put(("read",count)) else: diff --git a/tests/simple_read_eth0_ncom_2s1r/receiver.py b/tests/simple_read_eth0_ncom_2s1r/receiver.py index 819fc84..e2d317b 100644 --- a/tests/simple_read_eth0_ncom_2s1r/receiver.py +++ b/tests/simple_read_eth0_ncom_2s1r/receiver.py @@ -1,12 +1,12 @@ #!/usr/bin/env python def execute(api): - api.log("eth0 is {}".format(api.read("eth0_ncom"))) + api.log("eth0 is {}".format(api.read("ncom_eth0"))) api.wait(624) - api.log("eth0 is {}".format(api.read("eth0_ncom"))) + api.log("eth0 is {}".format(api.read("ncom_eth0"))) api.wait(624) # Now we are at 624*2=1248 (first sender start a communication) api.wait(1) # Let the communication starts - api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 1 + api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 1 api.wait(1) # Now second sender start a communication - api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 2 + api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 2 diff --git a/tests/simple_read_wlan0_ncom_2s1r/receiver.py b/tests/simple_read_wlan0_ncom_2s1r/receiver.py index 9f652aa..d41304e 100644 --- a/tests/simple_read_wlan0_ncom_2s1r/receiver.py +++ b/tests/simple_read_wlan0_ncom_2s1r/receiver.py @@ -1,12 +1,12 @@ #!/usr/bin/env python def execute(api): - api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) + api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) api.wait(624) - api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) + api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) api.wait(624) # Now we are at 624*2=1248 (first sender start a communication) api.wait(1) # Let the communication starts - api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 1 + api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 1 api.wait(1) # Second sender start a communication - api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 2 + api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 2