Remove interface name from registers

This commit is contained in:
Loic Guegan 2022-06-11 10:32:23 +02:00
parent fa09187031
commit b75498604a
3 changed files with 17 additions and 19 deletions
esds.py
tests
simple_read_eth0_ncom_2s1r
simple_read_wlan0_ncom_2s1r

20
esds.py
View file

@ -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_<interface> 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:

View file

@ -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

View file

@ -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