Table of Contents

Class CodeParameter

Namespace
DuetAPI.Commands
Assembly
DuetAPI.dll

Represents a parsed parameter of a G/M/T-code Initial parsing is done whenever a code is processed

[JsonConverter(typeof(CodeParameterConverter))]
public class CodeParameter
Inheritance
CodeParameter
Inherited Members

Constructors

CodeParameter(char, object?)

Creates a new CodeParameter instance and with the given value

public CodeParameter(char letter, object? value)

Parameters

letter char

Letter of the code parameter (automatically converted to upper-case)

value object

Value of this parameter

CodeParameter(char, string, bool, bool)

Creates a new CodeParameter instance and parses value to a native data type if applicable

public CodeParameter(char letter, string value, bool isString, bool isDriverId)

Parameters

letter char

Letter of the code parameter

value string

String representation of the value

isString bool

Whether this is a string. This is set to true if the parameter was inside quotation marks

isDriverId bool

Whether this is a driver ID

Remarks

This constructor does not parsed long (aka int64) values because RRF cannot handle them

Properties

IsDriverId

Indicates if this parameter is a driver identifier

public bool IsDriverId { get; }

Property Value

bool

IsExpression

Indicates if this parameter is an expression that can be evaluated

public bool IsExpression { get; }

Property Value

bool

IsNull

Check if the parameter does not have any data

[JsonIgnore]
public bool IsNull { get; }

Property Value

bool

Letter

Letter of the code parameter (e.g. P in M106 P3)

public char Letter { get; }

Property Value

char

Remarks

If this is an unprecedented parameter without a letter, '@' is used

Type

Data type of the internally parsed value

[JsonIgnore]
public Type? Type { get; }

Property Value

Type

Methods

Equals(object?)

Checks if the other obj equals this instance

public override bool Equals(object? obj)

Parameters

obj object

Other object

Returns

bool

True if both objects are not equal

GetHashCode()

Returns the hash code of this instance

public override int GetHashCode()

Returns

int

Computed hash code

ToString()

Converts this parameter to a string

public override string ToString()

Returns

string

String representation

Operators

operator ==(CodeParameter?, object?)

Equality operator

public static bool operator ==(CodeParameter? a, object? b)

Parameters

a CodeParameter

Code parameter

b object

Other object

Returns

bool

True if both objects are equal

explicit operator DriverId?(CodeParameter?)

Explicit conversion operator to a driver ID

public static explicit operator DriverId?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

DriverId

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator DriverId[]?(CodeParameter?)

Explicit conversion operator to a driver ID array

public static explicit operator DriverId[]?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

DriverId[]

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator bool(CodeParameter?)

Explicit conversion operator to bool

public static explicit operator bool(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

bool

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator int(CodeParameter?)

Explicit conversion operator to int

public static explicit operator int(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

int

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator int[]?(CodeParameter?)

Explicit conversion operator to integer array

public static explicit operator int[]?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

int[]

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator long(CodeParameter?)

Explicit conversion operator to long

public static explicit operator long(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

long

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator long[]?(CodeParameter?)

Explicit conversion operator to long array

public static explicit operator long[]?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

long[]

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator IPAddress?(CodeParameter?)

Explicit conversion operator to an IP address

public static explicit operator IPAddress?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

IPAddress

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator bool?(CodeParameter?)

Explicit conversion operator to bool?

public static explicit operator bool?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

bool?

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator int?(CodeParameter?)

Explicit conversion operator to int?

public static explicit operator int?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

int?

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator long?(CodeParameter?)

Explicit conversion operator to long?

public static explicit operator long?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

long?

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator float?(CodeParameter?)

Explicit conversion operator to float?

public static explicit operator float?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

float?

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator uint?(CodeParameter?)

Explicit conversion operator to uint?

public static explicit operator uint?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

uint?

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator float(CodeParameter?)

Explicit conversion operator to float

public static explicit operator float(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

float

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator float[]?(CodeParameter?)

Explicit conversion operator to float array

public static explicit operator float[]?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

float[]

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator string?(CodeParameter?)

Explicit conversion operator to string

public static explicit operator string?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

string

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator uint(CodeParameter?)

Explicit conversion operator to uint

public static explicit operator uint(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

uint

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

explicit operator uint[]?(CodeParameter?)

Explicit conversion operator to unsigned integer array

public static explicit operator uint[]?(CodeParameter? codeParameter)

Parameters

codeParameter CodeParameter

Target object

Returns

uint[]

Converted value

Exceptions

InvalidParameterTypeException

Failed to convert parameter value

operator !=(CodeParameter?, object?)

Inequality operator

public static bool operator !=(CodeParameter? a, object? b)

Parameters

a CodeParameter

Code parameter

b object

Other object

Returns

bool

True if both objects are not equal