Created by Docfx
  • DuetAPI
  • DuetAPIClient
  • DuetControlServer
  • DuetWebServer
  • DuetAPI.Commands
  • Code
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 Code

A parsed representation of a generic G/M/T-code

Inheritance
object
BaseCommand
Command<Message>
Code
Code
Inherited Members
Command<Message>.Execute()
Command<Message>.Invoke()
BaseCommand.Command
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: DuetAPI.Commands
Assembly: DuetAPI.dll
Syntax
[RequiredPermissions(SbcPermissions.CommandExecution)]
public class Code : Command<Message?>

Constructors

Code()

Create an empty Code representation

Declaration
public Code()

Code(string)

Create a new Code instance and attempt to parse the given code string

Declaration
public Code(string code)
Parameters
Type Name Description
string code

UTF8-encoded G/M/T-Code

Properties

Channel

Code channel to send this code to

Declaration
public CodeChannel Channel { get; set; }
Property Value
Type Description
CodeChannel

Comment

Comment of the G/M/T-code. May be null if no comment is present

Declaration
public string? Comment { get; set; }
Property Value
Type Description
string
Remarks

The parser combines different comment segments and concatenates them as a single value. So for example a code like 'G28 (Do homing) ; via G28' causes the Comment field to be filled with 'Do homing via G28'

FilePosition

File position of this code in bytes (optional)

Declaration
public long? FilePosition { get; set; }
Property Value
Type Description
long?

Flags

Flags of this code

Declaration
public CodeFlags Flags { get; set; }
Property Value
Type Description
CodeFlags

Indent

Number of whitespaces prefixing the command content

Declaration
public byte Indent { get; set; }
Property Value
Type Description
byte

IsFromFileChannel

Check if this code is from a file channel

Declaration
[JsonIgnore]
public bool IsFromFileChannel { get; }
Property Value
Type Description
bool

Keyword

Type of conditional G-code (if any)

Declaration
public KeywordType Keyword { get; set; }
Property Value
Type Description
KeywordType

KeywordArgument

Argument of the conditional G-code (if any)

Declaration
public string? KeywordArgument { get; set; }
Property Value
Type Description
string

Length

Length of the original code in bytes (optional)

Declaration
public int? Length { get; set; }
Property Value
Type Description
int?

LineNumber

Line number of this code

Declaration
public long? LineNumber { get; set; }
Property Value
Type Description
long?

MajorNumber

Major code number (e.g. 28 in G28)

Declaration
public int? MajorNumber { get; set; }
Property Value
Type Description
int?

MinorNumber

Minor code number (e.g. 3 in G54.3)

Declaration
public sbyte? MinorNumber { get; set; }
Property Value
Type Description
sbyte?

Parameters

List of parsed code parameters (see CodeParameter for further information)

Declaration
public List<CodeParameter> Parameters { get; set; }
Property Value
Type Description
List<CodeParameter>
See Also
CodeParameter

Result

Result of this code. This property is only set when the code has finished its excution. It remains null if the code has been cancelled

Declaration
public Message? Result { get; set; }
Property Value
Type Description
Message
Remarks

This used to be of type CodeResult but since v3.2 CodeResult can read Message JSON so it should remain compatible

SourceConnection

The connection ID this code was received from. If this is 0, the code originates from an internal DCS task

Declaration
public int SourceConnection { get; set; }
Property Value
Type Description
int
Remarks

Usually there is no need to populate this property. It is internally overwritten by the control server on receipt

Type

Type of the code

Declaration
public CodeType Type { get; set; }
Property Value
Type Description
CodeType

Methods

ConvertDriverIds()

Convert parameters of this code to driver id(s)

Declaration
public void ConvertDriverIds()
Exceptions
Type Condition
CodeParserException

Driver ID could not be parsed

GetBool(char)

Get a boolean parameter value

Declaration
public bool GetBool(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
bool

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetBool(char, bool)

Get a boolean parameter value

Declaration
public bool GetBool(char letter, bool defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

bool defaultValue

Default value to return if no parameter could be found

Returns
Type Description
bool

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetDriverId(char)

Get a driver ID parameter value

Declaration
public DriverId GetDriverId(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
DriverId

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetDriverId(char, DriverId)

Get a driver ID parameter value

Declaration
public DriverId GetDriverId(char letter, DriverId defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

DriverId defaultValue

Default value to return if no parameter could be found

Returns
Type Description
DriverId

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetDriverIdArray(char)

Get a driver ID array parameter value

Declaration
public DriverId[] GetDriverIdArray(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
DriverId[]

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetDriverIdArray(char, DriverId[])

Get a driver ID array parameter value

Declaration
public DriverId[] GetDriverIdArray(char letter, DriverId[] defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

DriverId[] defaultValue

Default value to return if no parameter could be found

Returns
Type Description
DriverId[]

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetFloat(char)

Get a float parameter value

Declaration
public float GetFloat(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
float

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetFloat(char, float)

Get a float parameter value

Declaration
public float GetFloat(char letter, float defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

float defaultValue

Default value to return if no parameter could be found

Returns
Type Description
float

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetFloatArray(char)

Get a float array parameter value

Declaration
public float[] GetFloatArray(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
float[]

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetFloatArray(char, float[])

Get a float array parameter value

Declaration
public float[] GetFloatArray(char letter, float[] defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

float[] defaultValue

Default value to return if no parameter could be found

Returns
Type Description
float[]

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetIPAddress(char)

Get an IP address parameter value

Declaration
public IPAddress GetIPAddress(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
IPAddress

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetIPAddress(char, IPAddress)

Get an IP address parameter value

Declaration
public IPAddress GetIPAddress(char letter, IPAddress defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

IPAddress defaultValue

Default value to return if no parameter could be found

Returns
Type Description
IPAddress

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetInt(char)

Get an integer parameter value

Declaration
public int GetInt(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
int

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetInt(char, int)

Get an integer parameter value

Declaration
public int GetInt(char letter, int defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

int defaultValue

Default value to return if no parameter could be found

Returns
Type Description
int

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetIntArray(char)

Get an integer array parameter value

Declaration
public int[] GetIntArray(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
int[]

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetIntArray(char, int[])

Get an integer array parameter value

Declaration
public int[] GetIntArray(char letter, int[] defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

int[] defaultValue

Default value to return if no parameter could be found

Returns
Type Description
int[]

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetLong(char)

Get a long parameter value

Declaration
public long GetLong(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
long

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetLong(char, long)

Get a long parameter value

Declaration
public long GetLong(char letter, long defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

long defaultValue

Default value to return if no parameter could be found

Returns
Type Description
long

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetLongArray(char)

Get a long array parameter value

Declaration
public long[] GetLongArray(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
long[]

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetLongArray(char, long[])

Get a long array parameter value

Declaration
public long[] GetLongArray(char letter, long[] defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

long[] defaultValue

Default value to return if no parameter could be found

Returns
Type Description
long[]

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetOptionalString(char)

Get a string parameter value

Declaration
public string? GetOptionalString(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
string

Parameter value or null

GetParameter(char)

Retrieve the parameter whose letter equals c

Declaration
public CodeParameter? GetParameter(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
CodeParameter

The parsed parameter instance or null if none could be found

GetParameter(char, object)

Retrieve the parameter whose letter equals c or generate a default parameter

Declaration
public CodeParameter GetParameter(char letter, object defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

object defaultValue

Default parameter value (no expression)

Returns
Type Description
CodeParameter

The parsed parameter instance or null if none could be found

GetString(char)

Get a string parameter value

Declaration
public string GetString(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
string

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetString(char, string)

Get an unsigned integer parameter value

Declaration
public string GetString(char letter, string defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

string defaultValue

Default value to return if no parameter could be found

Returns
Type Description
string

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetUInt(char)

Get an unsigned integer parameter value

Declaration
public uint GetUInt(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
uint

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetUInt(char, uint)

Get an unsigned integer parameter value

Declaration
public uint GetUInt(char letter, uint defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

uint defaultValue

Default value to return if no parameter could be found

Returns
Type Description
uint

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetUIntArray(char)

Get an unsigned integer array parameter value

Declaration
public uint[] GetUIntArray(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
uint[]

Parameter value

Exceptions
Type Condition
MissingParameterException

Parameter not found

InvalidParameterTypeException

Failed to convert parameter value

GetUIntArray(char, uint[])

Get an unsigned integer array parameter value

Declaration
public uint[] GetUIntArray(char letter, uint[] defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

uint[] defaultValue

Default value to return if no parameter could be found

Returns
Type Description
uint[]

Parameter value

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

GetUnprecedentedString(bool)

Reconstruct an unprecedented string from the parameter list or retrieve the parameter which does not have a letter assigned

Declaration
public string GetUnprecedentedString(bool quoteStrings = false)
Parameters
Type Name Description
bool quoteStrings

Encapsulate strings in double quotes

Returns
Type Description
string

Unprecedented string

Remarks

If no parameter is present, an empty string is returned

HasParameter(char)

Check if a given parameter exists

Declaration
public bool HasParameter(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
bool

If the parameter is present

Parameter(char)

Retrieve the parameter whose letter equals c

Declaration
[Obsolete("Use GetParameter or one of the typed getter methods instead")]
public CodeParameter? Parameter(char letter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

Returns
Type Description
CodeParameter

The parsed parameter instance or null if none could be found

Parameter(char, object)

Retrieve the parameter whose letter equals c or generate a default parameter

Declaration
[Obsolete("Use GetParameter or one of the typed getter methods instead")]
public CodeParameter Parameter(char letter, object defaultValue)
Parameters
Type Name Description
char letter

Letter of the parameter to find

object defaultValue

Default parameter value (no expression)

Returns
Type Description
CodeParameter

The parsed parameter instance or null if none could be found

Parse(TextReader, Code)

Parse the next available G/M/T-code from the given stream

Declaration
public static bool Parse(TextReader reader, Code result)
Parameters
Type Name Description
TextReader reader

Input to read from

Code result

Code to fill

Returns
Type Description
bool

Whether anything could be read

Remarks

In general it is better to use ParseAsync(StreamReader, Code, CodeParserBuffer) because this implementation

  • does not update the line number unless it is specified using the 'N' character
  • does not set the corresponding flag for G53 after the first code on a line
  • sets the indentation level only for the first code in a line
  • does not support Fanuc or LaserWeb styles
Exceptions
Type Condition
CodeParserException

Thrown if the code contains errors like unterminated strings or unterminated comments

ParseAsync(Stream, Code, CodeParserBuffer, CancellationToken)

Parse the next available G/M/T-code from the given stream asynchronously

Declaration
public static ValueTask<bool> ParseAsync(Stream stream, Code result, CodeParserBuffer buffer, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Stream stream

Stream to read from

Code result

Code to fill

CodeParserBuffer buffer

Internal buffer for parsing codes

CancellationToken cancellationToken

Cancellation token instance

Returns
Type Description
ValueTask<bool>

Whether anything could be read

Exceptions
Type Condition
ArgumentException

BOM from start of file showed that this file is neither ASCII nor UTF-8

CodeParserException

Thrown if the code contains errors like unterminated strings or unterminated comments

ParseAsync(StreamReader, Code, CodeParserBuffer)

Parse the next available G/M/T-code from the given stream reader asynchronously

Declaration
[Obsolete("This call is deprecated because the buffer position of a StreamReader is not accessible. Pass your stream directly instead")]
public static ValueTask<bool> ParseAsync(StreamReader reader, Code result, CodeParserBuffer buffer)
Parameters
Type Name Description
StreamReader reader

Stream reader to read from

Code result

Code to fill

CodeParserBuffer buffer

Internal buffer for parsing codes

Returns
Type Description
ValueTask<bool>

Whether anything could be read

Exceptions
Type Condition
CodeParserException

Thrown if the code contains errors like unterminated strings or unterminated comments

Reset()

Reset this instance

Declaration
public virtual void Reset()

ToShortString()

Convert only the command portion to a text-based G/M/T-code (e.g. G28)

Declaration
public string ToShortString()
Returns
Type Description
string

Command fraction of the code

ToString()

Convert the parsed code back to a text-based G/M/T-code

Declaration
public override string ToString()
Returns
Type Description
string

Reconstructed code string

Overrides
object.ToString()

TryGetBool(char, out bool)

Try to get a long parameter value by letter

Declaration
public bool TryGetBool(char letter, out bool parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

bool parameter

Parameter if found, else default

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetBool(char, out bool?)

Try to get a long parameter value by letter

Declaration
public bool TryGetBool(char letter, out bool? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

bool? parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetDriverId(char, out DriverId?)

Try to get a driver ID parameter value by letter

Declaration
public bool TryGetDriverId(char letter, out DriverId? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

DriverId parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetDriverIdArray(char, out DriverId[]?)

Try to get a long array parameter value by letter

Declaration
public bool TryGetDriverIdArray(char letter, out DriverId[]? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

DriverId[] parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetFloat(char, out float?)

Try to get a float parameter value by letter

Declaration
public bool TryGetFloat(char letter, out float? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

float? parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetFloat(char, out float)

Try to get a float parameter value by letter

Declaration
public bool TryGetFloat(char letter, out float parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

float parameter

Parameter if found, else default

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetFloatArray(char, out float[]?)

Try to get a float array parameter value by letter

Declaration
public bool TryGetFloatArray(char letter, out float[]? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

float[] parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetIPAddress(char, out IPAddress?)

Try to get a driver ID parameter value by letter

Declaration
public bool TryGetIPAddress(char letter, out IPAddress? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

IPAddress parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetInt(char, out int)

Try to get an integer parameter value by letter

Declaration
public bool TryGetInt(char letter, out int parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

int parameter

Parameter if found, else default

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetInt(char, out int?)

Try to get an integer parameter value by letter

Declaration
public bool TryGetInt(char letter, out int? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

int? parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetIntArray(char, out int[]?)

Try to get an integer array parameter value by letter

Declaration
public bool TryGetIntArray(char letter, out int[]? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

int[] parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetLong(char, out long)

Try to get a long parameter value by letter

Declaration
public bool TryGetLong(char letter, out long parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

long parameter

Parameter if found, else default

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetLong(char, out long?)

Try to get a long parameter value by letter

Declaration
public bool TryGetLong(char letter, out long? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

long? parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetLongArray(char, out long[]?)

Try to get a long array parameter value by letter

Declaration
public bool TryGetLongArray(char letter, out long[]? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

long[] parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetParameter(char, out CodeParameter?)

Try to get a parameter by letter

Declaration
public bool TryGetParameter(char letter, out CodeParameter? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

CodeParameter parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

TryGetString(char, out string?)

Try to get a string parameter value by letter

Declaration
public bool TryGetString(char letter, out string? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

string parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetUInt(char, out uint?)

Try to get an unsigned integer parameter value by letter

Declaration
public bool TryGetUInt(char letter, out uint? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

uint? parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetUInt(char, out uint)

Try to get an unsigned integer parameter value by letter

Declaration
public bool TryGetUInt(char letter, out uint parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

uint parameter

Parameter if found, else default

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

TryGetUIntArray(char, out uint[]?)

Try to get an unsigned integer array parameter value by letter

Declaration
public bool TryGetUIntArray(char letter, out uint[]? parameter)
Parameters
Type Name Description
char letter

Letter of the parameter to find

uint[] parameter

Parameter if found, else null

Returns
Type Description
bool

True if the requested parameter could be found

Exceptions
Type Condition
InvalidParameterTypeException

Failed to convert parameter value

In this article
  • Constructors
    • Code()
    • Code(string)
  • Properties
    • Channel
    • Comment
    • FilePosition
    • Flags
    • Indent
    • IsFromFileChannel
    • Keyword
    • KeywordArgument
    • Length
    • LineNumber
    • MajorNumber
    • MinorNumber
    • Parameters
    • Result
    • SourceConnection
    • Type
  • Methods
    • ConvertDriverIds()
    • GetBool(char)
    • GetBool(char, bool)
    • GetDriverId(char)
    • GetDriverId(char, DriverId)
    • GetDriverIdArray(char)
    • GetDriverIdArray(char, DriverId[])
    • GetFloat(char)
    • GetFloat(char, float)
    • GetFloatArray(char)
    • GetFloatArray(char, float[])
    • GetIPAddress(char)
    • GetIPAddress(char, IPAddress)
    • GetInt(char)
    • GetInt(char, int)
    • GetIntArray(char)
    • GetIntArray(char, int[])
    • GetLong(char)
    • GetLong(char, long)
    • GetLongArray(char)
    • GetLongArray(char, long[])
    • GetOptionalString(char)
    • GetParameter(char)
    • GetParameter(char, object)
    • GetString(char)
    • GetString(char, string)
    • GetUInt(char)
    • GetUInt(char, uint)
    • GetUIntArray(char)
    • GetUIntArray(char, uint[])
    • GetUnprecedentedString(bool)
    • HasParameter(char)
    • Parameter(char)
    • Parameter(char, object)
    • Parse(TextReader, Code)
    • ParseAsync(Stream, Code, CodeParserBuffer, CancellationToken)
    • ParseAsync(StreamReader, Code, CodeParserBuffer)
    • Reset()
    • ToShortString()
    • ToString()
    • TryGetBool(char, out bool)
    • TryGetBool(char, out bool?)
    • TryGetDriverId(char, out DriverId?)
    • TryGetDriverIdArray(char, out DriverId[]?)
    • TryGetFloat(char, out float?)
    • TryGetFloat(char, out float)
    • TryGetFloatArray(char, out float[]?)
    • TryGetIPAddress(char, out IPAddress?)
    • TryGetInt(char, out int)
    • TryGetInt(char, out int?)
    • TryGetIntArray(char, out int[]?)
    • TryGetLong(char, out long)
    • TryGetLong(char, out long?)
    • TryGetLongArray(char, out long[]?)
    • TryGetParameter(char, out CodeParameter?)
    • TryGetString(char, out string?)
    • TryGetUInt(char, out uint?)
    • TryGetUInt(char, out uint)
    • TryGetUIntArray(char, out uint[]?)
Back to top Generated by DocFX