Table of Contents

Class ObjectModel

Namespace
DuetControlServer.Model
Assembly
DuetControlServer.dll

Main object model with extensions for synchronization

[DiagnosticsPriority(-3)]
public class ObjectModel : ObjectModel, INotifyPropertyChanging, IStaticModelObject, IModelObject, ICloneable, INotifyPropertyChanged
Inheritance
ObjectModel
Implements
Inherited Members

Constructors

ObjectModel(IHostApplicationLifetime, ILogger<ObjectModel>, IOptions<Settings>)

Main constructor

public ObjectModel(IHostApplicationLifetime lifetime, ILogger<ObjectModel> logger, IOptions<Settings> settings)

Parameters

lifetime IHostApplicationLifetime

Host application lifetime

logger ILogger<ObjectModel>

Logger instance

settings IOptions<Settings>

Settings

Fields

MultipleMotionSystemsConfigured

Indicates whether multiple motion systems are configured. When false, the channel Active check in FlushAsync is skipped for performance. Updated by the model update service when the "move" key is refreshed.

public volatile bool MultipleMotionSystemsConfigured

Field Value

bool

Methods

AccessReadOnly()

Access the machine model for read operations only

public IDisposable AccessReadOnly()

Returns

IDisposable

Disposable lock object to be used with a using directive

AccessReadOnly(CancellationToken)

Access the machine model for read operations only

public IDisposable AccessReadOnly(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

IDisposable

Disposable lock object to be used with a using directive

AccessReadOnlyAsync()

Access the machine model asynchronously for read operations only

public Task<IDisposable> AccessReadOnlyAsync()

Returns

Task<IDisposable>

Disposable lock object to be used with a using directive

AccessReadOnlyAsync(CancellationToken)

Access the machine model asynchronously for read operations only

public Task<IDisposable> AccessReadOnlyAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<IDisposable>

Disposable lock object to be used with a using directive

AccessReadWrite()

Access the machine model for read/write operations

public IDisposable AccessReadWrite()

Returns

IDisposable

Disposable lock object to be used with a using directive

AccessReadWrite(CancellationToken)

Access the machine model for read/write operations

public IDisposable AccessReadWrite(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

IDisposable

Disposable lock object to be used with a using directive

AccessReadWriteAsync()

Access the machine model asynchronously for read/write operations

public Task<IDisposable> AccessReadWriteAsync()

Returns

Task<IDisposable>

Disposable lock object to be used with a using directive

AccessReadWriteAsync(CancellationToken)

Access the machine model asynchronously for read/write operations

public Task<IDisposable> AccessReadWriteAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task<IDisposable>

Disposable lock object to be used with a using directive

GetCpuHardware()

Get the CPU hardware

public string? GetCpuHardware()

Returns

string

CPU hardware or null if unknown

GetCpuNumCores()

Get the number of processor cores/threads

public int GetCpuNumCores()

Returns

int

Number of cores/threads or 1 if unknown

GetDistribution()

Get the current Linux distribution

public string? GetDistribution()

Returns

string

Distribution name or null if unknown

GetDistributionBuildTime()

Determine when the current Linux distribution was built

public DateTime? GetDistributionBuildTime()

Returns

DateTime?

Build datetime or null if unknown

GetSbcModel()

Get the SBC model name

public string? GetSbcModel()

Returns

string

SBC model or null if unknown

GetSbcSerial()

Get the SBC serial

public string? GetSbcSerial()

Returns

string

SBC model or null if unknown

GetTotalMemory()

Get the total memory of this SBC

public long? GetTotalMemory()

Returns

long?

HandleMacroErrorAsync(string, long, string)

Handle a macro file error asynchronously. Must be called WITHOUT locking this instance first!

public Task HandleMacroErrorAsync(string fileName, long lineNumber, string message)

Parameters

fileName string
lineNumber long
message string

Returns

Task

Exceptions

NotImplementedException

IsEmulatingMarlinAsync(CodeChannel, CancellationToken)

Check asynchronously if Marlin is being emulated on the given channel

public Task<bool> IsEmulatingMarlinAsync(CodeChannel channel, CancellationToken cancellationToken = default)

Parameters

channel CodeChannel

Code channel

cancellationToken CancellationToken

Cancellation token

Returns

Task<bool>

True if Marlin is being emulated

Output(EventLogLevel, Message, CancellationToken)

Output a generic message

public bool Output(EventLogLevel level, Message message, CancellationToken cancellationToken = default)

Parameters

level EventLogLevel

Log level

message Message

Message to output

cancellationToken CancellationToken

Returns

bool

Whether the message has been written

Output(Message, CancellationToken)

Output a generic message

public void Output(Message message, CancellationToken cancellationToken = default)

Parameters

message Message

Message to output

cancellationToken CancellationToken

Cancellation token

Output(MessageType, string)

Output a generic message

public void Output(MessageType type, string content)

Parameters

type MessageType

Type of the message

content string

Content of the message

OutputAsync(EventLogLevel, Message, CancellationToken)

Output a generic message asynchronously

public Task<bool> OutputAsync(EventLogLevel level, Message message, CancellationToken cancellationToken = default)

Parameters

level EventLogLevel

Log level

message Message

Message to output

cancellationToken CancellationToken

Cancellation token

Returns

Task<bool>

Whether the message has been written

OutputAsync(Message, CancellationToken)

Output a generic message asynchronously

public Task OutputAsync(Message message, CancellationToken cancellationToken = default)

Parameters

message Message

Message to output

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

OutputAsync(MessageType, string, CancellationToken)

Output a generic message asynchronously

public Task OutputAsync(MessageType type, string content, CancellationToken cancellationToken)

Parameters

type MessageType

Type of the message

content string

Content of the message

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

PrintDiagnostics(StringBuilder)

Report the diagnostics of this class

public void PrintDiagnostics(StringBuilder builder)

Parameters

builder StringBuilder

Target to write to

SetExecutingConfig(bool)

Flag asynchronously that a start-up file is being executed. Must be called WITHOUT locking this instance first!

public void SetExecutingConfig(bool executing)

Parameters

executing bool

Whether a start-up file is being executed or not

WaitForFullUpdate()

Wait for the model to be fully updated from RepRapFirmware

public void WaitForFullUpdate()

WaitForFullUpdateAsync(CancellationToken)

Wait asynchronously for the model to be fully updated from RepRapFirmware

public Task WaitForFullUpdateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

WaitForUpdate()

Wait for an update to occur

public void WaitForUpdate()

WaitForUpdate(CancellationToken)

Wait for an update to occur

public void WaitForUpdate(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

WaitForUpdateAsync()

Wait for an update to occur asynchronously

public Task WaitForUpdateAsync()

Returns

Task

Asynchronous task

WaitForUpdateAsync(CancellationToken)

Wait for an update to occur asynchronously

public Task WaitForUpdateAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task

Events

OnConnectionLost

Event that is raised when the connection to the firmware has been lost

public event EventHandler? OnConnectionLost

Event Type

EventHandler