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
channelCodeChannelCode channel
loggerILogger<ChannelProcessor>serviceProviderIServiceProviderService provider to create pipeline instances
Fields
Channel
Channel of this pipeline
public readonly CodeChannel Channel
Field Value
Logger
Logger instance
public readonly ILogger<ChannelProcessor> Logger
Field Value
Properties
HasValidJobFile
Check if the pipeline has a valid job file assigned
public bool HasValidJobFile { get; }
Property Value
Methods
Diagnostics(StringBuilder)
Get diagnostics from this pipeline
public void Diagnostics(StringBuilder builder)
Parameters
builderStringBuilderString 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
codeCodeCode waiting for the flush
cancellationTokenCancellationTokenOptional cancellation token
Returns
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
fileCodeFileCode file
cancellationTokenCancellationTokenOptional cancellation token
Returns
FlushAsync(bool, CancellationToken)
Wait for all pending codes to finish
public Task<bool> FlushAsync(bool flushAll, CancellationToken cancellationToken = default)
Parameters
flushAllboolWhether to flush all states
cancellationTokenCancellationTokenOptional cancellation token
Returns
IsIdle(Code?)
Check if all stages starting with a certain one are idle
public bool IsIdle(Code? code = null)
Parameters
codeCodeOptional 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
fileCodeFile
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
fileCodeFileJob 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
codeCodeCode to enqueue
stagePipelineStageStage 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
codeCodeCode to enqueue
stagePipelineStageStage level to enqueue it at