Example #1
0
    def start(self):  # type: () -> None
        logger.info('Starting gateway thermostatcontroller...')
        if not self._running:
            self._running = True

            self.refresh_config_from_db()
            self._pid_loop_thread = DaemonThread(
                name='thermostatpid',
                target=self._pid_tick,
                interval=self.THERMOSTAT_PID_UPDATE_INTERVAL)
            self._pid_loop_thread.start()

            self._update_pumps_thread = DaemonThread(
                name='thermostatpumps',
                target=self._update_pumps,
                interval=self.PUMP_UPDATE_INTERVAL)
            self._update_pumps_thread.start()

            self._periodic_sync_thread = DaemonThread(
                name='thermostatsync',
                target=self._periodic_sync,
                interval=self.SYNC_CONFIG_INTERVAL)
            self._periodic_sync_thread.start()

            self._scheduler.start()
            logger.info('Starting gateway thermostatcontroller... Done')
        else:
            raise RuntimeError(
                'GatewayThermostatController already running. Please stop it first.'
            )
 def start(self):
     super(FrontpanelClassicController, self).start()
     # Enable power led
     self._enabled_leds[FrontpanelController.Leds.POWER] = True
     # Start polling/writing threads
     self._poll_button_thread = DaemonThread(name='buttonpoller',
                                             target=self._poll_button,
                                             interval=0.25)
     self._poll_button_thread.start()
     self._write_leds_thread = DaemonThread(name='ledwriter',
                                            target=self._write_leds,
                                            interval=0.25)
     self._write_leds_thread.start()
    def __init__(self, pubsub=INJECTED):
        # type: (PubSub) -> None
        self._pubsub = pubsub
        self._status = {}  # type: Dict[int, VentilationStatusDTO]
        self.check_connected_runner = DaemonThread(
            'check_connected_thread',
            self._check_connected_timeout,
            interval=30,
            delay=15)

        self.periodic_event_update_runner = DaemonThread(
            'periodic_update',
            self._periodic_event_update,
            interval=900,
            delay=90)
Example #4
0
 def start(self):
     super(FrontpanelCoreController, self).start()
     # Start polling/writing threads
     self._check_buttons_thread = DaemonThread(name='buttonchecker',
                                               target=self._check_buttons,
                                               interval=0.25)
     self._check_buttons_thread.start()
Example #5
0
 def start(self):
     self._sync_orm_thread = DaemonThread(name='{0}sync'.format(
         self.__class__.__name__.lower()[:10]),
                                          target=self._sync_orm,
                                          interval=self._sync_orm_interval,
                                          delay=300)
     self._sync_orm_thread.start()
    def __init__(self,
                 output_controller=INJECTED,
                 master_controller=INJECTED,
                 pubsub=INJECTED):
        # type: (OutputController, MasterClassicController, PubSub) -> None
        super(ThermostatControllerMaster, self).__init__(output_controller)
        self._master_controller = master_controller  # classic only
        self._pubsub = pubsub

        self._monitor_thread = DaemonThread(name='thermostatctl',
                                            target=self._monitor,
                                            interval=30,
                                            delay=10)

        self._thermostat_status = ThermostatStatusMaster(
            on_thermostat_change=self._thermostat_changed,
            on_thermostat_group_change=self._thermostat_group_changed)
        self._thermostats_original_interval = 30
        self._thermostats_interval = self._thermostats_original_interval
        self._thermostats_last_updated = 0.0
        self._thermostats_restore = 0
        self._thermostats_config = {}  # type: Dict[int, ThermostatDTO]

        self._pubsub.subscribe_master_events(PubSub.MasterTopics.EEPROM,
                                             self._handle_master_event)
Example #7
0
 def start(self):
     # type: () -> None
     super(OutputController, self).start()
     self._sync_state_thread = DaemonThread(name='outputsyncstate',
                                            target=self._sync_state,
                                            interval=600,
                                            delay=10)
     self._sync_state_thread.start()
Example #8
0
 def __init__(self, name, collector, interval=5):
     self._data = None
     self._data_lock = Lock()
     self._interval = interval
     self._collector_function = collector
     self._collector_thread = DaemonThread(name='{0}coll'.format(name),
                                           target=self._collect,
                                           interval=interval)
Example #9
0
 def start(self,
           custom_interval=30
           ):  # Adding custom interval to pass the tests faster
     self._stop = False
     self._processor = DaemonThread(target=self._process,
                                    name='schedulingctl',
                                    interval=custom_interval)
     self._processor.start()
Example #10
0
 def start(self):
     # type: () -> None
     if self._watchdog_thread is None:
         self.start_time = time.time()
         self._watchdog_thread = DaemonThread(name='watchdog',
                                              target=self._watch,
                                              interval=60,
                                              delay=10)
         self._watchdog_thread.start()
Example #11
0
 def start(self):
     # type: () -> None
     if self._thread is None:
         logger.info('Starting master heartbeat')
         self._thread = DaemonThread(name='masterheartbeat',
                                     target=self._heartbeat,
                                     interval=30,
                                     delay=5)
         self._thread.start()
Example #12
0
 def __init__(self, cloud_api_client=INJECTED):  # type: (CloudAPIClient) -> None
     self._queue = deque()  # type: deque
     self._stopped = True
     self._cloud_client = cloud_api_client
     self._event_enabled_cache = {}  # type: Dict[int, bool]
     self._events_queue = deque()  # type: deque
     self._events_thread = DaemonThread(name='eventsender',
                                        target=self._send_events_loop,
                                        interval=0.1, delay=0.2)
Example #13
0
 def start(self):
     self._refresh_cloud_interval()
     self._collector_plugins = DaemonThread(name='metricplugincoll',
                                            target=self._collect_plugins,
                                            interval=1)
     self._collector_plugins.start()
     self._collector_openmotics = DaemonThread(name='metricplugindist',
                                               target=self._collect_openmotics,
                                               interval=1)
     self._collector_openmotics.start()
     self._distributor_plugins = DaemonThread(name='metricplugindist',
                                              target=self._distribute_plugins,
                                              interval=0, delay=0.1)
     self._distributor_plugins.start()
     self._distributor_openmotics = DaemonThread(name='metricomdist',
                                                 target=self._distribute_openmotics,
                                                 interval=0, delay=0.1)
     self._distributor_openmotics.start()
Example #14
0
 def __init__(self, message_client=INJECTED):
     self._configuration = {}
     self._intervals = {}
     self._vpn_open = False
     self._message_client = message_client
     self._vpn_controller = VpnController()
     self._tasks = deque()
     self._previous_amount_of_tasks = 0
     self._executor = DaemonThread(name='taskexecutor',
                                   target=self._execute_tasks,
                                   interval=300)
Example #15
0
 def __init__(self, master_communicator=INJECTED):
     # type: (MasterCommunicator) -> None
     self._master_communicator = master_communicator
     self._failures = -1  # Start "offline"
     self._backoff = 60
     self._last_restart = 0.0
     self._min_threshold = 2
     self._thread = DaemonThread(name='masterheartbeat',
                                 target=self._heartbeat,
                                 interval=30,
                                 delay=5)
Example #16
0
 def start(self):
     # type: () -> None
     """ Start the background thread of the TimeKeeper. """
     if self.__thread is None:
         logger.info("Starting TimeKeeper")
         self.__stop = False
         self.__thread = DaemonThread(name='timekeeper',
                                      target=self.__run,
                                      interval=self.__period)
         self.__thread.start()
     else:
         raise Exception("TimeKeeper thread already running.")
Example #17
0
 def __init__(self):
     # type: () -> None
     self._gateway_topics = defaultdict(
         list
     )  # type: Dict[GATEWAY_TOPIC,List[Callable[[GatewayEvent],None]]]
     self._master_topics = defaultdict(
         list
     )  # type: Dict[MASTER_TOPIC,List[Callable[[MasterEvent],None]]]
     self._master_events = Queue(
     )  # type: Queue  # Queue[Tuple[str, MasterEvent]]
     self._gateway_events = Queue(
     )  # type: Queue  # Queue[Tuple[str, GatewayEvent]]
     self._pub_thread = DaemonThread(name='pubsub',
                                     target=self._publisher_loop,
                                     interval=0.1,
                                     delay=0.2)
     self._is_running = False
Example #18
0
 def __init__(self):
     self.vpn_connected = False
     self._vpn_tester = DaemonThread(name='vpnctl',
                                     target=self._vpn_connected,
                                     interval=5)
 def start(self):
     self._check_network_activity_thread = DaemonThread(
         name='frontpanel', target=self._do_frontpanel_tasks, interval=0.5)
     self._check_network_activity_thread.start()
Example #20
0
 def start(self):
     self._stop = False
     self._processor = DaemonThread(target=self._process,
                                    name='schedulingctl',
                                    interval=60)
     self._processor.start()