示例#1
0
        public void GetBoolResultFromBytesTest( )
        {
            OperateResult <bool> result = ByteTransformHelper.GetBoolResultFromBytes(
                OperateResult.CreateSuccessResult(new byte[] { 0x01, 0x00 }), byteTransform);

            Assert.IsTrue(result.IsSuccess && result.Content);
        }
示例#2
0
        /// <summary>
        /// 读取输入线圈,需要指定起始地址
        /// </summary>
        /// <param name="address">起始地址,格式为"1234"</param>
        /// <returns>带有成功标志的bool对象</returns>
        public OperateResult <bool> ReadDiscrete(string address)
        {
            var read = ReadModBusBase(ModbusInfo.ReadDiscrete, address, 1);

            if (!read.IsSuccess)
            {
                return(OperateResult.CreateFailedResult <bool>(read));
            }

            return(ByteTransformHelper.GetBoolResultFromBytes(read, ByteTransform));
        }
 /// <summary>
 /// 将指定的OperateResult类型转化
 /// </summary>
 /// <param name="result">原始的类型</param>
 /// <returns>转化后的类型</returns>
 protected OperateResult <bool> GetBoolResultFromBytes(OperateResult <byte[]> result)
 {
     return(ByteTransformHelper.GetBoolResultFromBytes(result, byteTransform));
 }