| | |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | private short heartBeatVal = 1; |
| | | private StaError1 staError1; |
| | | // public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{ |
| | | // |
| | | // }}; |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(101);add(102);add(103); |
| | | add(104);add(105); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{ |
| | | add(1101); |
| | | add(1102); |
| | | add(1103); |
| | | add(1104); |
| | | add(1105); |
| | | add(1106); |
| | | add(1107); |
| | | }}; |
| | | |
| | | |
| | | public static final ArrayList<Integer> BarcodeList1 = new ArrayList<Integer>() {{ |
| | | add(1); add(2);add(3);add(4);add(5); |
| | | add(1); |
| | | }}; |
| | | |
| | | |
| | | |
| | | public static final ArrayList<Integer> staNosErrList1 = new ArrayList<Integer>() {{ |
| | | |
| | | add(102); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNoWeight1 = new ArrayList<Integer>() {{ |
| | | add(101);add(102);add(103);add(104);add(105); |
| | | add(101); |
| | | add(102); |
| | | add(103); |
| | | add(104); |
| | | add(105); |
| | | }}; |
| | | |
| | | |
| | | |
| | | private Integer count=0; |
| | |
| | | * 4.出库模式 |
| | | */ |
| | | public IoModeType ioModeOf2F = IoModeType.NONE; |
| | | // public IoModeType ioMode = IoModeType.NONE; |
| | | public IoModeType ioModeOf4F = IoModeType.NONE; |
| | | // public IoModeType ioMode = IoModeType.NONE; |
| | | |
| | | public SiemensDevpThread(DevpSlave slave) { |
| | | this.slave = slave; |
| | |
| | | throw new CoolException("服务器异常"); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<Integer> getBarcodeList() { |
| | | switch (slave.getId()) { |
| | | case 1: |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 初始化站点状态 |
| | | */ |
| | |
| | | return result; |
| | | } |
| | | |
| | | public static int getOffsetFromSiteId(int siteId) { |
| | | if (siteId < 100 || siteId > 450) { |
| | | throw new IllegalArgumentException("siteId 超出有效范围: " + siteId); |
| | | } |
| | | return (siteId - 100) * 8; |
| | | } |
| | | |
| | | public static int getOffsetFromSiteId2(int siteId) { |
| | | if (siteId < 100 || siteId > 450) { |
| | | throw new IllegalArgumentException("siteId 超出有效范围: " + siteId); |
| | | } |
| | | return (siteId - 100) * 6; |
| | | } |
| | | |
| | | /** |
| | | * 读取状态 ====> 整块plc |
| | |
| | | // // 更新入出库模式 |
| | | // updateIoMode(); |
| | | |
| | | // if (slave.getId()==1) return; |
| | | ArrayList<Integer> staNos = staNos1; |
| | | int staNoSize = staNos1.size(); |
| | | //ArrayList<Integer> staNos = getStaNo(); |
| | | ArrayList<Integer> staNosErrList = getStaNoErr(); |
| | | ArrayList<Integer> staNoWeight = getStaNoWeight(); |
| | | //int staNoSize = staNos.size(); |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNoSize * 8)); |
| | | OperateResultExOne<byte[]> resultWeight = null; |
| | | /*if(staNoWeight.size()>4){ |
| | | resultWeight = siemensS7Net.Read("DB102.0", (short) (8 * 4)); |
| | | }else{ |
| | | resultWeight = siemensS7Net.Read("DB102.0", (short) (4 * 4)); |
| | | } |
| | | OperateResultExOne<byte[]> resultWeight2 = siemensS7Net.Read("DB102.0", (short) (4 * 4));*/ |
| | | |
| | | //if (result.IsSuccess && resultWeight.IsSuccess) { |
| | | if (result.IsSuccess) { |
| | | int j = 0; |
| | | for(int i = 0 ; i<staNoSize;i++){ |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | boolean[] status = null; |
| | | int offset = getOffsetFromSiteId(siteId);//取余获得对应db块数据 |
| | | |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, i * 8)); // 工作号 |
| | | /*if (staNoWeight.contains(siteId)) { |
| | | if(staNoWeight.size() == 4){ |
| | | staProtocol.setWeight(siemensS7Net.getByteTransform().TransInt32(resultWeight2.Content, j)); |
| | | j = j + 4; |
| | | }else{ |
| | | staProtocol.setWeight(siemensS7Net.getByteTransform().TransInt32(resultWeight.Content, j)); |
| | | j = j + 4; |
| | | |
| | | } |
| | | }*/ |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i * 8 + 4)); // 目标站 |
| | | status = siemensS7Net.getByteTransform().TransBool(result.Content, i * 8 + 6, 1); |
| | | |
| | | status = siemensS7Net.getByteTransform().TransBool(result.Content, i * 8 + 6, 1); |
| | | staProtocol.setAutoing(status[0]); // 自动 |
| | | staProtocol.setLoading(status[1]); // 有物 |
| | | staProtocol.setInEnable(status[2]); // 可入 |
| | |
| | | if(write.IsSuccess && write1.IsSuccess){ |
| | | log.error("写入输送线命令成功。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | break; |
| | | } |
| | | else { |
| | | } else { |
| | | writeCount++; |
| | | log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); |
| | | } |