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
CodeFile(CodeFile, CodeChannel, CodeFactory, CodeProcessor, Expressions, LinkInterface, ObjectModel, ILoggerFactory, IOptions<Settings>)
Copy constructor
public CodeFile(CodeFile copyFrom, CodeChannel channel, CodeFactory codeFactory, CodeProcessor codeProcessor, Expressions expressions, LinkInterface linkInterface, ObjectModel model, ILoggerFactory loggerFactory, IOptions<Settings> settings)
Parameters
copyFromCodeFileFile to copy from
channelCodeChannelChannel where the file is executed
codeFactoryCodeFactoryFactory to create new codes
codeProcessorCodeProcessorCode processor to process the codes
expressionsExpressionsExpressions to evaluate the codes
linkInterfaceLinkInterfaceLink interface
modelObjectModelObject model to access the machine state
loggerFactoryILoggerFactoryLogger factory
settingsIOptions<Settings>Settings to use
CodeFile(CodeFilePath, CodeChannel, CodeFactory, CodeProcessor, Expressions, LinkInterface, ObjectModel, ILoggerFactory, IOptions<Settings>)
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
filePathCodeFilePathPath of the file
channelCodeChannelChannel to send the codes to
codeFactoryCodeFactoryFactory to create new codes
codeProcessorCodeProcessorCode processor to process the codes
expressionsExpressionsExpressions to evaluate the codes
linkInterfaceLinkInterfaceLink interface
modelObjectModelObject model to access the machine state
loggerFactoryILoggerFactoryLogger factory
settingsIOptions<Settings>Settings to use
Properties
Channel
Channel to send the codes to
public CodeChannel Channel { get; }
Property Value
FilePath
File path to the file being executed
public CodeFilePath FilePath { get; }
Property Value
IsClosed
Indicates if this file is closed
public bool IsClosed { get; }
Property Value
Length
Returns the length of the file in bytes
public long Length { get; }
Property Value
LineNumber
Current line number in the file
public long LineNumber { get; }
Property Value
NextFilePosition
File position of the next code to actually run
public long NextFilePosition { get; set; }
Property Value
Position
Gets or sets the current file position in bytes
public long Position { get; set; }
Property Value
Methods
AddLocalVariable(string)
Add a new local variable to the current code block
public void AddLocalVariable(string varName)
Parameters
varNamestringName 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
codeCodeCode 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
cancellationTokenCancellationTokenCancellation token
Returns
- IDisposable
Disposable lock
LockAsync(CancellationToken)
Lock this instance asynchronously
public AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation 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
sharedCodeCodeCode that may be reused
cancellationTokenCancellationTokenCancellation token
Returns
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