Example #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
Example #2
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
Example #3
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()
Example #4
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)
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)
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")
Example #7
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)
Example #8
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
Example #9
0
class GC_data_socket(object):

    def __init__(self):
        self.name = 'Sigrun_Gas_Chromatograph'
        self.data_entries = ['ready_voltage','retention_time','FID low V','FID high V','TCD low V','TCD high V']
        self.port = 9002
        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, entry, data_point):
        if entry not in self.data_entries:
            raise KeyError('Key not found in data_entries')
            return
        self.socket.set_point(entry, data_point)
Example #10
0
def main():
    LOGGER.info('main started')
    cni = CNi3244_C24(5)
    socket = DateDataPullSocket(FULL_NAME, [SHORT_NAME], timeouts=1.0)
    socket.start()
    db_logger = ContinuousLogger(table='dateplots_tower',
                                 username='******',
                                 password='******',
                                 measurement_codenames=[NAME],
                                 dsn='servcinf')
    db_logger.start()
    time.sleep(0.1)

    # Main part
    try:
        main_measure_loop(cni, socket, db_logger)
    except KeyboardInterrupt:
        LOGGER.info('Keyboard Interrupt. Shutting down!')
        db_logger.stop()
        cni.close()
        socket.stop()
Example #11
0
def main():
    LOGGER.info('main started')
    cni = CNi3244_C24(5)
    socket = DateDataPullSocket(FULL_NAME, [SHORT_NAME], timeouts=1.0)
    socket.start()
    db_logger = ContinuousLogger(
        table='dateplots_tower', username='******', password='******',
        measurement_codenames=[NAME],
        dsn='servcinf'
    )
    db_logger.start()
    time.sleep(0.1)

    # Main part
    try:
        main_measure_loop(cni, socket, db_logger)
    except KeyboardInterrupt:
        LOGGER.info('Keyboard Interrupt. Shutting down!')
        db_logger.stop()
        cni.close()
        socket.stop()
Example #12
0
#db_logger.start()

time.sleep(5)

run = True
while run:
    time.sleep(0.25)
    try:
        for name in codenames:
            v = loggers[name].read_value()
            socket.set_point_now(name, v)
            if loggers[name].read_trigged():
                print v
                #db_logger.enqueue_point_now(name, v)
                loggers[name].clear_trigged()
                print("resistance: {}, time: {}".format(v, time.time()))
    except (KeyboardInterrupt, SystemExit):
        print('raising error')
        run = False
        raise
    except:
        print('stoppiung everything')
        run = False
        reader.stop()
        socket.stop()
        for value, key in loggers.iteritems():
            value.stop()
        print('All is stopped')


Example #13
0
class MainTui(threading.Thread):
    """ Temperature reader """
    def __init__(self, ):
        threading.Thread.__init__(self)
        #from mytui import CursesTui
        self.quit = False
        self.codenames = [
            'tabs_guard_temperature_setpoint',
            'tabs_floor_temperature_setpoint',
            'tabs_ceiling_temperature_setpoint',
            'tabs_cooling_temperature_setpoint',
        ]
        sockname = 'tabs_setpoints'
        self.PullSocket = DateDataPullSocket(
            sockname,
            self.codenames,
            timeouts=[60.0] * len(self.codenames),
            port=socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()

        self.TUI = CursesTui(self.codenames)
        self.TUI.daemon = True
        self.TUI.start()
        #time.sleep(5)

        chlist = {
            'tabs_guard_temperature_setpoint': 0,
            'tabs_floor_temperature_setpoint': 1,
            'tabs_ceiling_temperature_setpoint': 2,
            'tabs_cooling_temperature_setpoint': 3
        }
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.TUI,
                                            comp_val=0.2,
                                            maximumtime=60,
                                            comp_type='lin',
                                            channel=chlist[key])
            self.loggers[key].start()
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()

        self.db_logger = ContinuousLogger(table='dateplots_tabs',
                                          username=credentials.user,
                                          password=credentials.passwd,
                                          measurement_codenames=self.codenames)
        #print('Hostname of db logger: ' + db_logger.host)
        self.db_logger.start()

    def run(self):
        i = 0
        while not self.quit:
            #print(i)
            if self.TUI.isAlive():
                pass
            else:
                print('TUI has shutdown')
                self.quit = True
            try:
                #print(i)
                time.sleep(2)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #print('Status: ', name , v)
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    if self.loggers[name].read_trigged():
                        #if __name__ == '__main__':
                        #    print('Log: ', i, name, v)
                        #print('Log: ', name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except:
                print('run error')
                pass
                #self.TUI.stop()
                #report error and proceed
            i += 1
        self.stop()

    def stop(self):
        self.quit = True
        self.TUI.stop()
        self.PullSocket.stop()
        self.db_logger.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #14
0
class MainPID(threading.Thread):
    """ pid controller """
    def __init__(self, ):
        logging.info('MainPID class started')
        threading.Thread.__init__(self)
        #from datalogger import TemperatureReader
        self.quit = False
        self.codenames = [
            'tabs_guard_pid_value',
            'tabs_floor_pid_value',
            'tabs_ceiling_pid_value',
            'tabs_cooling_pid_value',
            'tabs_guard_valve_heating',
            'tabs_floor_valve_heating',
            'tabs_ceiling_valve_heating',
            'tabs_guard_valve_cooling',
            'tabs_floor_valve_cooling',
            'tabs_ceiling_valve_cooling',
            'tabs_cooling_valve_cooling',
        ]
        sockname = 'tabs_pids'
        self.PullSocket = DateDataPullSocket(
            sockname,
            self.codenames,
            timeouts=[60.0] * len(self.codenames),
            port=socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()

        self.PTC = PidTemperatureControl(self.codenames)
        self.PTC.daemon = True
        self.PTC.start()
        #time.sleep(5)

        chlist = {
            'tabs_guard_pid_value': 0,
            'tabs_floor_pid_value': 1,
            'tabs_ceiling_pid_value': 2,
            'tabs_cooling_pid_value': 3,
            'tabs_guard_valve_heating': 4,
            'tabs_floor_valve_heating': 5,
            'tabs_ceiling_valve_heating': 6,
            'tabs_guard_valve_cooling': 7,
            'tabs_floor_valve_cooling': 8,
            'tabs_ceiling_valve_cooling': 9,
            'tabs_cooling_valve_cooling': 10
        }
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.PTC,
                                            comp_val=0.10,
                                            maximumtime=60,
                                            comp_type='lin',
                                            channel=chlist[key])
            self.loggers[key].start()
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()

        self.db_logger = ContinuousLogger(table='dateplots_tabs',
                                          username=credentials.user,
                                          password=credentials.passwd,
                                          measurement_codenames=self.codenames)
        self.db_logger.start()

    def run(self, ):
        i = 0
        while not self.quit and self.PTC.isAlive():
            try:
                #print(i)
                time.sleep(1)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #print('Status: ', name , v)
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    if self.loggers[name].read_trigged():
                        if __name__ == '__main__':
                            print('Log: ', i, name, v)
                        #print(i, name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except (KeyboardInterrupt, SystemExit):
                self.quit = True
                pass
                #self.PTC.stop()
                #report error and proceed
            i += 1
        self.stop()

    def stop(self):
        self.quit = True
        self.PTC.stop()
        self.PullSocket.stop()
        self.db_logger.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #15
0
    CODENAMES = ['hv_psu_current', 'hv_psu_voltage']

    # Pull socket
    datasocket = DateDataPullSocket('hv_psu', CODENAMES, timeouts=4, port=9002)
    datasocket.start()

    string = 'Channel {}: {: >6.4} V\tChannel {}: {: >6.4} V'
    dataq.start_measurement()
    sleep(1)
    while True:
        try:
            result = dataq.read_measurements()
        except KeyboardInterrupt:
            dataq.stop_measurement()
            datasocket.stop()
            break
        except:
            print('dataq error')
            dataq.stop_measurement()
            raise
        current = result[1]
        voltage = result[2]
        datasocket.set_point_now('hv_psu_current', current)
        datasocket.set_point_now('hv_psu_voltage', voltage)
        print(string.format(1, current, 2, voltage))
        try:
            sleep(0.18)
        except KeyboardInterrupt:
            dataq.stop_measurement()
            datasocket.stop()
Example #16
0
class MainMultilogger(threading.Thread):
    """ Temperature reader """
    def __init__(self, ):
        logging.info('MainMultilogger class started')
        threading.Thread.__init__(self)
        #from datalogger import TemperatureReader
        self.quit = False
        self.codenames = Setting_channel_list.keys()
        """['tabs_ceiling_temperature_delta',
                          'tabs_ceiling_temperature_deltaref',
                          'tabs_floor_temperature_delta',
                          'tabs_floor_temperature_deltaref',
                          'tabs_room_temperature_aircenter010',
                          'tabs_room_temperature_aircenter060',
                          'tabs_room_temperature_aircenter110',
                          'tabs_room_temperature_aircenter170',
                          'tabs_room_temperature_aircenter355',
                          'tabs_guard_temperature_airfloor',
                          'tabs_guard_temperature_airceiling',
                          'tabs_guard_temperature_airwallsouth',
                          'tabs_guard_temperature_airwallnorth',
                          'tabs_guard_temperature_airwalleast',
                          'tabs_guard_temperature_airwallwest',
                          
                          ]"""
        self.multiplex_reader = MultiplexReader(self.codenames)
        self.multiplex_reader.daemon = True
        self.multiplex_reader.start()
        #omega_temperature.update_values()

        time.sleep(3.5)

        chlist = Setting_channel_list
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.multiplex_reader,
                                            comp_val=0.5,
                                            maximumtime=300,
                                            comp_type='lin',
                                            channel=chlist[key])
            self.loggers[key].start()

        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()
        sockname = 'tabs_multiplexer'
        self.PullSocket = DateDataPullSocket(
            sockname,
            self.codenames,
            timeouts=[60.0] * len(self.codenames),
            port=socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()

        self.db_logger = ContinuousLogger(table='dateplots_tabs',
                                          username=credentials.user,
                                          password=credentials.passwd,
                                          measurement_codenames=self.codenames)
        self.db_logger.start()

    def run(self, ):
        i = 0
        while not self.quit and self.multiplex_reader.isAlive():
            try:
                #print(i)
                time.sleep(1)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    #print(i, name, v)
                    if self.loggers[name].read_trigged(
                    ) and abs(v) < 9.9E+5 and v != None:
                        if __name__ == '__main__':
                            print('Log: ', i, name, v)
                        #print(name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except (KeyboardInterrupt, SystemExit):
                self.quit = True
                pass
                #self.omega_temperature.close()
                #report error and proceed
            i += 1
        self.stop()

    def stop(self):
        self.quit = True
        self.multiplex_reader.stop()
        self.PullSocket.stop()
        self.db_logger.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #17
0
#                             password=credentials.passwd,
#                             measurement_codenames=codenames)
#db_logger.daemon = True
#db_logger.start()

time.sleep(5)
run = True
while run:
    time.sleep(0.25)
    try:
        for name in codenames:
            v = loggers[name].read_value()
            socket.set_point_now(name, v)
            if loggers[name].read_trigged():
                print v
                #db_logger.enqueue_point_now(name, v)
                loggers[name].clear_trigged()
                print("resistance: {}, time: {}".format(v, time.time()))
    except (KeyboardInterrupt, SystemExit):
        print('raising error')
        run = False
        raise
    except:
        print('stoppiung everything')
        run = False
        reader.stop()
        socket.stop()
        for value, key in loggers.iteritems():
            value.stop()
        print('All is stopped')
Example #18
0
from PyExpLabSys.drivers.dataq_binary import DI1110
from PyExpLabSys.common.sockets import DateDataPullSocket


if __name__ == '__main__':
    dataq = DI1110('/dev/serial/by-id/usb-DATAQ_Instruments_Generic_Bulk_Device_599C2B33_DI-1110-if00-port0')
    dataq.sample_rate(1000)
    sleep(0.2)
    dataq.scan_list([0, 1])
    sleep(0.2)

    CODENAMES = ['hv_psu_current', 'hv_psu_voltage']

    # Pull socket
    datasocket = DateDataPullSocket('hv_psu', CODENAMES, timeouts=4, port=9002)
    datasocket.start()
    
    dataq.start()
    try:
        while True:
            dataq.clear_buffer()
            sleep(0.2)
            data = dataq.read()
            string = 'Channel {}: {} V\tChannel {}: {} V'.format(data[0]['channel'], data[0]['value'], data[1]['channel'], data[1]['value'])
            print(string)
            for i in range(len(data)):
                datasocket.set_point_now(CODENAMES[i], data[i]['value'])
    except KeyboardInterrupt:
        dataq.stop()
        datasocket.stop()
Example #19
0
def main():
    """ Main function """
    log = get_logger('pressure readout', level='debug')
    #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()
    log.info('DateDataPullSocket started')
    live_socket = LiveSocket('XRD pressure', codenames)
    live_socket.start()
    log.info('LiveSocket started')

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_xrd',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()
    log.info('ContinuousDataSaver started')

    time.sleep(5)

    try:
        while True:
            time.sleep(0.25)
            for name in codenames:
                value = loggers[name].read_value()
                log.debug('Read codename %s value %s', name, value)
                socket.set_point_now(name, value)
                live_socket.set_point_now(name, value)
                if loggers[name].read_trigged():
                    log.debug('Saved codename %s value %s', name, value)
                    db_logger.save_point_now(name, value)
                    loggers[name].clear_trigged()
    except KeyboardInterrupt:
        log.info('Stopping everything and waiting 5 s')
        socket.stop()
        live_socket.stop()
        db_logger.stop()
        time.sleep(5)
        log.info('Everything stopped, bye!')
    except Exception:
        # Unexpected exception, log it
        log.exception('Unexpected exception during main loop')
        raise
Example #20
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()
Example #21
0
def main():
    """ Main function """
    log = get_logger('pressure readout', level='debug')
    #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()
    log.info('DateDataPullSocket started')
    live_socket = LiveSocket('XRD pressure', codenames)
    live_socket.start()
    log.info('LiveSocket started')

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_xrd',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()
    log.info('ContinuousDataSaver started')

    time.sleep(5)

    try:
        while True:
            time.sleep(0.25)
            for name in codenames:
                value = loggers[name].read_value()
                log.debug('Read codename %s value %s', name, value)
                socket.set_point_now(name, value)
                live_socket.set_point_now(name, value)
                if loggers[name].read_trigged():
                    log.debug('Saved codename %s value %s', name, value)
                    db_logger.save_point_now(name, value)
                    loggers[name].clear_trigged()
    except KeyboardInterrupt:
        log.info('Stopping everything and waiting 5 s')
        socket.stop()
        live_socket.stop()
        db_logger.stop()
        time.sleep(5)
        log.info('Everything stopped, bye!')
    except Exception:
        # Unexpected exception, log it
        log.exception('Unexpected exception during main loop')
        raise
Example #22
0
class MainDatalogger(threading.Thread):
    """ Temperature reader """

    def __init__(self,):
        logging.info("MainDatalogger class started")
        threading.Thread.__init__(self)
        # from datalogger import TemperatureReader
        self.quit = False
        self.codenames = [
            "tabs_guard_temperature_inlet",
            "tabs_floor_temperature_inlet",
            "tabs_ceiling_temperature_inlet",
            "tabs_cooling_temperature_inlet",
        ]
        self.MC302 = WaterTemperatureReader()
        self.MC302.start()
        self.codenames = ["tabs_cooling_temperature_inlet"]
        self.omega_temperature = TemperatureReader(["tabs_cooling_temperature_inlet"])
        self.omega_temperature.daemon = True
        self.omega_temperature.start()
        # omega_temperature.update_values()

        time.sleep(1.5)

        chlist = {
            "tabs_guard_temperature_control": 0,
            "tabs_room_temperature_control": 1,
            #'tabs_ceiling_temperature_inlet': 2,
            "tabs_cooling_temperature_inlet": 3,
        }
        self.loggers = {}
        for key in chlist.keys():
            self.loggers[key] = ValueLogger(
                self.omega_temperature, comp_val=0.2, maximumtime=300, comp_type="lin", channel=chlist[key]
            )
            self.loggers[key].start()
        chlist = {
            "tabs_guard_temperature_inlet": 0,
            "tabs_guard_temperature_outlet": 1,
            "tabs_guard_temperature_delta": 2,
            "tabs_floor_temperature_inlet": 3,
            "tabs_floor_temperature_outlet": 4,
            "tabs_floor_temperature_delta": 5,
            "tabs_ceiling_temperature_inlet": 6,
            "tabs_ceiling_temperature_outlet": 7,
            "tabs_ceiling_temperature_delta": 8,
            "tabs_guard_water_flow": 9,
            "tabs_floor_water_flow": 10,
            "tabs_ceiling_water_flow": 11,
        }
        for key in chlist.keys():
            self.loggers[key] = ValueLogger(
                self.MC302, comp_val=0.2, maximumtime=300, comp_type="lin", channel=chlist[key]
            )
            self.loggers[key].start()
        self.codenames = self.loggers.keys()
        # livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        # livesocket.start()
        sockname = "tabs_temperatures"
        self.PullSocket = DateDataPullSocket(
            sockname, self.codenames, timeouts=[60.0] * len(self.codenames), port=socketinfo.INFO[sockname]["port"]
        )
        self.PullSocket.start()

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

    def run(self,):
        i = 0
        while not self.quit and self.omega_temperature.isAlive():
            try:
                # print(i)
                time.sleep(1)
                for name in self.loggers.keys():
                    v = self.loggers[name].read_value()
                    # livesocket.set_point_now(name, v)
                    if v != None and v != 0:
                        self.PullSocket.set_point_now(name, v)
                        if self.loggers[name].read_trigged():
                            if __name__ == "__main__":
                                print("Log: ", i, name, v)
                            self.db_logger.enqueue_point_now(name, v)
                            self.loggers[name].clear_trigged()
                        else:
                            if __name__ == "__main__":
                                print("STA: ", i, name, v)
            except (KeyboardInterrupt, SystemExit):
                pass
                # self.omega_temperature.close()
                # report error and proceed
            i += 1
        self.stop()

    def stop(self):
        self.quit = True
        self.omega_temperature.stop()
        self.MC302.stop()
        self.db_logger.stop()
        self.PullSocket.stop()
        for key in self.codenames:
            self.loggers[key].status["quit"] = True
Example #23
0
class MainPID(threading.Thread):
    """ pid controller """
    def __init__(self,):
        logging.info('MainPID class started')
        threading.Thread.__init__(self)
        #from datalogger import TemperatureReader
        self.quit = False
        self.codenames = ['tabs_guard_pid_value',
                 'tabs_floor_pid_value',
                 'tabs_ceiling_pid_value',
                 'tabs_cooling_pid_value',
                 
                 'tabs_guard_valve_heating',
                 'tabs_floor_valve_heating',
                 'tabs_ceiling_valve_heating',
                 
                 'tabs_guard_valve_cooling',
                 'tabs_floor_valve_cooling',
                 'tabs_ceiling_valve_cooling',
                 'tabs_cooling_valve_cooling',
                 ]
        sockname = 'tabs_pids'
        self.PullSocket = DateDataPullSocket(sockname, self.codenames, timeouts=[60.0]*len(self.codenames), port = socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()
    
        self.PTC = PidTemperatureControl(self.codenames)
        self.PTC.daemon = True
        self.PTC.start()
        #time.sleep(5)
    
        chlist = {'tabs_guard_pid_value': 0,
                  'tabs_floor_pid_value': 1,
                  'tabs_ceiling_pid_value': 2,
                  'tabs_cooling_pid_value': 3,
                  
                  'tabs_guard_valve_heating': 4,
                  'tabs_floor_valve_heating': 5,
                  'tabs_ceiling_valve_heating': 6,
                  
                  'tabs_guard_valve_cooling': 7,
                  'tabs_floor_valve_cooling': 8,
                  'tabs_ceiling_valve_cooling': 9,
                  'tabs_cooling_valve_cooling': 10}
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.PTC, comp_val = 0.10, maximumtime=60,
                                        comp_type = 'lin', channel = chlist[key])
            self.loggers[key].start()
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()

    
        self.db_logger = ContinuousLogger(table='dateplots_tabs', username=credentials.user, password=credentials.passwd, measurement_codenames=self.codenames)
        self.db_logger.start()

    def run(self,):
        i = 0
        while not self.quit and self.PTC.isAlive():
            try:
                #print(i)
                time.sleep(1)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #print('Status: ', name , v)
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    if self.loggers[name].read_trigged():
                        if __name__ == '__main__':
                            print('Log: ', i, name, v)
                        #print(i, name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except (KeyboardInterrupt, SystemExit):
                self.quit = True
                pass
                #self.PTC.stop()
                #report error and proceed
            i += 1
        self.stop()

    def stop(self):
        self.quit = True
        self.PTC.stop()
        self.PullSocket.stop()
        self.db_logger.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #24
0
class MainDatalogger(threading.Thread):
    """ Temperature reader """
    def __init__(self,):
        logging.info('MainDatalogger class started')
        threading.Thread.__init__(self)
        #from datalogger import TemperatureReader
        self.quit = False
        self.codenames = ['tabs_guard_temperature_inlet',
                     'tabs_floor_temperature_inlet',
                     'tabs_ceiling_temperature_inlet',
                     'tabs_cooling_temperature_inlet',
                     ]
        self.MC302 = WaterTemperatureReader()
        self.MC302.start()
        self.codenames = [
                     'tabs_cooling_temperature_inlet',
                     ]
        self.omega_temperature = TemperatureReader(['tabs_cooling_temperature_inlet',])
        self.omega_temperature.daemon = True
        self.omega_temperature.start()
        #omega_temperature.update_values()
        
        time.sleep(1.5)
        
        chlist = {'tabs_guard_temperature_control': 0,
                  'tabs_room_temperature_control': 1,
                  #'tabs_ceiling_temperature_inlet': 2,
                  'tabs_cooling_temperature_inlet': 3}
        self.loggers = {}
        for key in chlist.keys():
            self.loggers[key] = ValueLogger(self.omega_temperature, comp_val = 0.2, maximumtime=300,
                                            comp_type = 'lin', channel = chlist[key])
            self.loggers[key].start()
        chlist = {'tabs_guard_temperature_inlet': 0,
                   'tabs_guard_temperature_outlet': 1,
                   'tabs_guard_temperature_delta': 2,
                   'tabs_floor_temperature_inlet': 3,
                   'tabs_floor_temperature_outlet': 4,
                   'tabs_floor_temperature_delta': 5,                   
                   'tabs_ceiling_temperature_inlet': 6,
                   'tabs_ceiling_temperature_outlet': 7,
                   'tabs_ceiling_temperature_delta': 8,
                   'tabs_guard_water_flow': 9,
                   'tabs_floor_water_flow': 10,
                   'tabs_ceiling_water_flow': 11,}
        for key in chlist.keys():
            self.loggers[ key] = ValueLogger(self.MC302, comp_val = 0.2, maximumtime=300,
                                            comp_type = 'lin', channel = chlist[key])
            self.loggers[key].start()
        self.codenames = self.loggers.keys()
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()
        sockname = 'tabs_temperatures'
        self.PullSocket = DateDataPullSocket(sockname, self.codenames, timeouts=[60.0]*len(self.codenames), port = socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()
        
        self.db_logger = ContinuousLogger(table='dateplots_tabs', username=credentials.user, password=credentials.passwd, measurement_codenames=self.codenames)
        self.db_logger.start()
    
    def run(self,):
        i = 0
        while not self.quit and self.omega_temperature.isAlive():
            try:
                #print(i)
                time.sleep(1)
                for name in self.loggers.keys():
                    v = self.loggers[name].read_value()
                    #livesocket.set_point_now(name, v)
                    if v != None and v != 0:
                        self.PullSocket.set_point_now(name, v)
                        if self.loggers[name].read_trigged():
                            if __name__ == '__main__':
                                print('Log: ', i, name, v)
                            self.db_logger.enqueue_point_now(name, v)
                            self.loggers[name].clear_trigged()
                        else:
                            if __name__ == '__main__':
                                print('STA: ', i, name, v)
            except (KeyboardInterrupt, SystemExit):
                pass
                #self.omega_temperature.close()
                #report error and proceed
            i += 1
        self.stop()
        
    def stop(self):
        self.quit = True
        self.omega_temperature.stop()
        self.MC302.stop()
        self.db_logger.stop()
        self.PullSocket.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #25
0
class MainTui(threading.Thread):
    """ Temperature reader """
    def __init__(self,):
        threading.Thread.__init__(self)
        #from mytui import CursesTui
        self.quit = False
        self.codenames = ['tabs_guard_temperature_setpoint',
                     'tabs_floor_temperature_setpoint',
                     'tabs_ceiling_temperature_setpoint',
                     'tabs_cooling_temperature_setpoint',
                     ]
        sockname = 'tabs_setpoints'
        self.PullSocket = DateDataPullSocket(sockname, self.codenames, timeouts=[60.0]*len(self.codenames), port = socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()
        
        self.TUI = CursesTui(self.codenames)
        self.TUI.start()
        #time.sleep(5)
        
        chlist = {'tabs_guard_temperature_setpoint': 0,
                  'tabs_floor_temperature_setpoint': 1,
                  'tabs_ceiling_temperature_setpoint': 2,
                  'tabs_cooling_temperature_setpoint': 3}
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.TUI, comp_val = 0.2, maximumtime=60,
                                            comp_type = 'lin', channel = chlist[key])
            self.loggers[key].start()
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()
        
        
        
        self.db_logger = ContinuousLogger(table='dateplots_tabs', username=credentials.user, password=credentials.passwd, measurement_codenames=self.codenames)
        #print('Hostname of db logger: ' + db_logger.host)
        self.db_logger.start()
    
    def run(self):
        i = 0
        while not self.quit:
            #print(i)
            if self.TUI.isAlive():
                pass
            else:
                print('TUI has shutdown')
                self.quit = True
            try:
                #print(i)
                time.sleep(2)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #print('Status: ', name , v)
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    if self.loggers[name].read_trigged():
                        #if __name__ == '__main__':
                        #    print('Log: ', i, name, v)
                        #print('Log: ', name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except:
                print('run error')
                pass
                #self.TUI.stop()
                #report error and proceed
            i += 1
        self.stop()
        
    def stop(self):
        self.quit = True
        self.TUI.stop()
        self.PullSocket.stop()
        self.db_logger.stop()
        for key in self.codenames:
            self.loggers[key].status['quit'] = True
Example #26
0
class MainMultilogger(threading.Thread):
    """ Temperature reader """
    def __init__(self,):
        logging.info('MainMultilogger class started')
        threading.Thread.__init__(self)
        #from datalogger import TemperatureReader
        self.quit = False
        self.codenames = Setting_channel_list.keys()
        """['tabs_ceiling_temperature_delta',
                          'tabs_ceiling_temperature_deltaref',
                          'tabs_floor_temperature_delta',
                          'tabs_floor_temperature_deltaref',
                          'tabs_room_temperature_aircenter010',
                          'tabs_room_temperature_aircenter060',
                          'tabs_room_temperature_aircenter110',
                          'tabs_room_temperature_aircenter170',
                          'tabs_room_temperature_aircenter355',
                          'tabs_guard_temperature_airfloor',
                          'tabs_guard_temperature_airceiling',
                          'tabs_guard_temperature_airwallsouth',
                          'tabs_guard_temperature_airwallnorth',
                          'tabs_guard_temperature_airwalleast',
                          'tabs_guard_temperature_airwallwest',
                          
                          ]"""
        self.multiplex_reader = MultiplexReader(self.codenames)
        self.multiplex_reader.daemon = True
        self.multiplex_reader.start()
        #omega_temperature.update_values()
        
        time.sleep(3.5)
        
        chlist = Setting_channel_list
        self.loggers = {}
        for key in self.codenames:
            self.loggers[key] = ValueLogger(self.multiplex_reader, comp_val = 0.5, maximumtime=300,
                                            comp_type = 'lin', channel = chlist[key])
            self.loggers[key].start()
        
        #livesocket = LiveSocket('tabs_temperature_logger', codenames, 2)
        #livesocket.start()
        sockname = 'tabs_multiplexer'
        self.PullSocket = DateDataPullSocket(sockname, self.codenames, timeouts=[60.0]*len(self.codenames), port = socketinfo.INFO[sockname]['port'])
        self.PullSocket.start()
        
        self.db_logger = ContinuousLogger(table='dateplots_tabs', username=credentials.user, password=credentials.passwd, measurement_codenames=self.codenames)
        self.db_logger.start()
    
    def run(self,):
        i = 0
        while not self.quit and self.multiplex_reader.isAlive():
            try:
                #print(i)
                time.sleep(1)
                for name in self.codenames:
                    v = self.loggers[name].read_value()
                    #livesocket.set_point_now(name, v)
                    self.PullSocket.set_point_now(name, v)
                    #print(i, name, v)
                    if self.loggers[name].read_trigged() and abs(v) < 9.9E+5 and v != None:
                        if __name__ == '__main__':
                            print('Log: ', i, name, v)
                        #print(name, v)
                        self.db_logger.enqueue_point_now(name, v)
                        self.loggers[name].clear_trigged()
            except (KeyboardInterrupt, SystemExit):
                self.quit = True
                pass
                #self.omega_temperature.close()
                #report error and proceed
            i += 1
        self.stop()
        
    def stop(self):
        self.quit = True
        self.multiplex_reader.stop()
        self.PullSocket.stop()
        self.db_logger.stop()        
        for key in self.codenames:
            self.loggers[key].status['quit'] = True