| | |
| | | } |
| | | } |
| | | } |
| | | // 侧面出库,给输送线写条码 |
| | | Short staNo = staProtocol.getStaNo(); |
| | | String barcode = staProtocol.getBarcode(); |
| | | if (staNo == 203 || staNo == 207 || staNo == 212) { |
| | | if (Cools.isEmpty(barcode)) { |
| | | log.error("侧面出库到:{}站点,条码值为空,任务号:{}", staNo, staProtocol.getWorkNo()); |
| | | } else { |
| | | |
| | | String[] split = barcode.split("#"); |
| | | int offset = 48 + (staNo - 201) * 24; |
| | | byte[] bytes = new byte[(split.length + 1) * 6]; |
| | | for (int j = 0, k = 0; j < split.length; j++) { |
| | | String s = split[j]; |
| | | for (int m = 0; m < s.length(); m++) { |
| | | bytes[k++] = (byte) s.charAt(m); |
| | | } |
| | | } |
| | | |
| | | OperateResult writeResult4 = siemensS7Net.Write("DB79" + offset, bytes); |
| | | if (writeResult4.IsSuccess) { |
| | | log.info("侧面出库到:{}站点,给输送线写条码:{}成功", staNo, barcode); |
| | | } else { |
| | | log.error("侧面出库到:{}站点,给输送线写条码:{}失败", staNo, barcode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | OperateResult writeResult1 = siemensS7Net.Write(workNoAddress, staProtocol.getWorkNo()); // 工作号 |
| | | OperateResult writeResult2 = siemensS7Net.Write(staNoAddress, staProtocol.getStaNo()); // 目标站 |
| | | if (writeResult1.IsSuccess && writeResult2.IsSuccess) { |
| | |
| | | public void close() { |
| | | siemensS7Net.ConnectClose(); |
| | | } |
| | | public static void main(String[] args) throws Exception { |
| | | DevpSlave slave = new DevpSlave(); |
| | | slave.setIp("10.49.210.41"); |
| | | // SiemensDevpThread devpThread = new SiemensDevpThread(slave); |
| | | // devpThread.connect(); |
| | | SiemensS7Net siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp()); |
| | | siemensS7Net.setRack(slave.getRack().byteValue()); |
| | | siemensS7Net.setSlot(slave.getSlot().byteValue()); |
| | | OperateResult connect = siemensS7Net.ConnectServer(); |
| | | // 侧面出库,给输送线写条码 |
| | | Short staNo = 212; |
| | | String barcode = "800001#123456#811112#811113"; |
| | | |
| | | |
| | | String[] split = barcode.split("#"); |
| | | int offset = 48 + (staNo - 201) * 24; |
| | | byte[] bytes = new byte[(split.length + 1) * 6]; |
| | | for (int j = 0, k = 0; j < split.length; j++) { |
| | | String s = split[j]; |
| | | for (int m = 0; m < s.length(); m++) { |
| | | bytes[k++] = (byte) s.charAt(m); |
| | | } |
| | | } |
| | | |
| | | OperateResult writeResult4 = siemensS7Net.Write("DB79" + offset, bytes); |
| | | if (writeResult4.IsSuccess) { |
| | | log.info("侧面出库到:{}站点,给输送线写条码:{}成功", staNo, barcode); |
| | | } else { |
| | | log.error("侧面出库到:{}站点,给输送线写条码:{}失败", staNo, barcode); |
| | | } |
| | | |
| | | // devpThread.write2(0); |
| | | // devpThread.read(); |
| | | // // 写 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(1); |
| | | // staProtocol.setWorkNo((short) 232); |
| | | // staProtocol.setStaNo((short) 6); |
| | | // staProtocol.setAutoing(true); |
| | | // staProtocol.setEmptyMk(true); |
| | | // staProtocol.setInEnable(true); |
| | | // devpThread.write(staProtocol); |
| | | // System.out.println("----------------------------------------"); |
| | | // // 读 |
| | | // devpThread.read(); |
| | | // System.out.println(JSON.toJSONString(devpThread.station)); |
| | | |
| | | } |
| | | |
| | | } |