Exemple #1
0
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    ports = dict()
    ports[
        'Sample'] = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY5BU0H-if00-port0'
    ports[
        'Base'] = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY3GX3T-if00-port0'

    # Set up criterium logger
    logger = LoggingCriteriumChecker(
        codenames=[CODENAMES['Base']],
        types=['lin'],
        criteria=[0.2],
        time_outs=[300],
    )

    # Set up pullsocket
    datasocket = DateDataPullSocket('mgw_temp',
                                    list(CODENAMES.values()),
                                    timeouts=4,
                                    port=9000)
    datasocket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_omicron',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=[CODENAMES['Base']])
    db_logger.start()

    measurement = TcReader(ports['Base'],
                           datasocket,
                           crit_logger=logger,
                           db_logger=db_logger,
                           codename=CODENAMES['Base'])
    measurement.start()

    sample_logger = TcReader(ports['Sample'],
                             datasocket,
                             codename=CODENAMES['Sample'])
    sample_logger.start()

    time.sleep(5)
    string = 'Base: {: >6.4} C, Sample: {: >6.4} C'
    while True:
        try:
            time.sleep(1)
            print(
                string.format(measurement.temperature,
                              sample_logger.temperature))
        except KeyboardInterrupt:
            measurement.stop()
            sample_logger.stop()
            time.sleep(2)
            print('\nTcReaders stopped')
            datasocket.stop()
            print('Pullsocket stopped\nExiting.')
            break
Exemple #2
0
def main():
    """ Main function """
    emission_control = EmissionControl()
    emission_control.set_bias(38)
    emission_control.start()

    logger = ValueLogger(emission_control, comp_val=0.01, comp_type='log')
    logger.start()

    codenames = ['tof_emission_value']
    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_tof',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    tui = emission_tui.CursesTui(emission_control)
    tui.daemon = True
    tui.start()
    time.sleep(10)

    while emission_control.running is True:
        time.sleep(1)
        value = logger.read_value()
        if logger.read_trigged():
            LOGGER.debug('Logged value: ' + str(value))
            db_logger.save_point_now('tof_emission_value', value)
            logger.clear_trigged()
Exemple #3
0
def main():
    """ Main function """

    codenames = []
    for channel in settings.channels.values():
        channel['reader'] = SocketReaderClass(channel['host'], channel['port'],
                                              channel['command'])
        channel['reader'].start()
        channel['logger'] = ValueLogger(channel['reader'], comp_val=channel['comp_value'])
        channel['logger'].daemon = True
        channel['logger'].start()
        codenames.append(channel['codename'])

    db_logger = ContinuousDataSaver(continuous_data_table=settings.dateplot_table,
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    time.sleep(2)

    everything_ok = True
    while everything_ok:
        time.sleep(0.25)
        for channel in settings.channels.values():
            if not channel['reader'].isAlive():
                everything_ok = False
            value = channel['logger'].read_value()
            if channel['logger'].read_trigged():
                print(value)
                db_logger.save_point_now(channel['codename'], value)
                channel['logger'].clear_trigged()
Exemple #4
0
def main():
    """ Main function """
    devices = ['M13201551A', 'M11200362F', 'M8203814A', 'M8203814B',
               'M11200362B', 'M11213502A']
    ranges = {}
    ranges['M13201551A'] = 5 # Microreactor, pressure controller
    ranges['M11200362F'] = 1 # Microreactor, flow 2
    ranges['M8203814A'] = 10 # Microreactor, flow 5 (argon calibrated)
    ranges['M8203814B'] = 3 # Microreactor, flow 1 (argon calibrated)

    flow_control = FlowControl(devices=devices, ranges=ranges, name='microreactor_mfc_control')
    flow_control.start()

    logger = ValueLogger(flow_control, comp_val=1, comp_type='log', low_comp=0.0001)
    logger.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_microreactor',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=['mr_reactor_pressure'])
    db_logger.start()

    time.sleep(5)
    while True:
        time.sleep(0.25)
        value = logger.read_value()
        if logger.read_trigged():
            print(value)
            db_logger.save_point_now('mr_reactor_pressure', value)
            logger.clear_trigged()
Exemple #5
0
def main():
    """ Main function """
    devices = ['M11200362H', 'M11200362C', 'M11200362A',
               'M11200362E', 'M11200362D', 'M11210022B', 'M11200362G']
    ranges = {}
    ranges['M11200362H'] = 2.5 # Pressure controller
    ranges['M11200362C'] = 10 # Flow1
    ranges['M11200362A'] = 10 # Flow2
    ranges['M11200362E'] = 5 # Flow3
    ranges['M11200362D'] = 5 # Flow4
    ranges['M11210022B'] = 10 # Flow5 (NH3 compatible)
    ranges['M11200362G'] = 1 # Flow6

    flow_control = FlowControl(devices=devices, ranges=ranges,
                               socket_name='microreactorNG_mfc_control')
    flow_control.start()

    logger = ValueLogger(flow_control, comp_val=1, comp_type='log', low_comp=0.0001)
    logger.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_microreactorNG',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=['microreactorng_pressure_reactor'])
    db_logger.start()

    time.sleep(5)
    while True:
        time.sleep(0.25)
        value = logger.read_value()
        if logger.read_trigged():
            print(value)
            db_logger.save_point_now('microreactorng_pressure_reactor', value)
            logger.clear_trigged()
Exemple #6
0
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()
Exemple #7
0
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"""
    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()
Exemple #9
0
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()
Exemple #10
0
def main():
    """ Main function """

    codenames = ['sniffer_inlet_gas_pressure']
    mfc = AnalogMFC(1, 10, 5)
    mfcs = {}
    mfcs[codenames[0]] = mfc

    flow_control = FlowControl(mfcs, 'sniffer')
    flow_control.start()

    loggers = {}
    loggers[codenames[0]] = ValueLogger(flow_control, comp_val=0.02, comp_type='lin',
                                        low_comp=0.01, channel=codenames[0])
    loggers[codenames[0]].start()
    
    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_sniffer',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    while True:
        time.sleep(0.5)
        for name in codenames:
            if loggers[name].read_trigged():
                print(name + ': ' + str(loggers[name].value))
                db_logger.save_point_now(name, loggers[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()
Exemple #12
0
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()
Exemple #13
0
def main():
    """ Main function """
    emission_control = EmissionControl()
    emission_control.set_bias(28)
    emission_control.start()

    logger = ValueLogger(emission_control, comp_val=0.01, comp_type='log')
    logger.start()

    codenames = ['tof_emission_value']
    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_tof',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    tui = emission_tui.CursesTui(emission_control)
    tui.daemon = True
    tui.start()
    time.sleep(10)

    while emission_control.running is True:
        time.sleep(1)
        value = logger.read_value()
        if logger.read_trigged():
            LOGGER.debug('Logged value: %s', value)
            db_logger.save_point_now('tof_emission_value', value)
            logger.clear_trigged()
Exemple #14
0
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    #port = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY5BU0H-if00-port0'
    port = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY3GX3T-if00-port0'

    # Set up criterium logger
    logger = LoggingCriteriumChecker(
        codenames=[CODENAME],
        types=['lin'],
        criteria=[0.2],
        time_outs=[300],
    )

    # Set up pullsocket
    datasocket = DateDataPullSocket('mgw_temp', [CODENAME],
                                    timeouts=4,
                                    port=9000)
    datasocket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_omicron',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=[CODENAME])
    db_logger.start()

    measurement = TcReader(port, datasocket, logger, db_logger)
    measurement.start()
Exemple #15
0
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()
Exemple #16
0
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()
Exemple #17
0
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
Exemple #18
0
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 """
    ports = dict()
    ports['Sample'] = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY5BU0H-if00-port0'
    ports['Base'] =   '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY3GX3T-if00-port0'

    # Set up criterium logger
    logger = LoggingCriteriumChecker(
        codenames=[CODENAMES['Base']],
        types=['lin'],
        criteria=[0.73],
        time_outs=[600],
        low_compare_values=[-200],
        )

    # Set up pullsocket
    datasocket = DateDataPullSocket('mgw_temp', list(CODENAMES.values()), timeouts=4, port=9000)
    datasocket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_omicron',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=[CODENAMES['Base']])
    db_logger.start()

    logger1 = LOGGER.getChild('Base_reader')
    measurement = TcReader(ports['Base'], datasocket, crit_logger=logger, db_logger=db_logger, codename=CODENAMES['Base'], logger=logger1)
    measurement.start()

    logger2 = LOGGER.getChild('Sample_reader')
    sample_logger = TcReader(ports['Sample'], datasocket, codename=CODENAMES['Sample'], logger=logger2)
    sample_logger.start()

    time.sleep(2)
    string = 'Base: {: <6.4} C, Sample: {: <6.4} C'
    while True:
        try:
            time.sleep(1)
            sample = sample_logger.temperature
            if sample is None:
                sample = '----'
            base = measurement.temperature
            if base is None:
                base = '----'
            print(string.format(base, sample))
        except ValueError:
            print('ValueError')
            print(repr(measurement.temperature), type(measurement.temperature))
            print(repr(sample_logger.temperature))
        except KeyboardInterrupt:
            measurement.stop()
            sample_logger.stop()
            time.sleep(2)
            LOGGER.info('\nTcReaders stopped')
            datasocket.stop()
            LOGGER.info('Pullsocket stopped\nExiting.')
            break
Exemple #20
0
def main():
    """ Main function """
    wp.wiringPiSetup()
    datasocket = DateDataPullSocket(
        'furnaceroom_controller',
        ['temperature', 'setpoint', 'dutycycle', 'pid_p', 'pid_i'],
        timeouts=999999,
        port=9000)
    datasocket.start()

    pushsocket = DataPushSocket('furnaceroom_push_control',
                                action='store_last')
    pushsocket.start()

    power_calculator = PowerCalculatorClass(datasocket, pushsocket)
    power_calculator.daemon = True
    power_calculator.start()

    codenames = [
        'fr307_furnace_1_dutycycle', 'fr307_furnace_1_S',
        'fr307_furnace_1_pid_p', 'fr307_furnace_1_pid_i'
    ]
    db_logger = ContinuousDataSaver(
        continuous_data_table='dateplots_furnaceroom307',
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames)
    db_logger.start()

    # Criterium checker
    criterium_checker = LoggingCriteriumChecker(
        codenames=codenames,
        types=['lin'] * len(codenames),
        criteria=[0.1, 0.99, 1., 1.],
        time_outs=[60, 600, 300, 300],
    )

    heater = HeaterClass(power_calculator, datasocket, db_logger,
                         criterium_checker)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
    # make sure tui close down properly and the T setpoint is put low.
    try:
        while not heater.quit:
            time.sleep(1)
    except KeyboardInterrupt:
        print("Keyboard Interrupt detected, closing program")
        heater.quit = True
    finally:
        power_calculator.quit = True
        time.sleep(0.1)
        tui.stop()
def main():
    """ Main function """
    pumpreaders = {}
    loggers = {}
    channels = [
        'temperature', 'controller_temperature', 'run_hours',
        'rotational_speed', 'controller_run_hours', 'time_to_service'
    ]
    codenames = []
    for port, codename in settings.channels.items():
        pumpreaders[port] = PumpReader(port)
        pumpreaders[port].daemon = True
        pumpreaders[port].start()
        pumpreaders[port].loggers = {}

        for channel in channels:
            codenames.append(codename + '_' +
                             channel)  # Build the list of codenames
            loggers[port + channel] = ValueLogger(pumpreaders[port],
                                                  comp_val=0.9,
                                                  channel=channel,
                                                  maximumtime=600)
            loggers[port + channel].start()

    #socket = DateDataPullSocket('Pump Reader', codenames, timeouts=2.0)
    #socket.start()
    #live_socket = LiveSocket('Pump Reader',  codenames)
    #live_socket.start()

    db_logger = ContinuousDataSaver(
        continuous_data_table=settings.table,
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames)  # Codename list created
    # along with loggers
    db_logger.start()

    time.sleep(10)

    alive = True
    while alive:
        for port, base_codename in settings.channels.items():
            time.sleep(10)
            for channel in channels:
                if loggers[port + channel].is_alive is False:
                    alive = False

                codename = base_codename + '_' + channel
                value = loggers[port + channel].read_value()
                #socket.set_point_now(codename, value)
                #live_socket.set_point_now(codename, value)
                if loggers[port + channel].read_trigged():
                    print(port + channel + ': ' + str(value))
                    db_logger.save_point_now(codename, value)
                    loggers[port + channel].clear_trigged()
Exemple #22
0
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    ports = '/dev/serial/by-id/'
    ports += 'usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0'
    xgs_instance = xgs600.XGS600Driver(ports)
    print(xgs_instance.read_all_pressures())

    pressure = PressureReader(xgs_instance)
    pressure.start()

    time.sleep(2.5)

    codenames = ['ps_qms_pressure', 'ps_chamber_pressure']
    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,
                                        low_comp=1e-11,
                                        comp_type='log',
                                        channel=1)
    loggers[codenames[1]].start()

    #livesocket = LiveSocket('PS', codenames, 2)
    #livesocket.start()

    socket = DateDataPullSocket('PS pressure logger',
                                codenames,
                                timeouts=2 * [1.0],
                                port=9001)
    socket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ps',
                                    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)
            socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(value)
                db_logger.save_point_now(name, value)
                loggers[name].clear_trigged()
Exemple #23
0
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()
Exemple #24
0
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()
Exemple #25
0
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()
Exemple #26
0
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()
Exemple #27
0
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()
Exemple #28
0
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()
Exemple #29
0
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()

    print('wait start 20s')
    time.sleep(25)
    print('Wait end')
    codenames = ['home_temperature_bedroom', 'home_humidity_bedroom']

    loggers = {}
    loggers[codenames[0]] = ValueLogger(reader,
                                        comp_val=0.25,
                                        comp_type='lin',
                                        channel=1)
    loggers[codenames[0]].start()
    loggers[codenames[1]] = ValueLogger(reader,
                                        comp_val=1.1,
                                        comp_type='lin',
                                        channel=2)
    loggers[codenames[1]].start()

    #livesocket = LiveSocket('Home Air Logger', codenames)
    #livesocket.start()

    socket = DateDataPullSocket('Home Air Logger',
                                codenames,
                                timeouts=[1.0] * len(loggers))
    socket.start()

    table = 'dateplots_rued_langgaards_vej'
    db_logger = ContinuousDataSaver(continuous_data_table=table,
                                    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()
Exemple #30
0
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()
Exemple #31
0
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()
Exemple #32
0
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():
    """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 """
    pumpreaders = {}
    loggers = {}
    channels = ['temperature', 'controller_temperature', 'run_hours', 'rotational_speed',
                'controller_run_hours', 'time_to_service']
    codenames = []
    for port, codename in settings.channels.items():
        pumpreaders[port] = PumpReader(port)
        pumpreaders[port].daemon = True
        pumpreaders[port].start()
        pumpreaders[port].loggers = {}

        for channel in channels:
            codenames.append(codename + '_' + channel) # Build the list of codenames
            loggers[port + channel] = ValueLogger(pumpreaders[port], comp_val=0.9,
                                                  channel=channel, maximumtime=600)
            loggers[port + channel].start()

    #socket = DateDataPullSocket('Pump Reader', codenames, timeouts=2.0)
    #socket.start()
    #live_socket = LiveSocket('Pump Reader',  codenames)
    #live_socket.start()

    db_logger = ContinuousDataSaver(continuous_data_table=settings.table,
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames) # Codename list created
                                                                     # along with loggers
    db_logger.start()

    time.sleep(10)

    alive = True
    while alive:
        for port, base_codename in settings.channels.items():
            time.sleep(10)
            for channel in channels:
                if loggers[port + channel].is_alive is False:
                    alive = False

                codename = base_codename + '_' + channel
                value = loggers[port + channel].read_value()
                #socket.set_point_now(codename, value)
                #live_socket.set_point_now(codename, value)
                if loggers[port + channel].read_trigged():
                    print(port + channel + ': ' + str(value))
                    db_logger.save_point_now(codename, value)
                    loggers[port + channel].clear_trigged()
Exemple #35
0
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()
Exemple #36
0
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()
Exemple #37
0
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()
Exemple #38
0
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    ports = '/dev/serial/by-id/'
    ports += 'usb-Prolific_Technology_Inc._USB-Serial_Controller_D-if00-port0'
    xgs_instance = xgs600.XGS600Driver(ports)
    print(xgs_instance.read_all_pressures())

    pressure = PressureReader(xgs_instance)
    pressure.start()

    time.sleep(2.5)

    codenames = ['ps_qms_pressure', 'ps_chamber_pressure']
    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, low_comp=1e-11,
                                        comp_type='log', channel=1)
    loggers[codenames[1]].start()

    #livesocket = LiveSocket('PS', codenames, 2)
    #livesocket.start()

    socket = DateDataPullSocket('PS pressure logger',
                                codenames, timeouts=2 * [1.0], port=9001)
    socket.start()


    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ps',
                                    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)
            socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(value)
                db_logger.save_point_now(name, value)
                loggers[name].clear_trigged()
Exemple #39
0
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    ports = dict()
    ports['Sample'] = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY5BU0H-if00-port0'
    ports['Base'] =   '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTY3GX3T-if00-port0'

    # Set up criterium logger
    logger = LoggingCriteriumChecker(
        codenames=[CODENAMES['Base']],
        types=['lin'],
        criteria=[0.2],
        time_outs=[300],
        )

    # Set up pullsocket
    datasocket = DateDataPullSocket('mgw_temp', list(CODENAMES.values()), timeouts=4, port=9000)
    datasocket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_omicron',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=[CODENAMES['Base']])
    db_logger.start()


    measurement = TcReader(ports['Base'], datasocket, crit_logger=logger, db_logger=db_logger, codename=CODENAMES['Base'])
    measurement.start()

    sample_logger = TcReader(ports['Sample'], datasocket, codename=CODENAMES['Sample'])
    sample_logger.start()

    time.sleep(5)
    string = 'Base: {: >6.4} C, Sample: {: >6.4} C'
    while True:
        try:
            time.sleep(1)
            print(string.format(measurement.temperature, sample_logger.temperature))
        except KeyboardInterrupt:
            measurement.stop()
            sample_logger.stop()
            time.sleep(2)
            print('\nTcReaders stopped')
            datasocket.stop()
            print('Pullsocket stopped\nExiting.')
            break
Exemple #40
0
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()
Exemple #41
0
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()

    try:
        while True:
            # Get board status
            #card_counts, times, high_scores = get_board_status()
            card_counts, times = get_board_status()
            print('Card counts')
            pprint(card_counts)
            print('\nTimes')
            pprint(times)

            # Total work 80 and 14 people
            total_work = 66.337
            estimate = max(total_work - since_9am() * 14, 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()),
            }
            # Send to and database
            print('\n##########\nbatch')
            #pprint(batch)

            for codename, value in batch.items():
                #print(codename, value)
                logger.save_point_now(codename, value)

            print('Sent', datetime.datetime.now())
            sleep(120)
    except (KeyboardInterrupt, ZeroDivisionError):
        print("Done")
        logger.stop()
Exemple #42
0
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()
Exemple #43
0
    def test_enqueue_point(self):
        """Test the continous logger by sending data with timestamps"""
        # Make timestamps to use
        number_of_points = 10
        start = time.time()
        times = [start + increment for increment in range(number_of_points)]

        # Form the lists for local storage of data, for tests
        data1 = []
        data2 = []

        # Init the db_saver
        db_saver = ContinuousDataSaver('dateplots_dummy', 'dummy', 'dummy',
                                       ['dummy_sine_one', 'dummy_sine_two'])
        db_saver.start()

        # Save the points
        for now in times:
            value = math.sin(now)
            data1.append([now, value])
            db_saver.save_point('dummy_sine_one', (now, value))
            value = math.sin(now + math.pi)
            data2.append([now, value])
            db_saver.save_point('dummy_sine_two', (now, value))

        # Make sure the queue has been cleared
        while db_saver.sql_saver.queue.qsize() > 0:
            time.sleep(0.01)

        # Get the measurement code numbers from the logger
        codes = (db_saver.codename_translation['dummy_sine_one'],
                 db_saver.codename_translation['dummy_sine_two'])

        # Check if the data has been properly written to the db
        for data, code in zip((data1, data2), codes):
            query = 'SELECT UNIX_TIMESTAMP(time), value FROM dateplots_dummy '\
                'WHERE type={} ORDER BY id DESC LIMIT {}'\
                    .format(code, number_of_points)
            CURSOR.execute(query)
            fetched = reversed(CURSOR.fetchall())
            for point_original, point_control in zip(data, fetched):
                # Time is rounded, so it is only correct to within ~0.51 s
                assert np.isclose(point_original[0],
                                  point_control[0],
                                  atol=0.51)
                assert np.isclose(point_original[1], point_control[1])

        db_saver.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 = 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()
Exemple #45
0
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()
Exemple #46
0
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 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)

    codenames = ['fr307_furnace_1_T', 'fr307_furnace_2_T']

    datasocket = DateDataPullSocket('furnaceroom_reader',
                                    codenames,
                                    timeouts=[3.0, 3.0],
                                    port=9001)
    datasocket.start()

    db_logger = ContinuousDataSaver(
        continuous_data_table='dateplots_furnaceroom307',
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames)
    db_logger.start()

    ports = {}
    ports['fr307_furnace_1_T'] = 'usb-FTDI_USB-RS485_Cable_FTYIZLJV-if00-port0'
    ports['fr307_furnace_2_T'] = 'usb-FTDI_USB-RS485_Cable_FTYJ1V33-if00-port0'
    loggers = {}
    temperature_readers = {}
    for logger_name in codenames:
        temperature_readers[logger_name] = TemperatureReader(
            ports[logger_name])
        temperature_readers[logger_name].daemon = True
        temperature_readers[logger_name].start()
        loggers[logger_name] = ValueLogger(temperature_readers[logger_name],
                                           comp_val=0.09)
        loggers[logger_name].start()

    time.sleep(5)

    values = {}
    while True:
        time.sleep(1)
        for logger_name in codenames:
            values[logger_name] = loggers[logger_name].read_value()
            datasocket.set_point_now(logger_name, values[logger_name])
            if loggers[logger_name].read_trigged():
                print(logger_name + ': ' + str(values[logger_name]))
                db_logger.save_point_now(logger_name, values[logger_name])
                loggers[logger_name].clear_trigged()
Exemple #49
0
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()
Exemple #50
0
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():
    """ Main function """

    codenames = []
    for channel in settings.channels.values():
        channel['reader'] = SocketReaderClass(channel['host'], channel['port'],
                                              channel['command'])
        channel['reader'].start()
        channel['logger'] = ValueLogger(channel['reader'], comp_val=channel['comp_value'])
        channel['logger'].daemon = True
        channel['logger'].start()
        codenames.append(channel['codename'])

    try:
        port = settings.port_number
    except AttributeError:
        port = 9000
    pullsocket = DateDataPullSocket(settings.user + '-socket_logger',
                                    codenames, timeouts=5, port=port)
    pullsocket.start()

        
    db_logger = ContinuousDataSaver(continuous_data_table=settings.dateplot_table,
                                    username=settings.user,
                                    password=settings.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    time.sleep(2)

    everything_ok = True
    while everything_ok:
        time.sleep(0.25)
        for channel in settings.channels.values():
            if not channel['reader'].isAlive():
                everything_ok = False
                # Report error here!!!
                # Consider to keep program running even in case of
                # socket failures
            value = channel['logger'].read_value()
            pullsocket.set_point_now(channel['codename'], value)
            if channel['logger'].read_trigged():
                print(value)
                db_logger.save_point_now(channel['codename'], value)
                channel['logger'].clear_trigged()
    def test_enqueue_point(self):
        """Test the continous logger by sending data with timestamps"""
        # Make timestamps to use
        number_of_points = 10
        start = time.time()
        times = [start + increment for increment in range(number_of_points)]

        # Form the lists for local storage of data, for tests
        data1 = []
        data2 = []

        # Init the db_saver
        db_saver = ContinuousDataSaver("dateplots_dummy", "dummy", "dummy", ["dummy_sine_one", "dummy_sine_two"])
        db_saver.start()

        # Save the points
        for now in times:
            value = math.sin(now)
            data1.append([now, value])
            db_saver.save_point("dummy_sine_one", (now, value))
            value = math.sin(now + math.pi)
            data2.append([now, value])
            db_saver.save_point("dummy_sine_two", (now, value))

        # Make sure the queue has been cleared
        while db_saver.sql_saver.queue.qsize() > 0:
            time.sleep(0.01)

        # Get the measurement code numbers from the logger
        codes = (db_saver.codename_translation["dummy_sine_one"], db_saver.codename_translation["dummy_sine_two"])

        # Check if the data has been properly written to the db
        for data, code in zip((data1, data2), codes):
            query = (
                "SELECT UNIX_TIMESTAMP(time), value FROM dateplots_dummy "
                "WHERE type={} ORDER BY id DESC LIMIT {}".format(code, number_of_points)
            )
            CURSOR.execute(query)
            fetched = reversed(CURSOR.fetchall())
            for point_original, point_control in zip(data, fetched):
                # Time is rounded, so it is only correct to within ~0.51 s
                assert np.isclose(point_original[0], point_control[0], atol=0.51)
                assert np.isclose(point_original[1], point_control[1])

        db_saver.stop()
Exemple #53
0
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()
Exemple #54
0
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()
Exemple #55
0
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()
Exemple #56
0
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()
Exemple #57
0
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()