Пример #1
0
 def run(this):
     # set up logger
     logger = Logger()
     logger.VERBOSE = VERBOSE
     logger.SUPPRESS = SUPPRESS
     logger.logInfo("Schedule distribution thread started.")
     # set up connector to get pi connections
     if DUMMY:
         connector = DummyConnector(logger)
     else:
         connector = Connector(logger)
     connector.connect_pis()
     pis = connector.get_pis()
     # set up distributor and schedule builder
     if DUMMY:
         distributor = DummyDistributor(pis, logger)
     else:
         distributor = Distributor(pis, logger)
     distributor.push_configs()
     scheduleBuilder = ScheduleBuilder(distributor, logger)
     while not this.stopEvent.is_set():
         distributor.push_configs_if_updated()
         # attempt to build and distribute schedules
         scheduleBuilder.run()
         # verify pi connections and update
         connector.update_connection_status()
         connector.connect_pis()
         # update pis in the distributor
         distributor.pis = connector.get_pis()
         this.wait(DistributorThread.interval)
     connector.dc_pis()
     logger.logInfo("Schedule distribution thread stopped.")
Пример #2
0
 def run(this):
     # set up logger
     logger = Logger()
     logger.VERBOSE = VERBOSE
     logger.SUPPRESS = SUPPRESS
     logger.logInfo("Data pulling thread started.")
     # set up connector to get pi connections
     if DUMMY:
         connector = DummyConnector(logger)
     else:
         connector = Connector(logger)
     connector.connect_pis()
     pis = connector.get_pis()
     # set up datapuller
     if DUMMY:
         dataPuller = DummyDataPuller(pis, logger)
     else:
         dataPuller = DataPuller(pis, logger)
     # optional data cleaning
     if (CLEAN):
         dataPuller.cleanState()
     elif (CLEAN_HARD):
         dataPuller.cleanState()
         FeedingData.objects.all().delete()
         RFIDLogData.objects.all().delete()
     while not this.stopEvent.is_set():
         # attempt to pull data
         dataPuller.pullCompleted()
         dataPuller.pullLogData()
         # verify pi connections and update
         connector.update_connection_status()
         connector.connect_pis()
         # update pis in the distributor
         dataPuller.pis = connector.get_pis()
         this.wait(DataPullerThread.interval)
     connector.dc_pis()
     logger.logInfo("Data pulling thread stopped.")