Ejemplo n.º 1
0
        public void GetSingleResultFromBytesTest( )
        {
            OperateResult <float> result = ByteTransformHelper.GetSingleResultFromBytes(
                OperateResult.CreateSuccessResult(BitConverter.GetBytes(123.456f)), byteTransform);

            Assert.IsTrue(result.IsSuccess && result.Content == 123.456f);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 将指定的OperateResult类型转化
 /// </summary>
 /// <param name="result">原始的类型</param>
 /// <returns>转化后的类型</returns>
 protected OperateResult <float> GetSingleResultFromBytes(OperateResult <byte[]> result)
 {
     return(ByteTransformHelper.GetSingleResultFromBytes(result, byteTransform));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 读取指定地址的float数据
 /// </summary>
 /// <param name="address">起始地址,格式为"1234"</param>
 /// <returns>带有成功标志的float数据</returns>
 public OperateResult <float> ReadFloat(string address)
 {
     return(ByteTransformHelper.GetSingleResultFromBytes(Read(address, 2), ByteTransform));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 读取设备的float类型的数据
 /// </summary>
 /// <param name="address">起始地址</param>
 /// <returns>带成功标志的结果数据对象</returns>
 public OperateResult <float> ReadFloat(string address)
 {
     return(ByteTransformHelper.GetSingleResultFromBytes(Read(address, (ushort)(2 * WordLength)), byteTransform));
 }