Initial commit

This commit is contained in:
2026-07-13 09:25:40 +07:00
parent c08ff54676
commit bccfb156d7
1938 changed files with 641646 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using Sick.SafetyScanners.DataStructures;
using Sick.SafetyScanners.Helpers;
using System.Text;
namespace Sick.SafetyScanners.DataProcessing;
/// <summary>
/// Parser for DeviceName response from COLA2 variable command
/// Thread-safe implementation
/// </summary>
public sealed class ParseDeviceName
{
/// <summary>
/// Parses the device name from a TCP sequence (COLA2 response)
/// Matches: ParseDeviceName::parseTCPSequence in C++
/// </summary>
public DeviceName ParseTcpSequence(PacketBuffer buffer)
{
var span = buffer.GetBufferSpan();
return new DeviceName
{
Name = ReadDeviceName(span)
};
}
/// <summary>
/// Reads device name from buffer
/// Matches: ParseDeviceName::readDeviceName in C++
/// </summary>
private string ReadDeviceName(ReadOnlySpan<byte> span)
{
ushort stringLength = ReadWriteHelper.ReadUint16LittleEndian(span, 0);
var nameBuilder = new StringBuilder(stringLength);
for (ushort i = 0; i < stringLength; i++)
{
byte ch = ReadWriteHelper.ReadUint8(span, 2 + i);
nameBuilder.Append((char)ch);
}
return nameBuilder.ToString();
}
}