Table of Contents

Class CodeFile

Namespace
DuetControlServer.Files
Assembly
DuetControlServer.dll

Class to read G/M/T-codes from files

public class CodeFile : IDisposable
Inheritance
CodeFile
Implements
Derived
Inherited Members

Constructors

Copy constructor

public CodeFile(CodeFile copyFrom, CodeChannel channel, CodeFactory codeFactory, CodeProcessor codeProcessor, Expressions expressions, LinkInterface linkInterface, ObjectModel model, ILoggerFactory loggerFactory, IOptions<Settings> settings)

Parameters

copyFrom CodeFile

File to copy from

channel CodeChannel

Channel where the file is executed

codeFactory CodeFactory

Factory to create new codes

codeProcessor CodeProcessor

Code processor to process the codes

expressions Expressions

Expressions to evaluate the codes

linkInterface LinkInterface

Link interface

model ObjectModel

Object model to access the machine state

loggerFactory ILoggerFactory

Logger factory

settings IOptions<Settings>

Settings to use

Class to read G/M/T-codes from files

public CodeFile(CodeFilePath filePath, CodeChannel channel, CodeFactory codeFactory, CodeProcessor codeProcessor, Expressions expressions, LinkInterface linkInterface, ObjectModel model, ILoggerFactory loggerFactory, IOptions<Settings> settings)

Parameters

filePath CodeFilePath

Path of the file

channel CodeChannel

Channel to send the codes to

codeFactory CodeFactory

Factory to create new codes

codeProcessor CodeProcessor

Code processor to process the codes

expressions Expressions

Expressions to evaluate the codes

linkInterface LinkInterface

Link interface

model ObjectModel

Object model to access the machine state

loggerFactory ILoggerFactory

Logger factory

settings IOptions<Settings>

Settings to use

Properties

Channel

Channel to send the codes to

public CodeChannel Channel { get; }

Property Value

CodeChannel

FilePath

File path to the file being executed

public CodeFilePath FilePath { get; }

Property Value

CodeFilePath

IsClosed

Indicates if this file is closed

public bool IsClosed { get; }

Property Value

bool

Length

Returns the length of the file in bytes

public long Length { get; }

Property Value

long

LineNumber

Current line number in the file

public long LineNumber { get; }

Property Value

long

NextFilePosition

File position of the next code to actually run

public long NextFilePosition { get; set; }

Property Value

long

Position

Gets or sets the current file position in bytes

public long Position { get; set; }

Property Value

long

Methods

AddLocalVariable(string)

Add a new local variable to the current code block

public void AddLocalVariable(string varName)

Parameters

varName string

Name of the variable

Close()

Close this file

public void Close()

Dispose()

Dispose this instance

public virtual void Dispose()

~CodeFile()

Finalizer of a base file

protected ~CodeFile()

GetIterations(Code)

Get the current number of iterations of the current loop

public int GetIterations(Code code)

Parameters

code Code

Code that requested the number of iterations

Returns

int

Number of iterations

Exceptions

CodeParserException

Query came outside a while loop

Lock(CancellationToken)

Lock this instance

public IDisposable Lock(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

IDisposable

Disposable lock

LockAsync(CancellationToken)

Lock this instance asynchronously

public AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

AwaitableDisposable<IDisposable>

Disposable lock

ReadCodeAsync(Code?, CancellationToken)

Read the next available code and interpret conditional codes performing flow control

public Task<Code?> ReadCodeAsync(Code? sharedCode = null, CancellationToken cancellationToken = default)

Parameters

sharedCode Code

Code that may be reused

cancellationToken CancellationToken

Cancellation token

Returns

Task<Code>

Read code or null if none found

Remarks

This instance must NOT be locked when this is called

Exceptions

CodeParserException

Failed to read the next code

OperationCanceledException

Failed to flush the pending codes