| | |
| | | return; |
| | | } |
| | | command.setCrnNo(slave.getId()); |
| | | /* 方法 1 */ |
| | | do { |
| | | if (command.getDestinationPosZ() != null) { |
| | | if (!melsecMcNet.Write("D2202", command.getDestinationPosZ()).IsSuccess) { break; } |
| | | } |
| | | if (command.getDestinationPosY() != null) { |
| | | if (!melsecMcNet.Write("D2204", command.getDestinationPosY()).IsSuccess) { break; } |
| | | } |
| | | if (command.getDestinationPosX() != null) { |
| | | if (!melsecMcNet.Write("D2208", command.getDestinationPosX()).IsSuccess) { break; } |
| | | } |
| | | if (command.getSourcePosZ() != null) { |
| | | if (!melsecMcNet.Write("D2210", command.getSourcePosZ()).IsSuccess) { break; } |
| | | } |
| | | if (command.getSourcePosY() != null) { |
| | | if (!melsecMcNet.Write("D2212", command.getSourcePosY()).IsSuccess) { break; } |
| | | } |
| | | if (command.getDestinationPosX() != null) { |
| | | if (!melsecMcNet.Write("D2214", command.getSourcePosX()).IsSuccess) { break; } |
| | | } |
| | | if (command.getTaskMode() != null) { |
| | | if (!melsecMcNet.Write("D2216", command.getTaskMode()).IsSuccess) { break; } |
| | | } |
| | | if (command.getTaskNo() != null) { |
| | | if (!melsecMcNet.Write("D2217", command.getTaskNo()).IsSuccess) { break; } |
| | | } |
| | | if (command.getAckFinish() != null) { |
| | | if (!melsecMcNet.Write("D2218", command.getAckFinish()).IsSuccess) { break; } |
| | | } |
| | | short[] array = new short[9]; |
| | | array[0] = command.getStatus(); |
| | | array[1] = command.getSourceRow(); // 排 |
| | | array[2] = command.getSourceBay(); // 列 |
| | | array[3] = command.getSourceLev(); // 层 |
| | | array[4] = command.getSourceSta(); // 站号 |
| | | array[5] = command.getDestinationPosRow(); // 排 |
| | | array[6] = command.getDestinationPosBay(); // 列 |
| | | array[7] = command.getDestinationPosLev(); // 层 |
| | | array[8] = command.getDestinationSta(); // 目标位置站号 |
| | | |
| | | try { |
| | | // 日志记录 |
| | |
| | | bean.insert(basCrnOpt); |
| | | } catch (Exception ignore) {} |
| | | |
| | | OperateResult result = melsecMcNet.Write("100", array); |
| | | if (result.IsSuccess) { |
| | | log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); |
| | | |
| | | return; |
| | | } while (false); |
| | | |
| | | |
| | | System.out.println(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | } else { |
| | | OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | |
| | | |
| | | |
| | | /* 方法 2 */ |
| | | // melsecMcNet.Write("D2218", command.getAckFinish()); |
| | | // melsecMcNet.Write("D2217", command.getTaskNo()); |
| | | // melsecMcNet.Write("D2216", command.getTaskMode()); |
| | | // melsecMcNet.Write("D2214", command.getSourcePosX()); |
| | | // melsecMcNet.Write("D2212", command.getSourcePosY()); |
| | | // melsecMcNet.Write("D2210", command.getSourcePosZ()); |
| | | // melsecMcNet.Write("D2208", command.getDestinationPosX()); |
| | | // melsecMcNet.Write("D2204", command.getDestinationPosY()); |
| | | // melsecMcNet.Write("D2202", command.getDestinationPosZ()); |
| | | } |
| | | |
| | | } |
| | | |