Class Processor
Class used to process data on a single code channel
Inherited Members
Namespace: DuetControlServer.SPI.Channel
Assembly: DuetControlServer.dll
Syntax
public sealed class Processor
Remarks
This class should be merged with Codes.Pipelines.Firmware at some point
Constructors
Processor(CodeChannel)
Constructor of a code channel processor
Declaration
public Processor(CodeChannel channel)
Parameters
Type | Name | Description |
---|---|---|
CodeChannel | channel | Code channel of this instance |
Properties
BaseState
First item on the stack
Declaration
public State BaseState { get; }
Property Value
Type | Description |
---|---|
State |
BufferedCodes
List of buffered G/M/T-codes that are being processed by the firmware
Declaration
public List<Code> BufferedCodes { get; }
Property Value
Type | Description |
---|---|
List<Code> |
BytesBuffered
Occupied space for buffered codes in bytes
Declaration
public int BytesBuffered { get; }
Property Value
Type | Description |
---|---|
int |
Channel
What code channel this class is about
Declaration
public CodeChannel Channel { get; }
Property Value
Type | Description |
---|---|
CodeChannel |
CurrentState
Get the current state from the stack
Declaration
public State CurrentState { get; }
Property Value
Type | Description |
---|---|
State |
IsWaitingForAcknowledgment
Checks if this channel is waiting for acknowledgement
Declaration
public bool IsWaitingForAcknowledgment { get; }
Property Value
Type | Description |
---|---|
bool |
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)
Declaration
public Stack<Tuple<MessageTypeFlags, string>> PendingReplies { get; }
Property Value
Type | Description |
---|---|
Stack<Tuple<MessageTypeFlags, string>> |
Stack
Stack of the different channel states
Declaration
public Stack<State> Stack { get; }
Property Value
Type | Description |
---|---|
Stack<State> |
Methods
AbortFilesAsync(bool, bool)
Abort the last or all files asynchronously
Declaration
public Task AbortFilesAsync(bool abortAll, bool fromFirmware)
Parameters
Type | Name | Description |
---|---|---|
bool | abortAll | Whether to abort all files |
bool | fromFirmware | Whether the request came from the firmware |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
CopyState(Processor)
Copy the state from another channel processor
Declaration
public void CopyState(Processor from)
Parameters
Type | Name | Description |
---|---|---|
Processor | from | Source |
Diagnostics(StringBuilder)
Write channel diagnostics to the given string builder
Declaration
public Task Diagnostics(StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | builder | Target to write to |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
DoFirmwareCode(string)
Perform a regular code that was requested from the firmware
Declaration
public void DoFirmwareCode(string code)
Parameters
Type | Name | Description |
---|---|---|
string | code | Code to perform |
DoMacroFile(string, bool)
Attempt to start a file macro
Declaration
public void DoMacroFile(string fileName, bool fromCode)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | Name of the macro file |
bool | fromCode | Request comes from a real G/M/T-code |
FilesAborted(bool, bool)
Called when the last or all files have been aborted
Declaration
public void FilesAborted(bool abortAll, bool fromFirmware)
Parameters
Type | Name | Description |
---|---|---|
bool | abortAll | Whether to abort all files |
bool | fromFirmware | Whether the request came from the firmware |
FlushAllAsync()
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)
Declaration
public Task<bool> FlushAllAsync()
Returns
Type | Description |
---|---|
Task<bool> | Whether the codes could be flushed |
FlushAsync(CodeFile?)
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)
Declaration
public Task<bool> FlushAsync(CodeFile? file = null)
Parameters
Type | Name | Description |
---|---|---|
CodeFile | file | Optional code file for the flush target |
Returns
Type | Description |
---|---|
Task<bool> | Whether the codes could be flushed |
HandleReply(MessageTypeFlags, string)
Handle a G-code reply
Declaration
public bool HandleReply(MessageTypeFlags flags, string reply)
Parameters
Type | Name | Description |
---|---|---|
MessageTypeFlags | flags | Message flags |
string | reply | Code reply |
Returns
Type | Description |
---|---|
bool | Whether the reply could be processed |
Invalidate()
Invalidate every request and buffered code on this channel
Declaration
public void Invalidate()
InvalidateRegular()
Invalidate buffered and regular codes + requests
Declaration
public void InvalidateRegular()
Lock()
Lock access to this code channel
Declaration
public IDisposable Lock()
Returns
Type | Description |
---|---|
IDisposable | Disposable lock |
LockAllMovementSystemsAndWaitForStandstill()
Lock all movement systems and wait for standstill
Declaration
public Task<bool> LockAllMovementSystemsAndWaitForStandstill()
Returns
Type | Description |
---|---|
Task<bool> | Whether the movement systems could be locked |
LockAsync()
Lock access to this code channel asynchronously
Declaration
public AwaitableDisposable<IDisposable> LockAsync()
Returns
Type | Description |
---|---|
AwaitableDisposable<IDisposable> | Disposable lock |
MacroFileClosed()
Called when RepRapFirmware has closed the last macro file internally
Declaration
public void MacroFileClosed()
MessageAcknowledged()
Called when a message has been acknowledged
Declaration
public void MessageAcknowledged()
Pop()
Pop the last state from the stack
Declaration
public void Pop()
PopAsync()
Pop the last state from the stack
Declaration
public Task PopAsync()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
PrintPaused()
Called when the print has been paused on the file channel
Declaration
public void PrintPaused()
Push(CodeFile?)
Push a new state on the stack
Declaration
public State Push(CodeFile? file = null)
Parameters
Type | Name | Description |
---|---|---|
CodeFile | file |
Returns
Type | Description |
---|---|
State | New state |
ResourceLocked()
Called when a resource has been locked
Declaration
public void ResourceLocked()
Run()
Process pending requests on this channel
Declaration
public void Run()
SetMacroPausable(bool)
Flag the currently executing macro file as (not) pausable
Declaration
public Task SetMacroPausable(bool isPausable)
Parameters
Type | Name | Description |
---|---|---|
bool | isPausable | Whether the macro is pausable or not |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
StartCopiedMacros()
Start copied macros. This must happen later to avoid race conditions
Declaration
public static void StartCopiedMacros()
UnlockAll()
Unlock all resources occupied by the given channel
Declaration
public Task UnlockAll()
Returns
Type | Description |
---|---|
Task | Asynchronous task |
WaitForAcknowledgement()
Wait for a message to be acknowledged
Declaration
public void WaitForAcknowledgement()