• 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 BaseCommandConnection

Base connection class for sending commands to the control server

Inheritance
object
BaseConnection
BaseCommandConnection
CommandConnection
InterceptConnection
Implements
IDisposable
Inherited Members
BaseConnection._unixSocket
BaseConnection.Dispose()
BaseConnection.Dispose(bool)
BaseConnection.Id
BaseConnection.Connect(ClientInitMessage, string, CancellationToken)
BaseConnection.IsConnected
BaseConnection.Close()
BaseConnection.Poll()
BaseConnection.PerformCommand(BaseCommand, CancellationToken)
BaseConnection.PerformCommand<T>(BaseCommand, CancellationToken)
BaseConnection.Receive<T>(CancellationToken)
BaseConnection.ReceiveJson(CancellationToken)
BaseConnection.Send(object, CancellationToken)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DuetAPIClient
Assembly: DuetAPIClient.dll
Syntax
public abstract class BaseCommandConnection : BaseConnection, IDisposable

Constructors

BaseCommandConnection(ConnectionMode)

Protected constructor for derived modes that can issue regular commands

Declaration
protected BaseCommandConnection(ConnectionMode mode)
Parameters
Type Name Description
ConnectionMode mode

Connection type

Methods

AddHttpEndpoint(HttpEndpointType, string, string, bool, int, CancellationToken)

Add a new third-party HTTP endpoint in the format /machine/{ns}/{path}

Declaration
public Task<HttpEndpointUnixSocket> AddHttpEndpoint(HttpEndpointType endpointType, string ns, string path, bool isUploadRequest = false, int backlog = 4, CancellationToken cancellationToken = default)
Parameters
Type Name Description
HttpEndpointType endpointType

HTTP request type

string ns

Namespace of the plugin

string path

Endpoint path

bool isUploadRequest

Whether this is an upload request

int backlog

Number of simultaneously pending connections

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<HttpEndpointUnixSocket>

Wrapper around the UNIX socket for accepting HTTP endpoint requests

Exceptions
Type Condition
ArgumentException

Endpoint namespace is reserved

InvalidOperationException

Endpoint is already in use

IOException

UNIX socket could not be opened

OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
RegisterHttpEndpoints

AddUserSession(AccessLevel, SessionType, string?, CancellationToken)

Add a new user session

Declaration
public Task<int> AddUserSession(AccessLevel access, SessionType type, string? origin = null, CancellationToken cancellationToken = default)
Parameters
Type Name Description
AccessLevel access

Access level of this session

SessionType type

Type of this session

string origin

Origin of the user session (e.g. IP address or PID)

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<int>

New session ID

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManageUserSessions

CheckPassword(string, CancellationToken)

Check the given password (see M551)

Declaration
public Task<bool> CheckPassword(string password, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string password

Password to check

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if the requested password is correct

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

SocketException

Command could not be processed

See Also
CommandExecution

EvaluateExpression<T>(string, CodeChannel, CancellationToken)

Evaluate an arbitrary expression

Declaration
public Task<T> EvaluateExpression<T>(string expression, CodeChannel channel = CodeChannel.SBC, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string expression

Expression to evaluate

CodeChannel channel

Context of the evaluation

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<T>

Evaluation result

Type Parameters
Name Description
T

Type of the evaluation result

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

JsonException

Expected and returned data type do not match

OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution

Flush(CodeChannel, CancellationToken)

Wait for all pending codes of the given channel to finish

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

Code channel to wait for

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

GetFileInfo(string, bool, CancellationToken)

Parse a G-code file and returns file information about it

Declaration
public Task<GCodeFileInfo> GetFileInfo(string fileName, bool readThumbnailContent, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string fileName

The file to parse

bool readThumbnailContent

Whether thumbnail content shall be returned

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<GCodeFileInfo>

Information about the parsed file

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
GetFileInfo()
CommandExecution
FileSystemAccess
ReadGCodes

GetFileInfo(string, CancellationToken)

Parse a G-code file and returns file information about it

Declaration
public Task<GCodeFileInfo> GetFileInfo(string fileName, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string fileName

The file to parse

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<GCodeFileInfo>

Information about the parsed file

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
GetFileInfo()
CommandExecution
FileSystemAccess
ReadGCodes

GetMachineModel(CancellationToken)

Retrieve the full object model of the machine. In subscription mode this is the first command that has to be called once a connection has been established

Declaration
[Obsolete("Deprecated in favor of GetObjectModel")]
public Task<ObjectModel> GetMachineModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<ObjectModel>

The current machine model

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

GetObjectModel(CancellationToken)

Retrieve the full object model of the machine. In subscription mode this is the first command that has to be called once a connection has been established

Declaration
public Task<ObjectModel> GetObjectModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<ObjectModel>

The current machine model

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelRead
ObjectModelReadWrite

GetSerializedMachineModel(CancellationToken)

Optimized method to directly query the machine model UTF-8 JSON

Declaration
[Obsolete("Deprecated in favor of GetSerializedObjectModel")]
public ValueTask<MemoryStream> GetSerializedMachineModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
ValueTask<MemoryStream>

Machine model JSON

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

GetSerializedObjectModel(CancellationToken)

Optimized method to directly query the machine model UTF-8 JSON

Declaration
public Task<string> GetSerializedObjectModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<string>

Machine model JSON

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelRead
ObjectModelReadWrite

InstallPlugin(string, CancellationToken)

Install or upgrade a plugin

Declaration
public Task InstallPlugin(string packageFile, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string packageFile

Absolute file path to the plugin ZIP bundle

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManagePlugins

InstallSystemPackage(string, CancellationToken)

Install or upgrade a system package

Declaration
public Task InstallSystemPackage(string packageFile, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string packageFile

Absolute file path to the package file

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
SuperUser

InvalidateChannel(CodeChannel, CancellationToken)

Invalidate all pending codes and files on the given channel

Declaration
public Task InvalidateChannel(CodeChannel channel, CancellationToken cancellationToken = default)
Parameters
Type Name Description
CodeChannel channel

Code channel where everything is supposed to be invalidated

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Remarks

This does NOT cancel the current code being executed by RRF!

Exceptions
Type Condition
SocketException

Command could not be processed

See Also
SuperUser

LockMachineModel(CancellationToken)

Lock the machine model for read/write access. It is MANDATORY to call UnlockMachineModel(CancellationToken) when write access has finished

Declaration
[Obsolete("Deprecated in favor of LockObjectModel")]
public Task LockMachineModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

LockObjectModel(CancellationToken)

Lock the machine model for read/write access.

Declaration
public Task<IAsyncDisposable> LockObjectModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<IAsyncDisposable>

Asynchronous object model lock

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelReadWrite

PatchMachineModel(string, object, CancellationToken)

Apply a full patch to the object model. Use with care!

Declaration
[Obsolete("Deprecated in favor of PatchObjectModel")]
public Task PatchMachineModel(string key, object patch, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string key

Key to update

object patch

Patch to apply

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelReadWrite

PatchObjectModel(string, object, CancellationToken)

Apply a full patch to the object model. Use with care!

Declaration
[Obsolete("Deprecated in favor of PatchObjectModel which takes a JsonElement instead of an object")]
public Task PatchObjectModel(string key, object patch, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string key

Key to update

object patch

Patch to apply

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelReadWrite

PatchObjectModel(string, JsonElement, CancellationToken)

Apply a full patch to the object model. Use with care!

Declaration
public Task PatchObjectModel(string key, JsonElement patch, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string key

Key to update

JsonElement patch

Patch to apply

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelReadWrite

PerformCode(Code, CancellationToken)

Execute an arbitrary pre-parsed code

Declaration
public Task<Message> PerformCode(Code code, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Code code

The code to execute

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<Message>

Result of the given code

Remarks

Cancelling the read operation does not cancel the code execution

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

OperationCanceledException

Code or operation has been cancelled

SocketException

Command could not be processed

See Also
Code
CommandExecution

PerformSimpleCode(string, CodeChannel, bool, CancellationToken)

Execute an arbitrary G/M/T-code in text form and return the result as a string

Declaration
public Task<string> PerformSimpleCode(string code, CodeChannel channel, bool executeAsynchronously, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string code

The code to execute

CodeChannel channel

Optional destination channel of this code

bool executeAsynchronously

Execute this code asynchronously in the background

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<string>

Result of the given code converted to a string

Remarks

Cancelling the read operation does not cancel the code execution

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

OperationCanceledException

Code or operation has been cancelled

SocketException

Command could not be processed

See Also
SimpleCode
CommandExecution

PerformSimpleCode(string, CodeChannel, CancellationToken)

Execute an arbitrary G/M/T-code in text form and return the result as a string

Declaration
public Task<string> PerformSimpleCode(string code, CodeChannel channel = CodeChannel.SBC, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string code

The code to execute

CodeChannel channel

Optional destination channel of this code

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<string>

Result of the given code converted to a string

Remarks

Cancelling the read operation does not cancel the code execution

Exceptions
Type Condition
InvalidOperationException

Requested code channel is disabled

OperationCanceledException

Code or operation has been cancelled

SocketException

Command could not be processed

See Also
SimpleCode
CommandExecution

ReloadPlugin(string, CancellationToken)

Reload a plugin manifest

Declaration
public Task ReloadPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string plugin

Identifier of the plugin

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManagePlugins

RemoveHttpEndpoint(HttpEndpointType, string, string, CancellationToken)

Remove an existing HTTP endpoint

Declaration
public Task<bool> RemoveHttpEndpoint(HttpEndpointType endpointType, string ns, string path, CancellationToken cancellationToken = default)
Parameters
Type Name Description
HttpEndpointType endpointType

Type of the endpoint to remove

string ns

Namespace of the endpoint to remove

string path

Endpoint to remove

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if the endpoint could be removed

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
RegisterHttpEndpoints

RemoveUserSession(int, CancellationToken)

Remove an existing user session

Declaration
public Task<bool> RemoveUserSession(int id, CancellationToken cancellationToken = default)
Parameters
Type Name Description
int id

Identifier of the session

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if the session could be removed

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManageUserSessions

ResolvePath(string, CancellationToken)

Resolve a RepRapFirmware-style file path to a real file path

Declaration
public Task<string> ResolvePath(string path, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string path

File path to resolve

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<string>

Resolved file path

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
FileSystemAccess

SetMachineModel(string, string, CancellationToken)

Set a given property to a certain value. Make sure to lock the object model before calling this

Declaration
[Obsolete("Deprecated in favor of SetObjectModel")]
public Task<bool> SetMachineModel(string path, string value, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string path

Path to the property

string value

New value as string

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if the property could be updated

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

SetObjectModel(string, string, CancellationToken)

Set a given property to a certain value. Make sure to lock the object model before calling this

Declaration
public Task<bool> SetObjectModel(string path, string value, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string path

Path to the property

string value

New value as string

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task<bool>

True if the property could be updated

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ObjectModelReadWrite

SetPluginData(string, object, string?, CancellationToken)

Set custom plugin data in the object model

Declaration
[Obsolete("Deprecated in favour of new overload which takes a JsonElement argument")]
public Task SetPluginData(string key, object value, string? plugin = null, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string key

Key to set

object value

Value to set

string plugin

Identifier of the plugin to update (optional)

CancellationToken cancellationToken
Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

UnauthorizedAccessException

Insufficient permissions to modify other plugin data

See Also
ObjectModelReadWrite
ManagePlugins

SetPluginData(string, JsonElement, string?, CancellationToken)

Set custom plugin data in the object model

Declaration
public Task SetPluginData(string key, JsonElement value, string? plugin = null, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string key

Key to set

JsonElement value

Value to set

string plugin

Identifier of the plugin to update (optional)

CancellationToken cancellationToken
Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

UnauthorizedAccessException

Insufficient permissions to modify other plugin data

See Also
ObjectModelReadWrite
ManagePlugins

SetUpdateStatus(bool, CancellationToken)

Override the current machine status if a software update is in progress

Declaration
public Task SetUpdateStatus(bool isUpdating, CancellationToken cancellationToken = default)
Parameters
Type Name Description
bool isUpdating

If the machine status is supposed to be overrridden

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Remarks

The object model must not be locked when this is called

StartPlugin(string, CancellationToken)

Start a plugin

Declaration
public Task StartPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string plugin

Identifier of the plugin

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManagePlugins

StopPlugin(string, CancellationToken)

Stop a plugin

Declaration
public Task StopPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string plugin

Identifier of the plugin

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManagePlugins

SyncMachineModel(CancellationToken)

Wait for the full machine model to be updated from RepRapFirmware

Declaration
[Obsolete("Deprecated in favor of SyncObjectModel")]
public Task SyncMachineModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

SyncObjectModel(CancellationToken)

Wait for the full object model to be updated from RepRapFirmware

Declaration
public Task SyncObjectModel(CancellationToken cancellationToken = default)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
ObjectModelRead
ObjectModelReadWrite

UninstallPlugin(string, CancellationToken)

Uninstall a plugin

Declaration
public Task UninstallPlugin(string plugin, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string plugin

Identifier of the plugin

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
ManagePlugins

UninstallSystemPackage(string, CancellationToken)

Uninstall a system package

Declaration
public Task UninstallSystemPackage(string package, CancellationToken cancellationToken = default)
Parameters
Type Name Description
string package

Identifier of the package

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
SuperUser

UnlockMachineModel(CancellationToken)

Unlock the machine model again

Declaration
[Obsolete("Deprecated in favor of UnlockObjectModel")]
public Task UnlockMachineModel(CancellationToken cancellationToken)
Parameters
Type Name Description
CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

WriteMessage(Message, bool, LogLevel, CancellationToken)

Write an arbitrary generic message

Declaration
public Task WriteMessage(Message message, bool outputMessage = true, LogLevel logLevel = LogLevel.Off, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Message message

Message

bool outputMessage

Whether to output the message

LogLevel logLevel

Target log level

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
ObjectModelReadWrite

WriteMessage(Message, bool, bool, CancellationToken)

Write an arbitrary generic message

Declaration
[Obsolete("This overload is deprecated because it lacks support for log levels")]
public Task WriteMessage(Message message, bool outputMessage = true, bool logMessage = false, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Message message

Message

bool outputMessage

Whether to output the message

bool logMessage

Whether to log the message

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
ObjectModelReadWrite

WriteMessage(MessageType, string, bool, bool, CancellationToken)

Write an arbitrary generic message

Declaration
[Obsolete("This overload is deprecated because it lacks support for log levels")]
public Task WriteMessage(MessageType type, string message, bool outputMessage, bool logMessage, CancellationToken cancellationToken = default)
Parameters
Type Name Description
MessageType type

Message type

string message

Message content

bool outputMessage

Whether to output the message

bool logMessage

Whether to log the message

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
ObjectModelReadWrite

WriteMessage(MessageType, string, bool, LogLevel?, CancellationToken)

Write an arbitrary generic message

Declaration
public Task WriteMessage(MessageType type, string message, bool outputMessage = true, LogLevel? logLevel = null, CancellationToken cancellationToken = default)
Parameters
Type Name Description
MessageType type

Message type

string message

Message content

bool outputMessage

Whether to output the message

LogLevel? logLevel

Target log level or null to determine log level from the message type

CancellationToken cancellationToken

Optional cancellation token

Returns
Type Description
Task

Asynchronous task

Exceptions
Type Condition
OperationCanceledException

Operation has been cancelled

SocketException

Command could not be processed

See Also
CommandExecution
ObjectModelReadWrite

Implements

IDisposable

See Also

Command
In this article
Back to top Generated by DocFX