DeviceCommunicationReadInt16Async 方法 (String, UInt16) |
命名空间: HslCommunication.Core.Device
public virtual Task<OperateResult<short[]>> ReadInt16Async( string address, ushort length )
MelsecMcNet melsec_net = new MelsecMcNet( "192.168.0.100", 6000 ); // 以下是简单的读取,没有仔细校验的方式 short[] d100_109_value = (await melsec_net.ReadInt16Async( "D100", 10 )).Content; // 如果需要判断是否读取成功 OperateResult<short[]> R_d100_109_value = await melsec_net.ReadInt16Async( "D100", 10 ); if (R_d100_109_value.IsSuccess) { // success short value_d100 = R_d100_109_value.Content[0]; short value_d101 = R_d100_109_value.Content[1]; short value_d102 = R_d100_109_value.Content[2]; short value_d103 = R_d100_109_value.Content[3]; short value_d104 = R_d100_109_value.Content[4]; short value_d105 = R_d100_109_value.Content[5]; short value_d106 = R_d100_109_value.Content[6]; short value_d107 = R_d100_109_value.Content[7]; short value_d108 = R_d100_109_value.Content[8]; short value_d109 = R_d100_109_value.Content[9]; } else { // failed }