Class CodeFile
Class to read G/M/T-codes from files
Implements
Inherited Members
Namespace: DuetControlServer.Files
Assembly: DuetControlServer.dll
Syntax
public class CodeFile : IDisposable
  Constructors
CodeFile(CodeFile, CodeChannel)
Copy constructor
Declaration
public CodeFile(CodeFile copyFrom, CodeChannel channel)
  Parameters
| Type | Name | Description | 
|---|---|---|
| CodeFile | copyFrom | |
| CodeChannel | channel | 
CodeFile(string, string, CodeChannel)
Constructor of the base class for reading from a G-code file
Declaration
public CodeFile(string fileName, string physicalFile, CodeChannel channel)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | fileName | Name of the file to process or null if it is optional  | 
      
| string | physicalFile | Physical path to the file  | 
      
| CodeChannel | channel | Channel to send the codes to  | 
      
Properties
Channel
Channel to send the codes to
Declaration
public CodeChannel Channel { get; }
  Property Value
| Type | Description | 
|---|---|
| CodeChannel | 
FileName
File path to the file being executed
Declaration
public string FileName { get; }
  Property Value
| Type | Description | 
|---|---|
| string | 
IsClosed
Indicates if this file is closed
Declaration
public bool IsClosed { get; }
  Property Value
| Type | Description | 
|---|---|
| bool | 
Length
Returns the length of the file in bytes
Declaration
public long Length { get; }
  Property Value
| Type | Description | 
|---|---|
| long | 
LineNumber
Current line number in the file
Declaration
public long LineNumber { get; }
  Property Value
| Type | Description | 
|---|---|
| long | 
NextFilePosition
File position of the next code to actually run
Declaration
public long NextFilePosition { get; set; }
  Property Value
| Type | Description | 
|---|---|
| long | 
PhysicalFileName
Physical file path to the file being executed
Declaration
public string PhysicalFileName { get; }
  Property Value
| Type | Description | 
|---|---|
| string | 
Position
Gets or sets the current file position in bytes
Declaration
public long Position { get; set; }
  Property Value
| Type | Description | 
|---|---|
| long | 
Methods
AddLocalVariable(string)
Add a new local variable to the current code block
Declaration
public void AddLocalVariable(string varName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | varName | Name of the variable  | 
      
Close()
Close this file
Declaration
public void Close()
  Dispose()
Dispose this instance
Declaration
public virtual void Dispose()
  ~CodeFile()
Finalizer of a base file
Declaration
protected ~CodeFile()
  GetIterations(Code)
Get the current number of iterations of the current loop
Declaration
public int GetIterations(Code code)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Code | code | Code that requested the number of iterations  | 
      
Returns
| Type | Description | 
|---|---|
| int | Number of iterations  | 
      
Exceptions
| Type | Condition | 
|---|---|
| CodeParserException | Query came outside a while loop  | 
      
Lock()
Lock this instance
Declaration
public IDisposable Lock()
  Returns
| Type | Description | 
|---|---|
| IDisposable | Disposable lock  | 
      
LockAsync()
Lock this instance asynchronously
Declaration
public AwaitableDisposable<IDisposable> LockAsync()
  Returns
| Type | Description | 
|---|---|
| AwaitableDisposable<IDisposable> | Disposable lock  | 
      
ReadCodeAsync(Code?)
Read the next available code and interpret conditional codes performing flow control
Declaration
public Task<Code?> ReadCodeAsync(Code? sharedCode = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Code | sharedCode | Code that may be reused  | 
      
Returns
| Type | Description | 
|---|---|
| Task<Code> | Read code or null if none found  | 
      
Remarks
This instance must NOT be locked when this is called
Exceptions
| Type | Condition | 
|---|---|
| CodeParserException | Failed to read the next code  | 
      
| OperationCanceledException | Failed to flush the pending codes  |