示例#1
0
    def __init__(self, master_communicator=INJECTED, pubsub=INJECTED):
        # type: (CoreCommunicator, PubSub) -> None
        """
        Initializes the MemoryFile instance, reprensenting read/write to EEPROM and FRAM
        """
        if not master_communicator:
            raise RuntimeError('Could not inject argument: core_communicator')

        self._core_communicator = master_communicator
        self._pubsub = pubsub

        self._eeprom_cache = {}  # type: Dict[int, bytearray]
        self._fram_cache = {}  # type: Dict[int, Tuple[float, bytearray]]

        # The write cache is a per-thread/per-type cache of all changes that need to be written that has the page
        # as key, and a list of tuples as value, where the tuples holds the start byte and contents
        self._write_cache = {
        }  # type: Dict[int, Dict[str, Dict[int, Dict[int, int]]]]
        self._write_cache_lock = {}  # type: Dict[int, Lock]
        self._select_write_cache_lock = Lock()
        self._activate_lock = Lock()

        self._eeprom_change_callback = None  # type: Optional[Callable[[], None]]
        self._self_activated = False
        self._activation_event = ThreadingEvent()

        self._core_communicator.register_consumer(
            BackgroundConsumer(CoreAPI.event_information(), 0,
                               self._handle_event))
示例#2
0
    def __init__(self, master_communicator=INJECTED, verbose=False):  # type: (CoreCommunicator, bool) -> None
        """
        :param master_communicator: CoreCommunicator
        :param verbose: Log all communication
        """
        self._verbose = verbose
        self._communicator = master_communicator
        self._consumers = {}  # type: Dict[str, List[Union[Consumer, PalletConsumer]]]
        self._cc_pallet_mode = {}  # type: Dict[str, bool]

        self._background_consumer = BackgroundConsumer(CoreAPI.ucan_rx_transport_message(), 1, self._process_transport_message)
        self._communicator.register_consumer(self._background_consumer)
示例#3
0
    def __init__(self, master_communicator=INJECTED, verbose=False):
        """
        :param master_communicator: CoreCommunicator
        :param verbose: Log all communication
        """
        self._verbose = verbose  # type: bool
        self._communicator = master_communicator  # type: CoreCommunicator
        self._consumers = []
        self._transparent_mode = False
        self._read_buffer = bytearray()

        self._background_consumer = BackgroundConsumer(
            CoreAPI.slave_rx_transport_message(), 2,
            self._process_transport_message)
        self._communicator.register_consumer(self._background_consumer)
 def __init__(
         self,
         master_communicator=INJECTED):  # type: (CoreCommunicator) -> None
     super(FrontpanelCoreController, self).__init__()
     self._master_communicator = master_communicator
     self._master_communicator.register_consumer(
         BackgroundConsumer(CoreAPI.event_information(), 0,
                            self._handle_event))
     self._led_states = {}  # type: Dict[str, LedStateTracker]
     self._led_event_lock = Lock()
     self._carrier = True
     self._connectivity = True
     self._activity = False
     self._cloud = False
     self._vpn = False
     self._led_drive_states = {}  # type: Dict[str, Tuple[bool, str]]
     self._check_buttons_thread = None
     self._authorized_mode_buttons = [False, False]
     self._authorized_mode_buttons_pressed_since = None  # type: Optional[float]
     self._authorized_mode_buttons_released = False
示例#5
0
    def __init__(self, memory_type, master_communicator=INJECTED, pubsub=INJECTED):
        # type: (str, CoreCommunicator, PubSub) -> None
        """
        Initializes the MemoryFile instance, reprensenting one of the supported memory types.
        It provides caching for EEPROM, and direct write/read through for FRAM
        """
        if not master_communicator:
            raise RuntimeError('Could not inject argument: core_communicator')

        self._core_communicator = master_communicator
        self._pubsub = pubsub
        self.type = memory_type
        self._cache = {}  # type: Dict[int, bytearray]
        self._eeprom_change_callback = None  # type: Optional[Callable[[], None]]
        self._pages, self._page_length = MemoryFile.SIZES[memory_type]  # type: int, int
        self._self_activated = False
        self._dirty = False
        self._activation_event = ThreadingEvent()

        if memory_type == MemoryTypes.EEPROM:
            self._core_communicator.register_consumer(
                BackgroundConsumer(CoreAPI.event_information(), 0, self._handle_event)
            )
 def new_consumer(*args):
     consumer = BackgroundConsumer(*args)
     consumer_list.append(consumer)
     return consumer