12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- # -*- coding: utf-8 -*-
- import apps.web.core.adapter.jndz
- reload(apps.web.core.adapter.jndz)
- from apps.web.core.adapter.jndz import *
- class ChargingMXZ3Box(ChargingJNDZBox):
- def __init__(self, device):
- super(ChargingMXZ3Box, self).__init__(device)
-
- def get_dev_setting(self):
- resultDict = super(ChargingMXZ3Box,self).get_dev_setting()
- #针对墨小智V3的,还有几个参数,需要特殊处理下
- devInfo = MessageSender.send(self.device, self.make_random_cmdcode(),
- {'IMEI': self._device['devNo'], "funCode": '1F', 'data': '00'})
-
- if devInfo.has_key('rst') and devInfo['rst'] != 0:
- if devInfo['rst'] == -1:
- raise ServiceException(
- {'result': 2, 'description': u'充电桩正在玩命找网络,请您稍候再试'})
- elif devInfo['rst'] == 1:
- raise ServiceException(
- {'result': 2, 'description': u'充电桩忙,无响应,请您稍候再试。也可能是您的设备版本过低,暂时不支持此功能'})
- data = devInfo['data'][6::]
- if data[0:2] == '01':#表示成功
- pass
- else:
- raise ServiceException({'result': 2, 'description': u'操作端口失败,请重试看能否解决'})
- confData = data[2:-2]
- stWTime = int(confData[0:2],16)
- temThre = int(confData[2:4],16)
- freeUse = int(confData[4:6],16)
- temValue = int(confData[6:8],16)
-
- resultDict.update({'stWTime':stWTime,'temThre':temThre,'freeUse':freeUse,'temValue':temValue})
-
- return resultDict
-
- def set_dev_setting(self,setConf):
- super(ChargingMXZ3Box,self).set_dev_setting(setConf)
- data = ''
- data += fill_2_hexByte(hex(int(setConf['stWTime'])),2)
- data += fill_2_hexByte(hex(int(setConf['temThre'])),2)
- data += fill_2_hexByte(hex(int(setConf['freeUse'])),2)
-
- devInfo = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": '19', 'data': data})
-
- if devInfo.has_key('rst') and devInfo['rst'] != 0:
- if devInfo['rst'] == -1:
- raise ServiceException(
- {'result': 2, 'description': u'充电桩正在玩命找网络,请您稍候再试'})
- elif devInfo['rst'] == 1:
- raise ServiceException(
- {'result': 2, 'description': u'充电桩忙,无响应,请您稍候再试。也可能是您的设备版本过低,暂时不支持此功能'})
- data = devInfo['data'][6::]
- if data[0:2] == '01':#表示成功
- pass
- else:
- raise ServiceException({'result': 2, 'description': u'操作端口失败,请重试看能否解决'})
-
|