public DmxData ReadFrame()
        {
            var target = new DmxData();
            byte start = this.binRead.ReadByte();
            target.Timestamp = (uint)this.binRead.ReadInt32();
            target.Universe = (ushort)this.binRead.ReadInt16();
            switch (start)
            {
                case 1:
                    target.DataType = DmxData.DataTypes.FullFrame;
                    ushort len = (ushort)this.binRead.ReadInt16();
                    target.Data = this.binRead.ReadBytes(len);
                    break;

                case 2:
                    target.DataType = DmxData.DataTypes.NoChange;
                    break;

                default:
                    throw new ArgumentException("Invalid data");
            }
            byte end = this.binRead.ReadByte();

            if (end != 4)
                throw new ArgumentException("Invalid data");

            return target;
        }
        public override DmxData ReadFrame()
        {
            var  target = new DmxData();
            byte start  = this.binRead.ReadByte();

            target.TimestampMS = (uint)this.binRead.ReadInt32();
            target.Universe    = (ushort)this.binRead.ReadInt16();
            switch (start)
            {
            case 1:
                target.DataType = DmxData.DataTypes.FullFrame;
                ushort len = (ushort)this.binRead.ReadInt16();
                target.Data = this.binRead.ReadBytes(len);
                break;

            case 2:
                target.DataType = DmxData.DataTypes.NoChange;
                break;

            default:
                throw new ArgumentException("Invalid data");
            }
            byte end = this.binRead.ReadByte();

            if (end != 4)
            {
                throw new ArgumentException("Invalid data");
            }

            return(target);
        }
        public override DmxData ReadFrame()
        {
            if (this.currentNetwork == 0)
            {
                // Read a full frame
                ReadFullFrame();

                this.currentReadPosition = 0;
            }

            FileFormat.NetworkNode network;
            while (true)
            {
                network = this.config.Network[this.currentNetwork];

                this.currentNetwork++;
                if (this.currentNetwork >= this.config.Network.Length)
                {
                    this.currentNetwork = 0;
                    break;
                }

                if (network.MaxChannels == 0)
                {
                    // Skip this network
                    continue;
                }

                break;
            }

            var dmxData = new DmxData
            {
                Data        = new byte[network.MaxChannels],
                TimestampMS = (ulong)(this.currentFrame * this.header.StepTimeMS),
                Sequence    = this.currentFrame
            };

            Buffer.BlockCopy(this.frameBuffer, this.currentReadPosition, dmxData.Data, 0, dmxData.Data.Length);
            this.currentReadPosition += dmxData.Data.Length;

            switch (network.NetworkType)
            {
            case "E131":
                dmxData.DataType = DmxData.DataTypes.FullFrame;
                dmxData.Universe = int.Parse(network.BaudRate);
                break;

            default:
                dmxData.DataType = DmxData.DataTypes.Nop;
                break;
            }

            return(dmxData);
        }
Beispiel #4
0
        public override void Output(DmxData dmxData)
        {
            switch (dmxData.DataType)
            {
            case DmxData.DataTypes.NoChange:
                this.streamWriter.WriteLine("{0},{1},{2},NoChange", dmxData.Sequence, dmxData.TimestampMS, dmxData.Universe);
                break;

            case DmxData.DataTypes.FullFrame:
                this.streamWriter.WriteLine("{0},{1},{2},Full,{3}",
                                            dmxData.Sequence, dmxData.TimestampMS, dmxData.Universe, string.Join(",", dmxData.Data.Select(x => x.ToString())));
                break;
            }
        }
Beispiel #5
0
        public override void Output(DmxData dmxData)
        {
            switch (dmxData.DataType)
            {
                case DmxData.DataTypes.NoChange:
                    this.streamWriter.WriteLine("{0},{1},{2},NoChange", dmxData.Sequence, dmxData.Timestamp, dmxData.Universe);
                    break;

                case DmxData.DataTypes.FullFrame:
                    this.streamWriter.WriteLine("{0},{1},{2},Full,{3}",
                        dmxData.Sequence, dmxData.Timestamp, dmxData.Universe, string.Join(",", dmxData.Data.Select(x => x.ToString())));
                    break;
            }
        }
        public override void Output(DmxData dmxData)
        {
            switch (dmxData.DataType)
            {
                case DmxData.DataTypes.FullFrame:
                    this.streamWriter.Write((byte)0x01);
                    this.streamWriter.Write((uint)dmxData.Timestamp);
                    this.streamWriter.Write((ushort)dmxData.Universe);
                    this.streamWriter.Write((ushort)dmxData.Data.Length);
                    this.streamWriter.Write(dmxData.Data);
                    this.streamWriter.Write((byte)0x04);
                    break;

                case DmxData.DataTypes.NoChange:
                    this.streamWriter.Write((byte)0x02);
                    this.streamWriter.Write((uint)dmxData.Timestamp);
                    this.streamWriter.Write((ushort)dmxData.Universe);
                    this.streamWriter.Write((byte)0x04);
                    break;
            }
        }
Beispiel #7
0
        public override void Output(DmxData dmxData)
        {
            switch (dmxData.DataType)
            {
            case DmxData.DataTypes.FullFrame:
                this.streamWriter.Write((byte)0x01);
                this.streamWriter.Write((uint)dmxData.TimestampMS);
                this.streamWriter.Write((ushort)dmxData.Universe);
                this.streamWriter.Write((ushort)dmxData.Data.Length);
                this.streamWriter.Write(dmxData.Data);
                this.streamWriter.Write((byte)0x04);
                break;

            case DmxData.DataTypes.NoChange:
                this.streamWriter.Write((byte)0x02);
                this.streamWriter.Write((uint)dmxData.TimestampMS);
                this.streamWriter.Write((ushort)dmxData.Universe);
                this.streamWriter.Write((byte)0x04);
                break;
            }
        }
Beispiel #8
0
        public void Output(DmxData dmxData)
        {
            var packet = new Acn.Packets.sAcn.StreamingAcnDmxPacket();

            packet.Framing.SourceName     = AcnSourceName;
            packet.Framing.Universe       = (short)dmxData.Universe;
            packet.Framing.Priority       = this.priority;
            packet.Framing.SequenceNumber = (byte)dmxData.Sequence;
            packet.Dmx.StartCode          = 0;
            packet.Dmx.Data = dmxData.Data;

            var destinationEP = Acn.Sockets.StreamingAcnSocket.GetUniverseEndPoint(dmxData.Universe);

            packet.Root.SenderId = AcnId;

            using (var data = new MemoryStream())
            {
                var writer = new Acn.IO.AcnBinaryWriter(data);

                Acn.AcnPacket.WritePacket(packet, writer);

                using (var networkData = new MemoryStream())
                {
                    BuildNetworkPacket(networkData, destinationEP, (int)data.Position);

                    SetIPCheckSum(networkData);

                    data.Position = 0;
                    data.WriteTo(networkData);

                    SetUDPCheckSum(networkData);

                    ulong secs     = dmxData.TimestampMS / 1000;
                    ulong usecs    = (dmxData.TimestampMS * 1000) - (secs * 1000000);
                    var   pcapData = new PcapngUtils.Pcap.PcapPacket(secs, usecs, networkData.ToArray(), 0);
                    this.writer.WritePacket(pcapData);
                }
            }
        }
Beispiel #9
0
 public abstract void Output(DmxData dmxData);
Beispiel #10
0
 public abstract void Output(DmxData dmxData);