Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 protected void RaiseNewRdmPacket(RdmEndPoint source, RdmPacket packet)
 {
     if (NewRdmPacket != null)
     {
         NewRdmPacket(this, new NewPacketEventArgs <RdmPacket>(source, packet));
     }
 }
Esempio n. 6
0
        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));
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
 private void ProcessEndpointListChange(IPEndPoint endpoint, RdmPacket packet)
 {
     EndpointListChange.Reply reply = packet as EndpointListChange.Reply;
     if (reply != null)
     {
         DiscoverEndpoints(new RdmEndPoint(endpoint));
     }
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        private RdmPacket ProcessPersonalityDescription(RdmPacket packet)
        {
            DmxPersonalityDescription.GetReply response = packet as DmxPersonalityDescription.GetReply;
            if (response != null)
            {
                Mode = response.Description;
            }

            return(null);
        }
Esempio n. 12
0
        private RdmPacket ProcessPanInvert(RdmPacket packet)
        {
            PanInvert.GetReply response = packet as PanInvert.GetReply;
            if (response != null)
            {
                panInvert = response.Inverted;
            }

            return(null);
        }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
        private RdmPacket ProcessParameterDescription(RdmPacket packet)
        {
            ParameterDescription.GetReply response = packet as ParameterDescription.GetReply;
            if (response != null)
            {
                parameters[response.ParameterId] = new ParameterInformation(response);
            }

            return(null);
        }
Esempio n. 15
0
        private RdmPacket ProcessLampStrikes(RdmPacket packet)
        {
            LampStrikes.GetReply response = packet as LampStrikes.GetReply;
            if (response != null)
            {
                LampStrikes = response.LampStrikes;
            }

            return(null);
        }
Esempio n. 16
0
        private RdmPacket ProcessPanTiltSwap(RdmPacket packet)
        {
            PanTiltSwap.GetReply response = packet as PanTiltSwap.GetReply;
            if (response != null)
            {
                panTiltSwap = response.Swapped;
            }

            return(null);
        }
Esempio n. 17
0
        private RdmPacket ProcessTiltInvert(RdmPacket packet)
        {
            TiltInvert.GetReply response = packet as TiltInvert.GetReply;
            if (response != null)
            {
                tiltInvert = response.Inverted;
            }

            return(null);
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        private RdmPacket ProcessPowerCycles(RdmPacket packet)
        {
            DevicePowerCycles.GetReply response = packet as DevicePowerCycles.GetReply;
            if (response != null)
            {
                PowerCycles = response.PowerCycles;
            }

            //return new LampHours.Get();
            return(null);
        }
Esempio n. 21
0
        private RdmPacket ProcessLampHours(RdmPacket packet)
        {
            LampHours.GetReply response = packet as LampHours.GetReply;
            if (response != null)
            {
                LampHours = response.LampHours;
            }

            //return new LampStrikes.Get();
            return(null);
        }
Esempio n. 22
0
        private RdmPacket ProcessDmxStartAddress(RdmPacket packet)
        {
            DmxStartAddress.GetReply response = packet as DmxStartAddress.GetReply;
            if (response != null)
            {
                this.dmxAddress = response.DmxAddress;
                RaisePropertyChanged("DmxAddress");
            }

            return(null);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
 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));
         }
     }
 }
Esempio n. 25
0
        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);
            }
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
 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;
             }
         }
     }
 }
Esempio n. 28
0
 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;
             }
         }
     }
 }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        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);
        }