Class LinkInterface
- Namespace
- DuetControlServer.Link
- Assembly
- DuetControlServer.dll
Main firmware interface
[DiagnosticsPriority(-5)]
public sealed class LinkInterface : IDiagnostics
- Inheritance
-
LinkInterface
- Implements
- Inherited Members
Constructors
LinkInterface(Manager, ILinkAdapter, ILogger<LinkInterface>, IOptions<Settings>)
Main firmware interface
public LinkInterface(Manager channels, ILinkAdapter linkAdapter, ILogger<LinkInterface> logger, IOptions<Settings> settings)
Parameters
channelsManagerChannel manager
linkAdapterILinkAdapterFirmware link adapter
loggerILogger<LinkInterface>Logger instance
settingsIOptions<Settings>Settings
Methods
AbortAllAsync(CodeChannel, CancellationToken)
Abort all files in RRF on the given channel asynchronously
public Task AbortAllAsync(CodeChannel channel, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelChannel where all the files have been aborted
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
Exceptions
- InvalidOperationException
Not connected over SPI
CopyStateAsync(CodeChannel, CodeChannel, CancellationToken)
Copy the state from one channel processor to another
public Task CopyStateAsync(CodeChannel from, CodeChannel to, CancellationToken cancellationToken = default)
Parameters
fromCodeChannelSource channel
toCodeChannelTarget channel
cancellationTokenCancellationTokenCancellation token
Returns
- Task
Asynchronous task
EmergencyStopAsync(CancellationToken)
Request an immediate emergency stop
public Task EmergencyStopAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
- Task
Asynchronous task
EvaluateExpressionAsync(CodeChannel, string, CancellationToken)
Evaluate an arbitrary expression
public Task<object?> EvaluateExpressionAsync(CodeChannel channel, string expression, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelWhere to evaluate the expression
expressionstringExpression to evaluate
cancellationTokenCancellationTokenOptional cancellation token
Returns
Exceptions
- CodeParserException
Failed to evaluate expression
- InvalidOperationException
Not connected over SPI
- NotSupportedException
Incompatible firmware version
- ArgumentException
Invalid parameter
FlushAsync(CodeChannel, bool, CancellationToken)
Wait for all pending codes of the first or last stack item to finish
public Task<bool> FlushAsync(CodeChannel channel, bool flushAll, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelCode channel to wait for
flushAllboolFlush everything
cancellationTokenCancellationTokenOptional cancellation token
Returns
FlushAsync(Code, CancellationToken)
Wait for all pending codes on the same stack level as the given code to finish. By default this replaces all expressions as well for convenient parsing by the code processors.
public Task<bool> FlushAsync(Code code, CancellationToken cancellationToken = default)
Parameters
codeCodeCode waiting for the flush
cancellationTokenCancellationTokenOptional cancellation token
Returns
FlushAsync(CodeFile, CancellationToken)
Wait for all pending codes to finish
public Task<bool> FlushAsync(CodeFile file, CancellationToken cancellationToken = default)
Parameters
fileCodeFileCode file
cancellationTokenCancellationTokenOptional cancellation token
Returns
LockAllMovementSystemsAndWaitForStandstill(CodeChannel, CancellationToken)
Lock all movement systems and wait for standstill
public Task<IAsyncDisposable> LockAllMovementSystemsAndWaitForStandstill(CodeChannel channel, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelCode channel acquiring the lock
cancellationTokenCancellationToken
Returns
- Task<IAsyncDisposable>
Disposable lock object that releases the lock when disposed
Exceptions
- InvalidOperationException
Not connected over SPI
- OperationCanceledException
Failed to get movement lock
ObjectModelKeyChanged(string)
Notify that an object model key has changed
public void ObjectModelKeyChanged(string key)
Parameters
keystringChanged key
PrintDiagnostics(StringBuilder)
Print diagnostics of this class
public void PrintDiagnostics(StringBuilder builder)
Parameters
builderStringBuilderString builder
RequestObjectModel(string, string, CancellationToken)
Request a specific update of the object model
public Task<byte[]> RequestObjectModel(string key, string flags, CancellationToken cancellationToken = default)
Parameters
keystringKey to request
flagsstringObject model flags
cancellationTokenCancellationTokenOptional cancellation token
Returns
ResetFirmwareAsync(CancellationToken)
Perform a firmware reset and wait for it to finish
public Task ResetFirmwareAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token
Returns
- Task
Asynchronous task
SendMessage(MessageTypeFlags, string)
Send a message to the firmware
public void SendMessage(MessageTypeFlags flags, string message)
Parameters
flagsMessageTypeFlagsMessage flags
messagestringMessage content
Exceptions
- InvalidOperationException
Incompatible firmware or not connected over SPI
- NotSupportedException
Incompatible firmware version
- ArgumentException
Invalid parameter
SetLastCodeResultAsync(Code, CancellationToken)
Set the last code result for a specific code channel
public Task SetLastCodeResultAsync(Code code, CancellationToken cancellationToken = default)
Parameters
codeCodecancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
SetMacroPausableAsync(CodeChannel, bool, CancellationToken)
Attempt to flag the currently executing macro file as (not) pausable
public Task SetMacroPausableAsync(CodeChannel channel, bool isPausable, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelCode channel where the macro is being executed
isPausableboolWhether or not the macro file is pausable
cancellationTokenCancellationTokenCancellation token
Returns
- Task
Asynchronous task
SetPrintFileInfo(CancellationToken)
Update the print file info in the firmware
public Task SetPrintFileInfo(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
Exceptions
- InvalidOperationException
Not connected over SPI
SetVariableAsync(CodeChannel, bool, string, string?, CancellationToken)
Set or delete a global or local variable
public Task<object?> SetVariableAsync(CodeChannel channel, bool createVariable, string varName, string? expression, CancellationToken cancellationToken = default)
Parameters
channelCodeChannelWhere to evaluate the expression
createVariableboolWhether the variable shall be created
varNamestringName of the variable
expressionstringExpression to evaluate
cancellationTokenCancellationTokenOptional cancellation token
Returns
Exceptions
- CodeParserException
Failed to assign or delete variable
- InvalidOperationException
Not connected over SPI
- NotSupportedException
Incompatible firmware version
- ArgumentException
Invalid parameter
StopPrintAsync(PrintStoppedReason, CancellationToken)
Notify the firmware that the file print has been stopped
public Task StopPrintAsync(PrintStoppedReason reason, CancellationToken cancellationToken = default)
Parameters
reasonPrintStoppedReasonReason why the print has stopped
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
Exceptions
- InvalidOperationException
Not connected over SPI
- OperationCanceledException
Connection lost while trying to notify RRF
UpdateFirmware(Stream, Stream, CancellationToken)
Perform an update of the main firmware via IAP
public Task UpdateFirmware(Stream iapStream, Stream firmwareStream, CancellationToken cancellationToken = default)
Parameters
iapStreamStreamIAP binary
firmwareStreamStreamFirmware binary
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task
Exceptions
- InvalidOperationException
Firmware is already being updated or not connected over SPI
WaitForUpdate()
Wait for potential firmware update to finish
public void WaitForUpdate()
WaitForUpdateAsync(CancellationToken)
Wait for potential firmware update to finish
public Task WaitForUpdateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenOptional cancellation token
Returns
- Task
Asynchronous task