| | |
| | | add(211);add(212);add(213);add(214);add(215);add(216);add(217);add(218);add(219);add(220); |
| | | add(221);add(222);add(224);add(225); |
| | | }}; |
| | | public static final ArrayList<Integer> staNos1W = new ArrayList<Integer>() {{ |
| | | add(118);add(121);add(124); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos2W = new ArrayList<Integer>() {{ |
| | | add(218);add(221);add(224); |
| | | }}; |
| | | private boolean connectDev = false; |
| | | public Long currentTimeMilliConnectDev= 0L; |
| | | |
| | |
| | | return staNos1; |
| | | case 2: |
| | | return staNos2; |
| | | default: |
| | | throw new CoolException("服务器异常"); |
| | | } |
| | | } |
| | | private ArrayList<Integer> getStaNoW() { |
| | | switch (slave.getId()) { |
| | | case 1: |
| | | return staNos1W; |
| | | case 2: |
| | | return staNos2W; |
| | | default: |
| | | throw new CoolException("服务器异常"); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | int[] staW = new int[]{1004,1014,1020}; |
| | | ArrayList<Integer> staW = getStaNoW(); |
| | | |
| | | //条码 |
| | | // Thread.sleep(50); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB400.100.0",(short) (barcodeSize*8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.212",(short) (barcodeSize*8)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | Integer siteId = staW[i]; // 站点编号 |
| | | Integer siteId = staW.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1+3*slave.getId()); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | if (!Cools.isEmpty(barcode) && !barcode.equals("000000")){ |
| | | if (!Cools.isEmpty(barcode) && !barcode.equals("00000000")){ |
| | | staProtocol.setBarcodeNow(barcode); |
| | | } else if (Cools.isEmpty(barcode)){ |
| | | staProtocol.setBarcodeNow("-"); |
| | |
| | | //条码 |
| | | // Thread.sleep(50); |
| | | |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB400.148.0",(short) (staW.length*4)); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.200",(short) (staW.size()*4)); |
| | | if (result3.IsSuccess) { |
| | | for (int i = 0; i < staW.length; i++) { |
| | | Integer siteId = staW[i]; // 站点编号 |
| | | for (int i = 0; i < staW.size(); i++) { |
| | | Integer siteId = staW.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | |
| | | //任务下发成功标识 |
| | | boolean writeFlag = false; |
| | | while(writeCount < 5){ |
| | | OperateResult writeResult1 = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 工作号 |
| | | OperateResult writeResult2 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo().shortValue()); // 目标站 |
| | | OperateResult writeResult1 = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 工作号 |
| | | if(writeResult1.IsSuccess && writeResult2.IsSuccess){ |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100.0" + index*6, (short)4); |
| | |
| | | |
| | | //更新任务步序 |
| | | TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); |
| | | TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo()); |
| | | TaskWrk taskWrk = taskWrkService.selectByTaskNo(staProtocol.getWorkNo()); |
| | | if (taskWrk != null) { |
| | | taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//更新指令步序 |
| | | taskWrkService.updateById(taskWrk); |