本文整理汇总了Python中PyExpLabSys.common.sockets.DateDataPullSocket类的典型用法代码示例。如果您正苦于以下问题:Python DateDataPullSocket类的具体用法?Python DateDataPullSocket怎么用?Python DateDataPullSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateDataPullSocket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: main
def main():
""" Main function """
code_names = ['pvd309_temp_dca_cell', 'pvd309_temp_mai_cell']
reader = TemperatureReader()
reader.start()
loggers = {}
loggers[code_names[0]] = ValueLogger(reader, channel=1, comp_val = 0.5, comp_type = 'lin')
loggers[code_names[0]].start()
loggers[code_names[1]] = ValueLogger(reader, channel=2, comp_val = 0.5, comp_type = 'lin')
loggers[code_names[1]].start()
datasocket = DateDataPullSocket('pvd_309_temp', code_names, timeouts=[2.0] * 2, port=9001)
datasocket.start()
livesocket = LiveSocket('pvd_309_temperatures', code_names)
livesocket.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_pvd309',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=code_names)
db_logger.start()
time.sleep(5)
while not reader.quit:
time.sleep(0.25)
for name in code_names:
print(reader.ttl)
value = loggers[name].read_value()
datasocket.set_point_now(name, value)
livesocket.set_point_now(name, value)
if loggers[name].read_trigged():
print(name + ': ' + str(value))
db_logger.save_point_now(name, value)
loggers[name].clear_trigged()
示例3: main
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()
示例4: __init__
def __init__(self):
sql_queue = queue.Queue()
self.data_saver = database_saver.SqlSaver(settings.username,
settings.username, sql_queue)
self.data_saver.start()
if settings.qmg == '420':
self.qmg = qmg420.qmg_420(settings.port)
if settings.qmg == '422':
print(settings.port)
self.qmg = qmg422.qmg_422(port=settings.port, speed=settings.speed)
try:
livesocket = LiveSocket(settings.name + '-mass-spec', ['qms-value'])
livesocket.start()
except:
livesocket = None
pullsocket = DateDataPullSocket(settings.name + '-mass-spec', ['qms-value'])
pullsocket.start()
self.qms = ms.QMS(self.qmg, sql_queue, chamber=settings.chamber,
credentials=settings.username, livesocket=livesocket,
pullsocket=pullsocket)
self.qmg.reverse_range = settings.reverse_range
self.printer = qmg_status_output.QmsStatusOutput(self.qms,
sql_saver_instance=self.data_saver)
self.printer.start()
示例5: 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
示例6: 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)
示例7: main
def main():
""" Main function """
tempreader = TemperatureReader()
tempreader.daemon = True
tempreader.start()
temp_logger = ValueLogger(tempreader, comp_val=1)
temp_logger.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_chemlab307',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=['chemlab307_muffle_furnace'])
socket = DateDataPullSocket('muffle_furnace',
['chemlab307_muffle_furnace'],
timeouts=[1.0])
socket.start()
livesocket = LiveSocket('muffle_furnace', ['chemlab307_muffle_furnace'])
livesocket.start()
db_logger.start()
time.sleep(5)
while True:
time.sleep(0.25)
value = temp_logger.read_value()
socket.set_point_now('chemlab307_muffle_furnace', value)
livesocket.set_point_now('chemlab307_muffle_furnace', value)
if temp_logger.read_trigged():
print(value)
db_logger.save_point_now('chemlab307_muffle_furnace', value)
temp_logger.clear_trigged()
示例8: main
def main():
""" Main loop """
mainpump = tp.TurboDriver(adress=1, port=settings.port)
mainpump.start()
tui = tp.CursesTui(mainpump)
tui.daemon = True
tui.start()
reader = tp.TurboReader(mainpump)
reader.daemon = True
reader.start()
time.sleep(10) # Allow reader to make meaningfull moving avarage
codenames = [settings.table_prefix + '_turbo_speed',
settings.table_prefix + '_turbo_power',
settings.table_prefix + '_turbo_current',
settings.table_prefix + '_turbo_temp_motor',
settings.table_prefix + '_turbo_temp_bottom',
settings.table_prefix + '_turbo_temp_bearings',
settings.table_prefix + '_turbo_temp_electronics']
loggers = {}
loggers[codenames[0]] = tp.TurboLogger(reader, 'rotation_speed', maximumtime=600)
loggers[codenames[1]] = tp.TurboLogger(reader, 'drive_power', maximumtime=600)
loggers[codenames[2]] = tp.TurboLogger(reader, 'drive_current', maximumtime=600)
loggers[codenames[3]] = tp.TurboLogger(reader, 'temp_motor', maximumtime=600)
loggers[codenames[4]] = tp.TurboLogger(reader, 'temp_bottom', maximumtime=600)
loggers[codenames[5]] = tp.TurboLogger(reader, 'temp_bearings', maximumtime=600)
loggers[codenames[6]] = tp.TurboLogger(reader, 'temp_electronics', maximumtime=600)
for name in codenames:
loggers[name].daemon = True
loggers[name].start()
livesocket = LiveSocket(settings.name + '-turboreader', codenames)
livesocket.start()
socket = DateDataPullSocket(settings.name + '-turboreader', codenames,
timeouts=[1.0] * len(codenames), port=9000)
socket.start()
db_logger = ContinuousDataSaver(continuous_data_table=settings.table,
username=settings.user,
password=settings.passwd,
measurement_codenames=codenames)
db_logger.start()
time.sleep(5)
while mainpump.running:
time.sleep(0.1)
for name in codenames:
value = loggers[name].read_value()
socket.set_point_now(name, value) # Notice, this is the averaged value
livesocket.set_point_now(name, value) # Notice, this is the averaged value
if loggers[name].trigged:
db_logger.save_point_now(name, value)
loggers[name].trigged = False
示例9: 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)
示例10: __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
示例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()
示例12: __init__
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])
示例13: __init__
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()
示例14: main
def main():
""" Main function """
logging.basicConfig(filename="logger.txt", level=logging.ERROR)
logging.basicConfig(level=logging.ERROR)
qcm_port = ('/dev/serial/by-id/' +
'usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0')
qcm = inficon.InficonSQM160(qcm_port)
reader = QcmReader(qcm)
reader.daemon = True
reader.start()
codenames = ['volvo_qcm_frequency',
'volvo_qcm_crystal_life',
'volvo_qcm_thickness']
loggers = {}
loggers[codenames[0]] = ValueLogger(reader, comp_val=0.1, channel=0)
loggers[codenames[0]].start()
loggers[codenames[1]] = ValueLogger(reader, comp_val=0.01, channel=1)
loggers[codenames[1]].start()
loggers[codenames[2]] = ValueLogger(reader, comp_val=0.001, channel=2)
loggers[codenames[2]].start()
socket = DateDataPullSocket('Volvo QCM', codenames, port=9000,
timeouts=[5.0] * len(codenames))
socket.start()
livesocket = LiveSocket('Volvo data logger', codenames)
livesocket.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_volvo',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames)
db_logger.start()
time.sleep(5)
while reader.isAlive():
time.sleep(0.25)
for name in codenames:
value = loggers[name].read_value()
socket.set_point_now(name, value)
livesocket.set_point_now(name, value)
if loggers[name].read_trigged():
print(value)
db_logger.save_point_now(name, value)
loggers[name].clear_trigged()
示例15: main
def main():
""" Main function """
codenames = []
for channel in settings.channels.values():
channel['reader'] = SocketReaderClass(channel['host'], channel['port'],
channel['command'])
channel['reader'].start()
channel['logger'] = ValueLogger(channel['reader'], comp_val=channel['comp_value'])
channel['logger'].daemon = True
channel['logger'].start()
codenames.append(channel['codename'])
try:
port = settings.port_number
except AttributeError:
port = 9000
pullsocket = DateDataPullSocket(settings.user + '-socket_logger',
codenames, timeouts=5, port=port)
pullsocket.start()
db_logger = ContinuousDataSaver(continuous_data_table=settings.dateplot_table,
username=settings.user,
password=settings.passwd,
measurement_codenames=codenames)
db_logger.start()
time.sleep(2)
everything_ok = True
while everything_ok:
time.sleep(0.25)
for channel in settings.channels.values():
if not channel['reader'].isAlive():
everything_ok = False
# Report error here!!!
# Consider to keep program running even in case of
# socket failures
value = channel['logger'].read_value()
pullsocket.set_point_now(channel['codename'], value)
if channel['logger'].read_trigged():
print(value)
db_logger.save_point_now(channel['codename'], value)
channel['logger'].clear_trigged()