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));
        }
Exemple #2
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));
            }
        }
Exemple #3
0
        public void SendRdm(RdmPacket packet, RdmEndPoint targetAddress, UId targetId, UId sourceId)
        {
            if (BlockRDM)
            {
                return;
            }

            //Fill in addition details
            packet.Header.SourceId      = sourceId;
            packet.Header.DestinationId = targetId;

            SubDeviceUId id = targetId as SubDeviceUId;

            if (id != null)
            {
                packet.Header.SubDevice = id.SubDeviceId;
            }

            //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()) + (byte)DmxStartCodes.RDM);

            //Create sACN Packet
            RdmNetPacket dmxPacket = new RdmNetPacket();

            dmxPacket.Framing.SourceName = SourceName;
            dmxPacket.Framing.EndpointID = (short)targetAddress.Universe;
            dmxPacket.RdmNet.RdmData     = rdmData.GetBuffer();

            SendPacket(dmxPacket, targetAddress);

            RaiseRdmPacketSent(new NewPacketEventArgs <RdmPacket>(targetAddress, packet));
        }