当前位置: 首页>>代码示例>>Python>>正文


Python DateDataPullSocket.stop方法代码示例

本文整理汇总了Python中PyExpLabSys.common.sockets.DateDataPullSocket.stop方法的典型用法代码示例。如果您正苦于以下问题:Python DateDataPullSocket.stop方法的具体用法?Python DateDataPullSocket.stop怎么用?Python DateDataPullSocket.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyExpLabSys.common.sockets.DateDataPullSocket的用法示例。


在下文中一共展示了DateDataPullSocket.stop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MySocket

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:57,代码来源:mysocket.py

示例2: TemperatureLogger

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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)
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:54,代码来源:temperature_logger.py

示例3: main

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:50,代码来源:data_logger.py

示例4: main

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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='N/A', password='N/A',
        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()
开发者ID:jlopezBolt,项目名称:PyExpLabSys,代码行数:23,代码来源:temperature.py

示例5: MainTui

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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
开发者ID:neilanderson,项目名称:PyExpLabSys,代码行数:77,代码来源:mytui.py

示例6: MainPID

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:89,代码来源:mypid.py

示例7: print

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
#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')


开发者ID:CINF,项目名称:PyExpLabSys,代码行数:30,代码来源:data_logger.py

示例8: MainDatalogger

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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
#.........这里部分代码省略.........
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:103,代码来源:mydatalogger.py

示例9: DI1110

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:32,代码来源:dataq_reader.py

示例10: MainMultilogger

# 需要导入模块: from PyExpLabSys.common.sockets import DateDataPullSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DateDataPullSocket import stop [as 别名]
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
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:82,代码来源:mymultiplexer.py


注:本文中的PyExpLabSys.common.sockets.DateDataPullSocket.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。