mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-06 10:06:28 +02:00
Fix node id
This commit is contained in:
parent
2b92cd3195
commit
96d8faef18
2 changed files with 3 additions and 5 deletions
|
@ -2,14 +2,12 @@ import threading,importlib,queue
|
||||||
from esds.rcode import RCode
|
from esds.rcode import RCode
|
||||||
|
|
||||||
class Node:
|
class Node:
|
||||||
available_node_id=0
|
def __init__(self,src,interfaces,grp,node_id):
|
||||||
def __init__(self,src,interfaces,grp):
|
|
||||||
"""
|
"""
|
||||||
self.chest: contains mutex protected data
|
self.chest: contains mutex protected data
|
||||||
"""
|
"""
|
||||||
self.node_id=Node.available_node_id
|
self.node_id=node_id
|
||||||
self.grp=grp # Node group
|
self.grp=grp # Node group
|
||||||
Node.available_node_id+=1 # Refresh node id
|
|
||||||
self.src=src # Store the node source code
|
self.src=src # Store the node source code
|
||||||
self.args=None # Store the node arguments (passed through Simulator.create_node()
|
self.args=None # Store the node arguments (passed through Simulator.create_node()
|
||||||
self.rargs=None # Store the requests arguments
|
self.rargs=None # Store the requests arguments
|
||||||
|
|
|
@ -83,7 +83,7 @@ class Simulator:
|
||||||
if intf not in self.netmat.keys():
|
if intf not in self.netmat.keys():
|
||||||
self.log("Cannot create node "+str(Node.available_node_id)+": interface "+ intf + " unknown")
|
self.log("Cannot create node "+str(Node.available_node_id)+": interface "+ intf + " unknown")
|
||||||
exit(1)
|
exit(1)
|
||||||
node=Node(src, interfaces, grp)
|
node=Node(src, interfaces, grp, len(self.nodes)) # len(self.nodes) starts at 0 since append just below
|
||||||
self.nodes.append(node)
|
self.nodes.append(node)
|
||||||
thread=threading.Thread(target=node.run,args=[args])
|
thread=threading.Thread(target=node.run,args=[args])
|
||||||
thread.setDaemon(True) # May not work on old version of pythons but allow to kill threads when main thread ends (see Node.abort())
|
thread.setDaemon(True) # May not work on old version of pythons but allow to kill threads when main thread ends (see Node.abort())
|
||||||
|
|
Loading…
Add table
Reference in a new issue