Beispiel #1
0
        public static RdmPacket ReadPacket(RdmCommands command, RdmParameters parameterId, RdmBinaryReader contentData)
        {
            RdmPacket rdmPacket = null;

            RdmHeader header = new RdmHeader();

            header.Command     = command;
            header.ParameterId = parameterId;

            rdmPacket = RdmPacket.Create(header);
            if (rdmPacket != null)
            {
                rdmPacket.ReadData(contentData);
                return(rdmPacket);
            }
            else
            {
                rdmPacket = RdmPacket.Create(header, typeof(RdmRawPacket)) as RdmRawPacket;
                if (rdmPacket != null)
                {
                    rdmPacket.ReadData(contentData);
                    return(rdmPacket);
                }
            }

            throw new UnknownRdmPacketException(header);
        }
Beispiel #2
0
        protected ParameterStatus GetParameterStatus(RdmParameters parameter)
        {
            ParameterStatus status;

            if (parameterStatus.TryGetValue(parameter, out status))
            {
                return(status);
            }

            return(ParameterStatus.Empty);
        }
        public static void RegisterPacketType(RdmCommands command, RdmParameters parameter, Type packetType)
        {
            PacketKey key = new PacketKey();

            key.Command   = command;
            key.Parameter = parameter;

            if (packetStore.ContainsKey(key))
            {
                throw new InvalidOperationException(string.Format("The packet {0} is already registered for {1}.", parameter.ToString(), command.ToString()));
            }

            packetStore[key] = packetType;
        }
Beispiel #4
0
        public void RegisterHandler(RdmCommands command, RdmParameters parameterId, ProcessPacketHandler packetHandler)
        {
            switch (command)
            {
            case RdmCommands.Get:
                packetGetHandlers[parameterId] = packetHandler;
                break;

            case RdmCommands.GetResponse:
                packetGetResponseHandlers[parameterId] = packetHandler;
                break;

            case RdmCommands.Set:
                packetSetHandlers[parameterId] = packetHandler;
                break;

            case RdmCommands.SetResponse:
                packetSetResponseHandlers[parameterId] = packetHandler;
                break;

            default:
                throw new NotSupportedException(string.Format("The packet command type {0} is not supported yet.", command.ToString()));
            }
        }
Beispiel #5
0
 public RdmResponsePacket(RdmCommands command, RdmParameters parameterId) : base(command, parameterId)
 {
 }
Beispiel #6
0
 protected override void ReadData(RdmBinaryReader data)
 {
     ParameterId = (RdmParameters)((ushort)data.ReadNetwork16());
 }
 public RdmRequestPacket(RdmCommands command, RdmParameters parameterId) : base(command, parameterId)
 {
 }
Beispiel #8
0
 public void RegisterResponse(RdmParameters parameterId, RdmPacket responsePacket)
 {
     responsePackets[parameterId] = responsePacket;
 }
Beispiel #9
0
 protected bool IsParameterStatus(RdmParameters parameter, ParameterStatus status)
 {
     return(GetParameterStatus(parameter) == status);
 }
Beispiel #10
0
 protected void SetParameterStatus(RdmParameters parameter, ParameterStatus status)
 {
     parameterStatus[parameter] = status;
 }
Beispiel #11
0
 public RdmPacket(RdmCommands command, RdmParameters parameterId)
 {
     Header             = new RdmHeader();
     Header.Command     = command;
     Header.ParameterId = parameterId;
 }
Beispiel #12
0
 public RdmNack(RdmCommands command, RdmParameters parameterId)
     : base(command, parameterId)
 {
     Header.PortOrResponseType = (byte)RdmResponseTypes.NackReason;
 }
 public PacketKey(RdmCommands command, RdmParameters parameter)
 {
     this.Command   = command;
     this.Parameter = parameter;
 }
Beispiel #14
0
 public RdmMessageAttribute(RdmCommands command, RdmParameters parameterId)
 {
     Command     = command;
     ParameterId = parameterId;
 }
 public RdmAckTimer(RdmCommands command, RdmParameters parameterId)
     : base(command, parameterId)
 {
     Header.PortOrResponseType = (byte)RdmResponseTypes.AckTimer;
 }
Beispiel #16
0
 public static bool IsManufacturerPID(this RdmParameters pid)
 {
     return((int)pid >= 0x8000 && (int)pid <= 0xFFDF);
 }