| | |
| | | while (true) { |
| | | try { |
| | | listenSocketMessage(); |
| | | listenInit();//监听初始化事件 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | Thread otherThread = new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | listenInit();//监听初始化事件 |
| | | saveLog();//保存数据 |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | JSONObject body = response.getJSONObject("body"); |
| | | if (body.containsKey("workingMode")) { |
| | | //read |
| | | socketReadResults.add(result); |
| | | socketReadResults.add(body); |
| | | return; |
| | | } |
| | | } |
| | |
| | | requestCommandAsync(readStatusCommand);//请求状态 |
| | | |
| | | if (this.socketReadResults.isEmpty()) { |
| | | if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60) { |
| | | //最后一次上线时间超过60s,认定离线 |
| | | this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE); |
| | | } |
| | | return; |
| | | } |
| | | |
| | |
| | | if (data == null) { |
| | | if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60) { |
| | | //最后一次上线时间超过60s,认定离线 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE); |
| | | this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE); |
| | | } |
| | | 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.setPakMk(true); |
| | | } |
| | | |
| | | if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 0) { |
| | | if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 1) { |
| | | //小车空闲状态、小车任务状态为未知,认定曾离线过,需要复位成空闲 |
| | | shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE); |
| | | this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | } |
| | | |
| | | if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE) && shuttleProtocol.getDeviceStatus().intValue() == 1) { |
| | | this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | } |
| | | |
| | | this.originDeviceData = data; |
| | |
| | | return false; |
| | | } |
| | | |
| | | if (this.shuttleProtocol.getMode() == 0) { |
| | | return true; |
| | | } |
| | | |
| | | if (!this.shuttleProtocol.getErrorCode().equals("0")) { |
| | | return true; |
| | | } |
| | | |
| | | InnerSuhttleExtend extend = (InnerSuhttleExtend) this.shuttleProtocol.getExtend(); |
| | | boolean res = this.shuttleProtocol.getMode() == 0 |
| | | && !this.shuttleProtocol.getErrorCode().equals("0") |
| | | && extend.getSuspendState() == 1 |
| | | ; |
| | | return res; |
| | | |
| | | if (extend.getSuspendState() == 1) { |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | @Override |