device.py 616 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web
  4. name:admin.py
  5. author:rabin
  6. """
  7. import time
  8. from demeter.core import *
  9. timeSleep = 60
  10. # 更改设备状态(离线)
  11. class Device(object):
  12. def run(self):
  13. self.handle()
  14. time.sleep(timeSleep)
  15. def handle(self):
  16. model = Demeter.model('device_info')
  17. cur = Demeter.time() - 1800
  18. model.cdate.assign(cur, '<=')
  19. model.status = True
  20. data = model.select()
  21. for v in data:
  22. model.id = v['id']
  23. if v['hardware_type'] == 5:
  24. model.update(value='0', status=False)
  25. elif v['hardware_type'] != 7 and v['hardware_type'] != 6:
  26. model.update(status=False)