Class JobProcessor
Main class dealing with job files
Inherited Members
Namespace: DuetControlServer.Files
Assembly: DuetControlServer.dll
Syntax
public static class JobProcessor
Remarks
Lock this class whenever it is accessed (except for Diagnostics(StringBuilder))
Properties
FileLength
Returns the length of the file being printed in bytes
Declaration
public static long FileLength { get; }
Property Value
Type | Description |
---|---|
long |
IsAborted
Indicates if the file print has been aborted
Declaration
public static bool IsAborted { get; }
Property Value
Type | Description |
---|---|
bool |
IsCancelled
Indicates if the file print has been cancelled
Declaration
public static bool IsCancelled { get; }
Property Value
Type | Description |
---|---|
bool |
IsFileSelected
Indicates if a file has been selected for printing
Declaration
public static bool IsFileSelected { get; }
Property Value
Type | Description |
---|---|
bool |
IsPaused
Indicates if the file print has been paused
Declaration
public static bool IsPaused { get; }
Property Value
Type | Description |
---|---|
bool |
IsProcessing
Indicates if a print is live
Declaration
public static bool IsProcessing { get; }
Property Value
Type | Description |
---|---|
bool |
IsSimulating
Indicates if a file is being simulated
Declaration
public static bool IsSimulating { get; }
Property Value
Type | Description |
---|---|
bool |
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
Declaration
public static void Abort()
Cancel()
Cancel the current print (e.g. when M0/M1 is called)
Declaration
public static void Cancel()
Diagnostics(StringBuilder)
Print diagnostics of this class
Declaration
public static Task Diagnostics(StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
StringBuilder | builder | String builder |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
DoSync(Code)
Synchronize the File and File2 code streams, may only be called when a job is live
Declaration
public static Task<bool> DoSync(Code code)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code to synchronize at |
Returns
Type | Description |
---|---|
Task<bool> | True if the sync request was successful, false otherwise |
Remarks
This must be called while the Job class is NOT locked and it must be called from the same code on File AND File2, else the sync request is never resolved (or at least not before the file is cancelled)
ForkAsync(Code)
Fork the file being processed to execute concurrently
Declaration
public static Task<Message> ForkAsync(Code code)
Parameters
Type | Name | Description |
---|---|---|
Code | code | Code initiating the fork |
Returns
Type | Description |
---|---|
Task<Message> | Message result |
GetFilePosition(int)
Get the current file position
Declaration
public static Task<long> GetFilePosition(int motionSystem)
Parameters
Type | Name | Description |
---|---|---|
int | motionSystem | Motion system |
Returns
Type | Description |
---|---|
Task<long> | File position |
Lock()
Lock this class
Declaration
public static IDisposable Lock()
Returns
Type | Description |
---|---|
IDisposable | Disposable lock |
Lock(CancellationToken)
Lock this class
Declaration
public static IDisposable Lock(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
IDisposable | Disposable lock |
LockAsync()
Lock this class asynchronously
Declaration
public static AwaitableDisposable<IDisposable> LockAsync()
Returns
Type | Description |
---|---|
AwaitableDisposable<IDisposable> | Disposable lock |
LockAsync(CancellationToken)
Lock this class asynchronously
Declaration
public static AwaitableDisposable<IDisposable> LockAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
AwaitableDisposable<IDisposable> | Disposable lock |
Pause(long?, PrintPausedReason)
Called when the print is being paused
Declaration
public static void Pause(long? filePosition, PrintPausedReason pauseReason)
Parameters
Type | Name | Description |
---|---|---|
long? | filePosition | File position where the print was paused |
PrintPausedReason | pauseReason | Reason why the print has been paused |
Resume()
Resume a file print
Declaration
public static void Resume()
Run()
Perform actual print jobs
Declaration
public static Task Run()
Returns
Type | Description |
---|---|
Task |
SelectFile(string, string, bool)
Start a new file print
Declaration
public static Task SelectFile(string fileName, string physicalFile, bool simulating = false)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | File to print |
string | physicalFile | Physical file to print |
bool | simulating | Whether the file is being simulated |
Returns
Type | Description |
---|---|
Task | Asynchronous task |
Remarks
This class has to be locked when this method is called
SetFilePosition(int, long)
Set the current file position
Declaration
public static Task SetFilePosition(int motionSystem, long filePosition)
Parameters
Type | Name | Description |
---|---|---|
int | motionSystem | Motion system |
long | filePosition | New file position |
Returns
Type | Description |
---|---|
Task | File position |
StartSecondJob()
Start the second file job if applicable
Declaration
public static void StartSecondJob()