Initial commit
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Text;
|
||||
using Sick.Tim781s.Colab.Helpers;
|
||||
|
||||
namespace Sick.Tim781s.Colab.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for ColaB commands
|
||||
/// </summary>
|
||||
public abstract class CommandBase : IColaBCommand
|
||||
{
|
||||
private readonly string _commandString;
|
||||
private bool _wasSuccessful;
|
||||
|
||||
protected CommandBase(string commandString)
|
||||
{
|
||||
_commandString = commandString ?? throw new ArgumentNullException(nameof(commandString));
|
||||
}
|
||||
|
||||
public ReadOnlyMemory<byte> GetCommandData()
|
||||
{
|
||||
return Encoding.ASCII.GetBytes(_commandString);
|
||||
}
|
||||
|
||||
public bool WasSuccessful
|
||||
{
|
||||
get => _wasSuccessful;
|
||||
protected set => _wasSuccessful = value;
|
||||
}
|
||||
|
||||
public abstract bool ProcessReply(ReadOnlyMemory<byte> replyData);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the command string
|
||||
/// </summary>
|
||||
protected string CommandString => _commandString;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user