Exemplo n.º 1
0
 public byte[] ToSource( )
 {
     byte[] buffer = new byte[10];
     byteTransform.TransByte(temperature).CopyTo(buffer, 0);
     byteTransform.TransByte(press).CopyTo(buffer, 2);
     byteTransform.TransByte(others).CopyTo(buffer, 6);
     return(buffer);
 }
 /// <summary>
 /// 将指定的OperateResult类型转化
 /// </summary>
 /// <param name="result">原始的类型</param>
 /// <param name="byteTransform">数据转换方法</param>
 /// <returns>转化后的类型</returns>
 public static OperateResult <byte> GetByteResultFromBytes(OperateResult <byte[]> result, IByteTransform byteTransform)
 {
     return(GetResultFromBytes(result, m => byteTransform.TransByte(m, 0)));
 }
 /// <summary>
 /// 往Modbus服务器中的指定寄存器写入数据
 /// </summary>
 /// <param name="address">起始地址</param>
 /// <param name="value">数据值</param>
 public void Write(ushort address, short value)
 {
     Write(address, byteTransform.TransByte(value));
 }