Class CodeParameter
Represents a parsed parameter of a G/M/T-code Initial parsing is done whenever a code is processed
Inherited Members
Namespace: DuetAPI.Commands
Assembly: DuetAPI.dll
Syntax
[JsonConverter(typeof(CodeParameterConverter))]
public class CodeParameter
Constructors
CodeParameter(char, object?)
Creates a new CodeParameter instance and with the given value
Declaration
public CodeParameter(char letter, object? value)
Parameters
Type | Name | Description |
---|---|---|
char | letter | Letter of the code parameter (automatically converted to upper-case) |
object | value | Value of this parameter |
CodeParameter(char, string, bool, bool)
Creates a new CodeParameter instance and parses value to a native data type if applicable
Declaration
public CodeParameter(char letter, string value, bool isString, bool isDriverId)
Parameters
Type | Name | Description |
---|---|---|
char | letter | Letter of the code parameter |
string | value | String representation of the value |
bool | isString | Whether this is a string. This is set to true if the parameter was inside quotation marks |
bool | isDriverId | 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
Declaration
public bool IsDriverId { get; }
Property Value
Type | Description |
---|---|
bool |
IsExpression
Indicates if this parameter is an expression that can be evaluated
Declaration
public bool IsExpression { get; }
Property Value
Type | Description |
---|---|
bool |
IsNull
Check if the parameter does not have any data
Declaration
[JsonIgnore]
public bool IsNull { get; }
Property Value
Type | Description |
---|---|
bool |
Letter
Letter of the code parameter (e.g. P in M106 P3)
Declaration
public char Letter { get; }
Property Value
Type | Description |
---|---|
char |
Remarks
If this is an unprecedented parameter without a letter, '@' is used
Type
Data type of the internally parsed value
Declaration
[JsonIgnore]
public Type? Type { get; }
Property Value
Type | Description |
---|---|
Type |
Methods
Equals(object?)
Checks if the other obj equals this instance
Declaration
public override bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | Other object |
Returns
Type | Description |
---|---|
bool | True if both objects are not equal |
Overrides
GetHashCode()
Returns the hash code of this instance
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | Computed hash code |
Overrides
ToString()
Converts this parameter to a string
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | String representation |
Overrides
Operators
operator ==(CodeParameter?, object?)
Equality operator
Declaration
public static bool operator ==(CodeParameter? a, object? b)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | a | Code parameter |
object | b | Other object |
Returns
Type | Description |
---|---|
bool | True if both objects are equal |
explicit operator DriverId?(CodeParameter?)
Explicit conversion operator to a driver ID
Declaration
public static explicit operator DriverId?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
DriverId | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator DriverId[]?(CodeParameter?)
Explicit conversion operator to a driver ID array
Declaration
public static explicit operator DriverId[]?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
DriverId[] | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator bool(CodeParameter?)
Explicit conversion operator to bool
Declaration
public static explicit operator bool(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
bool | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator int(CodeParameter?)
Explicit conversion operator to int
Declaration
public static explicit operator int(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
int | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator int[]?(CodeParameter?)
Explicit conversion operator to integer array
Declaration
public static explicit operator int[]?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
int[] | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator long(CodeParameter?)
Explicit conversion operator to long
Declaration
public static explicit operator long(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
long | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator long[]?(CodeParameter?)
Explicit conversion operator to long array
Declaration
public static explicit operator long[]?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
long[] | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator IPAddress?(CodeParameter?)
Explicit conversion operator to an IP address
Declaration
public static explicit operator IPAddress?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
IPAddress | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator bool?(CodeParameter?)
Explicit conversion operator to bool?
Declaration
public static explicit operator bool?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
bool? | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator int?(CodeParameter?)
Explicit conversion operator to int?
Declaration
public static explicit operator int?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
int? | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator long?(CodeParameter?)
Explicit conversion operator to long?
Declaration
public static explicit operator long?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
long? | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator float?(CodeParameter?)
Explicit conversion operator to float?
Declaration
public static explicit operator float?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
float? | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator uint?(CodeParameter?)
Explicit conversion operator to uint?
Declaration
public static explicit operator uint?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
uint? | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator float(CodeParameter?)
Explicit conversion operator to float
Declaration
public static explicit operator float(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
float | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator float[]?(CodeParameter?)
Explicit conversion operator to float array
Declaration
public static explicit operator float[]?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
float[] | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator string?(CodeParameter?)
Explicit conversion operator to string
Declaration
public static explicit operator string?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
string | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator uint(CodeParameter?)
Explicit conversion operator to uint
Declaration
public static explicit operator uint(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
uint | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
explicit operator uint[]?(CodeParameter?)
Explicit conversion operator to unsigned integer array
Declaration
public static explicit operator uint[]?(CodeParameter? codeParameter)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | codeParameter | Target object |
Returns
Type | Description |
---|---|
uint[] | Converted value |
Exceptions
Type | Condition |
---|---|
InvalidParameterTypeException | Failed to convert parameter value |
operator !=(CodeParameter?, object?)
Inequality operator
Declaration
public static bool operator !=(CodeParameter? a, object? b)
Parameters
Type | Name | Description |
---|---|---|
CodeParameter | a | Code parameter |
object | b | Other object |
Returns
Type | Description |
---|---|
bool | True if both objects are not equal |