本文整理汇总了Python中PyExpLabSys.common.loggers.ContinuousLogger.stop方法的典型用法代码示例。如果您正苦于以下问题:Python ContinuousLogger.stop方法的具体用法?Python ContinuousLogger.stop怎么用?Python ContinuousLogger.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyExpLabSys.common.loggers.ContinuousLogger
的用法示例。
在下文中一共展示了ContinuousLogger.stop方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger import stop [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!')
示例2: main
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger import stop [as 别名]
def main():
LOGGER.info('main started')
cni = CNi3244_C24(0)
socket = DateDataSocket([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()
示例3: MainTui
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger 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
示例4: MainPID
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger 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
示例5: GasAlarmMonitor
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger import stop [as 别名]
class GasAlarmMonitor(object):
"""Class that monitors the gas alarm the building 307"""
def __init__(self):
# Start logger
codenames = ['B307_gasalarm_CO_051', 'B307_gasalarm_H2_051',
'B307_gasalarm_CO_055', 'B307_gasalarm_H2_055',
'B307_gasalarm_CO_059', 'B307_gasalarm_H2_059',
'B307_gasalarm_CO_061', 'B307_gasalarm_H2_061',
'B307_gasalarm_CO_42-43', 'B307_gasalarm_H2_2sal',
'B307_gasalarm_CO_932', 'B307_gasalarm_H2_932']
self.db_logger = ContinuousLogger(table='dateplots_b307gasalarm',
username=credentials.USERNAME,
password=credentials.PASSWORD,
measurement_codenames=codenames)
self.db_logger.start()
LOGGER.info('Logger started')
# Each value is measured about every 5 sec, so sane interval about 2
self.live_socket = LiveSocket(name='gas_alarm_307_live',
codenames=codenames,
sane_interval=2.0)
self.live_socket.start()
LOGGER.info('Live socket started')
# Start driver
self.vortex = Vortex('/dev/ttyUSB0', 1)
LOGGER.info('Vortex driver opened')
# Init database connection
self.db_connection = MySQLdb.connect(
host='servcinf', user=credentials.USERNAME,
passwd=credentials.PASSWORD, db='cinfdata')
self.db_cursor = self.db_connection.cursor()
# Initiate static information. All information about the except for
# the list of their numbers are placed in dicts because the numbering
# starts at 1.
# Detector numbers: [1, 2, 3, ..., 12]
self.detector_numbers = \
range(1, self.vortex.get_number_installed_detectors() + 1)
self.detector_info = \
{detector_num: self.vortex.detector_configuration(detector_num)
for detector_num in self.detector_numbers}
# trip_levels are the differences that are required to force a log
# The levels are set to 2 * the communication resolution
# (1000 values / full range)
self.trip_levels = {detector_num: info.range * 2.0 / 1000.0 for
detector_num, info in self.detector_info.items()}
# Initiate last measured values and their corresponding times
self.detector_levels_last_values = \
{detector_num: - (10 ** 9)
for detector_num in self.detector_numbers}
self.detector_levels_last_times = \
{detector_num: 0 for detector_num in self.detector_numbers}
self.detector_status_last_values = \
{detector_num: {'inhibit': False, 'status': ['OK'],
'codename': self.detector_info[detector_num].identity}
for detector_num in self.detector_numbers}
self.detector_status_last_times = \
{detector_num: 0 for detector_num in self.detector_numbers}
# Initiate variables for system power status
self.central_power_status_last_value = 'OK'
self.central_power_status_last_time = - (10 ** 9)
# Initiate variables for system status
self.central_status_last_value = ['All OK']
self.central_status_last_time = 0
def close(self):
"""Close the logger and the connection to the Vortex"""
self.db_logger.stop()
LOGGER.info('Logger stopped')
self.live_socket.stop()
LOGGER.info('Live socket stopped')
self.vortex.close()
LOGGER.info('Vortex driver closed')
@staticmethod
def identity_to_codename(identity):
"""Convert the identity the sensor returns to the codename used in the
database
"""
identity = identity.replace(' ', '_').replace('/', '-')
return 'B307_gasalarm_{}'.format(identity)
def main(self):
"""Main monitoring and logging loop"""
# Each iteration takes about 5 sec
while True:
# Log detectors
for detector_num in self.detector_numbers:
self.log_detector(detector_num)
# Log Vortex unit status (force log every 24 hours)
self.log_central_unit()
def log_detector(self, detector_num):
#.........这里部分代码省略.........
示例6: MainDatalogger
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger 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
#.........这里部分代码省略.........
示例7: MainMultilogger
# 需要导入模块: from PyExpLabSys.common.loggers import ContinuousLogger [as 别名]
# 或者: from PyExpLabSys.common.loggers.ContinuousLogger 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