| | |
| | | JSONObject resultResponse = JSON.parseObject(result.get("response").toString()); |
| | | JSONObject resultHeader = JSON.parseObject(resultResponse.get("header").toString()); |
| | | int responseId = Integer.parseInt(resultHeader.get("responseId").toString()); |
| | | if (responseId != httpCommand.getRequest().getHeader().getRequestId()) { |
| | | return null;//响应ID与请求ID不一致 |
| | | } |
| | | // if (responseId != httpCommand.getRequest().getHeader().getRequestId()) { |
| | | // return null;//响应ID与请求ID不一致 |
| | | // } |
| | | |
| | | return filterBodyData(result);//返回Body结果集 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | try { |
| | | socket.close(); |
| | | } catch (IOException exception) { |
| | | exception.printStackTrace(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | |
| | | |
| | | private void read() { |
| | | try { |
| | | if (this.socket == null || !this.socket.isConnected()) { |
| | | if (this.socket == null || this.socket.isClosed()) { |
| | | //链接断开重新链接 |
| | | this.connect(); |
| | | } |
| | |
| | | NyShuttleHttpCommand readStatusCommand = NyHttpUtils.getReadStatusCommand(slave.getId()); |
| | | JSONObject jsonObject = NyHttpUtils.requestCommand(socket, readStatusCommand); |
| | | if (jsonObject == null) { |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】四向穿梭车plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】四向穿梭车Socket状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | }else { |
| | | //手动状态/自动状态 |
| | | shuttleProtocol.setWorkingMode(jsonObject.getInteger("workingMode")); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】四向穿梭车plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】四向穿梭车Socket状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | } |
| | | } |
| | | |