| | |
| | | */ |
| | | public IoModeType ioModeOf1F = IoModeType.NONE; |
| | | public IoModeType ioModeOf2F = IoModeType.NONE; |
| | | public IoModeType ioModeOf3F = IoModeType.NONE; |
| | | public short ioModeOf3FX = 0; |
| | | public short ioModeOf3FD = 0; |
| | | public IoModeType ioModeOf4F = IoModeType.NONE; |
| | | public short ioModeOf4FX = 0; |
| | | public short ioModeOf4FD = 0; |
| | | |
| | | private ArrayList<Integer> getStaNo() { |
| | | switch (slave.getId()) { |
| | |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2)); // 目标站 |
| | | } |
| | | } |
| | | if (slave.getId()!=1){ |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2F = siemensS7Net.Read("DB102.50", (short) (4)); |
| | | if (result2F.IsSuccess) { |
| | | if (slave.getId()==2){ |
| | | this.ioModeOf3FX = siemensS7Net.getByteTransform().TransInt16(result2F.Content, 0); |
| | | this.ioModeOf3FD = siemensS7Net.getByteTransform().TransInt16(result2F.Content, 2); |
| | | } if (slave.getId()==3){ |
| | | this.ioModeOf4FX = siemensS7Net.getByteTransform().TransInt16(result2F.Content, 0); |
| | | this.ioModeOf4FD = siemensS7Net.getByteTransform().TransInt16(result2F.Content, 2); |
| | | } |
| | | } |
| | | } |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.0", (short) (staNos.size()*2)); |
| | | if (result1.IsSuccess) { |
| | |
| | | |
| | | //读条码 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.100",(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 (slave.getId()==1){ |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.100",(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); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 充电信号位 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.50", (short)1); |
| | | if (result3.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 0, 1); |
| | | charge0 = status[0]; |
| | | charge1 = status[1]; |
| | | charge2 = status[2]; |
| | | } |
| | | } else { |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.100",(short)(8)); |
| | | if (result2.IsSuccess) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,0,8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, slave.getId()+1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 充电信号位 |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB102.50", (short)1); |
| | | if (result3.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, 0, 1); |
| | | charge0 = status[0]; |
| | | charge1 = status[1]; |
| | | charge2 = status[2]; |
| | | } |
| | | |
| | | if (result.IsSuccess && result0.IsSuccess && result1.IsSuccess) { |
| | |
| | | |
| | | // 更新入出库模式 |
| | | private void updateIoMode() throws InterruptedException { |
| | | if (this.ioModeOf1F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.180", this.ioModeOf1F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线103入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | News.error("写入输送线103入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | if (slave.getId()==1){ |
| | | if (this.ioModeOf1F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.180", this.ioModeOf1F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线103入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | // News.error("写入输送线103入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | } |
| | | if (this.ioModeOf2F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.182", this.ioModeOf2F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线203入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | News.error("写入输送线203入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | if (this.ioModeOf2F != IoModeType.NONE) { |
| | | if (!siemensS7Net.Write("DB100.182", this.ioModeOf2F.id).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线203入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | // News.error("写入输送线203入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | } else if (slave.getId()==2){ |
| | | if (this.ioModeOf3F != IoModeType.NONE && this.ioModeOf3F.id/2 != this.ioModeOf3FX) { |
| | | if (!siemensS7Net.Write("DB102.50", (short) (this.ioModeOf3F.id/2)).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线113入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | // News.error("写入输送线113入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | } else if (slave.getId()==3){ |
| | | if (this.ioModeOf4F != IoModeType.NONE && this.ioModeOf4F.id/2 != this.ioModeOf4FX) { |
| | | if (!siemensS7Net.Write("DB102.50", (short) (this.ioModeOf4F.id/2)).IsSuccess) { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线213入出库模式失败。输送线plc编号={1}", slave.getId())); |
| | | // News.error("写入输送线213入出库模式失败。输送线plc编号={}", slave.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |