def create_evt(self): """ Create the dictionnary of simpy event. Hence each node of communication graph can send signal to others """ self.devt={} for e in self.edges(keys=True): self.devt[e]=(SimEvent(e,sim=self.sim))
def __init__(self, **args): defaults = { 'sim': None, 'net': Network(), #'gcom': Gcom(), 'gcom': [], # Temporary 'ID': 0, 'dec': {}, 'devt': {}, 'lcst': [] } ## initialize attributes for key, value in defaults.items(): if key in args: setattr(self, key, args[key]) else: setattr(self, key, value) args[key] = value self.args = args self.gcom = self.args['gcom'] if sys.version_info.major == 2: self.cmdrq = SimEvent('RQ' + str(self.ID), sim=self.sim) # command request else: pass # Python3 implementation not done try: self.PN = self.net.node[self.ID]['PN'] except: self.PN = Network() # self.create_evt() # self.c_init() if sys.version_info.major == 2: Process.__init__(self, name='Tx' + str(self.ID), sim=self.sim) else: pass #Process.__init__(self,env,generator) # Python3 implementation not done Cf = ConfigParser.ConfigParser() Cf.read(pyu.getlong('agent.ini', 'ini')) for s in Cf.sections(): try: d = dict(Cf.items(s)) if d['id'] == self.ID: self.refreshTOA = eval(d['refreshtoa']) break except: pass
def __init__(self, **args): defaults = { 'sim': None, 'net': Network(), 'gcom': Gcom(), 'ID': 0, 'dec': {}, 'devt': {}, 'lcst': [] } ## initialize attributes for key, value in defaults.items(): if args.has_key(key): setattr(self, key, args[key]) else: setattr(self, key, value) args[key] = value self.args = args self.gcom = self.args['gcom'] self.cmdrq = SimEvent('RQ' + str(self.ID), sim=self.sim) # command request try: self.PN = self.net.node[self.ID]['PN'] except: self.PN = Network() # self.create_evt() # self.c_init() Process.__init__(self, name='Tx' + str(self.ID), sim=self.sim) Cf = ConfigParser.ConfigParser() Cf.read(pyu.getlong('agent.ini', 'ini')) for s in Cf.sections(): try: d = dict(Cf.items(s)) if d['id'] == self.ID: self.refreshTOA = eval(d['refreshtoa']) break except: pass