Table of Contents

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

This class should be merged with Codes.Pipelines.Firmware at some point

Constructors

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

channel CodeChannel

Code channel of this instance

commandFactory CommandFactory
codeProcessor CodeProcessor

Code processor

filePathResolver FilePathResolver

File path resolver

linkAdapter ILinkAdapter

Link adapter

linkInterface LinkInterface

Link interface

jobProcessor JobProcessor

Job processor

macroFileFactory FileFactory

Macro file factory

model ObjectModel

Object model

lifetime IHostApplicationLifetime
loggerFactory ILoggerFactory

Logger factory

settings IOptions<Settings>

Settings

Properties

First item on the stack

public StackState BaseState { get; }

Property Value

StackState

List of buffered G/M/T-codes that are being processed by the firmware

public List<Code> BufferedCodes { get; }

Property Value

List<Code>

Occupied space for buffered codes in bytes

public int BytesBuffered { get; }

Property Value

int

What code channel this class is about

public CodeChannel Channel { get; }

Property Value

CodeChannel

Get the current state from the stack

public StackState CurrentState { get; }

Property Value

StackState

Checks if this channel is waiting for acknowledgement

public bool IsWaitingForAcknowledgment { get; }

Property Value

bool

This is volatile to allow fast access without locking this instance first

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<Tuple<MessageTypeFlags, string>>

Stack of the different channel states

public Stack<StackState> Stack { get; }

Property Value

Stack<StackState>

Methods

Abort all files asynchronously

public Task AbortAllFilesAsync()

Returns

Task

Asynchronous task

Copy the state from another channel processor

public void CopyState(Processor from)

Parameters

from Processor

Source

Perform a regular code that was requested from the firmware

public void DoFirmwareCode(string code)

Parameters

code string

Code to perform

Attempt to start a file macro

public void DoMacroFile(string virtualFile, bool fromCode)

Parameters

virtualFile string

Requested name of the macro file

fromCode bool

Request comes from a real G/M/T-code

Called when the last or all files have been aborted by the firmware

public void FilesAborted(bool abortAll)

Parameters

abortAll bool

Whether to abort all files

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

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes could be flushed

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

file CodeFile

Optional code file for the flush target

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes could be flushed

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

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes could be flushed

Handle a G-code reply

public bool HandleReply(MessageTypeFlags flags, string reply)

Parameters

flags MessageTypeFlags

Message flags

reply string

Code reply

Returns

bool

Whether the reply could be processed

Invalidate every request and buffered code on this channel

public void Invalidate()

Invalidate buffered and regular codes + requests

public void InvalidateRegular()

Lock access to this code channel

public IDisposable Lock(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

IDisposable

Disposable lock

Lock all movement systems and wait for standstill

public Task<bool> LockAllMovementSystemsAndWaitForStandstill()

Returns

Task<bool>

Whether the movement systems could be locked

Lock access to this code channel asynchronously

public AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

AwaitableDisposable<IDisposable>

Disposable lock

Called when RepRapFirmware has closed the last macro file internally

public void MacroFileClosed()

Called when a message has been acknowledged

public void MessageAcknowledged()

Pop the last state from the stack

public void Pop()

Pop the last state from the stack

public Task PopAsync()

Returns

Task

Asynchronous task

Print diagnostics of this class

public ValueTask PrintDiagnosticsAsync(StringBuilder builder, CancellationToken cancellationToken)

Parameters

builder StringBuilder

String builder to print to

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

Asynchronous task

Called when the print has been paused on the file channel

public void PrintPaused()

Push a new state on the stack

public StackState Push(CodeFile? file = null)

Parameters

file CodeFile

Optional file being executed

Returns

StackState

New state

Called when a resource has been locked

public void ResourceLocked()

Flag the currently executing macro file as (not) pausable

public Task SetMacroPausable(bool isPausable)

Parameters

isPausable bool

Whether the macro is pausable or not

Returns

Task

Asynchronous task

Process pending requests on this channel

public void Spin()

Start copied macros. This must happen later to avoid race conditions

public static void StartCopiedMacros()

Unlock all resources occupied by the given channel

public Task UnlockAll()

Returns

Task

Asynchronous task

Wait for a message to be acknowledged

public void WaitForAcknowledgement()