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


Python sockets.DataPushSocket类代码示例

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


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

示例1: main

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()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:26,代码来源:temperature_controller.py

示例2: main

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
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:26,代码来源:socket_server.py

示例3: FlowControl

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)
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:34,代码来源:socket_server.py

示例4: main

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)
开发者ID:jlopezBolt,项目名称:PyExpLabSys,代码行数:25,代码来源:socket_server.py

示例5: test_init_enqueue

 def test_init_enqueue(self):
     """Test initialization with when action is enqueue"""
     dps = DataPushSocket(NAME, action='enqueue')
     dps.start()
     self.init_common_tests(dps, 'enqueue')
     assert(isinstance(dps.queue, Queue.Queue))
     assert(DATA[PORT]['queue'] is dps.queue)
     dps.stop()
开发者ID:JNRiedel,项目名称:PyExpLabSys,代码行数:8,代码来源:test_data_push_socket.py

示例6: test_init_custom_queue

 def test_init_custom_queue(self):
     """Test initialization when action is enqueue and use custom queue"""
     queue = Queue.Queue()
     dps = DataPushSocket(NAME, action='enqueue', queue=queue)
     dps.start()
     self.init_common_tests(dps, 'enqueue')
     assert(dps.queue is queue)
     assert(DATA[PORT]['queue'] is queue)
     dps.stop()
开发者ID:JNRiedel,项目名称:PyExpLabSys,代码行数:9,代码来源:test_data_push_socket.py

示例7: test_init_callback_direct_default

 def test_init_callback_direct_default(self):
     """Test initialization when action is callback_direct"""
     # Test init of callback
     dps = DataPushSocket(NAME, action='callback_direct', callback=dir)
     dps.start()
     self.init_common_tests(dps, 'callback_direct')
     assert(DATA[PORT]['callback'] is dir)
     assert(DATA[PORT]['return_format'] == 'json')
     dps.stop()
开发者ID:JNRiedel,项目名称:PyExpLabSys,代码行数:9,代码来源:test_data_push_socket.py

示例8: test_init_callback_direct_raw

 def test_init_callback_direct_raw(self):
     """Test initialization when action is callback_direct"""
     # Test init of callback
     dps_ = DataPushSocket(NAME, action='callback_direct', callback=dir,
                          return_format='raw')
     dps_.start()
     self.init_common_tests(dps_, 'callback_direct')
     assert DATA[PORT]['callback'] is dir
     assert DATA[PORT]['return_format'] == 'raw'
     dps_.stop()
开发者ID:neilanderson,项目名称:PyExpLabSys,代码行数:10,代码来源:test_data_push_socket.py

示例9: test_init_callback_async

 def test_init_callback_async(self):
     """Test initialization when action is callback_async"""
     # Test init of callback
     dps = DataPushSocket(NAME, action='callback_async', callback=dir)
     dps.start()
     self.init_common_tests(dps, 'callback_async')
     assert(isinstance(dps.queue, Queue.Queue))
     assert(DATA[PORT]['queue'] is dps.queue)  
     assert(isinstance(dps._callback_thread, CallBackThread))
     assert(dps._callback_thread.callback is dir)
     dps.stop()
开发者ID:JNRiedel,项目名称:PyExpLabSys,代码行数:11,代码来源:test_data_push_socket.py

示例10: IonOpticsControl

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)
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:54,代码来源:ion_optics_controller.py

示例11: __init__

    def __init__(self):
        threading.Thread.__init__(self)
        self.watchdog = Watchdog()
        self.watchdog.daemon = True
        self.watchdog.start()
        time.sleep(1)

        self.setup = settings.setup
        self.quit = False
        for i in range(0, 7): #Set GPIO pins to output
            wp.pinMode(i, 1)
        self.setup = settings.setup
        self.dutycycles = [0, 0, 0, 0, 0, 0]

        channels = ['1', '2', '3', '4', '5', '6']
        # Setup up extra status for the diode relay status
        diode_channels = ['diode' + number for number in channels]
        self.diode_channel_last = {name: None for name in diode_channels}

        # Setup sockets
        self.livesocket = LiveSocket(self.setup + '-bakeout', channels + diode_channels)
        self.livesocket.start()
        self.pullsocket = DateDataPullSocket(self.setup + '-bakeout', channels, timeouts=None)
        self.pullsocket.start()
        self.pushsocket = DataPushSocket(self.setup + '-push_control', action='enqueue')
        self.pushsocket.start()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:26,代码来源:bakeout.py

示例12: __init__

    def __init__(self):
        threading.Thread.__init__(self)
        channels = ['setpoint', 'emission', 'ionenergy']
        self.datasocket = DateDataPullSocket('emission_tof', channels,
                                             timeouts=[99999999, 1.0, 99999999])
        self.datasocket.start()
        self.pushsocket = DataPushSocket('tof-emission-push_control', action='enqueue')
        self.pushsocket.start()
        self.livesocket = LiveSocket('tof-emission', channels)
        self.livesocket.start()
        self.filament = {}
        port = '/dev/serial/by-id/usb-TTI_CPX400_Series_PSU_C2F952E5-if00'
        self.filament['device'] = CPX.CPX400DPDriver(1, interface='serial', device=port)
        self.filament['voltage'] = 0
        self.filament['current'] = 0
        self.filament['idle_voltage'] = 1.7
        self.filament['device'].set_current_limit(4.0)
        self.filament['device'].output_status(True)
        self.bias = {}
        self.bias['device'] = CPX.CPX400DPDriver(2, interface='serial', device=port)
        self.bias['grid_voltage'] = 0
        self.bias['grid_current'] = 0
        self.bias['device'].output_status(True)
        cns = 'USB0::0x0957::0x0607::MY45000583::INSTR'
        self.bias['current_reader'] = a34410A.Agilent34410ADriver(interface='usbtmc',
                                                                  connection_string=cns)

        self.bias['current_reader'].select_measurement_function('CURRENT')
        self.pid = pid.PID(0.01, 0.1, 0, 4)
        self.looptime = 0
        self.setpoint = 0.05
        self.pid.update_setpoint(self.setpoint)
        self.running = True
        self.wanted_voltage = 0
        self.emission_current = 999
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:35,代码来源:emission_control.py

示例13: FlowControl

class FlowControl(threading.Thread):
    """ Keep updated values of the current flow or pressure """
    def __init__(self, mfcs, name):
        threading.Thread.__init__(self)
        self.daemon = True
        self.mfcs = mfcs
        print(mfcs)
        devices = list(self.mfcs.keys())
        self.values = {}
        for device in devices:
            self.values[device] = None

        self.pullsocket = DateDataPullSocket(name + '_analog_control', devices,
                                             timeouts=[3.0] * len(devices))
        self.pullsocket.start()

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

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

    def value(self, device):
        """ Return the current value of a device """
        return self.values[device]

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

            for mfc in self.mfcs:
                flow = self.mfcs[mfc].read_flow()
                self.values[mfc] = flow
                print(flow)
                self.pullsocket.set_point_now(mfc, flow)
                self.livesocket.set_point_now(mfc, flow)
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:44,代码来源:analog_flow_control.py

示例14: __init__

    def __init__(self, ranges, devices, socket_name):
        threading.Thread.__init__(self)
        self.devices = devices
        name = {}
        mfcs = {}
        print('!')
        for i in range(0, 8):
            print('----------------')
            print('Cheking port number: {}'.format(i))
            error = 0
            name[i] = ''
            while (error < 3) and (name[i] == ''):
                # Pro forma-range will be update in a few lines
                ioerror = 0
                while ioerror < 10:
                    time.sleep(0.5)
                    print(ioerror)
                    try:
                        bronk = bronkhorst.Bronkhorst('/dev/ttyUSB' + str(i), 1)
                        print('MFC Found')
                        break
                    except:  # pylint: disable=bare-except
                        ioerror = ioerror + 1
                if ioerror == 10:
                    print('No MFC found on this port')
                    break
                print('Error count before identification: {}'.format(ioerror))
                name[i] = bronk.read_serial()
                print('MFC Name: {}'.format(name[i]))
                name[i] = name[i].strip()
                error = error + 1
            if name[i] in devices:
                ioerror = 0
                if ioerror < 10:
                    print(ioerror)
                    try:
                        mfcs[name[i]] = bronkhorst.Bronkhorst('/dev/ttyUSB' + str(i),
                                                              ranges[name[i]])
                        mfcs[name[i]].set_control_mode() #Accept setpoint from rs232
                    except IOError:
                        ioerror = ioerror + 1
                if ioerror == 10:
                    print('Found MFC but could not set range')

        self.mfcs = mfcs
        self.pullsocket = DateDataPullSocket(socket_name, devices,
                                             timeouts=3.0, port=9000)
        self.pullsocket.start()

        self.pushsocket = DataPushSocket(socket_name, action='enqueue')
        self.pushsocket.start()
        self.livesocket = LiveSocket(socket_name, devices)
        self.livesocket.start()
        self.running = True
        self.reactor_pressure = float('NaN')
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:55,代码来源:flow_control_bronkhorst.py

示例15: __init__

 def __init__(self):
     self.settings = {'power': 100, 'focus': 100, 'target': None}
     self._state = 'idle'
     self._stop = False
     self._temperature_meas = Queue.Queue()
     
     name = 'Laser control, callback socket, for giant laser on the moon'
     self.dps = DataPushSocket(name, action='callback_direct',
                               callback=self.callback,
                               return_format='json')
     self.dps.start()
开发者ID:CINF,项目名称:PyExpLabSys,代码行数:11,代码来源:laser_control_server.py


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