Initial commit

This commit is contained in:
2026-07-03 16:37:12 +07:00
commit 63b8c1ea8b
1931 changed files with 640587 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
using Sick.SafetyScanners.Helpers;
namespace Sick.SafetyScanners.Cola2.Commands;
/// <summary>
/// Command to read a variable from the sensor by index
/// </summary>
public sealed class VariableCommand : CommandBase
{
private readonly ushort _variableIndex;
public VariableCommand(ushort variableIndex)
: base(0x52, 0x49) // 'R' and 'I' in ASCII (Read by Index)
{
_variableIndex = variableIndex;
}
public ushort VariableIndex => _variableIndex;
public override bool CanBeExecutedWithoutSessionId => false;
protected override ReadOnlyMemory<byte> AddTelegramData()
{
var data = new byte[2];
var span = data.AsSpan();
// Variable index (2 bytes, little endian)
ReadWriteHelper.WriteUint16LittleEndian(span, 0, _variableIndex);
return data;
}
protected override bool ProcessReplyInternal(ReadOnlyMemory<byte> replyData,
byte replyCommandType, byte replyCommandMode)
{
// Reply should be 'R' (0x52) and 'A' (0x41) for Acknowledge
if ((replyCommandType == 0x52 && replyCommandMode == 0x41) ||
(replyCommandType == 'R' && replyCommandMode == 'A'))
{
return true;
}
return false;
}
}