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); }
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; }
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())); } }
public RdmResponsePacket(RdmCommands command, RdmParameters parameterId) : base(command, parameterId) { }
protected override void ReadData(RdmBinaryReader data) { ParameterId = (RdmParameters)((ushort)data.ReadNetwork16()); }
public RdmRequestPacket(RdmCommands command, RdmParameters parameterId) : base(command, parameterId) { }
public void RegisterResponse(RdmParameters parameterId, RdmPacket responsePacket) { responsePackets[parameterId] = responsePacket; }
protected bool IsParameterStatus(RdmParameters parameter, ParameterStatus status) { return(GetParameterStatus(parameter) == status); }
protected void SetParameterStatus(RdmParameters parameter, ParameterStatus status) { parameterStatus[parameter] = status; }
public RdmPacket(RdmCommands command, RdmParameters parameterId) { Header = new RdmHeader(); Header.Command = command; Header.ParameterId = parameterId; }
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; }
public RdmMessageAttribute(RdmCommands command, RdmParameters parameterId) { Command = command; ParameterId = parameterId; }
public RdmAckTimer(RdmCommands command, RdmParameters parameterId) : base(command, parameterId) { Header.PortOrResponseType = (byte)RdmResponseTypes.AckTimer; }
public static bool IsManufacturerPID(this RdmParameters pid) { return((int)pid >= 0x8000 && (int)pid <= 0xFFDF); }