예제 #1
0
class TestDependencyComponent(Component):

    next = Dependency(required=False)

    def __init__(self):
        self.is_started = False

    def start(self):
        if self.is_started:
            raise ValueError
        self.is_started = True
예제 #2
0
class SMSService(Component):
    """
    """

    # dependencies
    sms_driver = Dependency()
    device_communication_service = Dependency()

    # settings
    store_history = BooleanSetting(
        required=True,
        help="Specify whether or not message history should be maintained")

    max_rx_history = IntegerSetting(
        required=False,
        default=10,
        help="The number of received messages that should be maintained")

    min_rx_history = IntegerSetting(
        required=False,
        default=10,
        help="The number of transmitted messages that should be maintained")

    def __init__(self):
        Component.__init__(self)
        self._rx_messages = collections.deque()
        self._tx_messages = collections.deque()

    def start(self):
        self.sms_driver.register_rx_callback(self._rx_message)

    def _rx_message(self, sms_message):
        self._rx_messages.appendleft(sms_message)
        max_rx_history = self.max_rx_history
        if len(self._rx_messages) > max_rx_history:
            self._rx_messages.pop()
예제 #3
0
class TestComponent(Component):

    _comp_instantiation_counter = 0

    previous = Dependency(required=False)

    name = StringSetting(required=True, help="Name of this component")

    def __init__(self):
        self.is_main = False
        if self.previous is None:
            self.count = 0
        else:
            self.count = self.previous.count + 1

    def main(self):
        self.is_main = True
예제 #4
0
class TestDependencyComponent(Component):
    next = Dependency(required=False)
예제 #5
0
class TestDependencyComponent(Component):
    next = Dependency()
예제 #6
0
class TestRequiredDependencyComponent(Component):
    dependency = Dependency(required=True)
예제 #7
0
class TestDependencyListComponent(Component):

    others = Dependency()

    def ping(self):
        return True