点击或拖拽改变大小

IReadWriteNet 接口

所有的和设备或是交互类统一读写标准,公开了如何读写对方的一些api接口,并支持基于特性的读写操作
All unified read and write standards for devices and interaction classes, expose how to read and write some API interfaces of each other, and support feature-based read and write operations

命名空间:  HslCommunication.Core
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:9.1.3.0 (9.1.3.0)
语法
public interface IReadWriteNet

IReadWriteNet 类型公开以下成员。

属性
  名称说明
公共属性LogNet
当前读写交互类的日志信息,实例化之后,就可以看到系统运行的详细信息。
Currently read and write interactive log information. After instantiation, you can see detailed information about system operation.
Top
方法
  名称说明
公共方法Read(String, UInt16)
批量读取字节数组信息,需要指定地址和长度,返回原始的字节数组
Batch read byte array information, need to specify the address and length, return the original byte array
公共方法代码示例ReadT
读取支持Hsl特性的数据内容,该特性为HslDeviceAddressAttribute,详细参考api文档说明
Read the data content of the Hsl attribute. The attribute is HslDeviceAddressAttribute, please refer to the api documentation for details.
公共方法ReadAsync(String, UInt16)
异步批量读取字节数组信息,需要指定地址和长度,返回原始的字节数组
Asynchronous batch read byte array information, need to specify the address and length, return the original byte array
公共方法代码示例ReadAsyncT
异步读取支持Hsl特性的数据内容,该特性为HslDeviceAddressAttribute,详细参考api文档说明
Asynchronously read the data content of the Hsl attribute. The attribute is HslDeviceAddressAttribute, please refer to the api documentation for details.
公共方法ReadBool(String)
读取单个的Boolean数据信息
Read a single Boolean data message
公共方法ReadBool(String, UInt16)
批量读取Boolean数组信息,需要指定地址和长度,返回Boolean 数组
Batch read Boolean array information, need to specify the address and length, return Boolean array
公共方法ReadBoolAsync(String)
异步读取单个的Boolean数据信息
Asynchronously read a single Boolean data message
公共方法ReadBoolAsync(String, UInt16)
异步批量读取Boolean数组信息,需要指定地址和长度,返回Boolean 数组
Asynchronously batch read Boolean array information, need to specify the address and length, return Boolean array
公共方法代码示例ReadCustomerT
读取自定义的数据类型,需要继承自IDataTransfer接口
Read custom data types, need to inherit from IDataTransfer interface
公共方法代码示例ReadCustomerAsyncT
异步读取自定义的数据类型,需要继承自IDataTransfer接口
Asynchronously read custom data types, need to inherit from IDataTransfer interface
公共方法代码示例ReadDouble(String)
读取双浮点的数据
Read double floating point data
公共方法代码示例ReadDouble(String, UInt16)
读取双浮点数据的数组
Read double floating point data array
公共方法代码示例ReadDoubleAsync(String)
异步读取双浮点的数据
Asynchronously read double floating point data
公共方法代码示例ReadDoubleAsync(String, UInt16)
异步读取双浮点数据的数组
Asynchronously read double floating point data array
公共方法代码示例ReadFloat(String)
读取单浮点数据
Read single floating point data
公共方法代码示例ReadFloat(String, UInt16)
读取单浮点精度的数组
Read single floating point array
公共方法代码示例ReadFloatAsync(String)
异步读取单浮点数据
Asynchronously read single floating point data
公共方法代码示例ReadFloatAsync(String, UInt16)
异步读取单浮点精度的数组
Asynchronously read single floating point array
公共方法代码示例ReadInt16(String)
读取16位的有符号的整型数据
Read 16-bit signed integer data
公共方法代码示例ReadInt16(String, UInt16)
读取16位的有符号整型数组
Read 16-bit signed integer array
公共方法代码示例ReadInt16Async(String)
异步读取16位的有符号的整型数据
Asynchronously read 16-bit signed integer data
公共方法代码示例ReadInt16Async(String, UInt16)
异步读取16位的有符号整型数组
Asynchronously read 16-bit signed integer array
公共方法代码示例ReadInt32(String)
读取32位的有符号整型
Read 32-bit signed integer
公共方法代码示例ReadInt32(String, UInt16)
读取32位有符号整型数组
Read 32-bit signed integer array
公共方法代码示例ReadInt32Async(String)
异步读取32位的有符号整型
Asynchronously read 32-bit signed integer
公共方法代码示例ReadInt32Async(String, UInt16)
异步读取32位有符号整型数组
Asynchronously read 32-bit signed integer array
公共方法代码示例ReadInt64(String)
读取64位的有符号整型
Read 64-bit signed integer
公共方法代码示例ReadInt64(String, UInt16)
读取64位的有符号整型数组
Read 64-bit signed integer array
公共方法代码示例ReadInt64Async(String)
异步读取64位的有符号整型
Asynchronously read 64-bit signed integer
公共方法代码示例ReadInt64Async(String, UInt16)
异步读取64位的有符号整型数组
Asynchronously read 64-bit signed integer array
公共方法代码示例ReadString(String, UInt16)
读取字符串数据,默认为最常见的ASCII编码
Read string data, default is the most common ASCII encoding
公共方法代码示例ReadString(String, UInt16, Encoding)
使用指定的编码,读取字符串数据
Reads string data using the specified encoding
公共方法代码示例ReadStringAsync(String, UInt16)
异步读取字符串数据,默认为最常见的ASCII编码
Asynchronously read string data, default is the most common ASCII encoding
公共方法代码示例ReadStringAsync(String, UInt16, Encoding)
异步使用指定的编码,读取字符串数据
Asynchronously reads string data using the specified encoding
公共方法代码示例ReadUInt16(String)
读取16位的无符号整型
Read 16-bit unsigned integer
公共方法代码示例ReadUInt16(String, UInt16)
读取16位的无符号整型数组
Read 16-bit unsigned integer array
公共方法代码示例ReadUInt16Async(String)
异步读取16位的无符号整型
Asynchronously read 16-bit unsigned integer
公共方法代码示例ReadUInt16Async(String, UInt16)
异步读取16位的无符号整型数组
Asynchronously read 16-bit unsigned integer array
公共方法代码示例ReadUInt32(String)
读取32位的无符号整型
Read 32-bit unsigned integer
公共方法代码示例ReadUInt32(String, UInt16)
读取32位的无符号整型数组
Read 32-bit unsigned integer array
公共方法代码示例ReadUInt32Async(String)
异步读取32位的无符号整型
Asynchronously read 32-bit unsigned integer
公共方法代码示例ReadUInt32Async(String, UInt16)
异步读取32位的无符号整型数组
Asynchronously read 32-bit unsigned integer array
公共方法代码示例ReadUInt64(String)
读取64位的无符号整型
Read 64-bit unsigned integer
公共方法代码示例ReadUInt64(String, UInt16)
读取64位的无符号整型的数组
Read 64-bit unsigned integer array
公共方法代码示例ReadUInt64Async(String)
异步读取64位的无符号整型
Asynchronously read 64-bit unsigned integer
公共方法代码示例ReadUInt64Async(String, UInt16)
异步读取64位的无符号整型的数组
Asynchronously read 64-bit unsigned integer array
公共方法Write(String, Boolean)
写入单个的Boolean数据,返回是否成功
Write a single Boolean data, and return whether the write was successful
公共方法Write(String, Boolean)
批量写入Boolean数组数据,返回是否成功
Batch write Boolean array data, return whether the write was successful
公共方法Write(String, Byte)
写入原始的byte数组数据到指定的地址,返回是否写入成功
Write the original byte array data to the specified address, and return whether the write was successful
公共方法代码示例Write(String, Double)
写入double数据,返回是否成功
Write double data, return whether the write was successful
公共方法代码示例Write(String, Double)
写入double数组,返回是否成功
Write double array, return whether the write was successful
公共方法代码示例Write(String, Int16)
写入short数据,返回是否成功
Write short data, returns whether success
公共方法代码示例Write(String, Int16)
写入short数组,返回是否成功
Write short array, return whether the write was successful
公共方法代码示例Write(String, Int32)
写入int数据,返回是否成功
Write int data, return whether the write was successful
公共方法代码示例Write(String, Int32)
写入int[]数组,返回是否成功
Write int array, return whether the write was successful
公共方法代码示例Write(String, Int64)
写入long数据,返回是否成功
Write long data, return whether the write was successful
公共方法代码示例Write(String, Int64)
写入long数组,返回是否成功
Write long array, return whether the write was successful
公共方法代码示例Write(String, Single)
写入float数据,返回是否成功
Write float data, return whether the write was successful
公共方法代码示例Write(String, Single)
写入float数组,返回是否成功
Write float array, return whether the write was successful
公共方法代码示例Write(String, String)
写入字符串信息,编码为ASCII
Write string information, encoded as ASCII
公共方法代码示例Write(String, UInt16)
写入ushort数据,返回是否成功
Write ushort data, return whether the write was successful
公共方法代码示例Write(String, UInt16)
写入ushort数组,返回是否成功
Write ushort array, return whether the write was successful
公共方法代码示例Write(String, UInt32)
写入uint数据,返回是否成功
Write uint data, return whether the write was successful
公共方法代码示例Write(String, UInt32)
写入uint[]数组,返回是否成功
Write uint array, return whether the write was successful
公共方法代码示例Write(String, UInt64)
写入ulong数据,返回是否成功
Write ulong data, return whether the write was successful
公共方法代码示例Write(String, UInt64)
写入ulong数组,返回是否成功
Write ulong array, return whether the write was successful
公共方法代码示例Write(String, String, Int32)
写入指定长度的字符串信息,如果超出,就截断字符串,如果长度不足,那就补0操作,编码为ASCII
Write string information of the specified length. If it exceeds the value, the string is truncated. If the length is not enough, it is filled with 0 and the encoding is ASCII.
公共方法代码示例Write(String, String, Encoding)
写入字符串信息,需要指定的编码信息
Write string information, need to specify the encoding information
公共方法代码示例Write(String, String, Int32, Encoding)
写入指定长度的字符串信息,如果超出,就截断字符串,如果长度不足,那就补0操作,编码为指定的编码信息
Write string information of the specified length. If it exceeds the value, the string is truncated. If the length is not enough, then the operation is complemented with 0 , you should specified the encoding information
公共方法代码示例WriteT(T)
写入支持Hsl特性的数据,返回是否写入成功,该特性为HslDeviceAddressAttribute,详细参考api文档说明
Write data that supports the Hsl attribute, and return whether the write was successful. The attribute is HslDeviceAddressAttribute, please refer to the api documentation for details.
公共方法WriteAsync(String, Boolean)
异步批量写入Boolean数组数据,返回是否成功
Asynchronously batch write Boolean array data, return success
公共方法WriteAsync(String, Boolean)
异步批量写入Boolean数组数据,返回是否成功
Asynchronously batch write Boolean array data, return success
公共方法代码示例WriteAsync(String, Byte)
异步写入原始的byte数组数据到指定的地址,返回是否写入成功
Asynchronously writes the original byte array data to the specified address, and returns whether the write was successful
公共方法代码示例WriteAsync(String, Double)
异步写入double数据,返回是否成功
Asynchronously write double data, return whether the write was successful
公共方法代码示例WriteAsync(String, Double)
异步写入double数组,返回是否成功
Asynchronously write double array, return whether the write was successful
公共方法代码示例WriteAsync(String, Int16)
异步写入short数据,返回是否成功
Asynchronously write short data, returns whether success
公共方法代码示例WriteAsync(String, Int16)
异步写入short数组,返回是否成功
Asynchronously write short array, return whether the write was successful
公共方法代码示例WriteAsync(String, Int32)
异步写入int数据,返回是否成功
Asynchronously write int data, return whether the write was successful
公共方法代码示例WriteAsync(String, Int32)
异步写入int[]数组,返回是否成功
Asynchronously write int array, return whether the write was successful
公共方法代码示例WriteAsync(String, Int64)
异步写入long数据,返回是否成功
Asynchronously write long data, return whether the write was successful
公共方法代码示例WriteAsync(String, Int64)
异步写入long数组,返回是否成功
Asynchronously write long array, return whether the write was successful
公共方法代码示例WriteAsync(String, Single)
异步写入float数据,返回是否成功
Asynchronously write float data, return whether the write was successful
公共方法代码示例WriteAsync(String, Single)
异步写入float数组,返回是否成功
Asynchronously write float array, return whether the write was successful
公共方法代码示例WriteAsync(String, String)
异步写入字符串信息,编码为ASCII
Asynchronously write string information, encoded as ASCII
公共方法代码示例WriteAsync(String, UInt16)
异步写入ushort数据,返回是否成功
Asynchronously write ushort data, return whether the write was successful
公共方法代码示例WriteAsync(String, UInt16)
异步写入ushort数组,返回是否成功
Asynchronously write ushort array, return whether the write was successful
公共方法代码示例WriteAsync(String, UInt32)
异步写入uint数据,返回是否成功
Asynchronously write uint data, return whether the write was successful
公共方法代码示例WriteAsync(String, UInt32)
异步写入uint[]数组,返回是否成功
Asynchronously write uint array, return whether the write was successful
公共方法代码示例WriteAsync(String, UInt64)
异步写入ulong数据,返回是否成功
Asynchronously write ulong data, return whether the write was successful
公共方法代码示例WriteAsync(String, UInt64)
异步写入ulong数组,返回是否成功
Asynchronously write ulong array, return whether the write was successful
公共方法WriteAsync(String, String, Int32)
异步写入指定长度的字符串信息,如果超出,就截断字符串,如果长度不足,那就补0操作,编码为ASCII
Asynchronously write string information of the specified length. If it exceeds the value, the string is truncated. If the length is not enough, it is filled with 0 and the encoding is ASCII.
公共方法代码示例WriteAsync(String, String, Encoding)
异步写入字符串信息,需要指定的编码信息
Asynchronously write string information, need to specify the encoding information
公共方法WriteAsync(String, String, Int32, Encoding)
异步写入指定长度的字符串信息,如果超出,就截断字符串,如果长度不足,那就补0操作,编码为指定的编码信息
Asynchronously write string information of the specified length. If it exceeds the value, the string is truncated. If the length is not enough, then the operation is complemented with 0 , you should specified the encoding information
公共方法代码示例WriteAsyncT(T)
异步写入支持Hsl特性的数据,返回是否写入成功,该特性为HslDeviceAddressAttribute,详细参考api文档说明
Asynchronously write data that supports the Hsl attribute, and return whether the write was successful. The attribute is HslDeviceAddressAttribute, please refer to the api documentation for details.
公共方法代码示例WriteCustomerT
写入自定义类型的数据,该类型必须继承自IDataTransfer接口
Write data of a custom type, which must inherit from the IDataTransfer interface
公共方法代码示例WriteCustomerAsyncT
异步写入自定义类型的数据,该类型必须继承自IDataTransfer接口
Asynchronously write data of a custom type, which must inherit from the IDataTransfer interface
Top
备注
Modbus类,PLC类均实现了本接口,可以基于本接口实现统一所有的不同种类的设备的数据交互
示例
此处举例实现modbus,三菱,西门子三种设备的统一的数据交互
IReadWriteNet示例
List<IReadWriteNet> devices = new List<IReadWriteNet>( );
devices.Add( new ModbusTcpNet( "192.168.0.7" ) );                      // 新增modbus的设备
devices.Add( new MelsecMcNet( "192.168.0.8", 2000 ) );                 // 新增三菱的设备
devices.Add( new SiemensS7Net( SiemensPLCS.S1200, "192.168.0.9" ) );   // 新增西门子的设备

// 添加各自的数据地址,不同的设备的数据地址格式肯定不一致的
List<string> address = new List<string>( );
address.Add( "x=4;100" );                // 假设modbus的数据地址是输入寄存器的100的地址,类型为short
address.Add( "M100" );                  // 假设三菱的数据地址是数据寄存器M100
address.Add( "DB1.100" );                // 假设西门子的数据地址在DB块1的偏移地址100上

short[] values = new short[3];
for (int i = 0; i < devices.Count; i++)
{
    values[i] = devices[i].ReadInt16( address[i] ).Content;
}

// values即包含了多种设备的值,实际上如果想要开发一个完善的系统,还要更加复杂点
参见