| | |
| | | add(309);add(312); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(302);add(304); |
| | | add(305);add(306); |
| | | add(307);add(308); |
| | | add(310);add(311); |
| | | add(312);add(313); |
| | | add(314);add(315); |
| | | add(316);add(318); |
| | | add(319);add(320); |
| | | add(321);add(322); |
| | | add(323);add(324); |
| | | add(326);add(327); |
| | | add(328);add(329); |
| | | add(330);add(332); |
| | | add(334);add(335); |
| | | add(336);add(337); |
| | | add(338);add(342); |
| | | add(343);add(344); |
| | | }}; |
| | | |
| | | //高低信号站点 |
| | | public static final ArrayList<Integer> locType1StaNos = new ArrayList<Integer>() {{ |
| | | add(100);add(103); |
| | |
| | | for (Integer staNo : outInAlarmStaNos) { |
| | | OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB" + staNo + ".20.0", (short) 2); |
| | | if (result5.IsSuccess) { |
| | | if (staNo == 101 || staNo == 201) { |
| | | staNo--; |
| | | }else { |
| | | staNo++; |
| | | } |
| | | StaProtocol staProtocol = station.get(staNo); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 2); |
| | | staProtocol.setBarcodeErr(status[4]);//扫码失败 |
| | |
| | | staProtocol.setWeightErr(status[13]);//超重 |
| | | } |
| | | } |
| | | |
| | | // Thread.sleep(100); |
| | | // for (Integer staNo : staNos2) { |
| | | // OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB" + staNo + ".0", (short) 48); |
| | | // if (result5.IsSuccess) { |
| | | // StaProtocol staProtocol = station.get(staNo); |
| | | // if (null == staProtocol) { |
| | | // staProtocol = new StaProtocol(); |
| | | // staProtocol.setSiteId(staNo); |
| | | // station.put(staNo, staProtocol); |
| | | // } |
| | | // |
| | | // boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result5.Content, 8, 1); |
| | | // boolean[] status2 = siemensS7Net.getByteTransform().TransBool(result5.Content, 21, 1); |
| | | // staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, 34)); // 工作号 |
| | | // staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, 40)); // 目标站 |
| | | // staProtocol.setAutoing(status1[0]); // 自动 |
| | | // staProtocol.setLoading(status2[2]); // 有物 |
| | | // } |
| | | // } |
| | | |
| | | if (result.IsSuccess && result1.IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId())); |
| | |
| | | int writeCount = 0; |
| | | //任务下发成功标识 |
| | | boolean writeFlag = false; |
| | | while(writeCount < 5){ |
| | | while(writeCount < 1){ |
| | | writeResult = siemensS7Net.Write("DB1000." + index*4, array); // 工作号、目标站 |
| | | if(writeResult.IsSuccess){ |
| | | Thread.sleep(200); |
| | | Thread.sleep(500); |
| | | OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB1000." + index*4, (short)4); |
| | | if(readResult.IsSuccess){ |
| | | short workNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 0); |
| | |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令尝试5次失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol))); |
| | | log.error("写入输送线命令尝试5次失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | |
| | | //重新添加数据到任务队列 |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); |
| | | // //重新添加数据到任务队列 |
| | | // boolean result = MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol)); |
| | | read();//读取1次设备状态 |
| | | return; |
| | | } else { |