• DuetAPI
  • DuetAPIClient
  • DuetControlServer
  • DuetWebServer
Show / Hide Table of Contents
  • DuetAPI
    • CodeChannel
    • CodeParserException
    • IncompatibleVersionException
    • InternalServerException
    • InvalidParameterTypeException
    • MissingParameterException
  • DuetAPI.Commands
    • Acknowledge
    • AddHttpEndpoint
    • AddUserSession
    • BaseCommand
    • BaseResponse
    • Cancel
    • CheckPassword
    • Code
    • CodeFlags
    • CodeParameter
    • CodeParameterConverter
    • CodeParserBuffer
    • CodeType
    • Command
    • Command<T>
    • ErrorResponse
    • EvaluateExpression
    • Flush
    • GetFileInfo
    • GetObjectModel
    • HttpResponseType
    • Ignore
    • InstallPlugin
    • InstallSystemPackage
    • InvalidateChannel
    • KeywordType
    • LockObjectModel
    • PatchObjectModel
    • ReceivedHttpRequest
    • ReloadPlugin
    • RemoveHttpEndpoint
    • RemoveUserSession
    • Resolve
    • ResolvePath
    • Response<T>
    • SendHttpResponse
    • SetNetworkProtocol
    • SetObjectModel
    • SetPluginData
    • SetPluginProcess
    • SetUpdateStatus
    • SimpleCode
    • StartPlugin
    • StartPlugins
    • StopPlugin
    • StopPlugins
    • SyncObjectModel
    • UninstallPlugin
    • UninstallSystemPackage
    • UnlockObjectModel
    • WriteMessage
  • DuetAPI.Connection
    • ConnectionMode
    • Defaults
    • InterceptionMode
    • SubscriptionMode
  • DuetAPI.Connection.InitMessages
    • ClientInitMessage
    • CodeStreamInitMessage
    • CommandInitMessage
    • InterceptInitMessage
    • PluginServiceInitMessage
    • ServerInitMessage
    • SubscribeInitMessage
  • DuetAPI.ObjectModel
    • Accelerometer
    • AccessLevel
    • AnalogSensor
    • AnalogSensorType
    • AnalogSensorTypeConverter
    • Axis
    • BeepRequest
    • Board
    • BoardClosedLoop
    • BoardState
    • Build
    • BuildObject
    • CPU
    • ClosedLoopCurrentFraction
    • ClosedLoopPositionError
    • Compatibility
    • CoreKinematics
    • CurrentMove
    • DSF
    • DeltaKinematics
    • DeltaTower
    • DeserializationFailedEventArgs
    • DeserializationFailedEventHandler
    • DirectDisplay
    • DirectDisplayController
    • DirectDisplayEncoder
    • DirectDisplayScreen
    • DirectDisplayScreenST7567
    • Directories
    • DistanceUnit
    • DistanceUnitConverter
    • Driver
    • DriverClosedLoop
    • Duet3DFilamentMonitor
    • Endstop
    • EndstopType
    • Extruder
    • ExtruderNonlinear
    • Fan
    • FanThermostaticControl
    • FilamentMonitor
    • FilamentMonitorEnableMode
    • FilamentMonitorStatus
    • FilamentMonitorType
    • GCodeFileInfo
    • GCodeFileInfoConverter
    • GpInputPort
    • GpOutputPort
    • HangprinterKinematics
    • Heat
    • Heater
    • HeaterModel
    • HeaterModelPID
    • HeaterMonitor
    • HeaterMonitorAction
    • HeaterMonitorCondition
    • HeaterState
    • HttpEndpoint
    • HttpEndpointType
    • IGrowingModelCollection
    • IModelCollection
    • IModelDictionary
    • IModelObject
    • InductiveSensor
    • InputChannel
    • InputChannelState
    • InputShaping
    • InputShapingType
    • Inputs
    • Job
    • KeepoutZone
    • KeepoutZoneCoordinates
    • Kinematics
    • KinematicsName
    • KinematicsNameConverter
    • LaserFilamentMonitor
    • LaserFilamentMonitorCalibrated
    • LaserFilamentMonitorConfigured
    • Layer
    • LedStrip
    • LedStripType
    • LimitedResponseCountAttribute
    • Limits
    • LogLevel
    • MachineMode
    • MachineStatus
    • Memory
    • Message
    • MessageBox
    • MessageBoxMode
    • MessageType
    • Microstepping
    • MinMaxCurrent<T>
    • ModelCollection<T>
    • ModelDictionaryConverter
    • ModelDictionary<TValue>
    • ModelGrowingCollection<T>
    • ModelObject
    • MotorsIdleControl
    • Move
    • MoveCalibration
    • MoveCompensation
    • MoveCompensationType
    • MoveDeviations
    • MoveQueueItem
    • MoveRotation
    • MoveSegmentation
    • Network
    • NetworkInterface
    • NetworkInterfaceType
    • NetworkProtocol
    • NetworkState
    • ObjectModel
    • ObjectModelConverter
    • Plugin
    • PluginManifest
    • PolarKinematics
    • Probe
    • ProbeGrid
    • ProbeType
    • PulsedFilamentMonitor
    • PulsedFilamentMonitorCalibrated
    • PulsedFilamentMonitorConfigured
    • RestorePoint
    • RotatingMagnetFilamentMonitor
    • RotatingMagnetFilamentMonitorCalibrated
    • RotatingMagnetFilamentMonitorConfigured
    • SBC
    • SbcPropertyAttribute
    • ScaraKinematics
    • Sensors
    • SessionType
    • Skew
    • Spindle
    • SpindleState
    • StartupError
    • State
    • TemperatureError
    • ThumbnailInfo
    • ThumbnailInfoFormat
    • TiltCorrection
    • TimesLeft
    • Tool
    • ToolRetraction
    • ToolState
    • UserSession
    • Volume
    • ZLeadscrewKinematics
  • DuetAPI.Utility
    • DriverId
    • DriverIdJsonConverter
    • FileLists
    • Heightmap
    • JsonCamelCaseStringEnumConverter
    • JsonCharEnumConverter
    • JsonHelper
    • JsonLowerCaseStringEnumConverter
    • JsonOptionalShortDateTimeConverter
    • JsonPolymorphicWriteOnlyConverter<T>
    • JsonRegexListConverter
    • JsonShortDateTimeConverter
    • RequiredPermissionsAttribute
    • SbcPermissions
    • SbcPermissionsConverter
  • DuetAPIClient
    • BaseCommandConnection
    • BaseConnection
    • CodeStreamConnection
    • CommandConnection
    • HttpEndpointConnection
    • HttpEndpointUnixSocket
    • HttpEndpointUnixSocket.EndpointRequestReceived
    • InterceptConnection
    • SubscribeConnection
  • DuetControlServer
    • Program
    • Settings
  • DuetControlServer.Codes
    • ChannelProcessor
    • PipelineStage
    • Processor
  • DuetControlServer.Codes.Handlers
    • Functions
    • GCodes
    • Keywords
    • MCodes
    • TCodes
  • DuetControlServer.Codes.Pipelines
    • Executed
    • Firmware
    • PipelineBase
    • PipelineStackItem
    • Post
    • Pre
    • ProcessInternally
    • Start
  • DuetControlServer.Commands
    • AddHttpEndpoint
    • AddUserSession
    • CheckPassword
    • Code
    • EvaluateExpression
    • Flush
    • GetFileInfo
    • GetObjectModel
    • IConnectionCommand
    • InstallPlugin
    • InstallSystemPackage
    • InvalidateChannel
    • LockObjectModel
    • PatchObjectModel
    • ReloadPlugin
    • RemoveHttpEndpoint
    • RemoveUserSession
    • ResolvePath
    • SetNetworkProtocol
    • SetObjectModel
    • SetPluginData
    • SetPluginProcess
    • SetUpdateStatus
    • SimpleCode
    • StartPlugin
    • StartPlugins
    • StopPlugin
    • StopPlugins
    • SyncObjectModel
    • UninstallPlugin
    • UninstallSystemPackage
    • UnlockObjectModel
    • WriteMessage
  • DuetControlServer.Files
    • CodeBlock
    • CodeFile
    • FileDirectory
    • FilePath
    • InfoParser
    • JobProcessor
    • MacroFile
  • DuetControlServer.Files.ImageProcessing
    • IconImageParser
    • ImageParser
    • ImageProcessingException
  • DuetControlServer.IPC
    • Connection
    • LockManager
    • Server
  • DuetControlServer.IPC.Processors
    • Base
    • CodeInterception
    • CodeStream
    • Command
    • ModelSubscription
    • PluginService
  • DuetControlServer.Model
    • Expressions
    • Expressions.CustomAsyncFunctionResolver
    • Filter
    • ItemPathNode
    • Observer
    • Observer.PropertyPathChanged
    • PeriodicUpdater
    • PropertyChangeType
    • Provider
    • Updater
  • DuetControlServer.SPI
    • DataTransfer
    • EvaluateExpressionRequest
    • Interface
    • Interface.MovementLock
    • VariableRequest
  • DuetControlServer.SPI.Channel
    • LockRequest
    • Manager
    • Processor
    • State
  • DuetControlServer.SPI.Communication
    • Consts
  • DuetControlServer.SPI.Communication.FirmwareRequests
    • AbortFileHeader
    • CodeBufferUpdateHeader
    • DoCodeHeader
    • EvaluationResultHeader
    • ExecuteMacroHeader
    • FileChunkHeader
    • FileHandleHeader
    • OpenFileHeader
    • PrintPausedHeader
    • PrintPausedReason
    • ReadFileHeader
    • Request
    • SeekFileHeader
  • DuetControlServer.SPI.Communication.SbcRequests
    • AssignFilamentHeader
    • BooleanHeader
    • CodeFlags
    • CodeHeader
    • CodeParameter
    • DeleteLocalVariableHeader
    • FileChunkHeader
    • FileDataHeader
    • GetObjectModelHeader
    • MacroCompleteHeader
    • OpenFileResult
    • PrintStartedHeader
    • PrintStoppedHeader
    • Request
    • SetObjectModelHeader
    • SetVariableHeader
  • DuetControlServer.SPI.Communication.Shared
    • CodeChannelHeader
    • DataType
    • HeightMapHeader
    • MessageHeader
    • MessageTypeFlags
    • PacketHeader
    • PrintStoppedReason
    • StringHeader
    • TransferHeader
    • TransferResponse
  • DuetControlServer.SPI.Serialization
    • Reader
    • Writer
  • DuetControlServer.Utility
    • BuildDateTimeAttribute
    • CRC16
    • CRC32
    • Firmware
    • Logger
    • PriorityThreadRunner
  • DuetWebServer
    • Program
    • Settings
    • Startup
  • DuetWebServer.Authorization
    • Policies
    • SessionKeyAuthenticationHandler
    • SessionKeyAuthenticationSchemeOptions
  • DuetWebServer.Controllers
    • MachineController
    • RepRapFirmwareController
    • WebSocketController
  • DuetWebServer.FileProviders
    • DuetFileProvider
  • DuetWebServer.Middleware
    • CustomEndpointMiddleware
    • FallbackMiddleware
    • FixContentTypeMiddleware
    • HttpEndpointConnection
  • DuetWebServer.Services
    • ModelObserver
    • SessionExpiry
  • DuetWebServer.Singletons
    • IModelProvider
    • IModelProvider.WebDirectoryChanged
    • ISessionStorage
    • ModelProvider
    • SessionStorage
  • DuetWebServer.Utility
    • CRC32

Class InterceptConnection

Connection class for intercepting G/M/T-codes from the control server

Inheritance
object
BaseConnection
BaseCommandConnection
InterceptConnection
Implements
IDisposable
Inherited Members
BaseCommandConnection.AddHttpEndpoint(HttpEndpointType, string, string, bool, int, CancellationToken)
BaseCommandConnection.AddUserSession(AccessLevel, SessionType, string, CancellationToken)
BaseCommandConnection.CheckPassword(string, CancellationToken)
BaseCommandConnection.EvaluateExpression<T>(string, CodeChannel, CancellationToken)
BaseCommandConnection.Flush(CodeChannel, CancellationToken)
BaseCommandConnection.GetFileInfo(string, CancellationToken)
BaseCommandConnection.GetFileInfo(string, bool, CancellationToken)
BaseCommandConnection.GetMachineModel(CancellationToken)
BaseCommandConnection.GetObjectModel(CancellationToken)
BaseCommandConnection.GetSerializedMachineModel(CancellationToken)
BaseCommandConnection.GetSerializedObjectModel(CancellationToken)
BaseCommandConnection.InstallPlugin(string, CancellationToken)
BaseCommandConnection.InstallSystemPackage(string, CancellationToken)
BaseCommandConnection.InvalidateChannel(CodeChannel, CancellationToken)
BaseCommandConnection.LockMachineModel(CancellationToken)
BaseCommandConnection.LockObjectModel(CancellationToken)
BaseCommandConnection.PatchMachineModel(string, object, CancellationToken)
BaseCommandConnection.PatchObjectModel(string, object, CancellationToken)
BaseCommandConnection.PatchObjectModel(string, JsonElement, CancellationToken)
BaseCommandConnection.PerformCode(Code, CancellationToken)
BaseCommandConnection.PerformSimpleCode(string, CodeChannel, CancellationToken)
BaseCommandConnection.PerformSimpleCode(string, CodeChannel, bool, CancellationToken)
BaseCommandConnection.ReloadPlugin(string, CancellationToken)
BaseCommandConnection.RemoveHttpEndpoint(HttpEndpointType, string, string, CancellationToken)
BaseCommandConnection.RemoveUserSession(int, CancellationToken)
BaseCommandConnection.ResolvePath(string, CancellationToken)
BaseCommandConnection.SetMachineModel(string, string, CancellationToken)
BaseCommandConnection.SetObjectModel(string, string, CancellationToken)
BaseCommandConnection.SetPluginData(string, object, string, CancellationToken)
BaseCommandConnection.SetPluginData(string, JsonElement, string, CancellationToken)
BaseCommandConnection.SetUpdateStatus(bool, CancellationToken)
BaseCommandConnection.StartPlugin(string, CancellationToken)
BaseCommandConnection.StopPlugin(string, CancellationToken)
BaseCommandConnection.SyncMachineModel(CancellationToken)
BaseCommandConnection.SyncObjectModel(CancellationToken)
BaseCommandConnection.UninstallPlugin(string, CancellationToken)
BaseCommandConnection.UninstallSystemPackage(string, CancellationToken)
BaseCommandConnection.UnlockMachineModel(CancellationToken)
BaseCommandConnection.WriteMessage(MessageType, string, bool, bool, CancellationToken)
BaseCommandConnection.WriteMessage(MessageType, string, bool, LogLevel?, CancellationToken)
BaseCommandConnection.WriteMessage(Message, bool, bool, CancellationToken)
BaseCommandConnection.WriteMessage(Message, bool, LogLevel, CancellationToken)
BaseConnection.Dispose()
BaseConnection.Id
BaseConnection.IsConnected
BaseConnection.Close()
BaseConnection.Poll()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DuetAPIClient
Assembly: DuetAPIClient.dll
Syntax
public sealed class InterceptConnection : BaseCommandConnection, IDisposable

Constructors

InterceptConnection()

Creates a new connection in intercepting mode

Declaration
public InterceptConnection()

Properties

AutoEvaluateExpressions

Automatically evaluate expression parameters to their final values before sending it over to the client. This requires AutoFlush to be true and happens when the remaining codes have been processed.

Declaration
public bool AutoEvaluateExpressions { get; set; }
Property Value
Type Description
bool

AutoFlush

Automatically flush the code channel before notifying the client in case a code filter is specified

Declaration
public bool AutoFlush { get; set; }
Property Value
Type Description
bool
Remarks

This option makes extra Flush calls in the interceptor implementation obsolete. It is highly recommended to enable this in order to avoid potential deadlocks when dealing with macros!

Channels

List of input channels where codes may be intercepted. If the list is empty, all available channels are used

Declaration
public List<CodeChannel> Channels { get; set; }
Property Value
Type Description
List<CodeChannel>

Filters

List of G/M/T-codes to filter or Q0 for comments

Declaration
public List<string> Filters { get; set; }
Property Value
Type Description
List<string>
Remarks

This may only specify the code type and major/minor number (e.g. G1)

Mode

Mode of the interceptor

Declaration
public InterceptionMode Mode { get; }
Property Value
Type Description
InterceptionMode

PriortyCodes

Defines if priority codes may be intercepted (e.g. M122 or M999)

Declaration
public bool PriortyCodes { get; }
Property Value
Type Description
bool
See Also
IsPrioritized

Methods

CancelCode(CancellationToken)

Instruct the control server to cancel the last received code (in intercepting mode)

Declaration
public ValueTask CancelCode(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
Cancel
CodeInterceptionReadWrite

Connect(InterceptionMode, IEnumerable<CodeChannel>?, IEnumerable<string>?, bool, string, CancellationToken)

Establishes a connection to the given UNIX socket file

Declaration
public Task Connect(InterceptionMode mode, IEnumerable<CodeChannel>? channels = null, IEnumerable<string>? filters = null, bool priorityCodes = false, string socketPath = "/run/dsf/dcs.sock", CancellationToken cancellationToken = default)
Parameters
Type Name Description
InterceptionMode mode

Interception mode

IEnumerable<CodeChannel> channels

List of input channels where codes may be intercepted or null for all available channels

IEnumerable<string> filters

Optional list of codes that may be intercepted

bool priorityCodes

Define if priority codes may be intercepted

string socketPath

Path to the UNIX socket file

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
IncompatibleVersionException

API level is incompatible

IOException

Connection mode is unavailable

OperationCanceledException

Operation has been cancelled

SocketException

Init message could not be processed

Connect(InterceptionMode, string, CancellationToken)

Establishes a connection to the given UNIX socket file

Declaration
[Obsolete("Use the new overload to specify the code channels to intercept")]
public Task Connect(InterceptionMode mode, string socketPath, CancellationToken cancellationToken = default)
Parameters
Type Name Description
InterceptionMode mode

Interception mode

string socketPath

Path to the UNIX socket file

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
IncompatibleVersionException

API level is incompatible

IOException

Connection mode is unavailable

OperationCanceledException

Operation has been cancelled

SocketException

Init message could not be processed

Flush(CancellationToken)

When intercepting a code wait for all previous codes of the given channel to finish

Declaration
public Task<bool> Flush(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if all pending codes could be flushed

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

SocketException

Command could not be processed

See Also
CommandExecution

IgnoreCode(CancellationToken)

Instruct the control server to ignore the last received code (in intercepting mode)

Declaration
public ValueTask IgnoreCode(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
Ignore
CodeInterceptionRead
CodeInterceptionReadWrite

ReceiveCode(CancellationToken)

Wait for a code to be intercepted and read it

Declaration
public ValueTask<Code> ReceiveCode(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask<Code>

Code being intercepted or null if the connection has been closed

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CodeInterceptionRead
CodeInterceptionReadWrite

ResolveCode(Message, CancellationToken)

Instruct the control server to resolve the last received code with the given message details (in intercepting mode)

Declaration
public ValueTask ResolveCode(Message message, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Message message

Message to resolve the code with

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
Message
Resolve
CodeInterceptionReadWrite

ResolveCode(MessageType, string, CancellationToken)

Instruct the control server to resolve the last received code with the given message details (in intercepting mode)

Declaration
public ValueTask ResolveCode(MessageType type, string content, CancellationToken cancellationToken = default)
Parameters
Type Name Description
MessageType type

Type of the resolving message

string content

Content of the resolving message

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
Message
Resolve
CodeInterceptionReadWrite

Implements

IDisposable

See Also

Intercept
In this article
Back to top Generated by DocFX