Table of Contents

Class ChannelProcessor

Namespace
DuetControlServer.Codes
Assembly
DuetControlServer.dll

Class delegating parallel G/M/T-code execution for a single code channel. Every instance holds the code pipeline elements through which incoming G/M/T-codes are sent. Note that code files and events disrupting the code flow require their own stack level to maintain the correct order of code execution.

public sealed class ChannelProcessor
Inheritance
ChannelProcessor
Inherited Members

Constructors

ChannelProcessor(CodeChannel, ILogger<ChannelProcessor>, IServiceProvider)

Constructor for the channel processor

public ChannelProcessor(CodeChannel channel, ILogger<ChannelProcessor> logger, IServiceProvider serviceProvider)

Parameters

channel CodeChannel

Code channel

logger ILogger<ChannelProcessor>
serviceProvider IServiceProvider

Service provider to create pipeline instances

Fields

Channel

Channel of this pipeline

public readonly CodeChannel Channel

Field Value

CodeChannel

Logger

Logger instance

public readonly ILogger<ChannelProcessor> Logger

Field Value

ILogger<ChannelProcessor>

Properties

HasValidJobFile

Check if the pipeline has a valid job file assigned

public bool HasValidJobFile { get; }

Property Value

bool

Methods

Diagnostics(StringBuilder)

Get diagnostics from this pipeline

public void Diagnostics(StringBuilder builder)

Parameters

builder StringBuilder

String builder to write to

ExecuteAsync()

Lifecycle of this pipeline

public Task ExecuteAsync()

Returns

Task

Asynchronous task

FlushAsync(Code, CancellationToken)

Wait for all pending codes on the same stack level as the given code to finish. By default this replaces all expressions as well for convenient parsing by the code processors.

public Task<bool> FlushAsync(Code code, CancellationToken cancellationToken = default)

Parameters

code Code

Code waiting for the flush

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

FlushAsync(CodeFile, CancellationToken)

Wait for all pending codes on the same stack level as the given file to finish

public Task<bool> FlushAsync(CodeFile file, CancellationToken cancellationToken = default)

Parameters

file CodeFile

Code file

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

FlushAsync(bool, CancellationToken)

Wait for all pending codes to finish

public Task<bool> FlushAsync(bool flushAll, CancellationToken cancellationToken = default)

Parameters

flushAll bool

Whether to flush all states

cancellationToken CancellationToken

Optional cancellation token

Returns

Task<bool>

Whether the codes have been flushed successfully

IsIdle(Code?)

Check if all stages starting with a certain one are idle

public bool IsIdle(Code? code = null)

Parameters

code Code

Optional code requesting the check

Returns

bool

True if the pipeline is empty

Pop()

Pop the last state from the stack

public void Pop()

Push(CodeFile?)

Push a new state on the stack

public PipelineStackItem Push(CodeFile? file)

Parameters

file CodeFile

Returns

PipelineStackItem

New pipeline state of the firmware for the SPI connector

SetJobFile(CodeFile?)

Set the job file of this channel

public void SetJobFile(CodeFile? file)

Parameters

file CodeFile

Job file

WriteCode(Code, PipelineStage)

Execute a given code on this pipeline stage. This should not be used unless the corresponding code channel is unbounded

public void WriteCode(Code code, PipelineStage stage)

Parameters

code Code

Code to enqueue

stage PipelineStage

Stage level to enqueue it at

WriteCodeAsync(Code, PipelineStage)

Execute a given code on a given pipeline stage

public ValueTask WriteCodeAsync(Code code, PipelineStage stage)

Parameters

code Code

Code to enqueue

stage PipelineStage

Stage level to enqueue it at

Returns

ValueTask