| | |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { |
| | | log.error("-------------------------------------------第一步、[堆垛机号:{}][工作号:{}]==>> 状态为90,等待确认!!",slave.getId(),crnProtocol.getTaskNo()); |
| | | if (resetFlag) { |
| | | if (melsecMcNet.Write("D2218", (short) 1).IsSuccess) { |
| | | CrnCommand crnCommand = new CrnCommand(); |
| | | crnCommand.setAckFinish((short)1); |
| | | if (write(crnCommand)) { |
| | | resetFlag = false; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * 写入数据 |
| | | */ |
| | | private void write(CrnCommand command){ |
| | | private boolean write(CrnCommand command){ |
| | | if (null == command) { |
| | | log.error("堆垛机写入命令为空"); |
| | | return; |
| | | return false; |
| | | } |
| | | command.setCrnNo(slave.getId()); |
| | | short[] array = new short[10]; |
| | | 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(); // 目标位置站号 |
| | | OperateResult result = melsecMcNet.Write("100", array); |
| | | |
| | | OperateResult result; |
| | | if (command.getAckFinish() == 0) { |
| | | array[0] = command.getAckFinish(); |
| | | array[1] = command.getTaskNo(); |
| | | array[2] = command.getTaskMode(); |
| | | array[3] = command.getSourcePosX(); |
| | | array[4] = command.getSourcePosY(); |
| | | array[5] = command.getSourcePosZ(); |
| | | array[6] = command.getDestinationPosX(); |
| | | array[7] = command.getDestinationPosY(); |
| | | array[8] = command.getDestinationPosZ(); |
| | | array[9] = command.getCommand(); |
| | | result = melsecMcNet.Write("D0", array); |
| | | |
| | | short[] array0 = new short[1]; |
| | | array0[0] = 1; |
| | | result = melsecMcNet.Write("D9", array); |
| | | |
| | | } else { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | try { |
| | | // 日志记录 |
| | |
| | | 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 true; |
| | | } 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()); |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |