| | |
| | | if (null == liftProtocol) { |
| | | liftProtocol = new LiftProtocol(); |
| | | liftProtocol.setLiftNo(device.getDeviceNo()); |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.NONE); |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | |
| | | InnerLiftExtend innerLiftExtend = new InnerLiftExtend(); |
| | | liftProtocol.setExtend(innerLiftExtend); |
| | |
| | | liftProtocol.setModel(data.getInteger("model")); |
| | | //PLC任务号 |
| | | liftProtocol.setPlcTaskNo(data.getInteger("plcTaskNo")); |
| | | //任务状态 |
| | | liftProtocol.setProtocolStatus(data.getInteger("protocolStatus")); |
| | | //设备状态 |
| | | liftProtocol.setDeviceStatus(data.getInteger("deviceStatus")); |
| | | //任务模式 |
| | | liftProtocol.setTaskMode(data.getInteger("taskMode")); |
| | | //取货数据 |
| | |
| | | |
| | | @Override |
| | | public CommandResponse reset() { |
| | | CommandResponse response = new CommandResponse(false); |
| | | try { |
| | | LiftCommand resetCommand = getResetCommand(9999); |
| | | |
| | | //发出请求 |
| | | String resultKey = requestCommand(resetCommand); |
| | | //查询请求结果 |
| | | JSONObject result = queryCommandStatus(resultKey); |
| | | if (result == null) { |
| | | return response;//请求失败 |
| | | } |
| | | if(!result.getString("result").equals("success")) { |
| | | return response;//请求失败 |
| | | } |
| | | |
| | | this.liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间 |
| | | response.setMessage(JSON.toJSONString(result)); |
| | | response.setResult(true); |
| | | return response; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | response.setMessage(e.getMessage()); |
| | | return response; |
| | | } |
| | | CommandResponse response = new CommandResponse(true); |
| | | this.setSyncTaskNo(0); |
| | | this.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | |
| | | InnerLiftExtend extend = (InnerLiftExtend) this.liftProtocol.getExtend(); |
| | | |
| | | boolean res = this.liftProtocol.getProtocolStatus() == LiftProtocolStatusType.IDLE.id |
| | | && this.liftProtocol.getPlcTaskNo() == 0 |
| | | // && this.liftProtocol.getPlcTaskNo() == 0 |
| | | && this.liftProtocol.getTaskNo() == 0 |
| | | && this.liftProtocol.getModel() == 2 |
| | | && this.liftProtocol.getErrorCode() == 0 |
| | |
| | | |
| | | @Override |
| | | public boolean setSyncTaskNo(Integer taskNo) { |
| | | this.liftProtocol.setSyncTaskNo(taskNo); |
| | | redisUtil.setSync(RedisKeyType.LIFT_FLAG.key + liftProtocol.getLiftNo(), taskNo); |
| | | this.liftProtocol.setTaskNo(taskNo); |
| | | return true; |
| | | } |
| | | |