Skip to content

Commit

Permalink
Renamed variables for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
HakanL committed Dec 13, 2024
1 parent 3e943dc commit a82a8b5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/Haukcode.sACN/Haukcode.sACN.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Haukcode.Network" Version="1.0.18" />
<PackageReference Include="Haukcode.Network" Version="1.0.22" />
<PackageReference Include="HdrHistogram" Version="2.5.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
Expand Down
18 changes: 9 additions & 9 deletions src/Haukcode.sACN/Model/DMPLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ public int WriteToBuffer(Memory<byte> buffer)
return writer.BytesWritten;
}

internal static DMPLayer Parse(BigEndianBinaryReader buffer)
internal static DMPLayer Parse(BigEndianBinaryReader reader)
{
short flagsAndDMPLength = buffer.ReadInt16();
byte vector3 = buffer.ReadByte();
short flagsAndDMPLength = reader.ReadInt16();
byte vector3 = reader.ReadByte();
Debug.Assert(vector3 == DMP_VECTOR);
byte addressTypeAndDataType = buffer.ReadByte();
byte addressTypeAndDataType = reader.ReadByte();
Debug.Assert(addressTypeAndDataType == ADDRESS_TYPE_AND_DATA_TYPE);
short firstPropertyAddress = buffer.ReadInt16();
short firstPropertyAddress = reader.ReadInt16();
Debug.Assert(firstPropertyAddress == FIRST_PROPERTY_ADDRESS);
short addressIncrement = buffer.ReadInt16();
short addressIncrement = reader.ReadInt16();
Debug.Assert(addressIncrement == ADDRESS_INCREMENT);
short propertyValueCount = buffer.ReadInt16();
short propertyValueCount = reader.ReadInt16();

byte startCode = buffer.ReadByte();
byte startCode = reader.ReadByte();
if (propertyValueCount > 0)
{
var properties = buffer.ReadSlice(propertyValueCount - 1);
var properties = reader.ReadSlice(propertyValueCount - 1);

var dmpLayer = new DMPLayer(properties, startCode);

Expand Down
20 changes: 10 additions & 10 deletions src/Haukcode.sACN/Model/DataFramingLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,29 @@ public override int WriteToBuffer(Memory<byte> buffer)
return writer.BytesWritten + DMPLayer.WriteToBuffer(writer.Memory);
}

internal static DataFramingLayer Parse(BigEndianBinaryReader buffer)
internal static DataFramingLayer Parse(BigEndianBinaryReader reader)
{
ushort flagsAndFramingLength = buffer.ReadUInt16();
ushort flagsAndFramingLength = reader.ReadUInt16();
ushort flags = (ushort)(flagsAndFramingLength & SACNPacket.FIRST_FOUR_BITS_MASK);
Debug.Assert(flags == SACNPacket.FLAGS);
ushort length = (ushort)(flagsAndFramingLength & SACNPacket.LAST_TWELVE_BITS_MASK);

int vector = buffer.ReadInt32();
int vector = reader.ReadInt32();
Debug.Assert(vector == VECTOR_E131_DATA_PACKET);
string sourceName = buffer.ReadString(64);
byte priority = buffer.ReadByte();
ushort syncAddress = buffer.ReadUInt16();
byte sequenceID = buffer.ReadByte();
byte optionsByte = buffer.ReadByte();
string sourceName = reader.ReadString(64);
byte priority = reader.ReadByte();
ushort syncAddress = reader.ReadUInt16();
byte sequenceID = reader.ReadByte();
byte optionsByte = reader.ReadByte();
var options = FramingOptions.Parse(optionsByte);

ushort universeID = buffer.ReadUInt16();
ushort universeID = reader.ReadUInt16();

var framingLayer = new DataFramingLayer
{
SequenceId = sequenceID,
SourceName = sourceName,
DMPLayer = DMPLayer.Parse(buffer),
DMPLayer = DMPLayer.Parse(reader),
Options = options,
UniverseId = universeID,
Priority = priority,
Expand Down
18 changes: 9 additions & 9 deletions src/Haukcode.sACN/Model/RootLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,42 @@ public int WriteToBuffer(Memory<byte> buffer)
return writer.BytesWritten + FramingLayer.WriteToBuffer(writer.Memory);
}

internal static RootLayer Parse(BigEndianBinaryReader buffer)
internal static RootLayer Parse(BigEndianBinaryReader reader)
{
short preambleLength = buffer.ReadInt16();
short preambleLength = reader.ReadInt16();
if (preambleLength != PREAMBLE_LENGTH)
throw new InvalidDataException("preambleLength != PREAMBLE_LENGTH");

short postambleLength = buffer.ReadInt16();
short postambleLength = reader.ReadInt16();
if (postambleLength != POSTAMBLE_LENGTH)
throw new InvalidDataException("postambleLength != POSTAMBLE_LENGTH");

if (!buffer.VerifyBytes(PACKET_IDENTIFIER))
if (!reader.VerifyBytes(PACKET_IDENTIFIER))
throw new InvalidDataException("packetIdentifier != PACKET_IDENTIFIER");

ushort flagsAndRootLength = (ushort)buffer.ReadInt16();
ushort flagsAndRootLength = (ushort)reader.ReadInt16();
ushort flags = (ushort)(flagsAndRootLength & SACNPacket.FIRST_FOUR_BITS_MASK);
if (flags != SACNPacket.FLAGS)
throw new InvalidDataException("flags != SACNPacket.FLAGS");

ushort length = (ushort)(flagsAndRootLength & SACNPacket.LAST_TWELVE_BITS_MASK);
int vector = buffer.ReadInt32();
Guid cid = buffer.ReadGuid();
int vector = reader.ReadInt32();
Guid cid = reader.ReadGuid();

switch (vector)
{
case VECTOR_ROOT_E131_DATA:
return new RootLayer
{
UUID = cid,
FramingLayer = DataFramingLayer.Parse(buffer)
FramingLayer = DataFramingLayer.Parse(reader)
};

case VECTOR_ROOT_E131_EXTENDED:
return new RootLayer
{
UUID = cid,
FramingLayer = SyncFramingLayer.Parse(buffer)
FramingLayer = SyncFramingLayer.Parse(reader)
};

default:
Expand Down
8 changes: 4 additions & 4 deletions src/Haukcode.sACN/Model/SACNPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public SACNPacket(RootLayer rootLayer)
RootLayer = rootLayer;
}

public int WriteToBuffer(Memory<byte> buffer)
public int WriteToBuffer(Memory<byte> outputBuffer)
{
return RootLayer.WriteToBuffer(buffer);
return RootLayer.WriteToBuffer(outputBuffer);
}

public static SACNPacket Parse(ReadOnlyMemory<byte> inputBuffer)
{
var buffer = new BigEndianBinaryReader(inputBuffer);
var rootLayer = RootLayer.Parse(buffer);
var reader = new BigEndianBinaryReader(inputBuffer);
var rootLayer = RootLayer.Parse(reader);

if (rootLayer.FramingLayer is DataFramingLayer)
return new SACNDataPacket(rootLayer);
Expand Down
12 changes: 6 additions & 6 deletions src/Haukcode.sACN/Model/SyncFramingLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ public override int WriteToBuffer(Memory<byte> buffer)
return writer.BytesWritten;
}

internal static SyncFramingLayer Parse(BigEndianBinaryReader buffer)
internal static SyncFramingLayer Parse(BigEndianBinaryReader reader)
{
ushort flagsAndFramingLength = (ushort)buffer.ReadInt16();
ushort flagsAndFramingLength = (ushort)reader.ReadInt16();
ushort flags = (ushort)(flagsAndFramingLength & SACNPacket.FIRST_FOUR_BITS_MASK);
Debug.Assert(flags == SACNPacket.FLAGS);
ushort length = (ushort)(flagsAndFramingLength & SACNPacket.LAST_TWELVE_BITS_MASK);

int vector = buffer.ReadInt32();
int vector = reader.ReadInt32();
Debug.Assert(vector == VECTOR_E131_EXTENDED_SYNCHRONIZATION);
byte sequenceID = buffer.ReadByte();
ushort syncAddress = buffer.ReadUInt16();
ushort reserved = buffer.ReadUInt16();
byte sequenceID = reader.ReadByte();
ushort syncAddress = reader.ReadUInt16();
ushort reserved = reader.ReadUInt16();

var framingLayer = new SyncFramingLayer
{
Expand Down

0 comments on commit a82a8b5

Please sign in to comment.