record_control.py 635 B

123456789101112131415161718192021
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter service
  5. name:record_control.py 处理控制器的状态数据
  6. author:rabin
  7. key:control/type/gateway/device
  8. """
  9. import time
  10. import json
  11. from demeter.core import *
  12. class Record_control(object):
  13. def handle(self, record, config, value):
  14. self.record = record
  15. model = Demeter.model('setting_device_type')
  16. model.key = config['type']
  17. device_type = model.select(type='fetchone')
  18. if device_type:
  19. name = device_type['name'] + '#' + str(config['child'])
  20. self.record.save(config, value, name, device_type)