点击或拖拽改变大小

OmronCipNetReadUInt16Async 方法 (String, UInt16)

异步读取16位的无符号整型数组
Asynchronously read 16-bit unsigned integer array

命名空间:  HslCommunication.Profinet.Omron
程序集:  HslCommunication (在 HslCommunication.dll 中) 版本:12.1.2.0 (12.1.2.0)
语法
public override Task<OperateResult<ushort[]>> ReadUInt16Async(
	string address,
	ushort length
)

参数

address
类型:SystemString
起始地址
length
类型:SystemUInt16
读取的数组长度

返回值

类型:TaskOperateResultUInt16
带有成功标识的ushort数组

实现

IReadWriteNetReadUInt16Async(String, UInt16)
IReadWriteNetReadUInt16Async(String, UInt16)
示例
以下为三菱的连接对象示例,其他的设备读写情况参照下面的代码:
UInt16类型示例
MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 );

// 以下是简单的读取,没有仔细校验的方式
ushort[] d100_109 = (await melsec_net.ReadUInt16Async( "D100", 10 )).Content;

// 如果需要判断是否读取成功
OperateResult<ushort[]> R_d100_109 = await melsec_net.ReadUInt16Async( "D100", 10 );
if (R_d100_109.IsSuccess)
{
    // success
    ushort value_d100 = R_d100_109.Content[0];
    ushort value_d101 = R_d100_109.Content[1];
    ushort value_d102 = R_d100_109.Content[2];
    ushort value_d103 = R_d100_109.Content[3];
    ushort value_d104 = R_d100_109.Content[4];
    ushort value_d105 = R_d100_109.Content[5];
    ushort value_d106 = R_d100_109.Content[6];
    ushort value_d107 = R_d100_109.Content[7];
    ushort value_d108 = R_d100_109.Content[8];
    ushort value_d109 = R_d100_109.Content[9];
}
else
{
    // failed
}
参见