1234567891011121314151617181920212223242526272829303132333435 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- """
- demeter web
- name:admin.py
- author:rabin
- """
- import time
- from demeter.core import *
- # 处理定时命令、周期命令、条件控制、消息、设备状态等
- timeSleep = 10
- # 更改控制设备的超时状态
- def control():
- model = Demeter.model('device_info')
- cur = Demeter.time() - 10
- model.operdate.assgin(cur, '<=')
- model.oper = True
- model.hardware_type = 3
- service = Demeter.service('device')
- data = model.select()
- if data:
- for v in data:
- model.id = v['id']
- if v['exp'] == '-1':
- msg = service.notice('timeout')
- service.mul(v, v['name'] + '失败:' + msg, False)
- model.update(exp=msg, oper=True, operdate=Demeter.time())
- else:
- msg = '1'
- service.mul(v, '', True)
- model.update(exp=msg, oper=False, operdate=Demeter.time())
- while 1:
- control()
- time.sleep(timeSleep)
|