| | |
| | | private short heartBeatVal = 1; |
| | | |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(101);add(102);add(103);add(104); |
| | | add(201);add(202);add(203);add(204); |
| | | add(301);add(302);add(303);add(304);add(305);add(306); |
| | | add(100);add(101);add(102);add(103);add(104); |
| | | add(105);add(106);add(107); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(401);add(402); |
| | | // add(401);add(402); |
| | | }}; |
| | | |
| | | private Integer count=0; |
| | |
| | | * 3.出库启动中 (不能生成入库工作档) |
| | | * 4.出库模式 |
| | | */ |
| | | public IoModeType ioModeOf1F = IoModeType.NONE; |
| | | public IoModeType ioModeOf2F = IoModeType.NONE; |
| | | // public IoModeType ioMode = IoModeType.NONE; |
| | | public IoModeType ioModeOf3F = IoModeType.NONE; |
| | | public IoModeType ioModeOf4F = IoModeType.NONE; |
| | | // public IoModeType ioMode = IoModeType.NONE; |
| | | |
| | |
| | | } |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4)); // 工作号 |
| | | |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2)); // 目标站 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2)); // 目标站 |
| | | } |
| | | } |
| | | // Thread.sleep(200); |
| | | // OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186); |
| | | Thread.sleep(200); |
| | | // OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB100.2", (short) (staNoSize*2)); |
| | | // if (result0.IsSuccess) { |
| | | // for (int i = 0; i < 93; i++) { |
| | | // for (int i = 0; i < staNoSize; i++) { |
| | | // Integer siteId = staNos.get(i); // 站点编号 |
| | | // StaProtocol staProtocol = station.get(siteId); |
| | | // if (null == staProtocol) { |
| | |
| | | // staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2)); // 目标站 |
| | | // } |
| | | // } |
| | | Thread.sleep(200); |
| | | // Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result1 = null; |
| | | if(slave.getId()==1) { |
| | | result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize)); |
| | | result1 = siemensS7Net.Read("DB102.0", (short) (staNoSize*2)); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i, 1); |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | |
| | | } |
| | | } |
| | | } else if(slave.getId()==2) { |
| | | result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2)); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i * 2, 1); |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | | staProtocol.setOutEnable(status[3]);// 可出 |
| | | staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | staProtocol.setHigh(status[6]); // 高库位 |
| | | staProtocol.setLow(status[7]); // 低库位 |
| | | |
| | | if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | count = 0; |
| | | } |
| | | // result1 = siemensS7Net.Read("DB100.100", (short) (staNoSize * 2)); |
| | | // if (result1.IsSuccess) { |
| | | // for (int i = 0; i < staNoSize; i++) { |
| | | // Integer siteId = staNos.get(i); // 站点编号 |
| | | // boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i * 2, 1); |
| | | // StaProtocol staProtocol = station.get(siteId); |
| | | // staProtocol.setAutoing(status[0]); // 自动 |
| | | // staProtocol.setLoading(status[1]); // 有物 |
| | | // staProtocol.setInEnable(status[2]); // 可入 |
| | | // staProtocol.setOutEnable(status[3]);// 可出 |
| | | // staProtocol.setEmptyMk(status[4]); // 空板信号 |
| | | // staProtocol.setFullPlt(status[5]); // 满托盘 |
| | | // staProtocol.setHigh(status[6]); // 高库位 |
| | | // staProtocol.setLow(status[7]); // 低库位 |
| | | // |
| | | // if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { |
| | | // staProtocol.setPakMk(true); |
| | | // } |
| | | // } |
| | | // count = 0; |
| | | // } |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | if(slave.getId()==1) { |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.150", (short) (barcodeSize * 8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB102.40", (short) (barcodeSize * 8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } else if(slave.getId()==2) { |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.150", (short) (1 * 8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < 1; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 4); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | |
| | | short[] array = new short[2]; |
| | | array[0] = staProtocol.getWorkNo(); |
| | | array[1] = staProtocol.getStaNo(); |
| | | OperateResult write = siemensS7Net.Write("DB100." + index*4, array); |
| | | OperateResult write = siemensS7Net.Write("DB100." + index*4, array); |
| | | |
| | | // OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo()); // 工作号 |
| | | // OperateResult write = siemensS7Net.Write("DB100.0" + index*4, staProtocol.getWorkNo()); // 工作号 |
| | | // Thread.sleep(500); |
| | | // OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo()); // 目标站 |
| | | // OperateResult write1 = siemensS7Net.Write("DB100.2" + index*4+2, staProtocol.getStaNo()); // 目标站 |
| | | |
| | | if (!write.IsSuccess) { |
| | | staProtocol = station.get(staProtocol.getSiteId()); |
| | |
| | | |
| | | // 更新入出库模式 |
| | | private void updateIoMode() throws InterruptedException { |
| | | if (slave.getId()==1 && this.ioModeOf2F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.180", this.ioModeOf2F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线2F入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | if (this.ioModeOf1F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.80", this.ioModeOf1F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F1入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | log.error("写入输送线1F入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | if (this.ioModeOf2F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.82", this.ioModeOf2F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F2入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | log.error("写入输送线2F入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | if (slave.getId()==2 && this.ioModeOf4F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.170", this.ioModeOf4F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线4F入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | if (this.ioModeOf3F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.84", this.ioModeOf3F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F3入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | log.error("写入输送线3F入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | if (this.ioModeOf4F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.86", this.ioModeOf4F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线F4入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | log.error("写入输送线4F入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |