| | |
| | | // |
| | | // }}; |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(100);add(101);add(102);add(103);add(104); |
| | | add(200);add(201);add(202);add(203);add(204); |
| | | add(100); |
| | | add(101); |
| | | add(102); |
| | | add(103); |
| | | add(104); |
| | | add(200); |
| | | add(201); |
| | | add(202); |
| | | add(203); |
| | | add(204); |
| | | }}; |
| | | public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{ |
| | | add(300);add(301);add(302);add(303);add(304); |
| | | add(311);add(312);add(313);add(314);add(315); |
| | | add(300); |
| | | add(301); |
| | | add(302); |
| | | add(303); |
| | | add(304); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos3 = new ArrayList<Integer>() {{ |
| | | add(311); |
| | | add(312); |
| | | add(313); |
| | | add(314); |
| | | add(315); |
| | | }}; |
| | | |
| | | |
| | | public static final ArrayList<Integer> barcode1 = new ArrayList<Integer>() {{ |
| | | add(1); add(2); |
| | | add(1); |
| | | add(2); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> barcode2 = new ArrayList<Integer>() {{ |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化站点状态 |
| | | */ |
| | |
| | | // log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | |
| | | // |
| | | OperateResultExOne<byte[]> resultsanqi = siemensS7Net.Read("DB101.120", (short) (staNoSize * 8)); |
| | | if (resultsanqi.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(resultsanqi.Content, i * 8)); // 工作号 |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(resultsanqi.Content, i * 8 + 4)); // 目标站 |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultsanqi.Content, i * 8 + 6, 1); |
| | | 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]); // 低库位 |
| | | // staProtocol.setWeight(status[8]); //是否为重货 |
| | | if (!staProtocol.isPakMk() && staProtocol.isLoading()) { |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | } |
| | | } else { |
| | | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】读取输送线plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); |
| | | // log.error("读取输送线plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | |
| | | |
| | | //外形检测 |
| | | OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB101.42", (short) 8); |
| | | if (resultErr.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, 0, 1); |
| | | StaProtocol staProtocol = station.get(304); |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | | staProtocol.setHighErr(status[2]); |
| | | staProtocol.setLeftErr(status[3]); |
| | | staProtocol.setRightErr(status[4]); |
| | | staProtocol.setWeightErr(status[5]); |
| | | staProtocol.setBarcodeErr(status[6]); |
| | | } |
| | | |
| | | |
| | | //外形检测 三期 |
| | | OperateResultExOne<byte[]> resultErrsanqi = siemensS7Net.Read("DB101.160", (short) 8); |
| | | if (resultErrsanqi.IsSuccess) { |
| | | boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErrsanqi.Content, 0, 1); |
| | | StaProtocol staProtocol = station.get(304); |
| | | staProtocol.setFrontErr(status[0]); |
| | | staProtocol.setBackErr(status[1]); |
| | |
| | | for (int i = 0; i < barcodeList.size(); i++) { |
| | | Integer barcodeId = barcodeList.get(i); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //条码扫描器 三期 |
| | | Thread.sleep(200); |
| | | ArrayList<Integer> barcodeListsanqi = getBarcodeList(); |
| | | OperateResultExOne<byte[]> result2siqi = siemensS7Net.Read("DB101.60", (short) (barcodeListsanqi.size() * 8)); |
| | | if (result2siqi.IsSuccess) { |
| | | for (int i = 0; i < barcodeList.size(); i++) { |
| | | Integer barcodeId = barcodeListsanqi.get(i); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2siqi.Content, i * 8, 8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId); |
| | | if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | OperateResult write = null; |
| | | OperateResult write1 = null; |
| | | int index = staNos.indexOf(staProtocol.getSiteId()); |
| | | int index; |
| | | if (staProtocol.getSiteId() >= 310) { |
| | | index = staNos3.indexOf(staProtocol.getSiteId()); |
| | | index = index + 54; |
| | | } else { |
| | | index = staNos.indexOf(staProtocol.getSiteId()); |
| | | } |
| | | |
| | | //// 写2号输送线 |
| | | //if (slave.getId() == 1) { |
| | |
| | | // System.out.println(staNos1.indexOf(129)); |
| | | // System.out.println(staNos1.size()); |
| | | // for (int i = 0; i<staNos1.size(); i++) { |
| | | |
| | | //// System.out.println(i*2); |
| | | //// System.out.println(i*2 + 200); |
| | | //// System.out.println(i); |
| | |
| | | // System.out.println(index*2); |
| | | // System.out.println(index*2 + 200); |
| | | // } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | DevpSlave slave = new DevpSlave(); |
| | | slave.setId(1); |