| | |
| | | add(1006); |
| | | add(1007); |
| | | |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | |
| | | add(101); |
| | | add(102); |
| | | add(103); |
| | |
| | | // 写数据 ID+目标站 |
| | | case 2: |
| | | write((StaProtocol) task.getData()); |
| | | log.error("输送线下发命令:" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo()); |
| | | log.info("输送线下发命令:" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo()); |
| | | break; |
| | | // 写数据 ID+目标站 |
| | | case 3: |
| | | write2((StaProtocol) task.getData()); |
| | | log.info("输送线下发命令3:"); |
| | | break; |
| | | case 4: |
| | | write4((StaProtocol) task.getData()); |
| | | log.info("输送线下发命令4:"); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } |
| | | ArrayList<Integer> staNosxx = staNos2; |
| | | int size = staNosxx.size(); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.14", (short) (size * 2)); |
| | | if (result3.IsSuccess) { |
| | | for (int i = 0; i < size; i++) { |
| | | Integer siteId = staNosxx.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | boolean[] status = null; |
| | | status = siemensS7Net.getByteTransform().TransBool(result3.Content, i * 2, 2); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB102.0", (short) 2); |
| | | if (result4.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1); |
| | | if (status[0] && status[1]) { |
| | | StaProtocol staProtocol = station.get(1007); |
| | | MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol)); |
| | | log.info("复位1007"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private void write2(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | return; |
| | | } |
| | | OperateResult write = null; |
| | | boolean[] array = new boolean[1]; |
| | | array[0] = true; |
| | | //任务下发次数 |
| | | int writeCount = 0; |
| | | do { |
| | | write = siemensS7Net.Write("DB102.0", array); |
| | | if (write.IsSuccess) { |
| | | log.error("写入输送线DB102.0命令成功3。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | break; |
| | | } else { |
| | | writeCount++; |
| | | log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | } |
| | | } while (writeCount < 5); |
| | | |
| | | if (!write.IsSuccess) { |
| | | News.error("SiemensDevp" + " - 4" + " - 写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } |
| | | } |
| | | |
| | | private void write4(StaProtocol staProtocol) throws InterruptedException { |
| | | if (null == staProtocol) { |
| | | return; |
| | | } |
| | | OperateResult write = null; |
| | | boolean[] array = new boolean[2]; |
| | | array[0] = false; |
| | | array[1] = false; |
| | | //任务下发次数 |
| | | int writeCount = 0; |
| | | do { |
| | | write = siemensS7Net.Write("DB102.0", array); |
| | | if (write.IsSuccess) { |
| | | log.error("44写入输送线DB102.0命令成功3。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | break; |
| | | } else { |
| | | writeCount++; |
| | | log.error("44写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | } |
| | | } while (writeCount < 5); |
| | | |
| | | if (!write.IsSuccess) { |
| | | News.error("SiemensDevp" + " - 4" + " - 写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol)); |
| | | } |
| | | } |
| | | |
| | | // 更新入出库模式 |
| | | private void updateIoMode() throws InterruptedException { |
| | | if (this.ioModeOf2F != IoModeType.NONE) { |