Ejemplo n.º 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
Ejemplo n.º 2
0
def main():
    """ Main function """
    power_supplies = {}
    for i in range(1, 3):
        power_supplies[i] = cpx.CPX400DPDriver(
            i,
            interface='lan',
            hostname='cinf-palle-heating-ps',
            tcp_port=9221)
        power_supplies[i].set_voltage(0)
        power_supplies[i].output_status(True)

    codenames = [
        'setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
        'actual_current_1', 'actual_current_2', 'power', 'temperature'
    ]
    pullsocket = DateDataPullSocket(
        'palle_temp_control',
        codenames,
        timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()

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

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

    heater = HeaterClass(power_calculator, pullsocket, power_supplies)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
Ejemplo n.º 3
0
class FlowControl(threading.Thread):
    """ Keep updated values of the current flow """
    def __init__(self, mks_instance, mfcs, devices, name):
        threading.Thread.__init__(self)
        self.mfcs = mfcs
        self.mks = mks_instance
        self.pullsocket = DateDataPullSocket(name, devices, timeouts=3.0, port=9000)
        self.pullsocket.start()

        self.pushsocket = DataPushSocket(name, action='enqueue')
        self.pushsocket.start()

        self.livesocket = LiveSocket(name, devices)
        self.livesocket.start()
        self.running = True

    def run(self):
        while self.running:
            time.sleep(0.1)
            qsize = self.pushsocket.queue.qsize()
            while qsize > 0:
                element = self.pushsocket.queue.get()
                mfc = list(element.keys())[0]
                print(element[mfc])
                print('Queue: ' + str(qsize))
                self.mks.set_flow(element[mfc], self.mfcs[mfc])
                qsize = self.pushsocket.queue.qsize()

            for mfc in self.mfcs:
                print('!!!')
                flow = self.mks.read_flow(self.mfcs[mfc])
                print(mfc + ': ' + str(flow))
                self.pullsocket.set_point_now(mfc, flow)
                self.livesocket.set_point_now(mfc, flow)
Ejemplo n.º 4
0
def main():
    port_brooks = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTWDN166-if00-port0'
    devices = ['3F2320902001', '3F2320901001']
    datasocket = DateDataPullSocket('palle_mfc_control', devices,
                                    timeouts=[3.0, 3.0], port=9000)
    datasocket.start()

    pushsocket = DataPushSocket('palle_brooks_push_control', action='enqueue')
    pushsocket.start()

    i = 0
    mfcs = {}
    for i in range(0, 2):
        device = devices[i]
        mfcs[device] = brooks.Brooks(device, port=port_brooks)
        print(mfcs[device].long_address)
        print(mfcs[device].read_flow())

    fc = FlowControl(mfcs, datasocket, pushsocket)
    fc.start()

    while fc.running:
        try:
            time.sleep(1)
        except KeyboardInterrupt:
            fc.running = False
            print('stopping, waiting for 2 sek')
            time.sleep(2)
    print('stopped')
Ejemplo n.º 5
0
def main():
    """ Main function """
    port = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTWGRR44-if00-port0'
    devices = ['F25600004', 'F25600005', 'F25600006', 'F25600001', 'F25600002',
               'F25600003', 'F25698001']
    datasocket = DateDataPullSocket('vhp_mfc_control',
                                    devices,
                                    timeouts=[3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0],
                                    port=9000)
    datasocket.start()

    pushsocket = DataPushSocket('vhp_push_control', action='enqueue')
    pushsocket.start()

    i = 0
    mfcs = {}
    for device in devices:
        mfcs[device] = brooks.Brooks(device, port=port)
        print(mfcs[device].read_flow())

    fc = FlowControl(mfcs, datasocket, pushsocket)
    fc.start()

    while True:
        time.sleep(0.5)
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
def main():
    """ Main function """
    ps1 = cpx.CPX400DPDriver(1, device='/dev/ttyACM0', interface='serial')
    ps2 = cpx.CPX400DPDriver(2, device='/dev/ttyACM0', interface='serial')
    isotech = ips.IPS(
        '/dev/serial/by-id/' +
        'usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0')

    pullsocket = DateDataPullSocket(
        'vhp_temp_control',
        ['setpoint', 'dutycycle', 'pid_p', 'pid_i', 'pid_e'],
        timeouts=[999999, 3.0, 3.0, 3.0, 3.0],
        port=9001)
    pullsocket.start()

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

    power_calc = PowerCalculatorClass(pullsocket, pushsocket)
    power_calc.daemon = True
    power_calc.start()

    heater = HeaterClass(power_calc, pullsocket, ps1, ps2, isotech)
    heater.start()

    tui = CursesTui(heater, ps1)
    tui.daemon = True
    tui.start()
Ejemplo n.º 8
0
def main():
    """ Main function """
    valve_names = [0] * 20
    for i in range(0, 20):
        valve_names[i] = str(i + 1)

    try: # Python 3
        name = chr(0x03BC)
    except ValueError:  # Python 2
        name = unichr(0x03BC) # pylint: disable=undefined-variable

    pullsocket = DateDataPullSocket(name + '-reacorNG valve control',
                                    valve_names, timeouts=[2]*20)
    pullsocket.start()

    pushsocket = DataPushSocket(name + '-reactorNG valve control',
                                action='enqueue')
    pushsocket.start()

    valve_controller = valve_control.ValveControl(valve_names, pullsocket, pushsocket)
    valve_controller.start()

    while True:
        time.sleep(1)

    valve_controller.running = False
Ejemplo n.º 9
0
class SocketSupervisor(threading.Thread):
    """ Supervisor will check that a list of ports are still open """
    def __init__(self):
        threading.Thread.__init__(self)
        self.quit = False
        self.ports = settings.ports
        self.setup = settings.setup
        self.pullsocket = DateDataPullSocket(self.setup + '-socket supervisor',
                                             [str(port) for port in self.ports],
                                             timeouts=len(self.ports)*[5])
        self.pullsocket.start()

    def run(self):
        """ Main loop """
        while not self.quit:
            for port in self.ports:
                time.sleep(1)
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                result = sock.connect_ex(('127.0.0.1', port))
                if result == 0:
                    self.pullsocket.set_point_now(str(port), True)
                    print(port, True)
                else:
                    self.pullsocket.set_point_now(str(port), False)
                    print(port, False)
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
    def __init__(self):
        sql_queue = queue.Queue()
        self.data_saver = database_saver.SqlSaver(settings.username,
                                                  settings.username, sql_queue)
        self.data_saver.start()
        if settings.qmg == '420':
            self.qmg = qmg420.qmg_420(settings.port)
        if settings.qmg == '422':
            print(settings.port)
            self.qmg = qmg422.qmg_422(port=settings.port, speed=settings.speed)

        try:
            livesocket = LiveSocket(settings.name + '-mass-spec',
                                    ['qms-value'])
            livesocket.start()
        except:
            livesocket = None

        pullsocket = DateDataPullSocket(settings.name + '-mass-spec',
                                        ['qms-value'])
        pullsocket.start()

        self.qms = ms.QMS(self.qmg,
                          sql_queue,
                          chamber=settings.chamber,
                          credentials=settings.username,
                          livesocket=livesocket,
                          pullsocket=pullsocket)
        self.qmg.reverse_range = settings.reverse_range
        self.printer = qmg_status_output.QmsStatusOutput(
            self.qms, sql_saver_instance=self.data_saver)
        self.printer.start()
Ejemplo n.º 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()
Ejemplo n.º 13
0
def main():
    """ Main function """
    power_supplies = {}
    for i in range(1, 3):
        power_supplies[i] = cpx.CPX400DPDriver(i, interface='lan',
                                               hostname='cinf-palle-heating-ps',
                                               tcp_port=9221)
        power_supplies[i].set_voltage(0)
        power_supplies[i].output_status(True)

    codenames = ['setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
                 'actual_current_1', 'actual_current_2', 'power', 'temperature']
    pullsocket = DateDataPullSocket('palle_temp_control', codenames,
                                    timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()

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

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

    heater = HeaterClass(power_calculator, pullsocket, power_supplies)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
Ejemplo n.º 14
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()

    heater = HeaterClass(power_calculator, datasocket)
    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()
Ejemplo n.º 15
0
def main():
    """ Main function """
    ps1 = cpx.CPX400DPDriver(1, device='/dev/ttyACM0', interface='serial')
    ps2 = cpx.CPX400DPDriver(2, device='/dev/ttyACM0', interface='serial')
    isotech = ips.IPS('/dev/serial/by-id/' +
                      'usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0')

    pullsocket = DateDataPullSocket('vhp_temp_control',
                                    ['setpoint', 'dutycycle', 'pid_p', 'pid_i', 'pid_e'],
                                    timeouts=[999999, 3.0, 3.0, 3.0, 3.0],
                                    port=9001)
    pullsocket.start()

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

    power_calc = PowerCalculatorClass(pullsocket, pushsocket)
    power_calc.daemon = True
    power_calc.start()

    heater = HeaterClass(power_calc, pullsocket, ps1, ps2, isotech)
    heater.start()

    tui = CursesTui(heater, ps1)
    tui.daemon = True
    tui.start()
Ejemplo n.º 16
0
class SocketSupervisor(threading.Thread):
    """ Supervisor will check that a list of ports are still open """
    def __init__(self):
        threading.Thread.__init__(self)
        self.quit = False
        self.ports = settings.ports
        self.setup = settings.setup
        print self.ports
        print len(self.ports)
        print[str(port) for port in self.ports]
        self.pullsocket = DateDataPullSocket(
            self.setup + '-socket supervisor',
            [str(port) for port in self.ports],
            timeouts=len(self.ports) * [5])
        self.pullsocket.start()

    def run(self):
        """ Main loop """
        while not self.quit:
            for port in self.ports:
                time.sleep(1)
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                result = sock.connect_ex(('127.0.0.1', port))
                if result == 0:
                    self.pullsocket.set_point_now(str(port), True)
                    print(port, True)
                else:
                    self.pullsocket.set_point_now(str(port), False)
                    print(port, False)
Ejemplo n.º 17
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()
Ejemplo n.º 18
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()
Ejemplo n.º 19
0
    def __init__(self):
        sql_queue = queue.Queue()
        self.data_saver = database_saver.SqlSaver(settings.username,
                                                  settings.username, sql_queue)
        self.data_saver.start()
        if settings.qmg == '420':
            self.qmg = qmg420.qmg_420(settings.port)
        if settings.qmg == '422':
            print(settings.port)
            self.qmg = qmg422.qmg_422(port=settings.port, speed=settings.speed)

        try:
            livesocket = LiveSocket(settings.name + '-mass-spec', ['qms-value'])
            livesocket.start()
        except:
            livesocket = None

        pullsocket = DateDataPullSocket(settings.name + '-mass-spec', ['qms-value'])
        pullsocket.start()

        self.qms = ms.QMS(self.qmg, sql_queue, chamber=settings.chamber,
                          credentials=settings.username, livesocket=livesocket,
                          pullsocket=pullsocket)
        self.qmg.reverse_range = settings.reverse_range
        self.printer = qmg_status_output.QmsStatusOutput(self.qms,
                                                         sql_saver_instance=self.data_saver)
        self.printer.start()
Ejemplo n.º 20
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()
Ejemplo n.º 21
0
def main():
    """ Main function """
    valve_names = [0] * 20
    for i in range(0, 20):
        valve_names[i] = str(i + 1)

    try:
        name = chr(0x03BC) # Python 3
    except ValueError:
        name = unichr(0x03BC) # Python 2

    pullsocket = DateDataPullSocket(name + '-reacor Valvecontrol',
                                    valve_names, timeouts=[2]*20)
    pullsocket.start()

    pushsocket = DataPushSocket(name + '-reactor valve control',
                                action='enqueue')
    pushsocket.start()

    valve_controller = valve_control.ValveControl(valve_names, pullsocket, pushsocket)
    valve_controller.start()

    while True:
        time.sleep(1)

    valve_controller.running = False
Ejemplo n.º 22
0
def main():
    """ Main loop """
    il800 = intellemetrics_il800.IL800(
        "/dev/serial/by-id/" + "usb-Prolific_Technology_Inc." + "_USB-Serial_Controller_D-if00-port0"
    )
    sqm160 = inficon_sqm160.InficonSQM160("/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0")

    qcm1 = QcmReader(il800)
    qcm1.start()

    qcm2 = QcmReader(sqm160)
    qcm2.start()

    time.sleep(2.5)

    codenames = [
        "pvd309_qcm1_rate",
        "pvd309_qcm1_thickness",
        "pvd309_qcm1_frequency",
        "pvd309_qcm2_rate",
        "pvd309_qcm2_thickness",
        "pvd309_qcm2_frequency",
    ]

    loggers = {}
    loggers[codenames[0]] = ValueLogger(qcm1, comp_val=0.01, comp_type="lin", channel=0)
    loggers[codenames[1]] = ValueLogger(qcm1, comp_val=0.1, comp_type="lin", channel=1)
    loggers[codenames[2]] = ValueLogger(qcm1, comp_val=1, comp_type="lin", channel=2)
    loggers[codenames[3]] = ValueLogger(qcm2, comp_val=0.3, comp_type="lin", channel=0)
    loggers[codenames[4]] = ValueLogger(qcm2, comp_val=0.1, comp_type="lin", channel=1)
    loggers[codenames[5]] = ValueLogger(qcm2, comp_val=1, comp_type="lin", channel=2)
    for name in codenames:
        loggers[name].daemon = True
        loggers[name].start()

    livesocket = LiveSocket("pvd309 qcm logger", codenames)
    livesocket.start()

    socket = DateDataPullSocket("pvd309 qcm", codenames, timeouts=[1.0] * len(codenames))
    socket.start()

    db_logger = ContinuousLogger(
        table="dateplots_pvd309",
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames,
    )
    db_logger.start()

    while qcm1.isAlive() and qcm2.isAlive():
        time.sleep(0.25)
        for name in codenames:
            value = loggers[name].read_value()
            livesocket.set_point_now(name, value)
            socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(name + ": " + str(value))
                db_logger.enqueue_point_now(name, value)
                loggers[name].clear_trigged()
Ejemplo n.º 23
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
Ejemplo n.º 24
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()
class IonOpticsControl(threading.Thread):
    """ Main optics control """
    def __init__(self, port, name, lenses):
        threading.Thread.__init__(self)
        name = name + '_ion_optics'
        self.pullsocket = DateDataPullSocket(name, lenses, timeouts=20.0)
        self.pullsocket.start()
        self.pushsocket = DataPushSocket(name, action='enqueue')
        self.pushsocket.start()
        self.ion_optics = stahl_hv_400.StahlHV400(port)
        self.lenses = lenses
        self.set_voltages = {}
        self.actual_voltages = {}
        for lens in self.lenses:
            self.set_voltages[lens] = 0
            self.actual_voltages[lens] = 0
        self.status = {}
        self.status['channel_status'] = {}
        for i in range(1, len(self.lenses) + 1):
            self.status['channel_status'][i] = False
        self.status['temperature'] = None
        self.status['output_error'] = None
        self.quit = False

    def run(self):
        current_lens = 1
        while not self.quit:
            self.status['temperature'] = self.ion_optics.read_temperature()
            if self.status['temperature'] > 50:
                for lens in self.lenses:
                    self.set_voltages[lens] = 0

            self.status[
                'channel_status'] = self.ion_optics.check_channel_status()
            self.status['output_error'] = False in self.status[
                'channel_status']

            actual_voltage = self.ion_optics.query_voltage(current_lens)
            self.actual_voltages[self.lenses[current_lens -
                                             1]] = actual_voltage
            self.pullsocket.set_point_now(self.lenses[current_lens - 1],
                                          actual_voltage)

            if current_lens == len(self.lenses):
                current_lens = 1
            else:
                current_lens += 1

            qsize = self.pushsocket.queue.qsize()
            while qsize > 0:
                element = self.pushsocket.queue.get()
                lens = str(list(element.keys())[0])
                value = element[lens]
                self.set_voltages[lens] = value
                channel_number = self.lenses.index(lens) + 1
                self.ion_optics.set_voltage(channel_number, value)
                qsize = self.pushsocket.queue.qsize()
            time.sleep(0.1)
Ejemplo n.º 26
0
def main():
    """ Main function """
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        network_adress = 'rasppi12'
        command = 'microreactorng_temp_sample#raw'.encode()
        sock.sendto(command, (network_adress, 9000))
        received = sock.recv(1024)
        received = received.decode('ascii')
        if received == 'OLD_DATA':
            raise RuntimeError(
                "Received OLD_DATA from rasppi12. Please check it.")
        start_temp = float(received[received.find(',') + 1:])
        agilent_hostname = '10.54.6.56'
        rtd_reader = RtdReader(agilent_hostname, start_temp)
    except socket.timeout:
        print('Could not find rasppi12')
        exit()
    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    power_supply = {}
    for k in range(1, 3):
        power_supply[k] = cpx.CPX400DPDriver(
            k,
            interface='lan',
            hostname='surfcat-stm312-heating-ps',
            tcp_port=9221)
        power_supply[k].set_voltage(0)
        power_supply[k].output_status(True)

    codenames = [
        'setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
        'actual_current_1', 'actual_current_2', 'power', 'temperature'
    ]
    pullsocket = DateDataPullSocket(
        MICRO + '-reactorng_temp_control',
        codenames,
        timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()

    pushsocket = DataPushSocket(MICRO + '-reactorng_push_control',
                                action='store_last')
    pushsocket.start()

    power_calculator = PowerCalculatorClass(pullsocket, pushsocket, rtd_reader)
    power_calculator.daemon = True
    power_calculator.start()

    heater = HeaterClass(power_calculator, pullsocket, power_supply)
    heater.start()

    tui_class = CursesTui(heater)
    tui_class.start()
    LOGGER.info('script ended')
Ejemplo n.º 27
0
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
Ejemplo n.º 28
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()
Ejemplo n.º 29
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()
Ejemplo n.º 30
0
class MySocket(threading.Thread):
    """ Temperature reader """
    def __init__(self):
        threading.Thread.__init__(self)
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.settimeout(2)
        self.quit = False
        sockname = 'tabs_all'
        self.codenames = socketinfo.INFO[sockname]['codenames']
        self.PullSocket = DateDataPullSocket(sockname, self.codenames, timeouts=[60.0]*len(self.codenames), port = socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()
        self.data = {}
        for co in self.codenames:
            self.data[co] = None
        
    def run(self,):
        i = 0
        while not self.quit:
            try:
                #print(i)
                time.sleep(2)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    v = self.data[name]
                    self.PullSocket.set_point_now(name, v)
            except (KeyboardInterrupt, SystemExit):
                pass
                #self.VC.stop()
                #report error and proceed
            i += 1
    def update_values(self,):
        """ Read the temperature from a external socket server"""
        for so in ['tabs_temperatures', 'tabs_setpoints', 'tabs_pids', 'tabs_valve', 'tabs_multiplexer']:
            try:
                info = socketinfo.INFO[so]
                host_port = (info['host'], info['port'])
                command = 'json_wn'
                self.sock.sendto(command, host_port)
                data = json.loads(self.sock.recv(2048))
                now = time.time()
                #print(data)
                for key, value in data.items():
                    try:
                        if abs(now - value[0]) > 3*60 or value[1] == 'OLD_DATA': # this is 3min change to 5s
                           self.data[key] = None
                        else:
                            self.data[key] = value[1]
                    except:
                        self.data[key] = None
            except socket.timeout:
                pass
        return self.data
    def stop(self):
        self.quit = True
        self.PullSocket.stop()
Ejemplo n.º 31
0
class IonOpticsControl(threading.Thread):
    """ Main optics control """
    def __init__(self, port, name, lenses):
        threading.Thread.__init__(self)
        name = name + '_ion_optics'
        self.pullsocket = DateDataPullSocket(name, lenses, timeouts=20.0)
        self.pullsocket.start()
        self.pushsocket = DataPushSocket(name, action='enqueue')
        self.pushsocket.start()
        self.ion_optics = stahl_hv_400.StahlHV400(port)
        self.lenses = lenses
        self.set_voltages = {}
        self.actual_voltages = {}
        for lens in self.lenses:
            self.set_voltages[lens] = 0
            self.actual_voltages[lens] = 0
        self.status = {}
        self.status['channel_status'] = {}
        for i in range(1, len(self.lenses)+1):
            self.status['channel_status'][i] = False
        self.status['temperature'] = None
        self.status['output_error'] = None
        self.quit = False

    def run(self):
        current_lens = 1
        while not self.quit:
            self.status['temperature'] = self.ion_optics.read_temperature()
            if self.status['temperature'] > 50:
                for lens in self.lenses:
                    self.set_voltages[lens] = 0

            self.status['channel_status'] = self.ion_optics.check_channel_status()
            self.status['output_error'] = False in self.status['channel_status']

            actual_voltage = self.ion_optics.query_voltage(current_lens)
            self.actual_voltages[self.lenses[current_lens-1]] = actual_voltage
            self.pullsocket.set_point_now(self.lenses[current_lens-1], actual_voltage)

            if current_lens == len(self.lenses):
                current_lens = 1
            else:
                current_lens += 1

            qsize = self.pushsocket.queue.qsize()
            while qsize > 0:
                element = self.pushsocket.queue.get()
                lens = str(list(element.keys())[0])
                value = element[lens]
                self.set_voltages[lens] = value
                channel_number = self.lenses.index(lens) + 1
                self.ion_optics.set_voltage(channel_number, value)
                qsize = self.pushsocket.queue.qsize()
            time.sleep(0.1)
Ejemplo n.º 32
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()
Ejemplo n.º 33
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()
Ejemplo n.º 34
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()
def main():
    """ Main function """
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        temperature_string = 'mr_sample_tc_temperature#raw'
        sock.sendto(temperature_string.encode('ascii'), ('rasppi12', 9000))
        received = sock.recv(1024).decode('ascii')
        start_temp = float(received[received.find(',') + 1:])
    except socket.gaierror:
        print('Could not find rasppi12')
        exit()
    except ValueError:
        print('Bad reply from rasppi12')
        exit()
    rtd_reader = RtdReader(start_temp)

    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    power_supply = {}
    for k in range(1, 3):
        power_supply[k] = cpx.CPX400DPDriver(k,
                                             interface='serial',
                                             device='/dev/ttyACM0')
        power_supply[k].set_voltage(0)
        power_supply[k].output_status(True)

    codenames = [
        'setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
        'actual_current_1', 'actual_current_2', 'power', 'temperature'
    ]
    pullsocket = DateDataPullSocket(
        MICRO + '-reactor_temp_control',
        codenames,
        timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()

    pushsocket = DataPushSocket(MICRO + '-reactor push control',
                                action='store_last')
    pushsocket.start()

    power_calculator = PowerCalculatorClass(pullsocket, pushsocket, rtd_reader)
    power_calculator.daemon = True
    power_calculator.start()

    heater = HeaterClass(power_calculator, pullsocket, power_supply)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
Ejemplo n.º 36
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()
Ejemplo n.º 37
0
class TemperatureLogger(object):

    def __init__(self):
        # Initialize omega driver
        LOGGER.info('Initialize omega d6400 driver')
        d6400_id = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTWGRP0B-if00'\
            '-port0'
        self.d6400 = D6400.OmegaD6400(1, d6400_id)
        for channel in range(1, 8):
            LOGGER.info('Set range for channel {}'.format(channel))
            self.d6400.update_range_and_function(channel, action='tc',
                                                 fullrange='K')

        # Initialize socket
        name = 'Coupled reactor temperatures'
        self.codenames = {
            1: 'R1_temp',
            2: 'R1_sample_temp',
            3: 'R2_temp',
            4: 'R2_sample_temp',
            5: 'pro_inlet_temp',
            6: 'pro_d1_temp',
            7: 'pro_d2_temp',
            }
        codenames_list = [self.codenames[channel] for channel in range(1, 8)]
        self.socket = DateDataPullSocket(name, codenames_list, timeouts = 2.0)
        self.socket.start()

        # Measure initial values
        self.temperatures = {}
        for channel in range(1, 8):
            self.temperatures[channel] = self.d6400.read_value(channel)
            LOGGER.info('Get initial value {} for channel: {}'.format(
                    self.temperatures[channel], channel))
            self.socket.set_point_now(self.codenames[channel],
                                      self.temperatures[channel])

    def main(self):
        """Main meaurement loop"""
        while True:
            for channel in range(1, 8):
                self.temperatures[channel] = self.d6400.read_value(channel)
                LOGGER.info('Measured value {} for channel: {}'.format(
                        self.temperatures[channel], channel))
                self.socket.set_point_now(self.codenames[channel],
                                          self.temperatures[channel])
                

    def close(self):
        """Shut down the socket"""
        self.socket.stop()
        time.sleep(2)
Ejemplo n.º 38
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()
Ejemplo n.º 39
0
class TemperatureLogger(object):
    def __init__(self):
        # Initialize omega driver
        LOGGER.info('Initialize omega d6400 driver')
        d6400_id = '/dev/serial/by-id/usb-FTDI_USB-RS485_Cable_FTWGRP0B-if00'\
            '-port0'
        self.d6400 = D6400.OmegaD6400(1, d6400_id)
        for channel in range(1, 8):
            LOGGER.info('Set range for channel {}'.format(channel))
            self.d6400.update_range_and_function(channel,
                                                 action='tc',
                                                 fullrange='K')

        # Initialize socket
        name = 'Coupled reactor temperatures'
        self.codenames = {
            1: 'R1_temp',
            2: 'R1_sample_temp',
            3: 'R2_temp',
            4: 'R2_sample_temp',
            5: 'pro_inlet_temp',
            6: 'pro_d1_temp',
            7: 'pro_d2_temp',
        }
        codenames_list = [self.codenames[channel] for channel in range(1, 8)]
        self.socket = DateDataPullSocket(name, codenames_list, timeouts=2.0)
        self.socket.start()

        # Measure initial values
        self.temperatures = {}
        for channel in range(1, 8):
            self.temperatures[channel] = self.d6400.read_value(channel)
            LOGGER.info('Get initial value {} for channel: {}'.format(
                self.temperatures[channel], channel))
            self.socket.set_point_now(self.codenames[channel],
                                      self.temperatures[channel])

    def main(self):
        """Main meaurement loop"""
        while True:
            for channel in range(1, 8):
                self.temperatures[channel] = self.d6400.read_value(channel)
                LOGGER.info('Measured value {} for channel: {}'.format(
                    self.temperatures[channel], channel))
                self.socket.set_point_now(self.codenames[channel],
                                          self.temperatures[channel])

    def close(self):
        """Shut down the socket"""
        self.socket.stop()
        time.sleep(2)
Ejemplo n.º 40
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()
Ejemplo n.º 41
0
class pressure_socket(object):
    
    def __init__(self):
        self.name = 'Sigrun_pressure'
        self.data_entries = ['pressure']
        self.port = 9009
        self.socket = DateDataPullSocket(self.name, self.data_entries, port=self.port)
        self.socket.start()
    
    def stop(self):
        self.socket.stop()

    def set_point_now(self, data_point):
        self.socket.set_point('pressure',data_point)
Ejemplo n.º 42
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()
Ejemplo n.º 43
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()
def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        temperature_string = 'mr_sample_tc_temperature#raw'
        sock.sendto(temperature_string.encode('ascii'), ('rasppi12', 9000))
        received = sock.recv(1024).decode('ascii')
        start_temp = float(received[received.find(',') + 1:])
        agilent_hostname = '10.54.6.79'
        rtd_reader = RtdReader(agilent_hostname, start_temp)
    except:
        print('Could not find rasppi12')
        exit()

    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    PS = {}
    for k in range(1, 3):
        PS[k] = cpx.CPX400DPDriver(k,
                                   interface='serial',
                                   device='/dev/ttyACM0')
        PS[k].set_voltage(0)
        PS[k].output_status(True)

    try:
        micro = chr(0x03BC)  # Python 3
    except ValueError:
        micro = unichr(0x03BC)  # Python 2
    Pullsocket = DateDataPullSocket(micro + 'reactor temp_control',
                                    ['setpoint', 'voltage', 'temperature'],
                                    timeouts=[999999, 3.0, 3.0],
                                    port=9000)
    Pullsocket.start()

    Pushsocket = DataPushSocket(micro + '-reactor push control',
                                action='store_last')
    Pushsocket.start()

    pcc = PowerCalculatorClass(Pullsocket, Pushsocket, rtd_reader)
    pcc.daemon = True
    pcc.start()

    heater = HeaterClass(P, Pullsocket, PS)
    heater.start()

    tui = CursesTui(H)
    tui.daemon = True
    tui.start()
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")
Ejemplo n.º 46
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()
Ejemplo n.º 47
0
def main():
    """ Main function """
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        network_adress = 'rasppi12'
        command = 'microreactorng_temp_sample#raw'.encode()
        sock.sendto(command, (network_adress, 9000))
        received = sock.recv(1024)
        received = received.decode('ascii')
        if received == 'OLD_DATA':
            raise RuntimeError("Received OLD_DATA from rasppi12. Please check it.")
        start_temp = float(received[received.find(',') + 1:])
        agilent_hostname = '10.54.6.56'
        rtd_reader = RtdReader(agilent_hostname, start_temp)
    except socket.timeout:
        print('Could not find rasppi12')
        exit()
    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    power_supply = {}
    for k in range(1, 3):
        power_supply[k] = cpx.CPX400DPDriver(k, interface='lan',
                                             hostname='surfcat-stm312-heating-ps',
                                             tcp_port=9221)
        power_supply[k].set_voltage(0)
        power_supply[k].output_status(True)

    codenames = ['setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
                 'actual_current_1', 'actual_current_2', 'power', 'temperature']
    pullsocket = DateDataPullSocket(MICRO + '-reactorng_temp_control', codenames,
                                    timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()
    
    pushsocket = DataPushSocket(MICRO + '-reactorng_push_control', action='store_last')
    pushsocket.start()

    power_calculator = PowerCalculatorClass(pullsocket, pushsocket, rtd_reader)
    power_calculator.daemon = True
    power_calculator.start()

    heater = HeaterClass(power_calculator, pullsocket, power_supply)
    heater.start()

    tui_class = CursesTui(heater)
    tui_class.start()
    LOGGER.info('script ended')
Ejemplo n.º 48
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
Ejemplo n.º 49
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()
Ejemplo n.º 50
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()
Ejemplo n.º 51
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()
Ejemplo n.º 52
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()
Ejemplo n.º 53
0
def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        temperature_string = 'mr_sample_tc_temperature#raw'
        sock.sendto(temperature_string.encode('ascii'), ('rasppi12', 9000))
        received = sock.recv(1024).decode('ascii')
        start_temp = float(received[received.find(',') + 1:])
        agilent_hostname = '10.54.6.79'
        rtd_reader = RtdReader(agilent_hostname, start_temp)
    except:
        print('Could not find rasppi12')
        exit()

    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    PS = {}
    for k in range(1, 3):
        PS[k] = cpx.CPX400DPDriver(k, interface='serial', device='/dev/ttyACM0')
        PS[k].set_voltage(0)
        PS[k].output_status(True)

    try:
        micro = chr(0x03BC) # Python 3
    except ValueError:
        micro = unichr(0x03BC) # Python 2
    Pullsocket = DateDataPullSocket(micro + 'reactor temp_control',
                                    ['setpoint', 'voltage', 'temperature'], 
                                    timeouts=[999999, 3.0, 3.0],
                                    port=9000)
    Pullsocket.start()

    Pushsocket = DataPushSocket(micro + '-reactor push control', action='store_last')
    Pushsocket.start()

    pcc = PowerCalculatorClass(Pullsocket, Pushsocket, rtd_reader)
    pcc.daemon = True
    pcc.start()

    heater = HeaterClass(pcc, Pullsocket, PS)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
Ejemplo n.º 54
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()
Ejemplo n.º 55
0
def main():
    """ Main function """
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.settimeout(1)
    try:
        temperature_string = 'mr_sample_tc_temperature#raw'
        sock.sendto(temperature_string.encode('ascii'), ('rasppi12', 9000))
        received = sock.recv(1024).decode('ascii')
        start_temp = float(received[received.find(',') + 1:])
    except socket.gaierror:
        print('Could not find rasppi12')
        exit()
    except ValueError:
        print('Bad reply from rasppi12')
        exit()
    rtd_reader = RtdReader(start_temp)

    rtd_reader.daemon = True
    rtd_reader.start()
    time.sleep(1)

    power_supply = {}
    for k in range(1, 3):
        power_supply[k] = cpx.CPX400DPDriver(k, interface='serial', device='/dev/ttyACM0')
        power_supply[k].set_voltage(0)
        power_supply[k].output_status(True)

    codenames = ['setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
                 'actual_current_1', 'actual_current_2', 'power', 'temperature']
    pullsocket = DateDataPullSocket(MICRO + '-reactor_temp_control', codenames,
                                    timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
    pullsocket.start()

    pushsocket = DataPushSocket(MICRO + '-reactor push control', action='store_last')
    pushsocket.start()

    power_calculator = PowerCalculatorClass(pullsocket, pushsocket, rtd_reader)
    power_calculator.daemon = True
    power_calculator.start()

    heater = HeaterClass(power_calculator, pullsocket, power_supply)
    heater.start()

    tui = CursesTui(heater)
    tui.daemon = True
    tui.start()
Ejemplo n.º 56
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()
Ejemplo n.º 57
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'])

    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()
Ejemplo n.º 58
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()