Skip to content

Commit

Permalink
Implement Revision 1.4dk 10/6/2024 and Bump to v0.0.34
Browse files Browse the repository at this point in the history
Comments on Revision DK:
• Additional commands added to ArtTodControl for improved RDMnet compatibility.
• StreamId added to ArtTimeCode.
• ArtPollReply->GoodOutputB updated with two new RDM discovery flags.
  • Loading branch information
patrick-dmxc committed Jul 3, 2024
1 parent 7dc91ec commit 1fba20a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ArtNetSharp/ArtNetSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>0.0.33</Version>
<Version>0.0.34</Version>
<RepositoryUrl>https://github.com/DMXControl/ArtNetSharp</RepositoryUrl>
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
<PackageTags>RDM; ArtNet; E1.20; E1.33; E1.37-1; E1.37-2; E1.37-7</PackageTags>
Expand Down
13 changes: 10 additions & 3 deletions ArtNetSharp/Messages/ArtTimeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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];
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}";
}
}
}
16 changes: 14 additions & 2 deletions ArtNetSharp/Misc/Enums/EArtTodControlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@ public enum EArtTodControlCommand : byte
/// </summary>
AtcNone = 0x00,
/// <summary>
/// The node flushes its TOD
/// The port flushes its TOD
/// and instigates full
/// discovery.
/// </summary>
AtcFlush = 0x01
AtcFlush = 0x01,
/// <summary>
/// The port ends current discovery but does not flush ToD.
/// </summary>
AtcEnd = 0x02,
/// <summary>
/// The port enables incremental discovery.
/// </summary>
AtcIncOn = 0x03,
/// <summary>
/// The port disables incremental discovery.
/// </summary>
AtcIncOff = 0x04
}
}
8 changes: 8 additions & 0 deletions ArtNetSharp/Misc/ObjectTypes/GoodOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ namespace ArtNetSharp
/// </summary>
public readonly EOutputStyle OutputStyle;
public readonly bool RDMisDisabled;
public readonly bool DiscoveryIsCurrentlyRunning;
public readonly bool BackgroundDiscoveryIsEnabled;

public static GoodOutput None = new GoodOutput();

Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions ArtNetTests/PackagesSerializeDeserialize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1fba20a

Please sign in to comment.