| | |
| | | private List<JSONObject> socketReadResults = new ArrayList<>(); |
| | | private List<DeviceMsgModel> socketResults = new ArrayList<>(); |
| | | |
| | | private Long requestReadTime = System.currentTimeMillis(); |
| | | //原始设备数据 |
| | | private Object originDeviceData; |
| | | |
| | |
| | | //指令超过2条,不再下发任务状态请求 |
| | | TreeSet<String> deviceCommandMsgListKey = deviceMsgUtils.getDeviceCommandMsgListKey(SlaveType.Shuttle, deviceConfig.getDeviceNo()); |
| | | if (deviceCommandMsgListKey.size() < 2) { |
| | | requestCommand(readStatusCommand);//请求状态 |
| | | if ((System.currentTimeMillis() - requestReadTime) > 500) { |
| | | requestCommand(readStatusCommand);//请求状态 |
| | | requestReadTime = System.currentTimeMillis(); |
| | | } |
| | | } |
| | | |
| | | if (this.socketReadResults.isEmpty()) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isRequireCharge() { |
| | | public ShuttleRequireChargeType isRequireCharge() { |
| | | if (this.shuttleProtocol.getDeviceStatus() == null |
| | | || this.shuttleProtocol.getPakMk() == null |
| | | || this.shuttleProtocol.getErrorCode() == null |
| | |
| | | || this.shuttleProtocol.getMode() == null |
| | | || this.shuttleProtocol.getExtend() == null |
| | | ) { |
| | | return false; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | |
| | | InnerSuhttleExtend extend = (InnerSuhttleExtend) this.shuttleProtocol.getExtend(); |
| | |
| | | && extend.getSuspendState() == 0 |
| | | ; |
| | | if (!res) { |
| | | return res; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } else { |
| | | // 电量小于阈值需要进行充电 |
| | | try { |
| | | BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class); |
| | | if (shuttleService == null) { |
| | | return false; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | |
| | | BasShuttle basShuttle = shuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", deviceConfig.getDeviceNo())); |
| | | if (basShuttle == null) { |
| | | return false; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | |
| | | Integer chargeLine = basShuttle.getChargeLine(); |
| | | if (chargeLine == null) { |
| | | return false; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | return Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < chargeLine; |
| | | |
| | | boolean chargeResult = Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < chargeLine; |
| | | if (chargeResult) { |
| | | return ShuttleRequireChargeType.FORCE_CHARGE;//需要强制充电 |
| | | } |
| | | |
| | | Integer suggestChargeLine = basShuttle.getSuggestChargeLine(); |
| | | if (suggestChargeLine == null) { |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | |
| | | boolean suggestChargeResult = Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < suggestChargeLine; |
| | | if (suggestChargeResult) { |
| | | return ShuttleRequireChargeType.SUGGEST_CHARGE;//建议充电 |
| | | } |
| | | |
| | | return ShuttleRequireChargeType.NONE; |
| | | } catch (Exception e) { |
| | | return false; |
| | | return ShuttleRequireChargeType.NONE; |
| | | } |
| | | } |
| | | } |