public void SendRdm(RdmPacket packet, RdmEndPoint targetAddress, UId targetId, UId sourceId) { //Queue this packet for sending. RegisterTransaction(packet, targetAddress, targetId); // socket.SendRdm(packet, targetAddress, targetId, sourceId); }
public void SendRdm(List <RdmPacket> packets, RdmEndPoint targetAddress, UId targetId) { if (packets.Count < 1) { throw new ArgumentException("Rdm packets list is empty."); } RdmPacket primaryPacket = packets[0]; //Create sACN Packet ArtRdmSubPacket rdmPacket = new ArtRdmSubPacket(); rdmPacket.DeviceId = targetId; rdmPacket.RdmVersion = (byte)RdmVersions.SubMessage; rdmPacket.Command = primaryPacket.Header.Command; rdmPacket.ParameterId = primaryPacket.Header.ParameterId; rdmPacket.SubDevice = (short)primaryPacket.Header.SubDevice; rdmPacket.SubCount = (short)packets.Count; MemoryStream rdmData = new MemoryStream(); RdmBinaryWriter dataWriter = new RdmBinaryWriter(rdmData); foreach (RdmPacket item in packets) { RdmPacket.WritePacket(item, dataWriter, true); } rdmPacket.RdmData = rdmData.ToArray(); Send(rdmPacket, targetAddress); }
protected RdmPacket DequeueOverflow(RdmPacket request) { Queue <RdmPacket> messages; if (overflowQueues.TryGetValue(request.Header.SourceId, out messages)) { RdmPacket reply = messages.Dequeue(); //If a different parameter is being requested then dump if (reply.Header.ParameterId != request.Header.ParameterId) { overflowQueues.Remove(request.Header.SourceId); return(null); } reply.Header.PortOrResponseType = (byte)(messages.Count == 0 ? RdmResponseTypes.Ack : RdmResponseTypes.AckOverflow); if (messages.Count == 0) { overflowQueues.Remove(request.Header.SourceId); } return(reply); } return(null); }
public void SendBackgroundRdm(RdmPacket packet) { if (!IsTcpConnectionAlive()) { throw new InvalidOperationException("No healthy TCP connection exists for RDMNet broadcast."); } //Fill in addition details packet.Header.SourceId = RdmSourceId; packet.Header.DestinationId = UId.Broadcast; //Create Rdm Packet MemoryStream rdmData = new MemoryStream(); RdmBinaryWriter rdmWriter = new RdmBinaryWriter(rdmData); //Write the RDM sub-start code. rdmWriter.Write((byte)RdmVersions.SubMessage); //Write the RDM packet RdmPacket.WritePacket(packet, rdmWriter); //Write the checksum rdmWriter.WriteNetwork((short)RdmPacket.CalculateChecksum(rdmData.GetBuffer())); //Create sACN Packet RdmNetPacket dmxPacket = new RdmNetPacket(); dmxPacket.Framing.SourceName = SourceName; dmxPacket.Framing.EndpointID = (short)0; dmxPacket.RdmNet.RdmData = rdmData.GetBuffer(); AliveTcpSocket.SendPacket(dmxPacket); RaiseRdmPacketSent(new NewPacketEventArgs <RdmPacket>(null, packet)); }
protected void RaiseNewRdmPacket(RdmEndPoint source, RdmPacket packet) { if (NewRdmPacket != null) { NewRdmPacket(this, new NewPacketEventArgs <RdmPacket>(source, packet)); } }
public void SendRdm(RdmPacket packet, RdmEndPoint targetAddress, UId targetId, UId sourceId) { //Fill in addition details packet.Header.SourceId = sourceId; packet.Header.DestinationId = targetId; //Sub Devices if (targetId is SubDeviceUId) { packet.Header.SubDevice = ((SubDeviceUId)targetId).SubDeviceId; } //Create Rdm Packet using (var rdmData = new MemoryStream()) { var rdmWriter = new RdmBinaryWriter(rdmData); //Write the RDM packet RdmPacket.WritePacket(packet, rdmWriter); //Write the checksum rdmWriter.WriteNetwork((short)(RdmPacket.CalculateChecksum(rdmData.GetBuffer()) + (int)RdmVersions.SubMessage + (int)DmxStartCodes.RDM)); //Create sACN Packet var rdmPacket = new ArtRdmPacket(); rdmPacket.Address = (byte)targetAddress.Universe; rdmPacket.SubStartCode = (byte)RdmVersions.SubMessage; rdmPacket.RdmData = rdmData.GetBuffer(); Send(rdmPacket, targetAddress); RdmPacketSent?.Invoke(this, new NewPacketEventArgs <RdmPacket>(new IPEndPoint(targetAddress.IpAddress, Port), packet)); } }
private RdmPacket ProcessSlotInfo(RdmPacket packet) { SlotInfo.GetReply response = packet as SlotInfo.GetReply; if (response != null) { foreach (SlotInfo.SlotInformation slot in response.Slots) { PersonalitySlotInformation slotInfo = new PersonalitySlotInformation(); slotInfo.Id = slot.Id; slotInfo.Offset = slot.Offset; slotInfo.Type = slot.Type; slotInfo.SlotLink = slot.SlotLink; Personality.Add(slotInfo); //Request the slot description. SlotDescription.Get slotDescription = new SlotDescription.Get(); slotDescription.SlotOffset = slot.Offset; foreach (var socket in sockets) { socket.SendRdm(slotDescription, Address, Id); } } } return(null); }
private void ProcessEndpointListChange(IPEndPoint endpoint, RdmPacket packet) { EndpointListChange.Reply reply = packet as EndpointListChange.Reply; if (reply != null) { DiscoverEndpoints(new RdmEndPoint(endpoint)); } }
protected void SendRdm(RdmPacket packet) { if (IsParameterStatus(packet.Header.ParameterId, ParameterStatus.Empty)) { SetParameterStatus(packet.Header.ParameterId, ParameterStatus.Pending); //packet.Header.PortOrResponseType = (byte) Address.Universe; socket.SendRdm(packet, Address, Id); } }
void socket_NewRdmPacket(object sender, NewPacketEventArgs <Acn.Rdm.RdmPacket> e) { RdmPacket replyPacket = broker.ProcessPacket(e.Packet); if (replyPacket != null) { socket.SendRdm(replyPacket, new RdmEndPoint(e.Source), e.Packet.Header.SourceId); } }
private RdmPacket ProcessPersonalityDescription(RdmPacket packet) { DmxPersonalityDescription.GetReply response = packet as DmxPersonalityDescription.GetReply; if (response != null) { Mode = response.Description; } return(null); }
private RdmPacket ProcessPanInvert(RdmPacket packet) { PanInvert.GetReply response = packet as PanInvert.GetReply; if (response != null) { panInvert = response.Inverted; } return(null); }
public Transaction(int transactionId, RdmPacket packet, RdmEndPoint address, UId id) { Id = transactionId; TransactionNumber = (byte)(transactionId % 255); Packet = packet; TargetAddress = address; TargetId = id; Attempts = 0; LastAttempt = DateTime.MinValue; }
private RdmPacket ProcessParameterDescription(RdmPacket packet) { ParameterDescription.GetReply response = packet as ParameterDescription.GetReply; if (response != null) { parameters[response.ParameterId] = new ParameterInformation(response); } return(null); }
private RdmPacket ProcessLampStrikes(RdmPacket packet) { LampStrikes.GetReply response = packet as LampStrikes.GetReply; if (response != null) { LampStrikes = response.LampStrikes; } return(null); }
private RdmPacket ProcessPanTiltSwap(RdmPacket packet) { PanTiltSwap.GetReply response = packet as PanTiltSwap.GetReply; if (response != null) { panTiltSwap = response.Swapped; } return(null); }
private RdmPacket ProcessTiltInvert(RdmPacket packet) { TiltInvert.GetReply response = packet as TiltInvert.GetReply; if (response != null) { tiltInvert = response.Inverted; } return(null); }
public void SendRdm(RdmPacket packet, RdmEndPoint targetAddress, UId targetId, UId sourceId) { List <RdmRouteBinding> transportsToUse = router.GetTransportsRoutes(targetId); //Send the packet on all transports. foreach (RdmRouteBinding binding in transportsToUse) { binding.Transport.Socket.SendRdm(packet, targetAddress, targetId, sourceId); } }
public RdmPacket ProcessOverflow(RdmPacket packet) { //Create an overflow response header to obtain the rest of the data. RdmHeader header = new RdmHeader(); header.ParameterId = packet.Header.ParameterId; header.Command = (packet.Header.Command == RdmCommands.SetResponse ? RdmCommands.Set : RdmCommands.Get); //Create a request packet to obtain the remaining data for the overflow. return(RdmPacket.Create(header)); }
private RdmPacket ProcessPowerCycles(RdmPacket packet) { DevicePowerCycles.GetReply response = packet as DevicePowerCycles.GetReply; if (response != null) { PowerCycles = response.PowerCycles; } //return new LampHours.Get(); return(null); }
private RdmPacket ProcessLampHours(RdmPacket packet) { LampHours.GetReply response = packet as LampHours.GetReply; if (response != null) { LampHours = response.LampHours; } //return new LampStrikes.Get(); return(null); }
private RdmPacket ProcessDmxStartAddress(RdmPacket packet) { DmxStartAddress.GetReply response = packet as DmxStartAddress.GetReply; if (response != null) { this.dmxAddress = response.DmxAddress; RaisePropertyChanged("DmxAddress"); } return(null); }
public void SendRdm(RdmPacket packet, RdmEndPoint targetAddress, UId targetId) { if (BlockRDM) { return; } //Queue this packet for sending. RegisterTransaction(packet, targetAddress, targetId); //socket.SendRdm(packet, targetAddress, targetId); }
private void ProcessDeviceList(IPEndPoint endpoint, RdmPacket packet) { EndpointDevices.Reply reply = packet as EndpointDevices.Reply; if (reply != null) { RdmEndPoint source = new RdmEndPoint(endpoint, reply.EndpointID); foreach (UId id in reply.DeviceIds) { NewDeviceFound(this, new DeviceFoundEventArgs(id, source)); } } }
private void ProcessDeviceListChange(IPEndPoint endpoint, RdmPacket packet) { EndpointDeviceListChange.Reply reply = packet as EndpointDeviceListChange.Reply; if (reply != null && Socket != null) { RdmEndPoint source = new RdmEndPoint(endpoint, reply.EndpointID); EndpointDevices.Get request = new EndpointDevices.Get(); request.EndpointID = reply.EndpointID; Socket.SendRdm(request, new RdmEndPoint(endpoint, 0), packet.Header.SourceId); } }
private RdmPacket ProcessSlotDescription(RdmPacket packet) { SlotDescription.GetReply response = packet as SlotDescription.GetReply; if (response != null) { if (response.SlotOffset >= 0 && response.SlotOffset < Personality.Count) { Personality[response.SlotOffset].Description = response.Description; } } return(null); }
private void ProcessEndpointUniverse(IPEndPoint endpoint, RdmPacket packet) { EndpointToUniverse.GetReply reply = packet as EndpointToUniverse.GetReply; if (reply != null) { foreach (RdmNetEndPoint port in DiscoveredEndpoints) { if (port.Id.Equals(packet.Header.SourceId) && port.Universe == reply.EndpointID) { port.AcnUniverse = reply.UniverseNumber; } } } }
private void ProcessDeviceLabel(IPEndPoint endpoint, RdmPacket packet) { DeviceLabel.GetReply reply = packet as DeviceLabel.GetReply; if (reply != null) { foreach (RdmNetEndPoint port in DiscoveredEndpoints) { if (port.Id.Equals(packet.Header.SourceId)) { port.DeviceLabel = reply.Label; } } } }
protected RdmPacket GetDefaultSlotValue(RdmPacket packet) { DefaultSlotValue.Get requestPacket = packet as DefaultSlotValue.Get; if (requestPacket != null) { DefaultSlotValue.GetReply replyPacket = new DefaultSlotValue.GetReply(); foreach (RdmSlot slot in this) { replyPacket.DefaultValues.Add(slot.DefaultValue); } } return(null); }
private RdmPacket ProcessSupportedParameters(RdmPacket packet) { SupportedParameters.GetReply response = packet as SupportedParameters.GetReply; if (response != null) { foreach (RdmParameters pid in response.ParameterIds.Where(item => item.IsManufacturerPID())) { ParameterDescription.Get descriptionPacket = new ParameterDescription.Get(); descriptionPacket.ParameterId = pid; socket.SendRdm(descriptionPacket, Address, Id); } } return(null); }