Beispiel #1
0
 def __init__(self, config_uri):
     FarmProcess.__init__(self, 'FM', config_uri)
     logging.info('FM: Initializing')
     self.parameters = None
     self.regulators = None
     self.real_regulators = None
     self.devices = None
     self.max_regulation_order = 0
     now = datetime.now()
     # query database
     self.cultivation_start = FieldSetting.get_cultivation_start(
         self.db_session)
     self.reload_parameters()
     self.reload_devices()
     self.handle_parameters(now)
     self.handle_device_setpoints(now)
     self.reload_regulators()
     self.handle_regulators(now)
     # listen for database changes (broadcat on redis channels)
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe('parameter_changes', 'device_changes',
                           'calendar_changes', 'field_setting_changes',
                           'regulator_changes',
                           'periphery_controller_changes',
                           'component_input_changes',
                           'component_property_changes')
     logging.info('FM: initialisation finished')
 def __init__(self, config_uri):
     FarmProcess.__init__(self, 'FM', config_uri)
     logging.info('FM: Initializing')
     self.parameters = None
     self.regulators = None
     self.real_regulators = None
     self.devices = None
     self.max_regulation_order = 0
     now = datetime.now()
     # query database
     self.cultivation_start = FieldSetting.get_cultivation_start(self.db_session)
     self.reload_parameters()
     self.reload_devices()
     self.handle_parameters(now)
     self.handle_device_setpoints(now)
     self.reload_regulators()
     self.handle_regulators(now)
     # listen for database changes (broadcat on redis channels)
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe('parameter_changes',
                           'device_changes',
                           'calendar_changes',
                           'field_setting_changes',
                           'regulator_changes',
                           'periphery_controller_changes',
                           'component_input_changes',
                           'component_property_changes')
     logging.info('FM: initialisation finished')
 def __init__(self, config_uri):
     FarmProcess.__init__(self, "PC", config_uri)
     logging.info("PC: Initializing")
     # connect with serial port
     self.dev_names = glob("/dev/ttyA*")
     self.shells = {}
     self.controller_ids = {}
     self.periphery_controllers = {}
     for dev_name in self.dev_names:
         self.initialize_dev(dev_name)
     self.db_session.commit()
     # listen for changes in the database
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe("periphery_controller_changes", "field_setting_changes")
     logging.info("PC: Initialisation finished\n\n")
Beispiel #4
0
 def __init__(self, config_uri):
     FarmProcess.__init__(self, "FL", config_uri)
     logging.info("Initializing Farm Logger")
     self.parameters = None
     self.devices = None
     now = datetime.now()
     # query database
     self.reload_parameters()
     self.reload_devices()
     self.handle_parameters()
     self.handle_devices()
     # listen for database changes (broadcat on redis channels)
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe("parameter_changes", "device_changes", "field_setting_changes")
     logging.info("Farm Logger initialized\n\n")
 def __init__(self, config_uri):
     FarmProcess.__init__(self, 'PC', config_uri)
     logging.info('PC: Initializing')
     # connect with serial port
     self.dev_names = glob('/dev/ttyA*')
     self.shells = {}
     self.controller_ids = {}
     self.periphery_controllers = {}
     for dev_name in self.dev_names:
         self.initialize_dev(dev_name)
     self.db_session.commit()
     # listen for changes in the database
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe('periphery_controller_changes',
                           'field_setting_changes')
     logging.info('PC: Initialisation finished\n\n')
Beispiel #6
0
 def __init__(self, config_uri):
     FarmProcess.__init__(self, 'FL', config_uri)
     logging.info('Initializing Farm Logger')
     self.parameters = None
     self.devices = None
     now = datetime.now()
     # query database
     self.reload_parameters()
     self.reload_devices()
     self.handle_parameters()
     self.handle_devices()
     # listen for database changes (broadcat on redis channels)
     self.pubsub = self.redis_conn.pubsub(ignore_subscribe_messages=True)
     self.pubsub.subscribe('parameter_changes',
                           'device_changes',
                           'field_setting_changes')
     logging.info('Farm Logger initialized\n\n')
Beispiel #7
0
 def run(self):
     logging.info('Farm Logger entered work loop')
     print('Farm Logger entered work loop')
     last_run = datetime.now()
     while True:
         # sleep
         while datetime.now() - last_run < self.loop_time:
             sleep(0.05)
         t0 = datetime.now()
         now = FarmProcess.unprecise_now(datetime.now())
         last_run = now
         self.handle_messages()
         # calculate setpoints, log parameters
         self.handle_parameters(now)
         self.handle_devices(now)
         try:
             self.db_session.commit()
         except IntegrityError as e:
             print('\n\nError: ' + str(e) + '\n\n')
             self.db_session.rollback()
         self.reset_watchdog()
         worktime = datetime.now() - t0
         if worktime > self.loop_time:
             logging.error('FL: t_w=%.2f ' % worktime.total_seconds())
Beispiel #8
0
 def run(self):
     logging.info("Farm Logger entered work loop")
     print("Farm Logger entered work loop")
     last_run = datetime.now()
     while True:
         # sleep
         while datetime.now() - last_run < self.loop_time:
             sleep(0.05)
         t0 = datetime.now()
         now = FarmProcess.unprecise_now(datetime.now())
         last_run = now
         self.handle_messages()
         # calculate setpoints, log parameters
         self.handle_parameters(now)
         self.handle_devices(now)
         try:
             self.db_session.commit()
         except IntegrityError as e:
             print("\n\nError: " + str(e) + "\n\n")
             self.db_session.rollback()
         self.reset_watchdog()
         worktime = datetime.now() - t0
         if worktime > self.loop_time:
             logging.error("FL: t_w=%.2f " % worktime.total_seconds())