public void GetDoubleResultFromBytesTest( ) { OperateResult <double> result = ByteTransformHelper.GetDoubleResultFromBytes( OperateResult.CreateSuccessResult(BitConverter.GetBytes(123.456d)), byteTransform); Assert.IsTrue(result.IsSuccess && result.Content == 123.456d); }
/// <summary> /// 将指定的OperateResult类型转化 /// </summary> /// <param name="result">原始的类型</param> /// <returns>转化后的类型</returns> protected OperateResult <double> GetDoubleResultFromBytes(OperateResult <byte[]> result) { return(ByteTransformHelper.GetDoubleResultFromBytes(result, byteTransform)); }
/// <summary> /// 读取指定地址的double数据 /// </summary> /// <param name="address">起始地址,格式为"1234"</param> /// <returns>带有成功标志的double数据</returns> public OperateResult <double> ReadDouble(string address) { return(ByteTransformHelper.GetDoubleResultFromBytes(Read(address, 4), ByteTransform)); }
/// <summary> /// 读取设备的double类型的数据 /// </summary> /// <param name="address">起始地址</param> /// <returns>带成功标志的结果数据对象</returns> public OperateResult <double> ReadDouble(string address) { return(ByteTransformHelper.GetDoubleResultFromBytes(Read(address, (ushort)(4 * WordLength)), byteTransform)); }