Class JobProcessor
- Namespace
- DuetControlServer.Files
- Assembly
- DuetControlServer.dll
Main class dealing with job files
[DiagnosticsPriority(-1)]
public class JobProcessor : BackgroundService, IHostedService, IDisposable, IAsyncDiagnostics
- Inheritance
-
JobProcessor
- Implements
- Inherited Members
Constructors
JobProcessor(CodeFactory, CodeProcessor, EventLogger, Expressions, FileFactory, FileInfoParser, LinkInterface, ObjectModel, IHostApplicationLifetime, ILogger<JobProcessor>, IOptions<Settings>)
Constructor of this class
public JobProcessor(CodeFactory codeFactory, CodeProcessor codeProcessor, EventLogger eventLogger, Expressions expressions, FileFactory fileFactory, FileInfoParser fileInfoParser, LinkInterface linkInterface, ObjectModel model, IHostApplicationLifetime lifetime, ILogger<JobProcessor> logger, IOptions<Settings> settings)
Parameters
codeFactoryCodeFactoryCode factory
codeProcessorCodeProcessorCode processor
eventLoggerEventLoggerEvent logger
expressionsExpressionsExpressions
fileFactoryFileFactoryFile factory
fileInfoParserFileInfoParserFile info parser
linkInterfaceLinkInterfaceLink interface
modelObjectModelObject Model
lifetimeIHostApplicationLifetimeHost application lifetime
loggerILogger<JobProcessor>Logger
settingsIOptions<Settings>Settings
Properties
FileLength
Returns the length of the file being printed in bytes
public long FileLength { get; }
Property Value
IsAborted
Indicates if the file print has been aborted
public bool IsAborted { get; }
Property Value
IsCancelled
Indicates if the file print has been cancelled
public bool IsCancelled { get; }
Property Value
IsFileSelected
Indicates if a file has been selected for printing
public bool IsFileSelected { get; }
Property Value
IsPaused
Indicates if the file print has been paused
public bool IsPaused { get; }
Property Value
IsProcessing
Indicates if a print is live
public bool IsProcessing { get; }
Property Value
IsSimulating
Indicates if a file is being simulated
public bool IsSimulating { get; }
Property Value
Remarks
This is volatile to allow fast access without locking the class first
Methods
Abort()
Abort the current print asynchronously. This is called when the print could not complete as expected
public void Abort()
Cancel()
Cancel the current print (e.g. when M0/M1 is called)
public void Cancel()
ExecuteAsync(CancellationToken)
Perform actual print jobs
protected override Task ExecuteAsync(CancellationToken stoppingToken)
Parameters
stoppingTokenCancellationToken
Returns
ForkAsync(CancellationToken)
Fork the file being processed to execute concurrently
public Task<Message> ForkAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
GetFilePositionAsync(int, CancellationToken)
Get the current file position
public Task<long> GetFilePositionAsync(int motionSystem, CancellationToken cancellationToken)
Parameters
motionSystemintMotion system
cancellationTokenCancellationTokenCancellation token
Returns
Lock()
Lock this class
public IDisposable Lock()
Returns
- IDisposable
Disposable lock
Lock(CancellationToken)
Lock this class
public IDisposable Lock(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
- IDisposable
Disposable lock
LockAsync()
Lock this class asynchronously
public AwaitableDisposable<IDisposable> LockAsync()
Returns
- AwaitableDisposable<IDisposable>
Disposable lock
LockAsync(CancellationToken)
Lock this class asynchronously
public AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
- AwaitableDisposable<IDisposable>
Disposable lock
Pause(long?, long?, PrintPausedReason)
Called when the print is being paused
public void Pause(long? filePosition, long? filePosition2, PrintPausedReason pauseReason)
Parameters
filePositionlong?File position where the print was paused
filePosition2long?pauseReasonPrintPausedReasonReason why the print has been paused
PrintDiagnosticsAsync(StringBuilder, CancellationToken)
Print diagnostics of this class
public ValueTask PrintDiagnosticsAsync(StringBuilder builder, CancellationToken cancellationToken)
Parameters
builderStringBuilderString builder
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
Asynchronous task
Resume()
Resume a file print
public void Resume()
SelectFileAsync(string, string, bool, CancellationToken)
Select a new file to print asynchronously
public Task SelectFileAsync(string virtualFile, string physicalFile, bool simulating = false, CancellationToken cancellationToken = default)
Parameters
virtualFilestringFile to print
physicalFilestringPhysical file to print
simulatingboolWhether the file is being simulated
cancellationTokenCancellationToken
Returns
- Task
Asynchronous task
Remarks
This class has to be locked when this method is called
SetFilePositionAsync(int, long, CancellationToken)
Set the current file position
public Task SetFilePositionAsync(int motionSystem, long filePosition, CancellationToken cancellationToken = default)
Parameters
motionSystemintMotion system
filePositionlongNew file position
cancellationTokenCancellationToken
Returns
- Task
File position
StartSecondJob()
Start the second file job if applicable
public void StartSecondJob()