| | |
| | | add(222);add(224);add(227);add(230); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNoWeight1 = new ArrayList<Integer>() {{ |
| | | add(123); |
| | | add(223);add(225);add(228);add(231); |
| | | }}; |
| | | |
| | | public static final ArrayList<Integer> staNoWeight2 = new ArrayList<Integer>() {{ |
| | | add(102);add(105);add(107);add(109); |
| | | add(203);add(205);add(208);add(211); |
| | | }}; |
| | | |
| | | private Integer count=0; |
| | | |
| | | /** |
| | |
| | | return staNosErrList1; |
| | | case 2: |
| | | return staNosErrList2; |
| | | default: |
| | | throw new CoolException("服务器异常"); |
| | | } |
| | | } |
| | | |
| | | private ArrayList<Integer> getStaNoWeight() { |
| | | switch (slave.getId()) { |
| | | case 1: |
| | | return staNoWeight1; |
| | | case 2: |
| | | return staNoWeight2; |
| | | default: |
| | | throw new CoolException("服务器异常"); |
| | | } |
| | |
| | | // updateIoMode(); |
| | | ArrayList<Integer> staNos = getStaNo(); |
| | | ArrayList<Integer> staNosErrList = getStaNoErr(); |
| | | ArrayList<Integer> staNoWeight = getStaNoWeight(); |
| | | int staNoSize = staNos.size(); |
| | | OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (500 * 8)); |
| | | OperateResultExOne<byte[]> resultWeight = siemensS7Net.Read("DB102.0", (short) (10 * 4)); |
| | | |
| | | if (result.IsSuccess) { |
| | | if (result.IsSuccess && resultWeight.IsSuccess) { |
| | | int j = 0; |
| | | for(int i = 0 ; i<staNoSize;i++){ |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | |
| | | int offset = getOffsetFromSiteId(siteId);//取余获得对应db块数据 |
| | | |
| | | staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset)); // 工作号 |
| | | |
| | | if (staNoWeight.contains(siteId)) { |
| | | staProtocol.setWeight(siemensS7Net.getByteTransform().TransInt32(resultWeight.Content, j)); |
| | | j = j + 4; |
| | | } |
| | | staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, offset+ 4)); // 目标站 |
| | | |
| | | status = siemensS7Net.getByteTransform().TransBool(result.Content, offset+ 6, 2); |
| | | |
| | | staProtocol.setAutoing(status[0]); // 自动 |