本文整理汇总了Python中datalogger.DataLogger.record_sensors方法的典型用法代码示例。如果您正苦于以下问题:Python DataLogger.record_sensors方法的具体用法?Python DataLogger.record_sensors怎么用?Python DataLogger.record_sensors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datalogger.DataLogger
的用法示例。
在下文中一共展示了DataLogger.record_sensors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PeerPressure
# 需要导入模块: from datalogger import DataLogger [as 别名]
# 或者: from datalogger.DataLogger import record_sensors [as 别名]
class PeerPressure(object):
def __init__(self, name):
adc = ADC("Analog input",0)
self.pressure = Strain_PressureSensor("Pressure (kPa)",adc)
print "Pressure is %s kPa" % self.pressure.get_pressure_kpa()
# put Port 8 Pin 3&4 into mode 7 (GPIO_1_6 & GPIO_1_7)
open('/sys/kernel/debug/omap_mux/gpmc_ad6', 'wb').write("%X" % 7)
open('/sys/kernel/debug/omap_mux/gpmc_ad7', 'wb').write("%X" % 7)
gpio1_6 = GPIO(38,GPIO.OUTPUT) #p8_3
gpio1_7 = GPIO(39,GPIO.OUTPUT) #p8_4
self.vi = Valve("Inlet",gpio1_6)
self.vo = Valve("Outlet",gpio1_7)
# put Port 8 Pin 5 into mode 7 (GPIO_1_2)
open('/sys/kernel/debug/omap_mux/gpmc_ad2', 'wb').write("%X" % 7)
gpio1_2 = GPIO(34,GPIO.OUTPUT) #p8_5
self.pump = Pump("Water cooling pump", gpio1_2)
# put Port 9 Pin 12 into mode 7 (GPIO_1_28)
gpio1_28 = GPIO(60,GPIO.INPUT) #p9_12
self.waterlevel = WaterLevel("Waterlevel sensor", gpio1_28)
sck=GPIO(49,GPIO.OUTPUT) #p9_23
s0=GPIO(115,GPIO.INPUT) #p9_27
cs_t1=GPIO(48,GPIO.OUTPUT) #p9_15 GPIO1_16 48
cs_t2=GPIO(117,GPIO.OUTPUT) #p9_25
self.max1 = MAX31855(cs_t1, sck, s0) #Maxim IC No 1, connected to the cartidge heater TC
self.max2 = MAX31855(cs_t2, sck, s0) #Maxim IC No 2, connected to the TC at the bottom of the vessel
# PWMHeater
self.h = PWMHeater("Cartridge heater (%)", "ehrpwm1a")
self.h.setfrequency(3)
# DS18B20
T1="28-000003f5b1c9"
T2="28-000003f5baa4"
T3="28-000003f5be11"
self.ds1=DS18B20("T in (C)",T1)
self.ds2=DS18B20("T out (C)",T2)
self.ds3=DS18B20("T Env (C)",T3)
print "ds1: ",self.ds1.get_temperature()
print "ds2: ",self.ds2.get_temperature()
print "ds3: ",self.ds3.get_temperature()
# CS5490 power meter
self.cs=CS5490("Power In (W)")
print "start DataLogger"
self.log = DataLogger("my datalogger",500)
self.log.add_sensor(("T Vessel bottom (C)","Maxim 2 Cld jnct (C)"),self.max2.get_celsius)
self.log.add_sensor(("T Cartridge (C)","Maxim 1 Cld jnct (C)"),self.max1.get_celsius)
self.log.add_sensor(self.ds1.get_name(),self.ds1.get_temperature)
self.log.add_sensor(self.ds2.get_name(),self.ds2.get_temperature)
self.log.add_sensor(self.ds3.get_name(),self.ds3.get_temperature)
self.log.add_sensor(self.pressure.get_name(),self.pressure.get_pressure_kpa)
self.log.add_sensor(self.cs.get_name(),self.cs.get_average_power)
def check(self):
'''
# Setup the Tool Watch Dog
'''
return self.waterlevel.is_water()
def shutdown(self):
print "Emergency shutdown at: ", time.ctime()
self.pomp.emergency_shutdown() # do not try to restart, pump is not self priming
self.h.emergency_shutdown() # Use the NON-logged version of heater
#log.record_flag("Emergency shutoff") # Logger not thread safe yet
# ToDo: gracefulle stop running script & prevent any new jobs to start
def heater_set_power(self,power):
self.h.setpower(power)
self.log.record_control(self.h.get_name(), power)
def v_in_open(self):
self.vi.open()
self.log.record_control(self.vi.get_name(),1)
def v_in_close(self):
self.vi.close()
self.log.record_control(self.vi.get_name(),0)
def v_out_open(self):
self.vo.open()
self.log.record_control(self.vo.get_name(),1)
def v_out_close(self):
self.vo.close()
self.log.record_control(self.vo.get_name(),0)
def l_wait(self, sec): # wait sec seconds but keep loggin
t_s = time.time()
dt = sec
interval = 10 # seconds
while dt > interval:
self.log.record_sensors()
time.sleep(interval)
dt = sec - (time.time() - t_s)
if dt > 0: time.sleep(dt)
#.........这里部分代码省略.........