| | |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse clearTaskBufferSlot(Integer deviceNo, Integer stationId, Integer slotIdx) { |
| | | CommandResponse commandResponse = new CommandResponse(false); |
| | | if (stationId == null) { |
| | | commandResponse.setMessage("站点号为空"); |
| | | return commandResponse; |
| | | } |
| | | if (slotIdx == null || slotIdx <= 0 || slotIdx > TASK_AREA_SLOT_COUNT) { |
| | | commandResponse.setMessage("缓存区槽位无效"); |
| | | return commandResponse; |
| | | } |
| | | |
| | | getStatus(deviceNo); |
| | | |
| | | int stationIdx = findIndex(stationId); |
| | | if (stationIdx < 0) { |
| | | commandResponse.setMessage("未找到站点状态"); |
| | | return commandResponse; |
| | | } |
| | | |
| | | int slotBaseOffset = stationIdx * TASK_AREA_LENGTH + slotIdx * TASK_AREA_SLOT_SIZE; |
| | | CommandResponse clearTaskNo = sendOriginCommand("DB13." + slotBaseOffset, new short[]{0, 0}); |
| | | if (clearTaskNo == null || !Boolean.TRUE.equals(clearTaskNo.getResult())) { |
| | | commandResponse.setMessage(clearTaskNo == null ? "清空任务号失败" : clearTaskNo.getMessage()); |
| | | return commandResponse; |
| | | } |
| | | |
| | | CommandResponse clearTarget = sendOriginCommand("DB13." + (slotBaseOffset + 6), new short[]{0}); |
| | | if (clearTarget == null || !Boolean.TRUE.equals(clearTarget.getResult())) { |
| | | commandResponse.setMessage(clearTarget == null ? "清空目标站失败" : clearTarget.getMessage()); |
| | | return commandResponse; |
| | | } |
| | | |
| | | commandResponse.setResult(true); |
| | | commandResponse.setMessage("缓存区槽位清理成功"); |
| | | return commandResponse; |
| | | } |
| | | |
| | | @Override |
| | | public synchronized CommandResponse sendOriginCommand(String address, short[] data) { |
| | | CommandResponse commandResponse = new CommandResponse(false); |
| | | if (null == data || data.length == 0) { |