Skip to content

Commit

Permalink
fix channel messages-connections and AwerbuchDFS
Browse files Browse the repository at this point in the history
  • Loading branch information
ufukygmr committed May 6, 2022
1 parent 02a0bc3 commit 669b389
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions adhoccomputing/DistributedAlgorithms/Waves/AwerbuchDFS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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



Expand Down
17 changes: 9 additions & 8 deletions adhoccomputing/Networking/LogicalChannels/GenericChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 669b389

Please sign in to comment.