123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573 |
- # -*- coding: utf-8 -*-
- from apps.web.core.adapter.base import *
- from apps.web.device.models import Device
- class WasherBox(SmartBox):
- def __init__(self, device):
- super(WasherBox, self).__init__(device)
- def analyze_event_data(self,data):
- return self.analyze_get_data(data)
- def analyze_get_data(self,data):
- temp = data[6:8]
- status = Const.DEV_WORK_STATUS_IDLE
- tempStatus = ''
- if temp == '01':
- tempStatus = u'待机'
- elif temp == '02':
- status =Const.DEV_WORK_STATUS_WORKING
- tempStatus = u'运转'
- elif temp == '03':
- status =Const.DEV_WORK_STATUS_PAUSE
- tempStatus = u'暂停'
- elif temp == '04':
- status = Const.DEV_WORK_STATUS_FAULT
- tempStatus = u'故障'
- elif temp == '05':
- status =Const.DEV_WORK_STATUS_WORKING
- tempStatus = u'参数设置'
- elif temp == '06':
- status =Const.DEV_WORK_STATUS_WORKING
- tempStatus = u'自检'
- else:
- status =Const.DEV_WORK_STATUS_IDLE
- tempStatus = u'待机'
- temp = data[8:10]
- program = ''
- if temp == '01':
- program = u'单脱水'
- elif temp == '02':
- program = u'快速'
- elif temp == '03':
- program = u'标准'
- elif temp == '04':
- program = u'大物'
- elif temp == '05':
- program = u'加热快速'
- elif temp == '06':
- program = u'加热标准'
- elif temp == '07':
- program = u'加热大物'
- temp = data[10:12]
- process = ''
- if temp == '01':
- process = u'预约'
- elif temp == '02':
- process = u'浸泡'
- elif temp == '03':
- process = u'洗涤'
- elif temp == '04':
- process = u'漂洗'
- elif temp == '05':
- process = u'脱水'
- elif temp == '06':
- process = u'主进水'
- temp = data[14:16] + data[12:14]
- leftTime= int(temp,16)
- temp = data[16:18]
- binFault = hexbyte_2_bin(temp)
- faultStr = ''
- if binFault[0] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'进水超时'
- if binFault[1] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'排水超时'
- if binFault[2] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'脱水开盖'
- if binFault[3] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'脱水不平衡'
- if binFault[4] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'通讯故障'
- if binFault[5] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'童锁开盖'
- if binFault[6] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'溢水'
- if binFault[7] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'水位传感器故障'
- temp = data[18:20]
- binFault = hexbyte_2_bin(temp)
- if binFault[0] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'数据存储故障'
- if binFault[1] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'温度传感器故障'
- if binFault[2] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'无水加热故障'
- if binFault[3] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'电机堵转故障'
- if binFault[4] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'IPM温度过高故障'
- if binFault[5] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'电机过流故障'
- if binFault[6] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'电机缺相故障'
- if binFault[7] == '1':
- status = Const.DEV_WORK_STATUS_FAULT
- faultStr = u'驱动器故障'
- if status == Const.DEV_WORK_STATUS_FAULT:
- statusInfo = faultStr
- elif status == Const.DEV_WORK_STATUS_FORBIDDEN:
- statusInfo = u'禁用'
- elif status == Const.DEV_WORK_STATUS_IDLE:
- statusInfo = u'待机'
- elif status == Const.DEV_WORK_STATUS_PAUSE:
- statusInfo = u'暂停'
- else:
- statusInfo = u'%s 当前套餐:%s 当前环节:%s' % (tempStatus,program,process)
- return {'status':status,'statusInfo':statusInfo,'leftTime':leftTime}
- def get_dev_info(self):
- devInfo = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "A1", "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'当前洗衣机忙,无响应,请您稍候再试'})
- info = self.analyze_get_data(devInfo['data'])
- return info
- def start_device(self, package, openId, attachParas):
- info = self.get_dev_info()
- if info['status'] == Const.DEV_WORK_STATUS_FAULT:
- raise ServiceException(
- {'result': 2, 'description': u'当前洗衣机故障:%s' % info['statusInfo']})
- if u'待机' not in info['statusInfo']:
- raise ServiceException(
- {'result': 2, 'description': u'当前洗衣机%s,请稍候使用' % info['statusInfo']})
- data = ''
- washName = package['name']
- temp = ''
- if washName == Const.WASHER_BOX_SET_TQJ:
- temp = '10'
- elif washName == Const.WASHER_BOX_SET_DTS:
- temp = '08'
- elif washName == Const.WASHER_BOX_SET_KSX:
- temp = '04'
- elif washName == Const.WASHER_BOX_SET_BZX:
- temp = '02'
- elif washName == Const.WASHER_BOX_SET_DWX:
- temp = '01'
- data = data + temp
- data = data + '00'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "81", "data": data},
- timeout = MQTT_TIMEOUT.START_DEVICE)
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,您的金币还在,重试不需要重新付款,建议您试试旁边其他设备,或者试试投硬币,或者稍后再试哦'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,您的金币还在,设备暂时不能网络支付,请尝试投币哦'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误,您的金币还在,款请尝试投币哦'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'主板见通讯失败,请试试投币,并报障给老板哦'})
- Device.update_dev_control_cache(self._device['devNo'], {'openId':openId})
- return result
- def get_device_function_by_key(self,keyName):
- if keyName == 'workingStatus':
- infoDict = self.get_dev_info()
- return {"workingStatus": infoDict['statusInfo']}
- return None
- def stop_pause_continue(self,state):
- cmd = ''
- if state == 'stop':
- cmd = '20'
- elif state == 'pause':
- cmd = '40'
- elif state == 'continue':
- cmd = '80'
- cmd += '00'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "81", "data": cmd})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,建议您试试旁边其他设备,或者试试投硬币,或者稍后再试哦'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,设备暂时不能网络支付,请尝试投币哦'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误,请尝试投币哦'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'主板见通讯失败,请试试投币,并报障给老板哦'})
- if state == 'stop':
- Device.update_dev_control_cache(self._device['devNo'], {'status':Const.DEV_WORK_STATUS_IDLE})
- else:
- Device.update_dev_control_cache(self._device['devNo'], {'status':Const.DEV_WORK_STATUS_WORKING})
- return result
- def get_wash_config(self):
- result = {
- Const.WASHER_BOX_DTS :{'price':0,'time':0},
- Const.WASHER_BOX_KS :{'price':0,'time':0},
- Const.WASHER_BOX_BZ :{'price':0,'time':0},
- Const.WASHER_BOX_DW:{'price':0,'time':0},
- Const.WASHER_BOX_YEBENG:{'price':0,'time':0},
- Const.WASHER_BOX_JRKS :{'price':0,'time':0},
- Const.WASHER_BOX_JRBZ :{'price':0,'time':0},
- Const.WASHER_BOX_JRDW :{'price':0,'time':0},
- }
- devInfo = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "A2", "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'洗衣机主板连接故障,设备暂时不能网络支付,请尝试投币哦'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- priceData = devInfo['data'][6:20]
- result[Const.WASHER_BOX_DTS]['price'] = int(priceData[0:2],16)
- result[Const.WASHER_BOX_KS]['price'] = int(priceData[2:4],16)
- result[Const.WASHER_BOX_BZ]['price'] = int(priceData[4:6],16)
- result[Const.WASHER_BOX_DW]['price'] = int(priceData[6:8],16)
- result[Const.WASHER_BOX_JRKS]['price'] = int(priceData[8:10],16)
- result[Const.WASHER_BOX_JRBZ]['price'] = int(priceData[10:12],16)
- result[Const.WASHER_BOX_JRDW]['price'] = int(priceData[12:14],16)
- devInfo = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "A3", "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'洗衣机主板连接故障,设备暂时不能网络支付,请尝试投币哦'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- timeData = devInfo['data'][6:22]
- result[Const.WASHER_BOX_DTS]['time'] = int(timeData[0:2],16)
- result[Const.WASHER_BOX_KS]['time'] = int(timeData[2:4],16)
- result[Const.WASHER_BOX_BZ]['time'] = int(timeData[4:6],16)
- result[Const.WASHER_BOX_DW]['time'] = int(timeData[6:8],16)
- result[Const.WASHER_BOX_YEBENG]['time'] = int(timeData[8:10],16)
- result[Const.WASHER_BOX_JRKS]['time'] = int(timeData[10:12],16)
- result[Const.WASHER_BOX_JRBZ]['time'] = int(timeData[12:14],16)
- result[Const.WASHER_BOX_JRDW]['time'] = int(timeData[14:16],16)
- return result
- def set_wash_config(self,washConfig):
- priceTemp,timeTemp = '',''
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_DTS]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_KS]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_BZ]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_DW]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRKS]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRBZ]['price'])
- priceTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRDW]['price'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_DTS]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_KS]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_BZ]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_DW]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_YEBENG]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRKS]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRBZ]['time'])
- timeTemp += decimal_2_hexByte(washConfig[Const.WASHER_BOX_JRDW]['time'])
- priceTemp += '00'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "82", "data": priceTemp})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'设置价格失败,主板间通讯失败,检查下是否GSM通讯模块和主板之间的连接'})
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "83", "data": timeTemp})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'设置时间失败,主板间通讯失败,检查下是否GSM通讯模块和主板之间的连接'})
- return result
- #快速水位设定 标准水位设定 大物水位设定 脱水转速设定 温度设定
- def set_process_config(self,config):
- cmd = decimal_2_hexByte(config['kssw']) + decimal_2_hexByte(config['bzsw'])\
- + decimal_2_hexByte(config['dwsw']) + decimal_2_hexByte(config['tszs']) + decimal_2_hexByte(config['wdsz']) + '000000'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "84", "data": cmd})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'设置过程参数失败,主板间通讯失败,检查下是否GSM通讯模块和主板之间的连接'})
- return result
- def get_process_config(self):
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": 'A4', "data": ""})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- temp = result['data'][6:16]
- result['kssw'] = int(temp[0:2],16)
- result['bzsw'] = int(temp[2:4],16)
- result['dwsw'] = int(temp[4:6],16)
- result['tszs'] = int(temp[6:8],16)
- result['wdsz'] = int(temp[8:10],16)
- return result
- def set_special_config(self,specialConfig):
- cmd = ''
- bConfig = '000000'+ str(specialConfig['qcbcbh']) + str(specialConfig['ddjy'])
- hexConfig = decimal_2_hexByte(int(bConfig,2))
- cmd =cmd + hexConfig +'00'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "85", "data": cmd})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'设置过程参数失败,主板间通讯失败,检查下是否GSM通讯模块和主板之间的连接'})
- return result
- def press_down_key(self,keyName):
- if keyName in ['stop','pause','continue']:
- return self.stop_pause_continue(keyName)
- self.set_control_config(keyName)
- def set_control_config(self,buttonName):
- cmd = ''
- if buttonName == 'ccms1' :
- cmd = '01'
- elif buttonName == 'ccms2':
- cmd = '02'
- elif buttonName == 'tz':
- cmd = '03'
- elif buttonName == 'js':
- cmd = '04'
- elif buttonName == 'ajkq':
- cmd = '05'
- elif buttonName == 'ajgb':
- cmd = '06'
- elif buttonName == 'tbkq':
- cmd = '07'
- elif buttonName == 'tbgb':
- cmd = '08'
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "86", "data": cmd})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- resCode = result['data'][6:8]
- if resCode == '0F':
- raise ServiceException({'result': 2, 'description': u'设置过程参数失败,主板间通讯失败,检查下是否GSM通讯模块和主板之间的连接'})
- return result
- def get_special_config(self):
- result = MessageSender.send(self.device, DeviceCmdCode.OPERATE_DEV_SYNC,
- {'IMEI': self._device['devNo'], "funCode": "A5", "data": ''})
- if result['rst'] != 0:
- if result['rst'] == -1:
- raise ServiceException({'result': 2, 'description': u'洗衣机正在玩命找网络,请稍候再试'})
- elif result['rst'] == 1:
- raise ServiceException({'result': 2, 'description': u'洗衣机主板连接故障,请检查下GSM模块和主板之间的连接'})
- else:
- raise ServiceException({'result': 2, 'description': u'系统错误'})
- temp = result['data'][6:8]
- binTemp = hexbyte_2_bin(temp)[::-1]
- result['ddjy'] = int(binTemp[0])
- result['qcbcbh'] = int(binTemp[1])
- return result
- def get_dev_setting(self):
- sConfig = self.get_special_config()
- wConfig = self.get_wash_config()
- pConfig = self.get_process_config()
- para = {}
- para.update(sConfig)
- para.update(wConfig)
- para.update(pConfig)
- #为了配合前台,还需要给他转义下
- para['kssw'] = pConfig['kssw']
- para['bzsw'] = pConfig['bzsw']
- para['dwsw'] = pConfig['dwsw']
- para['liquidPump'] = wConfig[Const.WASHER_BOX_YEBENG]['time']
- para['tszs'] = pConfig['tszs']
- para['wdsz'] = pConfig['wdsz']
- para['powerDownMemory'] = True if sConfig['ddjy'] == 1 else False
- para['protect'] = True if sConfig['qcbcbh'] == 1 else False
- return para
-
- def set_device_function(self,request,lastSetConf):
- oldSConfig = {'ddjy': lastSetConf['ddjy'], 'qcbcbh': lastSetConf['qcbcbh']}
- if request.POST.has_key('powerDownMemory'):
- powerDownMemory = bool(request.POST.get('powerDownMemory'))
- ddjy = 1 if powerDownMemory else 0
- oldSConfig.update({'ddjy': ddjy})
- lastSetConf.update({'ddjy': ddjy})
- self.set_special_config(oldSConfig)
- if request.POST.has_key('protect'):
- protect = bool(request.POST.get('protect'))
- qcbcbh = 1 if protect else 0
- oldSConfig.update({'qcbcbh': qcbcbh})
- lastSetConf.update({'qcbcbh': qcbcbh})
- self.set_special_config(oldSConfig)
-
- def set_device_function_param(self,request,lastSetConf):
- oldPConfig = {'kssw': lastSetConf['kssw'], 'bzsw': lastSetConf['bzsw'], 'dwsw': lastSetConf['dwsw'],
- 'tszs': lastSetConf['tszs'], 'wdsz': lastSetConf['wdsz']}
- kssw = request.POST.get('kssw', None)
- if kssw:
- oldPConfig['kssw'] = int(kssw)
- bzsw = request.POST.get('bzsw', None)
- if bzsw:
- oldPConfig['bzsw'] = int(bzsw)
- dwsw = request.POST.get('dwsw', None)
- if dwsw:
- oldPConfig['dwsw'] = int(dwsw)
- tszs = request.POST.get('tszs', None)
- if tszs:
- oldPConfig['tszs'] = int(tszs)
- wdsz = request.POST.get('wdsz', None)
- if wdsz:
- oldPConfig['wdsz'] = int(wdsz)
- if kssw or bzsw or dwsw or tszs or wdsz:
- self.set_process_config(oldPConfig)
- if request.POST.has_key('nightPump'):
- oldWConfig = {
- Const.WASHER_BOX_DTS: lastSetConf[Const.WASHER_BOX_DTS],
- Const.WASHER_BOX_KS: lastSetConf[Const.WASHER_BOX_KS],
- Const.WASHER_BOX_BZ: lastSetConf[Const.WASHER_BOX_BZ],
- Const.WASHER_BOX_DW: lastSetConf[Const.WASHER_BOX_DW],
- Const.WASHER_BOX_YEBENG: lastSetConf[Const.WASHER_BOX_YEBENG],
- Const.WASHER_BOX_JRKS: lastSetConf[Const.WASHER_BOX_JRKS],
- Const.WASHER_BOX_JRBZ: lastSetConf[Const.WASHER_BOX_JRBZ],
- Const.WASHER_BOX_JRDW: lastSetConf[Const.WASHER_BOX_JRDW],
- }
- yebeng = request.POST.get('nightPump', None)
- if yebeng:
- oldWConfig[Const.WASHER_BOX_YEBENG]['time'] = yebeng
-
- self.set_wash_config(oldWConfig)
-
- def count_down(self,request,dev,agent,group,devType,lastOpenId,port=None):
- devInfo = self.get_dev_info()
- if devInfo['rst'] == -1:
- return JsonResponse({'result': 0, 'description': u'洗衣机网络不太好,您试下投币,或者周边其他设备,或者稍后再试试哦'})
- if devInfo['rst'] == 1:
- return JsonResponse({'result': 0, 'description': u'洗衣机设备主板连接故障,请投币试试'})
- if devInfo['status'] == Const.WASHER_BOX_GZ:
- statusDesc = Const.WASHER_STATUS_CODE_DESC[Const.WASHER_BOX_GZ]
- if len(devInfo['faultList']) > 0:
- faultDesc = Const.EVENT_CODE_DESC[devInfo['faultList'][0]]
- desc = '出现了%s,%s' % (statusDesc, faultDesc)
- else:
- desc = '出现了%s' % statusDesc
- return JsonResponse({'result': 0, 'description': u'洗衣机' + desc + u'。您联系下老板哦'})
- return JsonResponse(
- {
- 'result': 1,
- 'description': '',
- 'payload': {
- 'surplus': devInfo['surplus'],
- 'sum': devInfo['surplus'],
- 'name': group['groupName'],
- 'address': group['address'],
- 'code': devType.get('code'),
- 'orderProcessing': False,
- 'logicalCode': dev['logicalCode'],
- 'user': 'me' if lastOpenId == request.user.openId else 'notme',
- 'agentFeatures': agent.features,
- }
- })
|