public void GetUInt16ResultFromBytesTest( ) { OperateResult <ushort> result = ByteTransformHelper.GetUInt16ResultFromBytes( OperateResult.CreateSuccessResult(BitConverter.GetBytes((ushort)52345)), byteTransform); Assert.IsTrue(result.IsSuccess && result.Content == 52345); }
/// <summary> /// 将指定的OperateResult类型转化 /// </summary> /// <param name="result">原始的类型</param> /// <returns>转化后的类型</returns> protected OperateResult <ushort> GetUInt16ResultFromBytes(OperateResult <byte[]> result) { return(ByteTransformHelper.GetUInt16ResultFromBytes(result, byteTransform)); }
/// <summary> /// 读取指定地址的ushort数据 /// </summary> /// <param name="address">起始地址,格式为"1234"</param> /// <returns>带有成功标志的ushort数据</returns> public OperateResult <ushort> ReadUInt16(string address) { return(ByteTransformHelper.GetUInt16ResultFromBytes(Read(address, 1), ByteTransform)); }