| | |
| | | staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+40)); // 目标站 |
| | | } |
| | | } |
| | | Thread.sleep(100); |
| | | Thread.sleep(5000); |
| | | OperateResultExOne<boolean[]> result1 = melsecMcNet.ReadBool("M800", (short) 64); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 1; i <= 7; i++) { |
| | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | DevpSlave slave = new DevpSlave(); |
| | | slave.setIp("192.168.2.125"); |
| | | slave.setIp("192.168.6.21"); |
| | | slave.setPort(6000); |
| | | MelsecDevpThread devpThread = new MelsecDevpThread(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)); |
| | | |
| | | for (int i = 1; i < 999; i ++) { |
| | | OperateResultExOne<Short> d = devpThread.getMelsecMcNet().ReadInt16("D" + i); |
| | | Thread.sleep(200); |
| | | if (d.IsSuccess) { |
| | | System.out.println(DateUtils.convert(new Date()) + d.Content); |
| | | } else { |
| | | System.out.println("读取失败"); |
| | | } |
| | | } |
| | | devpThread.getMelsecMcNet().ConnectClose(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |