本文整理汇总了Python中scheduler.Scheduler.desired方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.desired方法的具体用法?Python Scheduler.desired怎么用?Python Scheduler.desired使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.desired方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Controller
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import desired [as 别名]
class Controller(Daemon):
def run(self):
if lacrosse_serial:
self.lacrosse_cleaner=lacrosse.Cleaner(mainDB,debug=False,dbdebug=False)
self.lacrosse_cleaner.start()
else:
log('no lacrosse sensors')
if ciseco_serial:
self.ciseco_cleaner=ciseco.Cleaner(mainDB,debug=False,dbdebug=False)
self.ciseco_cleaner.start()
else:
log('no ciseco sensors')
self.scheduler=Scheduler(mainDB,debug=False)
self.session_maker=SessionMaker(mainDB,debug=False)
log('CONTROLLER STARTED')
while True:
zones=None
try:
session = self.session_maker.get_session()
zones=session.query(Zone)
for zone in zones.filter(Zone.desc!='outside'):
#log('zone id: %d'%(zone.id))
desired=self.scheduler.desired(zone_id=zone.id)
#log('desired temp in "%s": %.1f'%(zone.desc,desired))
sensors=session.query(Sensor).filter(Sensor.zone_id==zone.id)
min=None
for sensor in zone.sensors:
log('sensor %s in %s'%(sensor.desc,zone.desc))
'''
for measure in sensor.measurements:
if measure.what=='temp':
#log('%s: %.1f'%(measure.what,measure.howmuch))
if min==None or measure.howmuch<min:
min=measure.howmuch
'''
#measurements=session.query(Measure).filter(Measure.what='temp',Measure.sensor.in(sensors.subquery()))
#for measure in measurements:
# log('%s: %.1f'%(measure.what,measure.howmuch))
if min:
log('min: %.1f'%min)
if min<(desired-0.5):
log('heating ON in "%s"'%zone.desc)
elif min>(desired+0.5):
log('heating OFF in "%s"'%zone.desc)
#latest=zone.sensors.measurements.order_by(Measure.when.desc(),Measure.howmuch).first()
#print 'latest measurement:',latest
except:
e = sys.exc_info()[0]
log('zones query error: %s'%e)
traceback.print_exc()
finally:
try:
session.close()
except:
zones=None
log('db (zones) session close error')
time.sleep(5)
log('CONTROLLER ENDED')
示例2:
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import desired [as 别名]
schedules=session.query(Schedule).filter_by(what='temp')
if schedules and schedules.count()>0:
weekly=schedules.filter_by(date=None)
if weekly and weekly.count()>0:
print 'saved weekly schedule:'
for schedule in weekly:
print ' - on %s: %.1f from %s to %s'%(schedule.day,schedule.howmuch,schedule.start.strftime('%H:%M'),schedule.stop.strftime('%H:%M'))
dates=schedules.filter_by(day=None)
if dates and dates.count()>0:
print 'specific dates schedule:'
for schedule in dates:
print ' - on %s: %.1f from %s to %s'%(schedule.date.strftime('%d/%m/%Y'),schedule.howmuch,schedule.start.strftime('%H:%M'),schedule.stop.strftime('%H:%M'))
sched=Scheduler(mainDB,debug=True)
temp=sched.desired(zone1.id)
if temp:
print 'desired temperature in "%s": %.1f'%(zone1.desc,temp)
else:
print 'unknown desired temperature... will fall back to minimum!'
else:
print 'no schedule configured: exiting...'
try:
session.close()
except:
schedules=None
log(self,'db (schedule) session close error')