本文整理汇总了Python中PyExpLabSys.common.sockets.LiveSocket.set_point_now方法的典型用法代码示例。如果您正苦于以下问题:Python LiveSocket.set_point_now方法的具体用法?Python LiveSocket.set_point_now怎么用?Python LiveSocket.set_point_now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyExpLabSys.common.sockets.LiveSocket
的用法示例。
在下文中一共展示了LiveSocket.set_point_now方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
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()
示例2: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
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()
示例3: FlowControl
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [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)
示例4: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
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
示例5: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
"""The main method for the pressure logger"""
# Open communication to the pressure measurement unit
tpg = TPG262(port='/dev/ttyUSB0', baudrate=9600)
LOGGER.info('Initiated driver to TPG 262')
# Get a continuous logger
codenames = ['thetaprobe_pressure_loadlock', 'thetaprobe_pressure_uvgun']
db_logger = ContinuousLogger(table='dateplots_thetaprobe',
username=credentials.USERNAME,
password=credentials.PASSWORD,
measurement_codenames=codenames)
db_logger.start()
LOGGER.info('Initiated and started database logger')
livesocket = LiveSocket(codenames, 0.2)
livesocket.start()
loadlock_last = {'value': 1E20, 'time': 0}
uvgun_last = {'value': 1E20, 'time': 0}
try:
while True:
# get the values: returns:
# (value1, (status_code1, status_message1),
# value2, (status_code2, status_message2))
value_ll, code_ll, value_uv, code_uv = tpg.pressure_gauges()
livesocket.set_point_now('thetaprobe_pressure_loadlock', value_ll)
livesocket.set_point_now('thetaprobe_pressure_uvgun', value_uv)
### Load lock
if code_ll[0] in [0, 1]: # If measurement is OK or underranged
if logging_criteria(value_ll, loadlock_last):
LOGGER.info('Add value {} for load lock'.format(value_ll))
now_ll = db_logger.enqueue_point_now(
'thetaprobe_pressure_loadlock',
value_ll)
loadlock_last['value'] = value_ll
loadlock_last['time'] = now_ll
### UV gun
if code_uv[0] in [0, 1]: # If measurement is OK or underranged
if logging_criteria(value_uv, uvgun_last):
LOGGER.info('Add value {} for UV gun'.format(value_uv))
now_uv = db_logger.enqueue_point_now(
'thetaprobe_pressure_uvgun',
value_uv)
uvgun_last['value'] = value_uv
uvgun_last['time'] = now_uv
except KeyboardInterrupt:
LOGGER.info('Keyboard interrupt. Shutting down')
db_logger.stop()
livesocket.stop()
LOGGER.info('Database logger stoppped. Exiting!')
示例6: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
""" Main function """
ups = galaxy_3500.Galaxy3500('b312-ups')
reader = UpsReader(ups)
reader.daemon = True
reader.start()
time.sleep(5)
codenames = ['b312_ups_temperature', 'b312_ups_kVAPh1', 'b312_ups_kVAPh2',
'b312_ups_kVAPh3', 'b312_ups_output_current_Ph1',
'b312_ups_output_current_Ph2', 'b312_ups_output_current_Ph3',
'b312_ups_input_frequency', 'b312_ups_input_voltage_Ph1',
'b312_ups_input_voltage_Ph2', 'b312_ups_input_voltage_Ph3',
'b312_ups_output_voltage_Ph1', 'b312_ups_output_voltage_Ph2',
'b312_ups_output_voltage_Ph3', 'b312_ups_battery_voltage',
'b312_ups_battery_current', 'b312_ups_battery_state_of_charge',
'b312_ups_output_frequency']
loggers = {}
for i in range(0, len(codenames)):
loggers[codenames[i]] = ValueLogger(reader, comp_val=0.1, channel=i)
loggers[codenames[i]].start()
socket = DateDataPullSocket('UPS status', codenames,
timeouts=[5.0] * len(codenames))
socket.start()
live_socket = LiveSocket('UPS Status', codenames)
live_socket.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_ups_b312',
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)
live_socket.set_point_now(name, value)
if loggers[name].read_trigged():
print(value)
db_logger.save_point_now(name, value)
loggers[name].clear_trigged()
示例7: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
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()
示例8: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
"""Main function"""
chiller_port = '/dev/serial/by-id/'
chiller_port += 'usb-1a86_USB2.0-Ser_-if00-port0'
LOG.info('Using chiller port %s', chiller_port)
reader = ChillerReader(chiller_port)
reader.start()
LOG.info('ChillerReader started')
codenames = ['uhv_sputterchamber_chiller_temperature',
'uhv_sputterchamber_chiller_flow',
'uhv_sputterchamber_chiller_temperature_ambient',
'uhv_sputterchamber_chiller_pressure',
'uhv_sputterchamber_chiller_temperature_setpoint']
LOG.debug('Using codenames %s', codenames)
loggers = {}
for i in range(0, len(codenames)):
loggers[codenames[i]] = ValueLogger(reader, comp_val=0.11, channel=i)
loggers[codenames[i]].start()
live_socket_name = 'uhv_sputterchamber'
live_socket = LiveSocket(live_socket_name, codenames)
live_socket.start()
LOG.info('Live socket init and started with name "%s"', live_socket_name)
db_table = 'dateplots_uhv_sputterchamber'
db_logger = ContinuousDataSaver(continuous_data_table=db_table,
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames)
db_logger.start()
LOG.info('ContinuousLogger init and started on table "%s"', db_table)
time.sleep(5)
while reader.isAlive():
time.sleep(0.25)
for name in codenames:
value = loggers[name].read_value()
if not math.isnan(value):
live_socket.set_point_now(name, value)
if loggers[name].read_trigged():
LOG.debug('Log value %s for codename "%s"', value, name)
db_logger.save_point_now(name, value)
loggers[name].clear_trigged()
示例9: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
""" Main function """
logging.basicConfig(filename="logger.txt", level=logging.ERROR)
logging.basicConfig(level=logging.ERROR)
i2c_helper = ABEHelpers()
bus = i2c_helper.get_smbus()
adc_instance = DeltaSigma(bus, 0x68, 0x69, 18)
tempreader = TemperatureReader(adc_instance)
tempreader.daemon = True
tempreader.start()
codenames = ["cooling_water_hot", "cooling_water_cold"]
loggers = {}
for i in range(0, 2):
loggers[codenames[i]] = ValueLogger(tempreader, comp_val=0.5, channel=i)
loggers[codenames[i]].start()
socket = DateDataPullSocket("hall_cooling_water_temp", codenames, timeouts=2.0)
socket.start()
live_socket = LiveSocket("hall_waterpressure", codenames)
live_socket.start()
db_logger = ContinuousDataSaver(
continuous_data_table="dateplots_hall",
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames,
)
db_logger.start()
time.sleep(5)
while tempreader.is_alive():
time.sleep(0.25)
for name in codenames:
value = loggers[name].read_value()
socket.set_point_now(name, value)
live_socket.set_point_now(name, value)
if loggers[name].read_trigged():
print(value)
db_logger.save_point_now(name, value)
loggers[name].clear_trigged()
示例10: FlowControl
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [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)
示例11: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
""" Main function """
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()
live_socket = LiveSocket('XRD pressure', codenames, 2)
live_socket.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_xrd',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames)
db_logger.start()
time.sleep(5)
while True:
time.sleep(0.25)
for name in codenames:
value = loggers[name].read_value()
socket.set_point_now(name, value)
live_socket.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()
示例12: main
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
def main():
""" Main function """
logging.basicConfig(filename="logger.txt", level=logging.ERROR)
logging.basicConfig(level=logging.ERROR)
ports = '/dev/ttyUSB0'
xgs_instance = xgs600.XGS600Driver(ports)
print(xgs_instance.read_all_pressures())
pressure = PressureReader(xgs_instance)
pressure.start()
time.sleep(2.5)
codenames = ['tof_iongauge_ft', 'tof_iongauge_main', 'tof_pirani_roughing']
loggers = {}
loggers[codenames[0]] = ValueLogger(pressure, comp_val=0.1,
low_comp=1e-11, comp_type='log', channel=0)
loggers[codenames[0]].start()
loggers[codenames[1]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', channel=1)
loggers[codenames[1]].start()
loggers[codenames[2]] = ValueLogger(pressure, comp_val=0.1, comp_type='log', channel=2)
loggers[codenames[2]].start()
livesocket = LiveSocket('TOF data logger', codenames, 2)
livesocket.start()
db_logger = ContinuousDataSaver(continuous_data_table='dateplots_tof',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames)
db_logger.start()
while pressure.isAlive():
time.sleep(0.5)
for name in codenames:
value = loggers[name].read_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()
示例13: ValueLogger
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
tempreader.start()
temp_logger = ValueLogger(tempreader, comp_val=1)
#temp_logger = TemperatureLogger(tempreader)
temp_logger.start()
db_logger = ContinuousLogger(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'], 2)
livesocket.start()
db_logger.start()
time.sleep(5)
while True:
time.sleep(0.25)
t = temp_logger.read_value()
socket.set_point_now('chemlab307_muffle_furnace', t)
livesocket.set_point_now('chemlab307_muffle_furnace', t)
if temp_logger.read_trigged():
print t
db_logger.enqueue_point_now('chemlab307_muffle_furnace', t)
temp_logger.clear_trigged()
示例14: Bakeout
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
class Bakeout(threading.Thread):
""" The actual heater """
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']
self.livesocket = LiveSocket(self.setup + '-bakeout', channels, 1)
self.livesocket.start()
self.pullsocket = DateDataPullSocket(self.setup + '-bakeout', channels, timeouts=[2]*6)
self.pullsocket.start()
self.pushsocket = DataPushSocket(self.setup + '-push_control', action='enqueue')
self.pushsocket.start()
def activate(self, pin):
""" Activate a pin """
if settings.count_from_right:
pin = pin
else:
pin = 7 - pin
if self.watchdog.watchdog_safe:
wp.digitalWrite(pin, 1)
else:
wp.digitalWrite(pin, 0)
def deactivate(self, pin):
""" De-activate a pin """
if settings.count_from_right:
pin = pin
else:
pin = 7 - pin
wp.digitalWrite(pin, 0)
def modify_dutycycle(self, channel, amount=None, value=None):
""" Change the dutycycle of a channel """
if amount is not None:
self.dutycycles[channel-1] = self.dutycycles[channel-1] + amount
if value is not None:
self.dutycycles[channel-1] = value
if self.dutycycles[channel-1] > 1:
self.dutycycles[channel-1] = 1
if self.dutycycles[channel-1] < 0.0001:
self.dutycycles[channel-1] = 0
self.livesocket.set_point_now(str(channel), self.dutycycles[channel-1])
self.pullsocket.set_point_now(str(channel), self.dutycycles[channel-1])
return self.dutycycles[channel-1]
def run(self):
totalcycles = settings.number_of_cycles
self.quit = False
cycle = 0
while not self.quit:
start_time = time.time()
qsize = self.pushsocket.queue.qsize()
LOGGER.debug('qsize: ' + str(qsize))
while qsize > 0:
element = self.pushsocket.queue.get()
LOGGER.debug('Element: ' + str(element))
channel = element.keys()[0]
value = element[channel]
self.modify_dutycycle(int(channel), value=value)
qsize = self.pushsocket.queue.qsize()
self.watchdog.reset_ttl()
for i in range(1, 7):
if (1.0*cycle/totalcycles) < self.dutycycles[i-1]:
self.activate(i)
else:
self.deactivate(i)
cycle = cycle + 1
cycle = cycle % totalcycles
run_time = time.time() - start_time
sleep_time = 1.0 * settings.cycle_time / settings.number_of_cycles
try:
time.sleep(sleep_time - run_time)
except IOError:
self.quit = True
LOGGER.fatal('Program runs too slow to perform this operation!')
for i in range(0, 7): # Ready to quit
self.deactivate(i)
示例15: ValueLogger
# 需要导入模块: from PyExpLabSys.common.sockets import LiveSocket [as 别名]
# 或者: from PyExpLabSys.common.sockets.LiveSocket import set_point_now [as 别名]
loggers = {}
loggers[codenames[0]] = ValueLogger(omron_reader, comp_val = 1.5,
comp_type = 'lin', channel = 0)
loggers[codenames[0]].start()
loggers[codenames[1]] = ValueLogger(omron_reader, comp_val = 1,
comp_type = 'lin', channel = 1)
loggers[codenames[1]].start()
livesocket = LiveSocket('Hall Ventilation Logger', codenames, 2)
livesocket.start()
socket = DateDataPullSocket('Hall Ventilation logger', codenames, timeouts=[1.0]*2)
socket.start()
db_logger = ContinuousLogger(table='dateplots_hall',
username=credentials.user,
password=credentials.passwd,
measurement_codenames=codenames)
db_logger.start()
while omron_reader.isAlive():
time.sleep(1)
for name in codenames:
v = loggers[name].read_value()
livesocket.set_point_now(name, v)
socket.set_point_now(name, v)
if loggers[name].read_trigged():
print v
db_logger.enqueue_point_now(name, v)
loggers[name].clear_trigged()