| | |
| | | OperateResult connect = siemens_net.ConnectServer(); |
| | | if(connect.IsSuccess){ |
| | | System.out.println("connect success!"); |
| | | } |
| | | else { |
| | | } else { |
| | | System.out.println("failed:"+connect.Message); |
| | | } |
| | | siemens_net.ConnectClose(); |
| | |
| | | |
| | | MelsecMcAsciiNet melsec = new MelsecMcAsciiNet("192.168.1.192",6001); |
| | | OperateResultExOne<short[]> read = melsec.ReadInt16("D100",(short) 2); |
| | | if(read.IsSuccess) |
| | | { |
| | | if (read.IsSuccess) { |
| | | System.out.println(Arrays.toString(read.Content)); |
| | | } |
| | | else { |
| | | } else { |
| | | System.out.println(read.ToMessageShowString()); |
| | | } |
| | | } |
| | |
| | | OperateResult connect = siemens_net.ConnectServer(); |
| | | if(connect.IsSuccess){ |
| | | System.out.println("connect success!"); |
| | | } |
| | | else { |
| | | } else { |
| | | System.out.println("failed:"+connect.Message); |
| | | } |
| | | siemens_net.ConnectClose(); |
| | |
| | | |
| | | OperateResultExOne<byte[]> read = siemens_net.Read( "M100", (short) 10 ); |
| | | { |
| | | if(read.IsSuccess) |
| | | { |
| | | if (read.IsSuccess) { |
| | | byte m100 = read.Content[0]; |
| | | byte m101 = read.Content[1]; |
| | | byte m102 = read.Content[2]; |
| | |
| | | byte m107 = read.Content[7]; |
| | | byte m108 = read.Content[8]; |
| | | byte m109 = read.Content[9]; |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | // 发生了异常 |
| | | } |
| | | } |
| | |
| | | OperateResultExOne<Double> read = modbusTcpNet.ReadDouble("s=2;x=4;200"); |
| | | if(read.IsSuccess){ |
| | | System.out.println(read.Content); |
| | | } |
| | | else { |
| | | } else { |
| | | System.out.println(read.Message); |
| | | } |
| | | |