34 lines
958 B
C#
34 lines
958 B
C#
using Sick.SafetyScanners.DataStructures;
|
|
using Sick.SafetyScanners.Helpers;
|
|
|
|
namespace Sick.SafetyScanners.DataProcessing;
|
|
|
|
/// <summary>
|
|
/// Parser for DeviceStatus response from COLA2 variable command
|
|
/// Thread-safe implementation
|
|
/// </summary>
|
|
public sealed class ParseDeviceStatus
|
|
{
|
|
/// <summary>
|
|
/// Parses the device status from a TCP sequence (COLA2 response)
|
|
/// Matches: ParseDeviceStatusData::parseTCPSequence in C++
|
|
/// </summary>
|
|
public DeviceStatus ParseTcpSequence(PacketBuffer buffer)
|
|
{
|
|
var span = buffer.GetBufferSpan();
|
|
return new DeviceStatus
|
|
{
|
|
Status = (SopasDeviceStatus)ReadDeviceStatus(span)
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Matches: ParseDeviceStatusData::readDeviceStatus in C++
|
|
/// </summary>
|
|
private byte ReadDeviceStatus(ReadOnlySpan<byte> span)
|
|
{
|
|
return ReadWriteHelper.ReadUint8(span, 0);
|
|
}
|
|
}
|
|
|