| | |
| | | // 写数据 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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) { |