mxzv3.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # -*- coding: utf-8 -*-
  2. import apps.web.core.adapter.jndz
  3. reload(apps.web.core.adapter.jndz)
  4. from apps.web.core.adapter.jndz import *
  5. class ChargingMXZ3Box(ChargingJNDZBox):
  6. def __init__(self, device):
  7. super(ChargingMXZ3Box, self).__init__(device)
  8. def get_dev_setting(self):
  9. resultDict = super(ChargingMXZ3Box,self).get_dev_setting()
  10. #针对墨小智V3的,还有几个参数,需要特殊处理下
  11. devInfo = MessageSender.send(self.device, self.make_random_cmdcode(),
  12. {'IMEI': self._device['devNo'], "funCode": '1F', 'data': '00'})
  13. if devInfo.has_key('rst') and devInfo['rst'] != 0:
  14. if devInfo['rst'] == -1:
  15. raise ServiceException(
  16. {'result': 2, 'description': u'充电桩正在玩命找网络,请您稍候再试'})
  17. elif devInfo['rst'] == 1:
  18. raise ServiceException(
  19. {'result': 2, 'description': u'充电桩忙,无响应,请您稍候再试。也可能是您的设备版本过低,暂时不支持此功能'})
  20. data = devInfo['data'][6::]
  21. if data[0:2] == '01':#表示成功
  22. pass
  23. else:
  24. raise ServiceException({'result': 2, 'description': u'操作端口失败,请重试看能否解决'})
  25. confData = data[2:-2]
  26. stWTime = int(confData[0:2],16)
  27. temThre = int(confData[2:4],16)
  28. freeUse = int(confData[4:6],16)
  29. temValue = int(confData[6:8],16)
  30. resultDict.update({'stWTime':stWTime,'temThre':temThre,'freeUse':freeUse,'temValue':temValue})
  31. return resultDict
  32. def set_dev_setting(self,setConf):
  33. super(ChargingMXZ3Box,self).set_dev_setting(setConf)
  34. data = ''
  35. data += fill_2_hexByte(hex(int(setConf['stWTime'])),2)
  36. data += fill_2_hexByte(hex(int(setConf['temThre'])),2)
  37. data += fill_2_hexByte(hex(int(setConf['freeUse'])),2)
  38. devInfo = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
  39. {'IMEI': self._device['devNo'], "funCode": '19', 'data': data})
  40. if devInfo.has_key('rst') and devInfo['rst'] != 0:
  41. if devInfo['rst'] == -1:
  42. raise ServiceException(
  43. {'result': 2, 'description': u'充电桩正在玩命找网络,请您稍候再试'})
  44. elif devInfo['rst'] == 1:
  45. raise ServiceException(
  46. {'result': 2, 'description': u'充电桩忙,无响应,请您稍候再试。也可能是您的设备版本过低,暂时不支持此功能'})
  47. data = devInfo['data'][6::]
  48. if data[0:2] == '01':#表示成功
  49. pass
  50. else:
  51. raise ServiceException({'result': 2, 'description': u'操作端口失败,请重试看能否解决'})