本文整理汇总了Python中PyExpLabSys.common.sockets.DataPushSocket.start方法的典型用法代码示例。如果您正苦于以下问题:Python DataPushSocket.start方法的具体用法?Python DataPushSocket.start怎么用?Python DataPushSocket.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyExpLabSys.common.sockets.DataPushSocket
的用法示例。
在下文中一共展示了DataPushSocket.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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
示例2: main
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
def main():
""" Main function """
power_supplies = {}
for i in range(1, 3):
power_supplies[i] = cpx.CPX400DPDriver(i, interface='lan',
hostname='cinf-palle-heating-ps',
tcp_port=9221)
power_supplies[i].set_voltage(0)
power_supplies[i].output_status(True)
codenames = ['setpoint', 'wanted_voltage', 'actual_voltage_1', 'actual_voltage_2',
'actual_current_1', 'actual_current_2', 'power', 'temperature']
pullsocket = DateDataPullSocket('palle_temp_control', codenames,
timeouts=[999999, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0])
pullsocket.start()
pushsocket = DataPushSocket('mgw_push_control', action='store_last')
pushsocket.start()
power_calculator = PowerCalculatorClass(pullsocket, pushsocket)
power_calculator.daemon = True
power_calculator.start()
heater = HeaterClass(power_calculator, pullsocket, power_supplies)
heater.start()
tui = CursesTui(heater)
tui.daemon = True
tui.start()
示例3: main
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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)
示例4: FlowControl
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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)
示例5: test_init_enqueue
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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()
示例6: test_init_custom_queue
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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()
示例7: test_init_callback_direct_default
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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()
示例8: test_init_callback_direct_raw
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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()
示例9: dps
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
def dps(request):
"""DataPushSocket fixture, if requested in a class that has dps_kwargs
class variable, use those in init
"""
if hasattr(request, 'cls') and hasattr(request.cls, 'dps_kwargs'):
dps = DataPushSocket(NAME, **request.cls.dps_kwargs)
else:
dps = DataPushSocket(NAME)
dps.start()
yield dps
dps.stop()
示例10: test_init_callback_async
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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()
示例11: IonOpticsControl
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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)
示例12: class_dps
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
def class_dps(request):
"""DataPushSocket fixture
If requested in a class that has dps_kwargs class variable, use those in init
.. note:: This fixture lasts for the duration of a test class. It has been setup like this
because the sockets take a long time to shut down. So in order to save time on the test
run, we only initiate the socket once per class, but reset it in the dps fixture. It is
the dps fixture that should be used.
"""
if hasattr(request, 'cls') and hasattr(request.cls, 'dps_kwargs'):
dps_ = DataPushSocket(NAME, **request.cls.dps_kwargs)
else:
dps_ = DataPushSocket(NAME)
dps_.start()
yield dps_
dps_.stop()
示例13: FlowControl
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
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)
示例14: FlowControl
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
class FlowControl(threading.Thread):
""" Keep updated values of the current flow """
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')
def value(self):
""" Helper function for the reactor logger functionality """
return self.reactor_pressure
def run(self):
while self.running:
time.sleep(0.1)
qsize = self.pushsocket.queue.qsize()
print("Qsize: " + str(qsize))
while qsize > 0:
element = self.pushsocket.queue.get()
mfc = list(element.keys())[0]
self.mfcs[mfc].set_flow(str(element[mfc]))
qsize = self.pushsocket.queue.qsize()
for mfc in self.mfcs:
flow = self.mfcs[mfc].read_flow()
self.pullsocket.set_point_now(mfc, flow)
self.livesocket.set_point_now(mfc, flow)
if mfc == self.devices[0]: # First device is considered pressure controller
print("Pressure: " + str(flow))
self.reactor_pressure = flow
示例15: I2CComm
# 需要导入模块: from PyExpLabSys.common.sockets import DataPushSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.DataPushSocket import start [as 别名]
class I2CComm(object):
"""Handle I2C communication with DAC and ADC"""
def __init__(self):
self.measurements = {}
self.mcp3428 = MCP3428()
#self.ad5667 = AD5667()
self.dps = DataPushSocket(
'large_CO2_mea_push_socket',
action='callback_direct',
callback=self.communicate,
return_format='json',
)
# These two queues form a pair, that is used to interrupt the
# continuous measurement of the values from the ADC to allow
# setting the DAC and return copy the values from the ADC
self.comm_flag = Queue()
self.comm_return = Queue()
self.dps.start()
def measure(self):
"""Main measure loop (busy)"""
last_print = 0
while True:
for channel in range(1, 5):
self.measurements[channel] = self.mcp3428.read_sample(channel)
now = time()
if (now - last_print) > 10:
print(now, "Measured:", self.measurements)
last_print = now
try:
values_to_set = self.comm_flag.get(block=False)
except Empty:
continue
# If we escaped the comm_flag test, we should set and enqueue current values
if "no_voltages_to_set" not in values_to_set:
print("Asked to set DAC values", values_to_set)
sleep(0.01)
#self.ad5667.set_channel_A(values_to_set['A'])
#self.ad5667.set_channel_B(values_to_set['B'])
sleep(0.01)
self.comm_return.put(dict(self.measurements))
def run(self):
"""Run method used to allow keyboard interrupts"""
try:
self.measure()
except KeyboardInterrupt:
self.dps.stop()
def communicate(self, data):
"""Send the received values to be written on the DAC and return values
from the ADC
"""
print("Received comm request")
# Make sure there are no results hanging in the result queue
while True:
try:
self.comm_return.get(block=False)
except Empty:
break
print("Set comm flag")
self.comm_flag.put(data)
# Wait until we get values back
result = self.comm_return.get()
print("Got result, return")
return result