| | |
| | | private MelsecMcNet melsecMcNet; |
| | | private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>(); |
| | | private short heartBeatVal = 1; |
| | | public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{ |
| | | add(101);add(102);add(103);add(104);add(105);add(106);add(107); |
| | | }}; |
| | | |
| | | public MelsecDevpThread(DevpSlave slave) { |
| | | this.slave = slave; |
| | |
| | | private void read() throws InterruptedException { |
| | | OperateResultExOne<byte[]> result = melsecMcNet.Read("DB100.0", (short) 40); |
| | | if (result.IsSuccess) { |
| | | for (int i = 1; i <= 8; i++) { |
| | | StaProtocol staProtocol = station.get(i); |
| | | for (int i = 1; i <= 7; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | | StaProtocol staProtocol = station.get(siteId); |
| | | if (null == staProtocol) { |
| | | staProtocol = new StaProtocol(); |
| | | staProtocol.setSiteId(i); |
| | | station.put(i, staProtocol); |
| | | staProtocol.setSiteId(siteId); |
| | | station.put(siteId, staProtocol); |
| | | } |
| | | |
| | | staProtocol.setWorkNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2)); // 工作号 |
| | | staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+20)); // 目标站 |
| | | } |