def __init__(self) : Scenario.__init__(self) m = Model(name='n0', position=(50,50,0), agents = [], interfaces = {}) m.get('agents').append(CircleWalkerAgent(Model(job='send'))) self._nodes.append(m)
def __init__(self) : Scenario.__init__(self) for node_id in range(0, 5) : ''' Make the node model ''' node = Model(name='n%s' % node_id, position=(0,0,0), agents = [], interfaces = {}) ''' Instance of a 'MovingAgent' ''' agent_instance = MovingAgent() ''' Place the agent on the node ''' node.get('agents').append(agent_instance) ''' Add the node to the scenario ''' self._nodes.append(node)
def _process(self, data, addr) : typestr, modelstr = data.strip().split(' ', 1) if typestr in self._conditions.keys() : self._conditions[typestr].acquire() self._conditions[typestr].notify_all() self._conditions[typestr].release() if typestr in self._subscriptions.keys() or '*' in self._subscriptions.keys() : model = Model.from_string(modelstr) instance = Event(typestr, model) if self._subscriptions.has_key('*') : callback = self._subscriptions['*'][0] args = self._subscriptions['*'][1] else : callback = self._subscriptions[typestr][0] args = self._subscriptions[typestr][1] if len(args) > 0 : callback(instance, args) else : callback(instance)
def __init__(self, model) : self._model = Model.from_string(model) self._name = self._model.get('name') self._api = API(self) self._api.get_event_channel().subscribe('MOVEACPT', self._on_move) self._position = self._model.get('position')