diff --git a/adhoccomputing/DistributedAlgorithms/Waves/AwerbuchDFS.py b/adhoccomputing/DistributedAlgorithms/Waves/AwerbuchDFS.py index f1438c8..437d7ab 100644 --- a/adhoccomputing/DistributedAlgorithms/Waves/AwerbuchDFS.py +++ b/adhoccomputing/DistributedAlgorithms/Waves/AwerbuchDFS.py @@ -16,7 +16,6 @@ from ...GenericModel import GenericModel, GenericMessageHeader, GenericMessagePayload, GenericMessage from ...Generics import * -topo = Topology() # hocam artik boyle cagirinca topology yi yeni bir class olusuyor ondan dolayi bu tur cagirmalari # mainde yaparsaniz daha iyi olabilir kod anlasilabilirligi acisindan # topology bilgisini kendi kurdugunuz AdHocNode classina mesela atabilirsiniz topology classini extend ederek vs. @@ -39,7 +38,7 @@ class ApplicationLayerMessagePayload(GenericMessagePayload): class WaveAwerbuchComponent(GenericModel): def on_init(self, eventobj: Event): print(f"Initializing {self.componentname}.{self.componentinstancenumber}") - neighbour_list = topo.get_neighbors(self.componentinstancenumber) + neighbour_list = self.topology.get_neighbors(self.componentinstancenumber) self.NeighbourList = neighbour_list self.Unvisited = neighbour_list.copy() self.father = self.componentinstancenumber @@ -158,12 +157,13 @@ def on_ack(self, eventobj: Event): - def __init__(self, componentname, componentinstancenumber): + def __init__(self, componentname, componentinstancenumber, topology): super().__init__(componentname, componentinstancenumber) self.eventhandlers["discover"] = self.on_discover self.eventhandlers["return"] = self.on_return self.eventhandlers["visited"] = self.on_visited self.eventhandlers["ack"] = self.on_ack + self.topology = topology diff --git a/adhoccomputing/Networking/LogicalChannels/GenericChannel.py b/adhoccomputing/Networking/LogicalChannels/GenericChannel.py index 5309c66..6354ea3 100644 --- a/adhoccomputing/Networking/LogicalChannels/GenericChannel.py +++ b/adhoccomputing/Networking/LogicalChannels/GenericChannel.py @@ -115,14 +115,15 @@ def on_deliver_to_component(self, eventobj: Event): caller_id = eventobj.eventsource.componentinstancenumber for connector in self.connectors: callee = self.connectors[connector] - callee_id = callee.componentinstancenumber - # return - #print(f"I am connected to {callee}. Will check if I have to distribute it to {callee_id}") - if callee_id == caller_id: - pass - else: - myevent = Event(eventobj.eventsource, EventTypes.MFRB, eventobj.eventcontent, self.componentinstancenumber) - callee.trigger_event(myevent) + for caller in callee: + callee_id = caller.componentinstancenumber + # return + #print(f"I am connected to {callee}. Will check if I have to distribute it to {callee_id}") + if callee_id == caller_id: + pass + else: + myevent = Event(eventobj.eventsource, EventTypes.MFRB, eventobj.eventcontent, self.componentinstancenumber) + caller.trigger_event(myevent) def connect_me_to_component(self, name, component): try: