| | |
| | | } |
| | | |
| | | // 心跳 |
| | | heartbeat(); |
| | | // heartbeat(); |
| | | Thread.sleep(400); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setWorkNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i)*2)); // 工作号 |
| | | short workNo = melsecMcNet.getByteTransform().TransInt16(result.Content, (i) * 2); |
| | | staProtocol.setWorkNo(workNo==-1?0:workNo); // 工作号 |
| | | staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i)*2+40)); // 目标站 |
| | | } |
| | | } |
| | | Thread.sleep(3000); |
| | | Thread.sleep(200); |
| | | OperateResultExOne<boolean[]> result1 = melsecMcNet.ReadBool("M800", (short) 64); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 0; i < staNos.size(); i++) { |
| | |
| | | return; |
| | | } |
| | | System.out.println(); |
| | | OperateResult write = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+1), 2), staProtocol.getWorkNo()); // 工作号 |
| | | Thread.sleep(400); |
| | | OperateResult write1 = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+21), 2), staProtocol.getStaNo()); // 目标站 |
| | | Thread.sleep(200); |
| | | OperateResult write = melsecMcNet.Write("D1" + Utils.zerofill(String.valueOf(staNos.indexOf(staProtocol.getSiteId())+1), 2), staProtocol.getWorkNo()); // 工作号 |
| | | if (!write.IsSuccess || !write1.IsSuccess) { |
| | | staProtocol = station.get(staProtocol.getSiteId()); |
| | | if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) { |
| | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } else { |
| | | log.error("-------------------------------------------第三步、[站点号:{}][工作号:{}]==>> 下发输送线启动信号成功!!",staProtocol.getSiteId(),staProtocol.getWorkNo()); |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } |