Esempio n. 1
0
    def __init__(self, componentname, componentid):
        # SUBCOMPONENTS
        self.appllayer = ApplicationLayerComponent("ApplicationLayer",
                                                   componentid)
        self.netlayer = AllSeingEyeNetworkLayer("NetworkLayer", componentid)
        self.linklayer = LinkLayer("LinkLayer", componentid)
        # self.failuredetect = GenericFailureDetector("FailureDetector", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.appllayer.connect_me_to_component(ConnectorTypes.DOWN,
                                               self.netlayer)
        # self.failuredetect.connectMeToComponent(PortNames.DOWN, self.netlayer)
        self.netlayer.connect_me_to_component(ConnectorTypes.UP,
                                              self.appllayer)
        # self.netlayer.connectMeToComponent(PortNames.UP, self.failuredetect)
        self.netlayer.connect_me_to_component(ConnectorTypes.DOWN,
                                              self.linklayer)
        self.linklayer.connect_me_to_component(ConnectorTypes.UP,
                                               self.netlayer)

        # Connect the bottom component to the composite component....
        self.linklayer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.linklayer)

        super().__init__(componentname, componentid)
Esempio n. 2
0
class DijkstraScholtenAdHocNode(ComponentModel):
    def __init__(self, componentname, componentid, context):
        self.context = context
        # SUBCOMPONENTS
        self.appllayer = DijkstraScholtenApplicationLayerComponent(
            "ApplicationLayer", componentid, context=self.context)
        self.netlayer = AllSeingEyeNetworkLayer("NetworkLayer", componentid)
        self.linklayer = LinkLayer("LinkLayer", componentid)
        # self.failuredetect = GenericFailureDetector("FailureDetector", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.appllayer.connect_me_to_component(ConnectorTypes.DOWN,
                                               self.netlayer)
        # self.failuredetect.connectMeToComponent(PortNames.DOWN, self.netlayer)
        self.netlayer.connect_me_to_component(ConnectorTypes.UP,
                                              self.appllayer)
        # self.netlayer.connectMeToComponent(PortNames.UP, self.failuredetect)
        self.netlayer.connect_me_to_component(ConnectorTypes.DOWN,
                                              self.linklayer)
        self.linklayer.connect_me_to_component(ConnectorTypes.UP,
                                               self.netlayer)

        # Connect the bottom component to the composite component....
        self.linklayer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.linklayer)

        super().__init__(componentname, componentid, context=self.context)

    def on_init(self, eventobj: Event):
        # print(f"Initializing {self.componentname}.{self.componentinstancenumber}")
        pass

    def on_message_from_top(self, eventobj: Event):
        self.send_down(Event(self, EventTypes.MFRT, eventobj.eventcontent))

    def on_message_from_bottom(self, eventobj: Event):
        self.send_up(Event(self, EventTypes.MFRB, eventobj.eventcontent))

    def simulation_tick(self):
        return self.appllayer.simulation_tick()

    @property
    def waiting_packages_on_queue(self):
        if self.appllayer.simulation_state == DSAHCNodeSimulationStatus.OUT_OF_CLOCK or self.appllayer.simulation_state == DSAHCNodeSimulationStatus.OUT_OF_TREE:
            return 0

        return self.appllayer.basic_message_queue.qsize()

    @property
    def parent_node(self):
        return self.appllayer._parent_node
Esempio n. 3
0
    def __init__(self, componentname, componentid):
        # SUBCOMPONENTS
        self.traverse_service = DfsTraverse("DfsTraverse", componentid)
        self.link_layer = LinkLayer("LinkLayer", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.traverse_service.connect_me_to_component(ConnectorTypes.DOWN,
                                                      self.link_layer)
        self.link_layer.connect_me_to_component(ConnectorTypes.UP,
                                                self.traverse_service)

        # Connect the bottom component to the composite component....
        self.link_layer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.link_layer)

        super().__init__(componentname, componentid)
Esempio n. 4
0
    def __init__(self, componentname, componentid):
        # SUBCOMPONENTS
        self.broadcastservice = ControlledFlooding("SimpleFlooding",
                                                   componentid)
        self.linklayer = LinkLayer("LinkLayer", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.broadcastservice.connect_me_to_component(ConnectorTypes.DOWN,
                                                      self.linklayer)
        self.linklayer.connect_me_to_component(ConnectorTypes.UP,
                                               self.broadcastservice)

        # Connect the bottom component to the composite component....
        self.linklayer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.linklayer)

        super().__init__(componentname, componentid)
Esempio n. 5
0
class AdHocNode(ComponentModel):
    def on_message_from_top(self, eventobj: Event):
        self.send_down(Event(self, EventTypes.MFRT, eventobj.eventcontent))

    def on_message_from_bottom(self, eventobj: Event):
        self.send_up(Event(self, EventTypes.MFRB, eventobj.eventcontent))

    def __init__(self, componentname, componentid):
        # SUBCOMPONENTS
        self.traverse_service = DfsTraverse("DfsTraverse", componentid)
        self.link_layer = LinkLayer("LinkLayer", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.traverse_service.connect_me_to_component(ConnectorTypes.DOWN,
                                                      self.link_layer)
        self.link_layer.connect_me_to_component(ConnectorTypes.UP,
                                                self.traverse_service)

        # Connect the bottom component to the composite component....
        self.link_layer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.link_layer)

        super().__init__(componentname, componentid)
Esempio n. 6
0
class AdHocNode(ComponentModel):
    def on_init(self, eventobj: Event):
        print(
            f"Initializing {self.componentname}.{self.componentinstancenumber}"
        )

    def on_message_from_top(self, eventobj: Event):
        self.send_down(Event(self, EventTypes.MFRT, eventobj.eventcontent))

    def on_message_from_bottom(self, eventobj: Event):
        self.send_up(Event(self, EventTypes.MFRB, eventobj.eventcontent))

    def __init__(self, componentname, componentid):
        # SUBCOMPONENTS
        self.appllayer = ApplicationLayerComponent("ApplicationLayer",
                                                   componentid)
        self.netlayer = AllSeingEyeNetworkLayer("NetworkLayer", componentid)
        self.linklayer = LinkLayer("LinkLayer", componentid)
        # self.failuredetect = GenericFailureDetector("FailureDetector", componentid)

        # CONNECTIONS AMONG SUBCOMPONENTS
        self.appllayer.connect_me_to_component(ConnectorTypes.DOWN,
                                               self.netlayer)
        # self.failuredetect.connectMeToComponent(PortNames.DOWN, self.netlayer)
        self.netlayer.connect_me_to_component(ConnectorTypes.UP,
                                              self.appllayer)
        # self.netlayer.connectMeToComponent(PortNames.UP, self.failuredetect)
        self.netlayer.connect_me_to_component(ConnectorTypes.DOWN,
                                              self.linklayer)
        self.linklayer.connect_me_to_component(ConnectorTypes.UP,
                                               self.netlayer)

        # Connect the bottom component to the composite component....
        self.linklayer.connect_me_to_component(ConnectorTypes.DOWN, self)
        self.connect_me_to_component(ConnectorTypes.UP, self.linklayer)

        super().__init__(componentname, componentid)