| | |
| | | add(200);add(201);add(202);add(203);add(204);add(205); |
| | | }}; |
| | | |
| | | public static void main(String[] args) { |
| | | for (Integer siteId : staNos) { |
| | | int divides = (int) Arith.divides(0, siteId, 100); |
| | | int remainder = (int) Arith.remainder(siteId, 100); |
| | | int index = ((divides - 1) * 50) + remainder; |
| | | // System.out.print(siteId + " 任务地址 : " + index*2); |
| | | // System.out.print(" 目标地址 : " + (index*2+200) ); |
| | | System.out.println(siteId + " 状态 : " + (index*2) ); |
| | | } |
| | | } |
| | | |
| | | public SiemensDevpThread(DevpSlave slave) { |
| | | this.slave = slave; |
| | | } |
| | |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | // 心跳 |
| | | heartbeat(); |
| | | // heartbeat(); |
| | | Thread.sleep(400); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | siemensS7Net.ConnectClose(); |
| | | } |
| | | |
| | | // public static void main(String[] args) throws Exception { |
| | | // DevpSlave slave = new DevpSlave(); |
| | | // slave.setIp("192.168.2.125"); |
| | | // SiemensDevpThread devpThread = new SiemensDevpThread(slave); |
| | | // devpThread.connect(); |
| | | // devpThread.read(); |
| | | // // 写 |
| | | // StaProtocol staProtocol = devpThread.getStation().get(1); |
| | | // staProtocol.setWorkNo((short) 232); |
| | | // staProtocol.setStaNo((short) 6); |
| | | // staProtocol.setAutoing(true); |
| | | // staProtocol.setEmptyMk(true); |
| | | // staProtocol.setInEnable(true); |
| | | // devpThread.write(staProtocol); |
| | | // System.out.println("----------------------------------------"); |
| | | // // 读 |
| | | // devpThread.read(); |
| | | // System.out.println(JSON.toJSONString(devpThread.station)); |
| | | // |
| | | // } |
| | | public static void main(String[] args) throws Exception { |
| | | DevpSlave slave = new DevpSlave(); |
| | | slave.setIp("192.168.2.125"); |
| | | SiemensDevpThread devpThread = new SiemensDevpThread(slave); |
| | | devpThread.connect(); |
| | | devpThread.read(); |
| | | // 写 |
| | | StaProtocol staProtocol = devpThread.getStation().get(1); |
| | | staProtocol.setWorkNo((short) 232); |
| | | staProtocol.setStaNo((short) 6); |
| | | staProtocol.setAutoing(true); |
| | | staProtocol.setEmptyMk(true); |
| | | staProtocol.setInEnable(true); |
| | | devpThread.write(staProtocol); |
| | | System.out.println("----------------------------------------"); |
| | | // 读 |
| | | devpThread.read(); |
| | | System.out.println(JSON.toJSONString(devpThread.station)); |
| | | |
| | | } |
| | | |
| | | } |