Class Processor
- Namespace
- DuetControlServer.Link.Channel
- Assembly
- DuetControlServer.dll
Class used to process data on a single code channel
public sealed class Processor
- Inheritance
-
Processor
- Inherited Members
Remarks
This class should be merged with Codes.Pipelines.Firmware at some point
Constructors
Processor(CodeChannel, CommandFactory, CodeProcessor, FilePathResolver, ILinkAdapter, LinkInterface, JobProcessor, FileFactory, ObjectModel, IHostApplicationLifetime, ILoggerFactory, IOptions<Settings>)
Constructor of a code channel processor
public Processor(CodeChannel channel, CommandFactory commandFactory, CodeProcessor codeProcessor, FilePathResolver filePathResolver, ILinkAdapter linkAdapter, LinkInterface linkInterface, JobProcessor jobProcessor, FileFactory macroFileFactory, ObjectModel model, IHostApplicationLifetime lifetime, ILoggerFactory loggerFactory, IOptions<Settings> settings)
Parameters
channelCodeChannelCode channel of this instance
commandFactoryCommandFactorycodeProcessorCodeProcessorCode processor
filePathResolverFilePathResolverFile path resolver
linkAdapterILinkAdapterLink adapter
linkInterfaceLinkInterfaceLink interface
jobProcessorJobProcessorJob processor
macroFileFactoryFileFactoryMacro file factory
modelObjectModelObject model
lifetimeIHostApplicationLifetimeloggerFactoryILoggerFactoryLogger factory
settingsIOptions<Settings>Settings
Properties
BaseState
First item on the stack
public StackState BaseState { get; }
Property Value
BufferedCodes
List of buffered G/M/T-codes that are being processed by the firmware
public List<Code> BufferedCodes { get; }
Property Value
BytesBuffered
Occupied space for buffered codes in bytes
public int BytesBuffered { get; }
Property Value
Channel
What code channel this class is about
public CodeChannel Channel { get; }
Property Value
CurrentState
Get the current state from the stack
public StackState CurrentState { get; }
Property Value
IsWaitingForAcknowledgment
Checks if this channel is waiting for acknowledgement
public bool IsWaitingForAcknowledgment { get; }
Property Value
Remarks
This is volatile to allow fast access without locking this instance first
PendingReplies
Stack of code replies for codes that pushed the stack (e.g. macro files or blocking messages)
public Stack<Tuple<MessageTypeFlags, string>> PendingReplies { get; }
Property Value
Stack
Stack of the different channel states
public Stack<StackState> Stack { get; }
Property Value
Methods
AbortAllFilesAsync()
Abort all files asynchronously
public Task AbortAllFilesAsync()
Returns
- Task
Asynchronous task
CopyState(Processor)
Copy the state from another channel processor
public void CopyState(Processor from)
Parameters
fromProcessorSource
DoFirmwareCode(string)
Perform a regular code that was requested from the firmware
public void DoFirmwareCode(string code)
Parameters
codestringCode to perform
DoMacroFile(string, bool)
Attempt to start a file macro
public void DoMacroFile(string virtualFile, bool fromCode)
Parameters
virtualFilestringRequested name of the macro file
fromCodeboolRequest comes from a real G/M/T-code
FilesAborted(bool)
Called when the last or all files have been aborted by the firmware
public void FilesAborted(bool abortAll)
Parameters
abortAllboolWhether to abort all files
FlushAllAsync(CancellationToken)
Flush all pending codes and return true on success or false on failure. This method may be deprecated; in theory it should suffice to flush the pipeline only (with stricter Busy conditions)
public Task<bool> FlushAllAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional cancellation token
Returns
FlushAsync(CodeFile, CancellationToken)
Flush pending codes and return true on success or false on failure. This method may be deprecated; in theory it should suffice to flush the pipeline only (with stricter Busy conditions)
public Task<bool> FlushAsync(CodeFile file, CancellationToken cancellationToken = default)
Parameters
fileCodeFileOptional code file for the flush target
cancellationTokenCancellationTokenOptional cancellation token
Returns
FlushAsync(CancellationToken)
Flush pending codes and return true on success or false on failure. This method may be deprecated; in theory it should suffice to flush the pipeline only (with stricter Busy conditions)
public Task<bool> FlushAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional cancellation token
Returns
HandleReply(MessageTypeFlags, string)
Handle a G-code reply
public bool HandleReply(MessageTypeFlags flags, string reply)
Parameters
flagsMessageTypeFlagsMessage flags
replystringCode reply
Returns
- bool
Whether the reply could be processed
Invalidate()
Invalidate every request and buffered code on this channel
public void Invalidate()
InvalidateRegular()
Invalidate buffered and regular codes + requests
public void InvalidateRegular()
Lock(CancellationToken)
Lock access to this code channel
public IDisposable Lock(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- IDisposable
Disposable lock
LockAllMovementSystemsAndWaitForStandstill()
Lock all movement systems and wait for standstill
public Task<bool> LockAllMovementSystemsAndWaitForStandstill()
Returns
LockAsync(CancellationToken)
Lock access to this code channel asynchronously
public AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
- AwaitableDisposable<IDisposable>
Disposable lock
MacroFileClosed()
Called when RepRapFirmware has closed the last macro file internally
public void MacroFileClosed()
MessageAcknowledged()
Called when a message has been acknowledged
public void MessageAcknowledged()
Pop()
Pop the last state from the stack
public void Pop()
PopAsync()
Pop the last state from the stack
public Task PopAsync()
Returns
- Task
Asynchronous task
PrintDiagnosticsAsync(StringBuilder, CancellationToken)
Print diagnostics of this class
public ValueTask PrintDiagnosticsAsync(StringBuilder builder, CancellationToken cancellationToken)
Parameters
builderStringBuilderString builder to print to
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
Asynchronous task
PrintPaused()
Called when the print has been paused on the file channel
public void PrintPaused()
Push(CodeFile?)
Push a new state on the stack
public StackState Push(CodeFile? file = null)
Parameters
fileCodeFileOptional file being executed
Returns
- StackState
New state
ResourceLocked()
Called when a resource has been locked
public void ResourceLocked()
SetMacroPausable(bool)
Flag the currently executing macro file as (not) pausable
public Task SetMacroPausable(bool isPausable)
Parameters
isPausableboolWhether the macro is pausable or not
Returns
- Task
Asynchronous task
Spin()
Process pending requests on this channel
public void Spin()
StartCopiedMacros()
Start copied macros. This must happen later to avoid race conditions
public static void StartCopiedMacros()
UnlockAll()
Unlock all resources occupied by the given channel
public Task UnlockAll()
Returns
- Task
Asynchronous task
WaitForAcknowledgement()
Wait for a message to be acknowledged
public void WaitForAcknowledgement()