Ejemplo n.º 1
0
        public override bool ServerDecode(
            ModbusCommand command,
            ByteArrayReader body)
        {
            if (ModbusCodecBase.PopRequestHeader(command, body) == false)
            {
                return(false);
            }

            var success = false;

            if (body.CanRead(1))
            {
                var count = body.ReadByte();

                if (body.CanRead(count))
                {
                    command.QueryTotalLength += (count + 1);
                    count       /= 2;
                    command.Data = new ushort[count];

                    for (int i = 0; i < count; i++)
                    {
                        command.Data[i] = body.ReadUInt16BE();
                    }

                    success = true;
                }
            }

            return(success);
        }
 public override bool ServerDecode(
     ModbusCommand command,
     ByteArrayReader body)
 {
     return
         (ModbusCodecBase.PopRequestHeader(command, body) &&
          ModbusCodecBase.PopDiscretes(command, body));
 }
 public override bool ClientDecode(
     ModbusCommand command,
     ByteArrayReader body)
 {
     return(ModbusCodecBase.PopRequestHeader(
                command,
                body));
 }
        public override bool ServerEncode(
            ModbusCommand command,
            ByteArrayWriter body)
        {
            ModbusCodecBase.PushRequestHeader(
                command,
                body);

            return(true);
        }
        public override bool ServerEncode(
            ModbusCommand command,
            ByteArrayWriter body)
        {
            ModbusCodecBase.PushDiscretes(
                command,
                body);

            return(true);
        }
        public override bool ClientEncode(
            ModbusCommand command,
            ByteArrayWriter body)
        {
            ModbusCodecBase.PushRequestHeader(
                command,
                body);

            ModbusCodecBase.PushDiscretes(
                command,
                body);

            return(true);
        }
 public override bool ServerDecode(
     ModbusCommand command,
     ByteArrayReader body)
 {
     if (ModbusCodecBase.PopRequestHeader(command, body))
     {
         command.Data = new ushort[command.Count];
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
        public override bool ClientEncode(
            ModbusCommand command,
            ByteArrayWriter body)
        {
            ModbusCodecBase.PushRequestHeader(
                command,
                body);

            var count = command.Count;

            body.WriteByte((byte)(count * 2));
            for (int i = 0; i < count; i++)
            {
                body.WriteUInt16BE(command.Data[i]);
            }

            return(true);
        }