shucai_converter.py 766 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. """
  4. @time: 2021/5/31 11:37
  5. @desc: sct003 和 moxae1210 的解析器
  6. """
  7. from converter import Converter
  8. from log import OutPutLog
  9. class ShucaiConverter(Converter):
  10. def __init__(self):
  11. self._log = OutPutLog()
  12. def convert(self, config, data):
  13. if data:
  14. try:
  15. format_data_dict = {}
  16. for index in config:
  17. name = 'c' + str(index['serial_number'])
  18. if data[index['address']] != None:
  19. format_data_dict[name] = data[index['address']]
  20. return format_data_dict
  21. except Exception as e:
  22. print(e)
  23. self._log.error(e)
  24. return "error"