OmronHostLinkCModeHelperRead 方法 |
命名空间: HslCommunication.Profinet.Omron.Helper
public static OperateResult<byte[]> Read( IReadWriteDevice omron, byte unitNumber, string address, ushort length )
[缺少 "M:HslCommunication.Profinet.Omron.Helper.OmronHostLinkCModeHelper.Read(HslCommunication.Core.IReadWriteDevice,System.Byte,System.String,System.UInt16)" 的 <param name="unitNumber"/> 文档]
OmronFinsNet omronFinsNet = new OmronFinsNet( "192.168.1.110", 9600 ); // 读取连续的byte[],然后自定义解析的示例 OperateResult<byte[]> read = omronFinsNet.Read( "D100", 4 ); if (read.IsSuccess) { float temp = omronFinsNet.ByteTransform.TransInt16( read.Content, 0 ) / 10f; float press = omronFinsNet.ByteTransform.TransInt16( read.Content, 2 ) / 100f; int count = omronFinsNet.ByteTransform.TransInt32( read.Content, 4 ); // do something } else { // failed }
OmronFinsNet omronFinsNet = new OmronFinsNet( "192.168.1.110", 9600 ); // 此处以D寄存器作为示例 bool D100_7 = omronFinsNet.ReadBool( "D100.7" ).Content; // 读取D100.7是否通断,注意D100.0等同于D100 short short_D100 = omronFinsNet.ReadInt16( "D100" ).Content; // 读取D100组成的字 ushort ushort_D100 = omronFinsNet.ReadUInt16( "D100" ).Content; // 读取D100组成的无符号的值 int int_D100 = omronFinsNet.ReadInt32( "D100" ).Content; // 读取D100-D101组成的有符号的数据 uint uint_D100 = omronFinsNet.ReadUInt32( "D100" ).Content; // 读取D100-D101组成的无符号的值 float float_D100 = omronFinsNet.ReadFloat( "D100" ).Content; // 读取D100-D101组成的单精度值 long long_D100 = omronFinsNet.ReadInt64( "D100" ).Content; // 读取D100-D103组成的大数据值 ulong ulong_D100 = omronFinsNet.ReadUInt64( "D100" ).Content; // 读取D100-D103组成的无符号大数据 double double_D100 = omronFinsNet.ReadDouble( "D100" ).Content; // 读取D100-D103组成的双精度值 string str_D100 = omronFinsNet.ReadString( "D100", 5 ).Content; // 读取D100-D104组成的ASCII字符串数据 // 读取数组 short[] short_D1000_array = omronFinsNet.ReadInt16( "D1000", 10 ).Content; // 读取D1000的short值 ushort[] ushort_D1000_array = omronFinsNet.ReadUInt16( "D1000", 10 ).Content; // 读取D1000的ushort值 int[] int_D1000_array = omronFinsNet.ReadInt32( "D1000", 10 ).Content; // 读取D1000-D1001组成的int数据 uint[] uint_D1000_array = omronFinsNet.ReadUInt32( "D1000", 10 ).Content; // 读取D1000-D1001组成的uint数据 float[] float_D1000_array = omronFinsNet.ReadFloat( "D1000", 10 ).Content; // 读取D1000-D1001组成的float数据 long[] long_D1000_array = omronFinsNet.ReadInt64( "D1000", 10 ).Content; // 读取D1000-D1003组成的long数据 ulong[] ulong_D1000_array = omronFinsNet.ReadUInt64( "D1000", 10 ).Content; // 读取D1000-D1003组成的long数据 double[] double_D1000_array = omronFinsNet.ReadDouble( "D1000", 10 ).Content; // 读取D1000-D1003组成的double数据