def __init__(self): threading.Thread.__init__(self) self.watchdog = Watchdog() self.watchdog.daemon = True self.watchdog.start() time.sleep(1) self.setup = settings.setup self.quit = False for i in range(0, 7): #Set GPIO pins to output wp.pinMode(i, 1) self.setup = settings.setup self.dutycycles = [0, 0, 0, 0, 0, 0] channels = ['1', '2', '3', '4', '5', '6'] # Setup up extra status for the diode relay status diode_channels = ['diode' + number for number in channels] self.diode_channel_last = {name: None for name in diode_channels} # Setup sockets self.livesocket = LiveSocket(self.setup + '-bakeout', channels + diode_channels) self.livesocket.start() self.pullsocket = DateDataPullSocket(self.setup + '-bakeout', channels, timeouts=None) self.pullsocket.start() self.pushsocket = DataPushSocket(self.setup + '-push_control', action='enqueue') self.pushsocket.start()
class FlowControl(threading.Thread): """ Keep updated values of the current flow """ def __init__(self, mks_instance, mfcs, devices, name): threading.Thread.__init__(self) self.mfcs = mfcs self.mks = mks_instance self.pullsocket = DateDataPullSocket(name, devices, timeouts=3.0, port=9000) self.pullsocket.start() self.pushsocket = DataPushSocket(name, action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket(name, devices) self.livesocket.start() self.running = True def run(self): while self.running: time.sleep(0.1) qsize = self.pushsocket.queue.qsize() while qsize > 0: element = self.pushsocket.queue.get() mfc = list(element.keys())[0] print(element[mfc]) print('Queue: ' + str(qsize)) self.mks.set_flow(element[mfc], self.mfcs[mfc]) qsize = self.pushsocket.queue.qsize() for mfc in self.mfcs: print('!!!') flow = self.mks.read_flow(self.mfcs[mfc]) print(mfc + ': ' + str(flow)) self.pullsocket.set_point_now(mfc, flow) self.livesocket.set_point_now(mfc, flow)
def __init__(self): sql_queue = queue.Queue() self.data_saver = database_saver.SqlSaver(settings.username, settings.username, sql_queue) self.data_saver.start() if settings.qmg == '420': self.qmg = qmg420.qmg_420(settings.port) if settings.qmg == '422': print(settings.port) self.qmg = qmg422.qmg_422(port=settings.port, speed=settings.speed) try: livesocket = LiveSocket(settings.name + '-mass-spec', ['qms-value']) livesocket.start() except: livesocket = None pullsocket = DateDataPullSocket(settings.name + '-mass-spec', ['qms-value']) pullsocket.start() self.qms = ms.QMS(self.qmg, sql_queue, chamber=settings.chamber, credentials=settings.username, livesocket=livesocket, pullsocket=pullsocket) self.qmg.reverse_range = settings.reverse_range self.printer = qmg_status_output.QmsStatusOutput( self.qms, sql_saver_instance=self.data_saver) self.printer.start()
def main(): """ Main function """ tempreader = TemperatureReader() tempreader.daemon = True tempreader.start() temp_logger = ValueLogger(tempreader, comp_val=1) temp_logger.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_chemlab307', username=credentials.user, password=credentials.passwd, measurement_codenames=['chemlab307_muffle_furnace']) socket = DateDataPullSocket('muffle_furnace', ['chemlab307_muffle_furnace'], timeouts=[1.0]) socket.start() livesocket = LiveSocket('muffle_furnace', ['chemlab307_muffle_furnace']) livesocket.start() db_logger.start() time.sleep(5) while True: time.sleep(0.25) value = temp_logger.read_value() socket.set_point_now('chemlab307_muffle_furnace', value) livesocket.set_point_now('chemlab307_muffle_furnace', value) if temp_logger.read_trigged(): print(value) db_logger.save_point_now('chemlab307_muffle_furnace', value) temp_logger.clear_trigged()
def main(): """ Main function """ code_names = ['pvd309_temp_dca_cell', 'pvd309_temp_mai_cell'] reader = TemperatureReader() reader.start() loggers = {} loggers[code_names[0]] = ValueLogger(reader, channel=1, comp_val = 0.5, comp_type = 'lin') loggers[code_names[0]].start() loggers[code_names[1]] = ValueLogger(reader, channel=2, comp_val = 0.5, comp_type = 'lin') loggers[code_names[1]].start() datasocket = DateDataPullSocket('pvd_309_temp', code_names, timeouts=[2.0] * 2, port=9001) datasocket.start() livesocket = LiveSocket('pvd_309_temperatures', code_names) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_pvd309', username=credentials.user, password=credentials.passwd, measurement_codenames=code_names) db_logger.start() time.sleep(5) while not reader.quit: time.sleep(0.25) for name in code_names: print(reader.ttl) value = loggers[name].read_value() datasocket.set_point_now(name, value) livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def __init__(self): sql_queue = queue.Queue() self.data_saver = database_saver.SqlSaver(settings.username, settings.username, sql_queue) self.data_saver.start() if settings.qmg == '420': self.qmg = qmg420.qmg_420(settings.port) if settings.qmg == '422': print(settings.port) self.qmg = qmg422.qmg_422(port=settings.port, speed=settings.speed) try: livesocket = LiveSocket(settings.name + '-mass-spec', ['qms-value']) livesocket.start() except: livesocket = None pullsocket = DateDataPullSocket(settings.name + '-mass-spec', ['qms-value']) pullsocket.start() self.qms = ms.QMS(self.qmg, sql_queue, chamber=settings.chamber, credentials=settings.username, livesocket=livesocket, pullsocket=pullsocket) self.qmg.reverse_range = settings.reverse_range self.printer = qmg_status_output.QmsStatusOutput(self.qms, sql_saver_instance=self.data_saver) self.printer.start()
def main(): """Main function""" pvci = PVCi('/dev/serial/by-id/' 'usb-FTDI_USB-RS485_Cable_FTY3M2GN-if00-port0') # Start live socket live_socket = LiveSocket('thetaprobe_pvci', list(CODENAME_TRANSLATION.keys()), sane_interval=0.5) live_socket.start() # Start database saver database_saver = ContinuousDataSaver( 'dateplots_thetaprobe', credentials.USERNAME, credentials.PASSWORD, list(CODENAME_TRANSLATION.keys()) ) database_saver.start() # Set up criterium checker criterium_checker = LoggingCriteriumChecker( codenames=list(CODENAME_TRANSLATION.keys()), types=['log', 'log', 'lin'], criteria=[0.1, 0.1, 1.0], ) try: run(pvci, live_socket, database_saver, criterium_checker) except KeyboardInterrupt: pvci.close() live_socket.stop() database_saver.stop()
def test_live_multiple_variables(sock): codenames = ['name1', 'name2'] live_socket = LiveSocket(NAME, codenames, 1.0) live_socket.start() port = 8000 # Test the 'codenames' command data = send_and_resc(sock, 'codenames', port) expected = ['name1', 'name2'] assert (json.loads(data) == expected) # Test the 'sane_interval' command data = send_and_resc(sock, 'sane_interval', port) assert (json.loads(data) - 1.0 < 1E-8) for n in range(3): now = time.time() live_socket.set_point('name1', (now, n)) live_socket.set_point('name2', (now, n + 1)) # Test the 'data' command data = send_and_resc(sock, 'data', port) expected = [[now, n], [now, n + 1]] assert (json.loads(data) == expected) time.sleep(0.1) live_socket.stop()
def __init__(self, ranges, devices, socket_name): threading.Thread.__init__(self) self.devices = devices name = {} mfcs = {} print('!') for i in range(0, 8): print('----------------') print('Cheking port number: {}'.format(i)) error = 0 name[i] = '' while (error < 3) and (name[i] == ''): # Pro forma-range will be update in a few lines ioerror = 0 while ioerror < 10: time.sleep(0.5) print(ioerror) try: bronk = bronkhorst.Bronkhorst('/dev/ttyUSB' + str(i), 1) print('MFC Found') break except: # pylint: disable=bare-except ioerror = ioerror + 1 if ioerror == 10: print('No MFC found on this port') break print('Error count before identification: {}'.format(ioerror)) name[i] = bronk.read_serial() print('MFC Name: {}'.format(name[i])) name[i] = name[i].strip() error = error + 1 if name[i] in devices: ioerror = 0 if ioerror < 10: print(ioerror) try: mfcs[name[i]] = bronkhorst.Bronkhorst( '/dev/ttyUSB' + str(i), ranges[name[i]]) mfcs[name[i]].set_control_mode( ) #Accept setpoint from rs232 except IOError: ioerror = ioerror + 1 if ioerror == 10: print('Found MFC but could not set range') self.mfcs = mfcs self.pullsocket = DateDataPullSocket(socket_name, devices, timeouts=3.0, port=9000) self.pullsocket.start() self.pushsocket = DataPushSocket(socket_name, action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket(socket_name, devices) self.livesocket.start() self.running = True self.reactor_pressure = float('NaN')
def main(): """ Main loop """ il800 = intellemetrics_il800.IL800( "/dev/serial/by-id/" + "usb-Prolific_Technology_Inc." + "_USB-Serial_Controller_D-if00-port0" ) sqm160 = inficon_sqm160.InficonSQM160("/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0") qcm1 = QcmReader(il800) qcm1.start() qcm2 = QcmReader(sqm160) qcm2.start() time.sleep(2.5) codenames = [ "pvd309_qcm1_rate", "pvd309_qcm1_thickness", "pvd309_qcm1_frequency", "pvd309_qcm2_rate", "pvd309_qcm2_thickness", "pvd309_qcm2_frequency", ] loggers = {} loggers[codenames[0]] = ValueLogger(qcm1, comp_val=0.01, comp_type="lin", channel=0) loggers[codenames[1]] = ValueLogger(qcm1, comp_val=0.1, comp_type="lin", channel=1) loggers[codenames[2]] = ValueLogger(qcm1, comp_val=1, comp_type="lin", channel=2) loggers[codenames[3]] = ValueLogger(qcm2, comp_val=0.3, comp_type="lin", channel=0) loggers[codenames[4]] = ValueLogger(qcm2, comp_val=0.1, comp_type="lin", channel=1) loggers[codenames[5]] = ValueLogger(qcm2, comp_val=1, comp_type="lin", channel=2) for name in codenames: loggers[name].daemon = True loggers[name].start() livesocket = LiveSocket("pvd309 qcm logger", codenames) livesocket.start() socket = DateDataPullSocket("pvd309 qcm", codenames, timeouts=[1.0] * len(codenames)) socket.start() db_logger = ContinuousLogger( table="dateplots_pvd309", username=credentials.user, password=credentials.passwd, measurement_codenames=codenames, ) db_logger.start() while qcm1.isAlive() and qcm2.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ": " + str(value)) db_logger.enqueue_point_now(name, value) loggers[name].clear_trigged()
def test_live_multiple_variables(sock): codenames = ['name1', 'name2'] live_socket = LiveSocket(NAME, codenames, 1.0) live_socket.start() port = 8000 # Test the 'codenames' command data = send_and_resc(sock, 'codenames', port) expected = ['name1', 'name2'] assert(json.loads(data) == expected) # Test the 'sane_interval' command data = send_and_resc(sock, 'sane_interval', port) assert(json.loads(data) - 1.0 < 1E-8) for n in range(3): now = time.time() live_socket.set_point('name1', (now, n)) live_socket.set_point('name2', (now, n+1)) # Test the 'data' command data = send_and_resc(sock, 'data', port) expected = [[now, n], [now, n+1]] assert(json.loads(data) == expected) time.sleep(0.1) live_socket.stop()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = 'usb-FTDI_USB-RS232_Cable_FTV9UVIO-if00-port0' omega = omegabus.OmegaBus(device='/dev/serial/by-id/' + port, model='D5251', baud=300) hih_instance = honeywell_6000.HIH6130() reader = Reader(omega, hih_instance) reader.start() time.sleep(2.5) codenames = ['b307_049_h2_pressure', 'b307_049_temperature', 'b307_049_humidity'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.1, maximumtime=600, comp_type='lin', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.2, maximumtime=600, comp_type='lin', channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(reader, comp_val=0.5, maximumtime=600, comp_type='lin', channel=2) loggers[codenames[2]].start() livesocket = LiveSocket('307_049 Logger', codenames) livesocket.start() socket = DateDataPullSocket('307_049 logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_b307_049', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """The main method for the pressure logger""" # Open communication to the pressure measurement unit tpg = TPG262(port='/dev/ttyUSB0', baudrate=9600) LOGGER.info('Initiated driver to TPG 262') # Get a continuous logger codenames = ['thetaprobe_pressure_loadlock', 'thetaprobe_pressure_uvgun'] db_logger = ContinuousLogger(table='dateplots_thetaprobe', username=credentials.USERNAME, password=credentials.PASSWORD, measurement_codenames=codenames) db_logger.start() LOGGER.info('Initiated and started database logger') livesocket = LiveSocket(codenames, 0.2) livesocket.start() loadlock_last = {'value': 1E20, 'time': 0} uvgun_last = {'value': 1E20, 'time': 0} try: while True: # get the values: returns: # (value1, (status_code1, status_message1), # value2, (status_code2, status_message2)) value_ll, code_ll, value_uv, code_uv = tpg.pressure_gauges() livesocket.set_point_now('thetaprobe_pressure_loadlock', value_ll) livesocket.set_point_now('thetaprobe_pressure_uvgun', value_uv) ### Load lock if code_ll[0] in [0, 1]: # If measurement is OK or underranged if logging_criteria(value_ll, loadlock_last): LOGGER.info('Add value {} for load lock'.format(value_ll)) now_ll = db_logger.enqueue_point_now( 'thetaprobe_pressure_loadlock', value_ll) loadlock_last['value'] = value_ll loadlock_last['time'] = now_ll ### UV gun if code_uv[0] in [0, 1]: # If measurement is OK or underranged if logging_criteria(value_uv, uvgun_last): LOGGER.info('Add value {} for UV gun'.format(value_uv)) now_uv = db_logger.enqueue_point_now( 'thetaprobe_pressure_uvgun', value_uv) uvgun_last['value'] = value_uv uvgun_last['time'] = now_uv except KeyboardInterrupt: LOGGER.info('Keyboard interrupt. Shutting down') db_logger.stop() livesocket.stop() LOGGER.info('Database logger stoppped. Exiting!')
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) l3g4200d_instance = l3g4200d.L3G4200D() l3g4200d_reader = Reader(l3g4200d_instance) l3g4200d_reader.start() ais328dq_instance = ais328dq.AIS328DQTR() ais328dq_reader = Reader(ais328dq_instance) ais328dq_reader.start() time.sleep(2.5) codenames = ['b307_049_vibration_measurement', 'b307_049_vibration_measurement_accl'] loggers = {} loggers[codenames[0]] = ValueLogger(l3g4200d_reader, comp_val=0.02, maximumtime=600, comp_type='lin', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(ais328dq_reader, comp_val=0.01, maximumtime=100, comp_type='lin', channel=0) loggers[codenames[1]].start() livesocket = LiveSocket('307 Vibraton logger', codenames) livesocket.start() socket = DateDataPullSocket('307 vibration logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_b307_049', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while l3g4200d_reader.isAlive(): time.sleep(10) for name in codenames: value = loggers[name].read_value() print(value) livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ ups = galaxy_3500.Galaxy3500('b312-ups') reader = UpsReader(ups) reader.daemon = True reader.start() time.sleep(5) codenames = ['b312_ups_temperature', 'b312_ups_kVAPh1', 'b312_ups_kVAPh2', 'b312_ups_kVAPh3', 'b312_ups_output_current_Ph1', 'b312_ups_output_current_Ph2', 'b312_ups_output_current_Ph3', 'b312_ups_input_frequency', 'b312_ups_input_voltage_Ph1', 'b312_ups_input_voltage_Ph2', 'b312_ups_input_voltage_Ph3', 'b312_ups_output_voltage_Ph1', 'b312_ups_output_voltage_Ph2', 'b312_ups_output_voltage_Ph3', 'b312_ups_battery_voltage', 'b312_ups_battery_current', 'b312_ups_battery_state_of_charge', 'b312_ups_output_frequency'] loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.1, channel=i) loggers[codenames[i]].start() socket = DateDataPullSocket('UPS status', codenames, timeouts=[5.0] * len(codenames)) socket.start() live_socket = LiveSocket('UPS Status', codenames) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ups_b312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) omron_instance = omron_d6fph.OmronD6fph() hih_instance = honeywell_6000.HIH6130() reader = Reader(omron_instance, hih_instance) reader.start() time.sleep(5) codenames = ['hall_ventilation_pressure', 'hall_temperature', 'hall_humidity'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=1.0, maximumtime=300, comp_type='lin', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.2, maximumtime=600, comp_type='lin', channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(reader, comp_val=0.2, maximumtime=600, comp_type='lin', channel=2) loggers[codenames[2]].start() livesocket = LiveSocket('Hall Ventilation Logger', codenames) livesocket.start() socket = DateDataPullSocket('Hall Ventilation logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_hall', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def __init__(self): threading.Thread.__init__(self) channels = ['setpoint', 'emission', 'ionenergy'] self.datasocket = DateDataPullSocket('emission_tof', channels, timeouts=[99999999, 1.0, 99999999]) self.datasocket.start() self.pushsocket = DataPushSocket('tof-emission-push_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('tof-emission', channels) self.livesocket.start() self.filament = {} port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00' self.filament['device'] = CPX.CPX400DPDriver(1, interface='serial', device=port) self.filament['voltage'] = 0 self.filament['current'] = 0 self.filament['idle_voltage'] = 1.7 self.filament['device'].set_current_limit(7) self.filament['device'].output_status(True) self.bias = {} port = '/dev/serial/by-id/' port += 'usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0' self.keithley_port = port self.bias['device'] = smu.KeithleySMU(interface='serial', device=self.keithley_port) self.bias['grid_voltage'] = 0 self.bias['grid_current'] = 0 self.bias['device'].output_state(True) self.pid = pid.PID(0.01, 0.1, 0, 4) self.looptime = 0 self.setpoint = 0.05 self.pid.update_setpoint(self.setpoint) self.running = True self.wanted_voltage = 0 self.emission_current = 999
def __init__(self, mks_instance, mfcs, devices, name): threading.Thread.__init__(self) self.mfcs = mfcs self.mks = mks_instance self.pullsocket = DateDataPullSocket(name, devices, timeouts=3.0, port=9000) self.pullsocket.start() self.pushsocket = DataPushSocket(name, action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('palle_mks_flows', devices) self.livesocket.start() self.running = True
def __init__(self): threading.Thread.__init__(self) channels = ['setpoint', 'emission', 'ionenergy'] self.datasocket = DateDataPullSocket('emission_tof', channels, timeouts=[99999999, 1.0, 99999999]) self.datasocket.start() self.pushsocket = DataPushSocket('tof-emission-push_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('tof-emission', channels) self.livesocket.start() self.filament = {} port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00' self.filament['device'] = CPX.CPX400DPDriver(1, interface='serial', device=port) self.filament['voltage'] = 0 self.filament['current'] = 0 self.filament['idle_voltage'] = 1.7 self.filament['device'].set_current_limit(4.0) self.filament['device'].output_status(True) self.bias = {} self.bias['device'] = CPX.CPX400DPDriver(2, interface='serial', device=port) self.bias['grid_voltage'] = 0 self.bias['grid_current'] = 0 self.bias['device'].output_status(True) cns = 'USB0::0x0957::0x0607::MY45000583::INSTR' self.bias['current_reader'] = a34410A.Agilent34410ADriver(interface='usbtmc', connection_string=cns) self.bias['current_reader'].select_measurement_function('CURRENT') self.pid = pid.PID(0.01, 0.1, 0, 4) self.looptime = 0 self.setpoint = 0.05 self.pid.update_setpoint(self.setpoint) self.running = True self.wanted_voltage = 0 self.emission_current = 999
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) qcm_port = ('/dev/serial/by-id/' + 'usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0') qcm = inficon.InficonSQM160(qcm_port) reader = QcmReader(qcm) reader.daemon = True reader.start() codenames = ['volvo_qcm_frequency', 'volvo_qcm_crystal_life', 'volvo_qcm_thickness'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.1, channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.01, channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(reader, comp_val=0.001, channel=2) loggers[codenames[2]].start() socket = DateDataPullSocket('Volvo QCM', codenames, port=9000, timeouts=[5.0] * len(codenames)) socket.start() livesocket = LiveSocket('Volvo data logger', codenames) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_volvo', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """Main function""" chiller_port = '/dev/serial/by-id/' chiller_port += 'usb-1a86_USB2.0-Ser_-if00-port0' LOG.info('Using chiller port %s', chiller_port) reader = ChillerReader(chiller_port) reader.start() LOG.info('ChillerReader started') codenames = ['uhv_sputterchamber_chiller_temperature', 'uhv_sputterchamber_chiller_flow', 'uhv_sputterchamber_chiller_temperature_ambient', 'uhv_sputterchamber_chiller_pressure', 'uhv_sputterchamber_chiller_temperature_setpoint'] LOG.debug('Using codenames %s', codenames) loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.11, channel=i) loggers[codenames[i]].start() live_socket_name = 'uhv_sputterchamber' live_socket = LiveSocket(live_socket_name, codenames) live_socket.start() LOG.info('Live socket init and started with name "%s"', live_socket_name) db_table = 'dateplots_uhv_sputterchamber' db_logger = ContinuousDataSaver(continuous_data_table=db_table, username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() LOG.info('ContinuousLogger init and started on table "%s"', db_table) time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() if not math.isnan(value): live_socket.set_point_now(name, value) if loggers[name].read_trigged(): LOG.debug('Log value %s for codename "%s"', value, name) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main code """ #mux_instance = agilent_34972A.Agilent34972ADriver(interface='lan', hostname='volvo-agilent-34972a') port = '/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0' xgs_instance = xgs600.XGS600Driver(port) #analog_measurement = MuxReader(mux_instance) #analog_measurement.start() pressure = PressureReader(xgs_instance) print('-') pressure.start() time.sleep(2.5) #codenames = ['volvo_pressure', 'volvo_temperature'] codenames = ['volvo_pressure'] loggers = {} loggers[codenames[0]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', low_comp=1e-9) loggers[codenames[0]].start() #loggers[codenames[1]] = ValueLogger(analog_measurement, comp_val=0.5, comp_type='lin') #loggers[codenames[1]].start() socket = DateDataPullSocket('Volvo data logger', codenames, timeouts=1.0) socket.start() livesocket = LiveSocket('Volvo data logger', codenames) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_volvo', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() #while pressure.isAlive() and analog_measurement.isAlive(): while True: time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def test_live_wrong_codename(): codenames = ['name1', 'name2'] live_socket = LiveSocket(NAME, codenames, 1.0) live_socket.start() # Test that trying to set an unknown name raises an exception with pytest.raises(ValueError): live_socket.set_point('bad name', (1, 2)) live_socket.stop()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) hih_instance = honeywell_6000.HIH6130() reader = Reader(hih_instance) reader.daemon = True reader.start() time.sleep(5) codenames = ['chemlab312_temperature', 'chemlab312_humidity'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.2, comp_type='lin', channel=1) loggers[codenames[0]].daemon = True loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.2, comp_type='lin', channel=2) loggers[codenames[1]].daemon = True loggers[codenames[1]].start() livesocket = LiveSocket('Chemlab312 Air Logger', codenames) livesocket.start() socket = DateDataPullSocket('Chemlab312 Air Logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_chemlab312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(0.5) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """The main function""" # Setup logger and live socket codenames = [ 'work_estimate', 'work_left', 'work_left_minus_started', 'work_completed', 'work_total' ] logger = ContinuousDataSaver( 'dateplots_hall', credentials_hall.username, credentials_hall.password, codenames ) logger.start() livesocket = LiveSocket('workday', codenames) livesocket.start() try: while True: # Get board status card_counts, times, high_scores = get_board_status() print('Card counts') pprint(card_counts) print('\nTimes') pprint(times) print('\nHigh Scores') pprint(high_scores) # format highscore highscore_str = 'High Score\n----------' if high_scores: largest_name = max(len(name) for name, value in high_scores) for name, value in high_scores: highscore_str += '\n{{: <{}}}: {{:.2f}}'.format(largest_name).format(name, value) # Total work 80 and 10 people total_work = 66.33 estimate = max(total_work - since_9am() * 10, 0) batch = { 'work_estimate': estimate, 'work_left': times['ToDo'] + times['In Progress'], 'work_left_minus_started': times['ToDo'], 'work_completed': times['Done'], 'work_total': sum(times.values()), 'work_highscore': highscore_str, } # Send to live socket and database print('\n##########\nbatch') pprint(batch) livesocket.set_batch_now(batch) batch.pop('work_highscore') for codename, value in batch.items(): logger.save_point_now(codename, value) print('Sent', datetime.datetime.now()) sleep(600) except KeyboardInterrupt: livesocket.stop() logger.stop()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) i2c_helper = ABEHelpers() bus = i2c_helper.get_smbus() adc_instance = DeltaSigma(bus, 0x68, 0x69, 18) tempreader = TemperatureReader(adc_instance) tempreader.daemon = True tempreader.start() codenames = ["cooling_water_hot", "cooling_water_cold"] loggers = {} for i in range(0, 2): loggers[codenames[i]] = ValueLogger(tempreader, comp_val=0.5, channel=i) loggers[codenames[i]].start() socket = DateDataPullSocket("hall_cooling_water_temp", codenames, timeouts=2.0) socket.start() live_socket = LiveSocket("hall_waterpressure", codenames) live_socket.start() db_logger = ContinuousDataSaver( continuous_data_table="dateplots_hall", username=credentials.user, password=credentials.passwd, measurement_codenames=codenames, ) db_logger.start() time.sleep(5) while tempreader.is_alive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = 'usb-FTDI_USB-RS232_Cable_FTWZKOU0-if00-port0' omega = omegabus.OmegaBus(device='/dev/serial/by-id/' + port, model='D5251', baud=300) reader = Reader(omega) reader.start() time.sleep(2.5) codenames = ['propene_ox_setup_abs_pressure'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=5, maximumtime=300, comp_type='lin') loggers[codenames[0]].start() livesocket = LiveSocket('propene_ox Logger', codenames) livesocket.start() socket = DateDataPullSocket('propene_ox logger', codenames, timeouts=[3.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_propene_ox', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = '/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port' port = '/dev/ttyUSB0' codenames = ['xrd_pressure_turbo_gas_system', 'xrd_pressure_gas_system_wrg', 'xrd_pressure_mass_spec_wrg', 'xrd_pressure_gas_system_baratron'] reader = PressureReader(port) reader.daemon = True reader.start() loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=1) loggers[codenames[1]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=2) loggers[codenames[2]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=3) loggers[codenames[3]] = ValueLogger(reader, comp_val=2, comp_type='lin', channel=4) for i in range(0, 4): loggers[codenames[i]].start() socket = DateDataPullSocket('XRD Pressure', codenames, timeouts=[2.0] * len(codenames)) socket.start() live_socket = LiveSocket('XRD pressure', codenames, 2) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_xrd', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while True: time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) i2c_helper = ABEHelpers() bus = i2c_helper.get_smbus() adc_instance = ADCPi(bus, 0x68, 0x69, 18) pressurereader = PressureReader(adc_instance) pressurereader.daemon = True pressurereader.start() codenames = ["chemlab312_sample_storage_pressure"] loggers = {} for i in range(0, 1): loggers[codenames[i]] = ValueLogger(pressurereader, comp_val=0.05, comp_type="log") loggers[codenames[i]].start() socket = DateDataPullSocket("chemlab312_sample_storage", codenames, timeouts=[2.0]) socket.start() live_socket = LiveSocket("chemlab312_sample_storage", codenames) live_socket.start() db_logger = ContinuousDataSaver( continuous_data_table="dateplots_chemlab312", username=credentials.user, password=credentials.passwd, measurement_codenames=codenames, ) db_logger.start() time.sleep(5) while True: time.sleep(0.5) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
class FlowControl(threading.Thread): """ Keep updated values of the current flow or pressure """ def __init__(self, mfcs, name): threading.Thread.__init__(self) self.daemon = True self.mfcs = mfcs print(mfcs) devices = list(self.mfcs.keys()) self.values = {} for device in devices: self.values[device] = None self.pullsocket = DateDataPullSocket(name + '_analog_control', devices, timeouts=[3.0] * len(devices)) self.pullsocket.start() self.pushsocket = DataPushSocket(name + '_analog_pc_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket(name + '_analog_mfc_control', devices) self.livesocket.start() self.running = True def value(self, device): """ Return the current value of a device """ return self.values[device] def run(self): while self.running: time.sleep(0.1) qsize = self.pushsocket.queue.qsize() while qsize > 0: print('queue-size: ' + str(qsize)) element = self.pushsocket.queue.get() mfc = list(element.keys())[0] self.mfcs[mfc].set_flow(element[mfc]) qsize = self.pushsocket.queue.qsize() for mfc in self.mfcs: flow = self.mfcs[mfc].read_flow() self.values[mfc] = flow print(flow) self.pullsocket.set_point_now(mfc, flow) self.livesocket.set_point_now(mfc, flow)
def __init__(self, mfcs, name): threading.Thread.__init__(self) self.mfcs = mfcs print(mfcs) devices = list(self.mfcs.keys()) self.values = {} for device in devices: self.values[device] = None self.pullsocket = DateDataPullSocket(name + '_analog_control', devices, timeouts=[3.0] * len(devices)) self.pullsocket.start() self.pushsocket = DataPushSocket(name + '_analog_pc_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket(name + '_analog_mfc_control', devices) self.livesocket.start() self.running = True
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = 'serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0' xgs = xgs600.XGS600Driver('/dev/' + port) print(xgs.read_all_pressures()) reader = PressureReader(xgs) reader.daemon = True reader.start() buffer_logger = ValueLogger(reader, comp_val=0.1, comp_type='log', channel=0, low_comp=1e-3) containment_logger = ValueLogger(reader, comp_val=0.1, comp_type='log', channel=1, low_comp=1e-3) buffer_logger.start() containment_logger.start() socket = DateDataPullSocket('mgw', ['containment_pressure', 'buffer_pressure'], timeouts=[1.0, 1.0]) socket.start() livesocket = LiveSocket('mgw', ['containment_pressure', 'buffer_pressure']) livesocket.start() codenames = ['mgw_pressure_containment', 'mgw_pressure_buffer'] db_logger = ContinuousDataSaver(continuous_data_table='dateplots_mgw', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.2) p_containment = containment_logger.read_value() p_buffer = buffer_logger.read_value() socket.set_point_now('containment_pressure', p_containment) socket.set_point_now('buffer_pressure', p_buffer) livesocket.set_point_now('containment_pressure', p_containment) livesocket.set_point_now('buffer_pressure', p_buffer) if containment_logger.read_trigged(): print(p_containment) db_logger.save_point_now('mgw_pressure_containment', p_containment) containment_logger.clear_trigged() if buffer_logger.read_trigged(): print(p_buffer) db_logger.save_point_now('mgw_pressure_buffer', p_buffer) buffer_logger.clear_trigged()
def __init__(self, ranges, devices, socket_name): threading.Thread.__init__(self) self.devices = devices name = {} mfcs = {} print('!') for i in range(0, 8): print('----------------') print('Cheking port number: {}'.format(i)) error = 0 name[i] = '' while (error < 3) and (name[i] == ''): # Pro forma-range will be update in a few lines ioerror = 0 while ioerror < 10: time.sleep(0.5) print(ioerror) try: bronk = bronkhorst.Bronkhorst('/dev/ttyUSB' + str(i), 1) print('MFC Found') break except: # pylint: disable=bare-except ioerror = ioerror + 1 if ioerror == 10: print('No MFC found on this port') break print('Error count before identification: {}'.format(ioerror)) name[i] = bronk.read_serial() print('MFC Name: {}'.format(name[i])) name[i] = name[i].strip() error = error + 1 if name[i] in devices: ioerror = 0 if ioerror < 10: print(ioerror) try: mfcs[name[i]] = bronkhorst.Bronkhorst('/dev/ttyUSB' + str(i), ranges[name[i]]) mfcs[name[i]].set_control_mode() #Accept setpoint from rs232 except IOError: ioerror = ioerror + 1 if ioerror == 10: print('Found MFC but could not set range') self.mfcs = mfcs self.pullsocket = DateDataPullSocket(socket_name, devices, timeouts=3.0, port=9000) self.pullsocket.start() self.pushsocket = DataPushSocket(socket_name, action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket(socket_name, devices) self.livesocket.start() self.running = True self.reactor_pressure = float('NaN')
def main(): """ Main method for the websocket server """ LOG.info('main: Start') global LIVESOCKET # pylint: disable=global-statement names = ['wss_hosts_defined', 'wss_hosts', 'wss_clients'] LIVESOCKET = LiveSocket('websocketserver', names, sane_interval=1.0) LIVESOCKET.start() udp_steward = UDPConnectionSteward() udp_steward.start() # Uncomment these two to get log from twisted #import sys #log.startLogging(sys.stdout) # Create context factor with key and certificate context_factory = ssl.DefaultOpenSSLContextFactory( '/home/kenni/certs/fysik.dtu.dk.key', '/home/kenni/certs/fysik.dtu.dk.crt' ) # Form the webserver factory factory = WebSocketServerFactory("wss://localhost:9001", debug=True) # Set the handler factory.protocol = CinfWebSocketHandler # Listen for incoming WebSocket connections: wss://localhost:9001 listenWS(factory, context_factory) try: reactor.run() # pylint: disable=E1101 time.sleep(1) LOG.info('main: Keyboard interrupt, websocket reactor stopped') udp_steward.stop() time.sleep(1) LOG.info('main: UPD Steward stopped') LIVESOCKET.stop() time.sleep(1) LOG.info('main: Own livesocket stoppped') except Exception as exception_: LOG.exception(exception_) raise exception_ LOG.info('main: Ended') raw_input('All stopped. Press enter to exit')
def __init__(self): threading.Thread.__init__(self) self.watchdog = Watchdog() self.watchdog.daemon = True self.watchdog.start() time.sleep(1) self.setup = settings.setup self.quit = False for i in range(0, 7): #Set GPIO pins to output wp.pinMode(i, 1) self.setup = settings.setup self.dutycycles = [0, 0, 0, 0, 0, 0] channels = ['1', '2', '3', '4', '5', '6'] self.livesocket = LiveSocket(self.setup + '-bakeout', channels, 1) self.livesocket.start() self.pullsocket = DateDataPullSocket(self.setup + '-bakeout', channels, timeouts=[2]*6) self.pullsocket.start() self.pushsocket = DataPushSocket(self.setup + '-push_control', action='enqueue') self.pushsocket.start()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) i2c_helper = ABEHelpers() bus = i2c_helper.get_smbus() adc_instance = DeltaSigma(bus, 0x68, 0x69, 18) pressurereader = PressureReader(adc_instance) pressurereader.daemon = True pressurereader.start() codenames = ['mr_iongauge_pressure'] logger = ValueLogger(pressurereader, comp_val=0.5) logger.start() socket = DateDataPullSocket('Microreactor Ion Gauge', codenames, timeouts=[1.0]) socket.start() live_socket = LiveSocket('Microreactor Ion Gauge', codenames) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_microreactor', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(2) while True: time.sleep(0.25) value = logger.read_value() socket.set_point_now(codenames[0], value) live_socket.set_point_now(codenames[0], value) if logger.read_trigged(): print(value) db_logger.save_point_now(codenames[0], value) logger.clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) ports = '/dev/ttyUSB0' xgs_instance = xgs600.XGS600Driver(ports) print(xgs_instance.read_all_pressures()) pressure = PressureReader(xgs_instance) pressure.start() time.sleep(2.5) codenames = ['tof_iongauge_ft', 'tof_iongauge_main', 'tof_pirani_roughing'] loggers = {} loggers[codenames[0]] = ValueLogger(pressure, comp_val=0.1, low_comp=1e-11, comp_type='log', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', channel=2) loggers[codenames[2]].start() livesocket = LiveSocket('TOF data logger', codenames, 2) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_tof', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while pressure.isAlive(): time.sleep(0.5) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def __init__(self): threading.Thread.__init__(self) channels = ['setpoint', 'emission', 'ionenergy'] self.datasocket = DateDataPullSocket( 'emission_tof', channels, timeouts=[99999999, 1.0, 99999999]) self.datasocket.start() self.pushsocket = DataPushSocket('tof-emission-push_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('tof-emission', channels) self.livesocket.start() self.filament = {} port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00' self.filament['device'] = CPX.CPX400DPDriver(1, interface='serial', device=port) self.filament['voltage'] = 0 self.filament['current'] = 0 self.filament['idle_voltage'] = 1.7 self.filament['device'].set_current_limit(4.0) self.filament['device'].output_status(True) self.bias = {} self.bias['device'] = CPX.CPX400DPDriver(2, interface='serial', device=port) self.bias['grid_voltage'] = 0 self.bias['grid_current'] = 0 self.bias['device'].output_status(True) cns = 'USB0::0x0957::0x0607::MY45000583::INSTR' self.bias['current_reader'] = a34410A.Agilent34410ADriver( interface='usbtmc', connection_string=cns) self.bias['current_reader'].select_measurement_function('CURRENT') self.pid = pid.PID(0.01, 0.1, 0, 4) self.looptime = 0 self.setpoint = 0.05 self.pid.update_setpoint(self.setpoint) self.running = True self.wanted_voltage = 0 self.emission_current = 999
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = '/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port' port = '/dev/ttyUSB0' codenames = [ 'xrd_pressure_turbo_gas_system', 'xrd_pressure_gas_system_wrg', 'xrd_pressure_mass_spec_wrg', 'xrd_pressure_gas_system_baratron' ] reader = PressureReader(port) reader.daemon = True reader.start() loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=1) loggers[codenames[1]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=2) loggers[codenames[2]] = ValueLogger(reader, comp_val=0.02, comp_type='log', channel=3) loggers[codenames[3]] = ValueLogger(reader, comp_val=2, comp_type='lin', channel=4) for i in range(0, 4): loggers[codenames[i]].start() socket = DateDataPullSocket('XRD Pressure', codenames, timeouts=[2.0] * len(codenames)) socket.start() live_socket = LiveSocket('XRD pressure', codenames, 2) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_xrd', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while True: time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """Main function""" pvci = PVCi('/dev/serial/by-id/' 'usb-FTDI_USB-RS485_Cable_FTY3M2GN-if00-port0') # Start live socket live_socket = LiveSocket( 'thetaprobe_pvci', list(CODENAME_TRANSLATION.keys()) + list(EXTRA_LIVE.keys()), ) live_socket.start() # Start database saver database_saver = ContinuousDataSaver('dateplots_thetaprobe', credentials.USERNAME, credentials.PASSWORD, list(CODENAME_TRANSLATION.keys())) database_saver.start() # Set up criterium checker criterium_checker = LoggingCriteriumChecker( codenames=list(CODENAME_TRANSLATION.keys()), types=['log', 'log', 'lin'], criteria=[0.1, 0.1, 1.0], ) try: run(pvci, live_socket, database_saver, criterium_checker) except KeyboardInterrupt: pvci.close() live_socket.stop() database_saver.stop()
def main(): """ Main function """ tempreader = TemperatureReader() tempreader.daemon = True tempreader.start() temp_logger = ValueLogger(tempreader, comp_val=1) temp_logger.start() db_logger = ContinuousDataSaver( continuous_data_table='dateplots_chemlab307', username=credentials.user, password=credentials.passwd, measurement_codenames=['chemlab307_muffle_furnace']) socket = DateDataPullSocket('muffle_furnace', ['chemlab307_muffle_furnace'], timeouts=[1.0]) socket.start() livesocket = LiveSocket('muffle_furnace', ['chemlab307_muffle_furnace']) livesocket.start() db_logger.start() time.sleep(5) while True: time.sleep(0.25) value = temp_logger.read_value() socket.set_point_now('chemlab307_muffle_furnace', value) livesocket.set_point_now('chemlab307_muffle_furnace', value) if temp_logger.read_trigged(): print(value) db_logger.save_point_now('chemlab307_muffle_furnace', value) temp_logger.clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) omron_instance = omron_d6fph.OmronD6fph() hih_instance = honeywell_6000.HIH6130() reader = Reader(omron_instance, hih_instance) reader.start() time.sleep(5) codenames = [ 'hall_ventilation_pressure', 'hall_temperature', 'hall_humidity' ] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=1.0, maximumtime=300, comp_type='lin', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.2, maximumtime=600, comp_type='lin', channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(reader, comp_val=0.2, maximumtime=600, comp_type='lin', channel=2) loggers[codenames[2]].start() livesocket = LiveSocket('Hall Ventilation Logger', codenames) livesocket.start() socket = DateDataPullSocket('Hall Ventilation logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_hall', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """The main method for the pressure logger""" # Open communication to the pressure measurement unit tpg = TPG262(port='/dev/ttyUSB0', baudrate=9600) LOGGER.info('Initiated driver to TPG 262') # Get a continuous logger codenames = ['thetaprobe_pressure_loadlock'] db_logger = ContinuousLogger(table='dateplots_thetaprobe', username=credentials.USERNAME, password=credentials.PASSWORD, measurement_codenames=codenames) db_logger.start() LOGGER.info('Initiated and started database logger') name = 'Thetaprobe pressure load lock and UV gun' livesocket = LiveSocket(name, codenames, 0.2) livesocket.start() loadlock_last = {'value': 1E20, 'time': 0} try: while True: # get the values: returns: # (value1, (status_code1, status_message1), # value2, (status_code2, status_message2)) try: value_ll, code_ll = tpg.pressure_gauge(gauge=1) except (IOError, ValueError): LOGGER.info( 'Serial communication failed. Sleep 10 and try again.') time.sleep(10) continue livesocket.set_point_now('thetaprobe_pressure_loadlock', value_ll) ### Load lock if code_ll[0] in [0, 1]: # If measurement is OK or underranged if logging_criteria(value_ll, loadlock_last): LOGGER.info('Add value {} for load lock'.format(value_ll)) now_ll = db_logger.enqueue_point_now( 'thetaprobe_pressure_loadlock', value_ll) loadlock_last['value'] = value_ll loadlock_last['time'] = now_ll except KeyboardInterrupt: LOGGER.info('Keyboard interrupt. Shutting down') db_logger.stop() livesocket.stop() LOGGER.info('Database logger stoppped. Exiting!')
def __init__(self): LOGGER.info('Started Picture Logbook') self.picaso = PicasouLCD28PTU(serial_device='/dev/ttyUSB0', baudrate=115200, debug=True) dev_ = detect_barcode_device() LOGGER.info('Barcode device: ' + dev_) self.tbs = ThreadedBarcodeReader(dev_) self.tbs.start() self.setup = settings.setup self.livesocket = LiveSocket(self.setup + '-Picture Logbook', ['logged_in_user'], 1) self.livesocket.start() self.force_logout_user = settings.force_logut_user self.camera = cv.CaptureFromCAM(0) cv.SetCaptureProperty(self.camera, cv.CV_CAP_PROP_FRAME_WIDTH, 320) cv.SetCaptureProperty(self.camera, cv.CV_CAP_PROP_FRAME_HEIGHT, 240) self.database = MySQLdb.connect(host='servcinf-sql', user='******', passwd='picturelogbook', db='cinfdata') self.database.ping(True) query = 'select user, login from picture_logbooks where setup = "' query += self.setup + '" order by time desc limit 1' cursor = self.database.cursor() cursor.execute(query) current_state = cursor.fetchone() try: current_login = current_state[1] except TypeError: # Happens with no items in database current_login = 0 if current_login == 0: self.logged_in_user = None else: self.logged_in_user = current_state[0] LOGGER.info('Initially logged in user:' + str(self.logged_in_user)) self.update_external_screen(str(self.logged_in_user))
def main(): """ Main loop """ mainpump = tp.TurboDriver(adress=1, port=settings.port) mainpump.start() tui = tp.CursesTui(mainpump) tui.daemon = True tui.start() reader = tp.TurboReader(mainpump) reader.daemon = True reader.start() time.sleep(10) # Allow reader to make meaningfull moving avarage codenames = [settings.table_prefix + '_turbo_speed', settings.table_prefix + '_turbo_power', settings.table_prefix + '_turbo_current', settings.table_prefix + '_turbo_temp_motor', settings.table_prefix + '_turbo_temp_bottom', settings.table_prefix + '_turbo_temp_bearings', settings.table_prefix + '_turbo_temp_electronics'] loggers = {} loggers[codenames[0]] = tp.TurboLogger(reader, 'rotation_speed', maximumtime=600) loggers[codenames[1]] = tp.TurboLogger(reader, 'drive_power', maximumtime=600) loggers[codenames[2]] = tp.TurboLogger(reader, 'drive_current', maximumtime=600) loggers[codenames[3]] = tp.TurboLogger(reader, 'temp_motor', maximumtime=600) loggers[codenames[4]] = tp.TurboLogger(reader, 'temp_bottom', maximumtime=600) loggers[codenames[5]] = tp.TurboLogger(reader, 'temp_bearings', maximumtime=600) loggers[codenames[6]] = tp.TurboLogger(reader, 'temp_electronics', maximumtime=600) for name in codenames: loggers[name].daemon = True loggers[name].start() livesocket = LiveSocket(settings.name + '-turboreader', codenames) livesocket.start() socket = DateDataPullSocket(settings.name + '-turboreader', codenames, timeouts=[1.0] * len(codenames), port=9000) socket.start() db_logger = ContinuousDataSaver(continuous_data_table=settings.table, username=settings.user, password=settings.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while mainpump.running: time.sleep(0.1) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) # Notice, this is the averaged value livesocket.set_point_now(name, value) # Notice, this is the averaged value if loggers[name].trigged: db_logger.save_point_now(name, value) loggers[name].trigged = False
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) l3g4200d_instance = l3g4200d.L3G4200D() l3g4200d_reader = Reader(l3g4200d_instance) l3g4200d_reader.start() ais328dq_instance = ais328dq.AIS328DQTR() ais328dq_reader = Reader(ais328dq_instance) ais328dq_reader.start() time.sleep(2.5) codenames = [ 'b307_049_vibration_measurement', 'b307_049_vibration_measurement_accl' ] loggers = {} loggers[codenames[0]] = ValueLogger(l3g4200d_reader, comp_val=0.02, maximumtime=600, comp_type='lin', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(ais328dq_reader, comp_val=0.01, maximumtime=100, comp_type='lin', channel=0) loggers[codenames[1]].start() livesocket = LiveSocket('307 Vibraton logger', codenames) livesocket.start() socket = DateDataPullSocket('307 vibration logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_b307_049', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while l3g4200d_reader.isAlive(): time.sleep(10) for name in codenames: value = loggers[name].read_value() print(value) livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def __init__(self): threading.Thread.__init__(self) channels = ['setpoint', 'emission', 'ionenergy'] self.datasocket = DateDataPullSocket( 'emission_tof', channels, timeouts=[99999999, 1.0, 99999999]) self.datasocket.start() self.pushsocket = DataPushSocket('tof-emission-push_control', action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('tof-emission', channels, 1) self.livesocket.start() self.filament = {} port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00' self.filament['device'] = CPX.CPX400DPDriver(1, interface='serial', device=port) self.filament['voltage'] = 0 self.filament['current'] = 0 self.filament['idle_voltage'] = 1.7 self.filament['device'].set_current_limit(7) self.filament['device'].output_status(True) self.bias = {} port = '/dev/serial/by-id/' port += 'usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0' self.keithley_port = port self.bias['device'] = smu.KeithleySMU(interface='serial', device=self.keithley_port) self.bias['grid_voltage'] = 0 self.bias['grid_current'] = 0 self.bias['device'].output_state(True) self.pid = pid.PID(0.01, 0.1, 0, 4) self.looptime = 0 self.setpoint = 0.05 self.pid.update_setpoint(self.setpoint) self.running = True self.wanted_voltage = 0 self.emission_current = 999
class FlowControl(threading.Thread): """ Keep updated values of the current flow """ def __init__(self, mks_instance, mfcs, devices, name): threading.Thread.__init__(self) self.mfcs = mfcs self.mks = mks_instance self.pullsocket = DateDataPullSocket(name, devices, timeouts=3.0, port=9000) self.pullsocket.start() self.pushsocket = DataPushSocket(name, action='enqueue') self.pushsocket.start() self.livesocket = LiveSocket('palle_mks_flows', devices) self.livesocket.start() self.running = True def run(self): while self.running: time.sleep(0.1) qsize = self.pushsocket.queue.qsize() while qsize > 0: element = self.pushsocket.queue.get() mfc = list(element.keys())[0] print(element[mfc]) print('Queue: ' + str(qsize)) self.mks.set_flow(element[mfc], self.mfcs[mfc]) qsize = self.pushsocket.queue.qsize() for mfc in self.mfcs: print('!!!') flow = self.mks.read_flow(self.mfcs[mfc]) print(mfc + ': ' + str(flow)) self.pullsocket.set_point_now(mfc, flow) self.livesocket.set_point_now(mfc, flow)
def main(): """ Main function """ i2c_helper = ABEHelpers() bus = i2c_helper.get_smbus() adc_instance = ADCPi(bus, 0x68, 0x69, 18) windreader = WindReader(adc_instance) windreader.daemon = True windreader.start() loggers = {} for channel, codename in settings.channels.items(): loggers[codename + '_raw'] = ValueLogger(windreader, comp_val=1.05, channel=channel + '_raw', maximumtime=30) loggers[codename + '_raw'].start() loggers[codename] = ValueLogger(windreader, comp_val=1.005, channel=channel, maximumtime=30) loggers[codename].start() codenames = [] for name in settings.channels.values(): codenames.append(name) codenames.append(name + '_raw') socket = DateDataPullSocket('Fumehood Wind Speed', codenames, timeouts=2.0) socket.start() live_socket = LiveSocket('Fumehood Wind Speed', codenames) live_socket.start() db_logger = ContinuousDataSaver( continuous_data_table=settings.dateplot_table, username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(10) while windreader.is_alive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main code """ mux_instance = agilent_34972A.Agilent34972ADriver( interface='lan', hostname='volvo-agilent-34972a') port = '/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0' xgs_instance = xgs600.XGS600Driver(port) analog_measurement = MuxReader(mux_instance) analog_measurement.start() pressure = PressureReader(xgs_instance) print('-') pressure.start() time.sleep(2.5) codenames = ['volvo_pressure', 'volvo_temperature'] loggers = {} loggers[codenames[0]] = ValueLogger(pressure, comp_val=0.1, comp_type='log') loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(analog_measurement, comp_val=0.5, comp_type='lin') loggers[codenames[1]].start() socket = DateDataPullSocket('Volvo data logger', codenames, timeouts=[1.0, 1.0]) socket.start() livesocket = LiveSocket('Volvo data logger', codenames) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_volvo', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() #while pressure.isAlive() and analog_measurement.isAlive(): while True: time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) ports = '/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0' xgs_instance = xgs600.XGS600Driver(ports) print(xgs_instance.read_all_pressures()) pressure = PressureReader(xgs_instance) pressure.start() time.sleep(2.5) codenames = ['tof_iongauge_ft', 'tof_iongauge_main', 'tof_pirani_roughing'] loggers = {} loggers[codenames[0]] = ValueLogger(pressure, comp_val=0.1, low_comp=1e-11, comp_type='log', channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(pressure, low_comp=1e-11, comp_val=0.1, comp_type='log', channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', channel=2) loggers[codenames[2]].start() livesocket = LiveSocket('TOF data logger', codenames) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_tof', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while pressure.isAlive(): time.sleep(0.5) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ ups = galaxy_3500.Galaxy3500('b312-ups') reader = UpsReader(ups) reader.daemon = True reader.start() time.sleep(5) codenames = [ 'b312_ups_temperature', 'b312_ups_kVAPh1', 'b312_ups_kVAPh2', 'b312_ups_kVAPh3', 'b312_ups_output_current_Ph1', 'b312_ups_output_current_Ph2', 'b312_ups_output_current_Ph3', 'b312_ups_input_frequency', 'b312_ups_input_voltage_Ph1', 'b312_ups_input_voltage_Ph2', 'b312_ups_input_voltage_Ph3', 'b312_ups_output_voltage_Ph1', 'b312_ups_output_voltage_Ph2', 'b312_ups_output_voltage_Ph3', 'b312_ups_battery_voltage', 'b312_ups_battery_current', 'b312_ups_battery_state_of_charge', 'b312_ups_output_frequency' ] loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.1, channel=i) loggers[codenames[i]].start() socket = DateDataPullSocket('UPS status', codenames, timeouts=[5.0] * len(codenames)) socket.start() live_socket = LiveSocket('UPS Status', codenames) live_socket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ups_b312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) live_socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) hih_instance = honeywell_6000.HIH6130() reader = Reader(hih_instance) reader.start() time.sleep(5) codenames = ['chemlab312_temperature', 'chemlab312_humidity'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=1, comp_type='lin', channel=1) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=1, comp_type='lin', channel=2) loggers[codenames[1]].start() livesocket = LiveSocket('Chemlab312 Air Logger', codenames, 2) livesocket.start() socket = DateDataPullSocket('Chemlab312 Air Logger', codenames, timeouts=[1.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver( continuous_data_table='dateplots_chemlab312', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """Main function """ pvci = epimax.PVCi( '/dev/serial/by-id/' 'usb-FTDI_USB-RS485_Cable_FT0N0UFX-if00-port0', slave_address=1) # Start live socket live_socket = LiveSocket( 'omicron_pvci', list(CODENAME_TRANSLATION.keys()), ) live_socket.start() # Start pull socket pullsocket = DateDataPullSocket( 'omicron_pvci_pull', list(CODENAME_TRANSLATION.keys()), timeouts=2.5, ) pullsocket.start() # Start database saver database_saver = ContinuousDataSaver( 'dateplots_omicron', credentials.USERNAME, credentials.PASSWORD, list(CODENAME_TRANSLATION.keys()), ) database_saver.start() # Criterium checker criterium_checker = LoggingCriteriumChecker( codenames=list(CODENAME_TRANSLATION.keys()), types=['log'] * len(CODENAME_TRANSLATION.keys()), criteria=[0.05] * len(CODENAME_TRANSLATION.keys()), time_outs=[300] * len(CODENAME_TRANSLATION.keys()), ) # Main loop try: run(pvci, live_socket, pullsocket, database_saver, criterium_checker) except KeyboardInterrupt: sleep(WAIT) pvci.close() live_socket.stop() pullsocket.stop() database_saver.stop() except: LOG.exception("Omicron pvci data logger stopped")
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) qcm_port = ( '/dev/serial/by-id/' + 'usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0') qcm = inficon.InficonSQM160(qcm_port) reader = QcmReader(qcm) reader.daemon = True reader.start() codenames = [ 'volvo_qcm_frequency', 'volvo_qcm_crystal_life', 'volvo_qcm_thickness' ] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=0.1, channel=0) loggers[codenames[0]].start() loggers[codenames[1]] = ValueLogger(reader, comp_val=0.01, channel=1) loggers[codenames[1]].start() loggers[codenames[2]] = ValueLogger(reader, comp_val=0.001, channel=2) loggers[codenames[2]].start() socket = DateDataPullSocket('Volvo QCM', codenames, port=9000, timeouts=[5.0] * len(codenames)) socket.start() livesocket = LiveSocket('Volvo data logger', codenames) livesocket.start() db_logger = ContinuousDataSaver(continuous_data_table='dateplots_volvo', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() socket.set_point_now(name, value) livesocket.set_point_now(name, value) if loggers[name].read_trigged(): print(value) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """ Main function """ logging.basicConfig(filename="logger.txt", level=logging.ERROR) logging.basicConfig(level=logging.ERROR) port = 'usb-FTDI_USB-RS232_Cable_FTWZKOU0-if00-port0' omega = omegabus.OmegaBus(device='/dev/serial/by-id/' + port, model='D5251', baud=300) reader = Reader(omega) reader.start() time.sleep(2.5) codenames = ['propene_ox_setup_abs_pressure'] loggers = {} loggers[codenames[0]] = ValueLogger(reader, comp_val=5, maximumtime=300, comp_type='lin') loggers[codenames[0]].start() livesocket = LiveSocket('propene_ox Logger', codenames) livesocket.start() socket = DateDataPullSocket('propene_ox logger', codenames, timeouts=[3.0] * len(loggers)) socket.start() db_logger = ContinuousDataSaver( continuous_data_table='dateplots_propene_ox', username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() while reader.isAlive(): time.sleep(1) for name in codenames: value = loggers[name].read_value() livesocket.set_point_now(name, value) socket.set_point_now(name, value) if loggers[name].read_trigged(): print(name + ': ' + str(value)) db_logger.save_point_now(name, value) loggers[name].clear_trigged()
def main(): """Main function""" chiller_port = '/dev/serial/by-id/' chiller_port += 'usb-1a86_USB2.0-Ser_-if00-port0' LOG.info('Using chiller port %s', chiller_port) reader = ChillerReader(chiller_port) reader.start() LOG.info('ChillerReader started') codenames = [ 'uhv_sputterchamber_chiller_temperature', 'uhv_sputterchamber_chiller_flow', 'uhv_sputterchamber_chiller_temperature_ambient', 'uhv_sputterchamber_chiller_pressure', 'uhv_sputterchamber_chiller_temperature_setpoint' ] LOG.debug('Using codenames %s', codenames) loggers = {} for i in range(0, len(codenames)): loggers[codenames[i]] = ValueLogger(reader, comp_val=0.11, channel=i) loggers[codenames[i]].start() live_socket_name = 'uhv_sputterchamber' live_socket = LiveSocket(live_socket_name, codenames) live_socket.start() LOG.info('Live socket init and started with name "%s"', live_socket_name) db_table = 'dateplots_uhv_sputterchamber' db_logger = ContinuousDataSaver(continuous_data_table=db_table, username=credentials.user, password=credentials.passwd, measurement_codenames=codenames) db_logger.start() LOG.info('ContinuousLogger init and started on table "%s"', db_table) time.sleep(5) while reader.isAlive(): time.sleep(0.25) for name in codenames: value = loggers[name].read_value() if not math.isnan(value): live_socket.set_point_now(name, value) if loggers[name].read_trigged(): LOG.debug('Log value %s for codename "%s"', value, name) db_logger.save_point_now(name, value) loggers[name].clear_trigged()