From 1fba20a048075d0fd9e7d6b1a1a74b09e5a407b7 Mon Sep 17 00:00:00 2001 From: Patrick Grote Date: Wed, 3 Jul 2024 17:02:00 +0200 Subject: [PATCH] =?UTF-8?q?Implement=20Revision=201.4dk=2010/6/2024=20and?= =?UTF-8?q?=20Bump=20to=20v0.0.34=20Comments=20on=20Revision=20DK:=20?= =?UTF-8?q?=E2=80=A2=20Additional=20commands=20added=20to=20ArtTodControl?= =?UTF-8?q?=20for=20improved=20RDMnet=20compatibility.=20=E2=80=A2=20Strea?= =?UTF-8?q?mId=20added=20to=20ArtTimeCode.=20=E2=80=A2=20ArtPollReply->Goo?= =?UTF-8?q?dOutputB=20updated=20with=20two=20new=20RDM=20discovery=20flags?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArtNetSharp/ArtNetSharp.csproj | 2 +- ArtNetSharp/Messages/ArtTimeCode.cs | 13 ++++++++++--- ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs | 16 ++++++++++++++-- ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs | 8 ++++++++ ArtNetTests/PackagesSerializeDeserialize.cs | 10 +++++----- 5 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ArtNetSharp/ArtNetSharp.csproj b/ArtNetSharp/ArtNetSharp.csproj index 1be7fee..aa4cfa9 100644 --- a/ArtNetSharp/ArtNetSharp.csproj +++ b/ArtNetSharp/ArtNetSharp.csproj @@ -2,7 +2,7 @@ netstandard2.0;net6.0;net7.0;net8.0 LICENSE - 0.0.33 + 0.0.34 https://github.com/DMXControl/ArtNetSharp $(RepositoryUrl) RDM; ArtNet; E1.20; E1.33; E1.37-1; E1.37-2; E1.37-7 diff --git a/ArtNetSharp/Messages/ArtTimeCode.cs b/ArtNetSharp/Messages/ArtTimeCode.cs index 0628406..501608e 100644 --- a/ArtNetSharp/Messages/ArtTimeCode.cs +++ b/ArtNetSharp/Messages/ArtTimeCode.cs @@ -9,13 +9,16 @@ public sealed class ArtTimeCode : AbstractArtPacket public override sealed EOpCodes OpCode => EOpCodes.OpTimeCode; protected override sealed ushort PacketMinLength => 19; + public readonly byte StreamID; + public readonly byte Frames; public readonly byte Secounds; public readonly byte Minutes; public readonly byte Hours; public readonly ETimecodeType Type; - public ArtTimeCode(in byte frames, + public ArtTimeCode(in byte streamID, + in byte frames, in byte secounds, in byte minutes, in byte hours, @@ -31,6 +34,7 @@ public ArtTimeCode(in byte frames, if (hours > 23) throw new ArgumentOutOfRangeException($"{nameof(hours)} has to be between 0 and 23"); + StreamID = streamID; Frames = frames; Secounds = secounds; Minutes = minutes; @@ -39,6 +43,8 @@ public ArtTimeCode(in byte frames, } public ArtTimeCode(in byte[] packet) : base(packet) { + //Filler1 = packet[12]; + StreamID = packet[13]; Frames = packet[14]; Secounds = packet[15]; Minutes = packet[16]; @@ -49,7 +55,7 @@ public ArtTimeCode(in byte[] packet) : base(packet) protected sealed override void fillPacket(ref byte[] p) { //p[12] = 0 // Filler 1 - //p[13] = 0 // Filler 2 + p[13] = StreamID; // Stream ID p[14] = Frames; // Frames p[15] = Secounds; // Secounds p[16] = Minutes; // Minutes @@ -61,6 +67,7 @@ public override bool Equals(object obj) { return base.Equals(obj) && obj is ArtTimeCode other + && StreamID == other.StreamID && Frames == other.Frames && Secounds == other.Secounds && Minutes == other.Minutes @@ -70,7 +77,7 @@ public override bool Equals(object obj) public override string ToString() { - return $"{nameof(ArtTimeCode)}: Type: {Type}, Time: {new TimeSpan(Hours, Minutes, Secounds)}, Frames: {Frames}"; + return $"{nameof(ArtTimeCode)}: StreamID: {StreamID}, Type: {Type}, Time: {new TimeSpan(Hours, Minutes, Secounds)}, Frames: {Frames}"; } } } \ No newline at end of file diff --git a/ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs b/ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs index 944a44e..1e9b1d2 100644 --- a/ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs +++ b/ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs @@ -7,10 +7,22 @@ public enum EArtTodControlCommand : byte /// AtcNone = 0x00, /// - /// The node flushes its TOD + /// The port flushes its TOD /// and instigates full /// discovery. /// - AtcFlush = 0x01 + AtcFlush = 0x01, + /// + /// The port ends current discovery but does not flush ToD. + /// + AtcEnd = 0x02, + /// + /// The port enables incremental discovery. + /// + AtcIncOn = 0x03, + /// + /// The port disables incremental discovery. + /// + AtcIncOff = 0x04 } } \ No newline at end of file diff --git a/ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs b/ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs index 5ffed96..c49ea34 100644 --- a/ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs +++ b/ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs @@ -47,6 +47,8 @@ namespace ArtNetSharp /// public readonly EOutputStyle OutputStyle; public readonly bool RDMisDisabled; + public readonly bool DiscoveryIsCurrentlyRunning; + public readonly bool BackgroundDiscoveryIsEnabled; public static GoodOutput None = new GoodOutput(); @@ -64,6 +66,8 @@ public GoodOutput(in byte byte1, in byte byte2) DMX_TestPacketsSupported2 = Tools.BitsMatch(Byte1, 0b01000000); IsBeingOutputAsDMX = Tools.BitsMatch(Byte1, 0b10000000); + BackgroundDiscoveryIsEnabled = Tools.BitsMatch(Byte2, 0b00010000); + DiscoveryIsCurrentlyRunning = Tools.BitsMatch(Byte2, 0b00100000); OutputStyle = (EOutputStyle)(Byte2 & 0b01000000); RDMisDisabled = Tools.BitsMatch(Byte2, 0b10000000); } @@ -111,6 +115,10 @@ public GoodOutput(in EConvertFrom convertFrom = EConvertFrom.ArtNet, Byte2 |= (byte)OutputStyle; if (RDMisDisabled) Byte2 |= 0b10000000; + if (DiscoveryIsCurrentlyRunning) + Byte2 |= 0b00100000; + if (BackgroundDiscoveryIsEnabled) + Byte2 |= 0b00010000; } public static GoodOutput operator |(in GoodOutput goodOutputA, in GoodOutput goodOutputB) diff --git a/ArtNetTests/PackagesSerializeDeserialize.cs b/ArtNetTests/PackagesSerializeDeserialize.cs index 46d86b7..421c0ae 100644 --- a/ArtNetTests/PackagesSerializeDeserialize.cs +++ b/ArtNetTests/PackagesSerializeDeserialize.cs @@ -398,12 +398,12 @@ public void ArtIpProgReply() [Test] public void ArtTimeCode() { - PackagesSerializeDeserialize.doTests(new ArtTimeCode(1, 2, 3, 4, ETimecodeType.SMTPE)); + PackagesSerializeDeserialize.doTests(new ArtTimeCode(5, 1, 2, 3, 4, ETimecodeType.SMTPE)); - Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(30, 2, 3, 4, ETimecodeType.SMTPE)); - Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(1, 60, 3, 4, ETimecodeType.SMTPE)); - Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(1, 2, 60, 4, ETimecodeType.SMTPE)); - Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(1, 2, 3, 24, ETimecodeType.SMTPE)); + Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(6, 30, 2, 3, 4, ETimecodeType.SMTPE)); + Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(7, 1, 60, 3, 4, ETimecodeType.SMTPE)); + Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(8, 1, 2, 60, 4, ETimecodeType.SMTPE)); + Assert.Throws(typeof(ArgumentOutOfRangeException), () => new ArtTimeCode(0, 1, 2, 3, 24, ETimecodeType.SMTPE)); } [Test] public void ArtTimeSync()