Class DlrAdcBtViewModel
ViewModel for the DlrAdcBt device card.
Inherited Members
Namespace: MOSAIC.ViewModels.Devices
Assembly: MOSAIC.dll
Syntax
public class DlrAdcBtViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Remarks
Live values are mirrored, never bound directly. Info is written
from the serial reader thread and its Flag is overwritten on every decoded frame, so an
error state survives about one tick and a binding would essentially never render it.
RefreshLive() samples the durable signals — monotonic counters and the last
decoded sample — on the UI thread, and everything the card shows is derived from those mirrors.
Editable configuration binds straight to the block, which is safe: those properties are only ever written from the UI thread, and the block reads them once, at Connect().
Constructors
DlrAdcBtViewModel(DlrAdcBt)
Creates a ViewModel bound to block.
Declaration
public DlrAdcBtViewModel(DlrAdcBt block)
Parameters
| Type | Name | Description |
|---|---|---|
| DlrAdcBt | block |
Fields
ErrorWindow
Parser errors within this window raise the fault banner.
Declaration
private static readonly TimeSpan ErrorWindow
Field Value
| Type | Description |
|---|---|
| TimeSpan |
_availablePorts
COM ports available for the picker.
Declaration
[ObservableProperty]
private ObservableCollection<string> _availablePorts
Field Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
_block
Declaration
private readonly DlrAdcBt _block
Field Value
| Type | Description |
|---|---|
| DlrAdcBt |
_flag
Latest status flag reported by the block.
Declaration
[ObservableProperty]
private string _flag
Field Value
| Type | Description |
|---|---|
| string |
_frameErrors
Total parser faults since the block was created.
Declaration
[ObservableProperty]
private int _frameErrors
Field Value
| Type | Description |
|---|---|
| int |
_frameRateHz
Smoothed rate at which real frames are decoded off the wire, in Hz.
Declaration
[ObservableProperty]
private double _frameRateHz
Field Value
| Type | Description |
|---|---|
| double |
Remarks
Not the same as PublishRateHz, which the header chip also shows. The block publishes on every clock tick whether or not a frame arrived, so the published rate is the clock rate while this is the rate of genuinely new data. The two agreeing is the healthy case; this one being lower means that share of published samples are repeats.
_framesProcessed
Total frames decoded since the block was created.
Declaration
[ObservableProperty]
private int _framesProcessed
Field Value
| Type | Description |
|---|---|
| int |
_hasRecentErrors
Whether a parser fault occurred within ErrorWindow.
Declaration
[ObservableProperty]
private bool _hasRecentErrors
Field Value
| Type | Description |
|---|---|
| bool |
_isReceiving
Whether frames are actually arriving, as opposed to merely being connected.
Declaration
[ObservableProperty]
private bool _isReceiving
Field Value
| Type | Description |
|---|---|
| bool |
_lastErrorAt
Declaration
private DateTime _lastErrorAt
Field Value
| Type | Description |
|---|---|
| DateTime |
_lastErrorCount
Declaration
private int _lastErrorCount
Field Value
| Type | Description |
|---|---|
| int |
_lastFrameCount
Declaration
private int _lastFrameCount
Field Value
| Type | Description |
|---|---|
| int |
_lastRateSample
Declaration
private DateTime _lastRateSample
Field Value
| Type | Description |
|---|---|
| DateTime |
_publishRateHz
Rate the block publishes at — the clock rate it inherited.
Declaration
[ObservableProperty]
private double _publishRateHz
Field Value
| Type | Description |
|---|---|
| double |
_selectedPort
Currently selected port. Writes through to the block.
Declaration
[ObservableProperty]
private string? _selectedPort
Field Value
| Type | Description |
|---|---|
| string |
_statusMessage
One-line summary shown under the card title.
Declaration
[ObservableProperty]
private string _statusMessage
Field Value
| Type | Description |
|---|---|
| string |
connectCommand
The backing field for ConnectCommand.
Declaration
private RelayCommand? connectCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
disconnectCommand
The backing field for DisconnectCommand.
Declaration
private RelayCommand? disconnectCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
reconnectCommand
The backing field for ReconnectCommand.
Declaration
private RelayCommand? reconnectCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
refreshPortsCommand
The backing field for RefreshPortsCommand.
Declaration
private RelayCommand? refreshPortsCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
Properties
AvailablePorts
COM ports available for the picker.
Declaration
[ExcludeFromCodeCoverage]
public ObservableCollection<string> AvailablePorts { get; set; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
Block
Direct access to the model for configuration bindings.
Declaration
public DlrAdcBt Block { get; }
Property Value
| Type | Description |
|---|---|
| DlrAdcBt |
ConnectCommand
Gets an IRelayCommand instance wrapping Connect().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ConnectCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
DisconnectCommand
Gets an IRelayCommand instance wrapping Disconnect().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand DisconnectCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
Flag
Latest status flag reported by the block.
Declaration
[ExcludeFromCodeCoverage]
public string Flag { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
FrameErrors
Total parser faults since the block was created.
Declaration
[ExcludeFromCodeCoverage]
public int FrameErrors { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
FrameRateHz
Smoothed rate at which real frames are decoded off the wire, in Hz.
Declaration
[ExcludeFromCodeCoverage]
public double FrameRateHz { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
Not the same as PublishRateHz, which the header chip also shows. The block publishes on every clock tick whether or not a frame arrived, so the published rate is the clock rate while this is the rate of genuinely new data. The two agreeing is the healthy case; this one being lower means that share of published samples are repeats.
FramesProcessed
Total frames decoded since the block was created.
Declaration
[ExcludeFromCodeCoverage]
public int FramesProcessed { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
HasRecentErrors
Whether a parser fault occurred within ErrorWindow.
Declaration
[ExcludeFromCodeCoverage]
public bool HasRecentErrors { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsReceiving
Whether frames are actually arriving, as opposed to merely being connected.
Declaration
[ExcludeFromCodeCoverage]
public bool IsReceiving { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
PublishRateHz
Rate the block publishes at — the clock rate it inherited.
Declaration
[ExcludeFromCodeCoverage]
public double PublishRateHz { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
ReconnectCommand
Gets an IRelayCommand instance wrapping Reconnect().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ReconnectCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
RefreshPortsCommand
Gets an IRelayCommand instance wrapping RefreshPorts().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand RefreshPortsCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
SelectedPort
Currently selected port. Writes through to the block.
Declaration
[ExcludeFromCodeCoverage]
public string? SelectedPort { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
StatusMessage
One-line summary shown under the card title.
Declaration
[ExcludeFromCodeCoverage]
public string StatusMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Viz
Live plot of the published sample.
Declaration
public BlockVisualization Viz { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Methods
Connect()
Opens the port and starts the board streaming.
Declaration
[RelayCommand]
private void Connect()
Disconnect()
Stops the board and closes the port.
Declaration
[RelayCommand]
private void Disconnect()
OnAvailablePortsChanged(ObservableCollection<string>)
Executes the logic for when AvailablePorts just changed.
Declaration
private void OnAvailablePortsChanged(ObservableCollection<string> value)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<string> | value | The new property value that was set. |
Remarks
This method is invoked right after the value of AvailablePorts is changed.
OnAvailablePortsChanged(ObservableCollection<string>?, ObservableCollection<string>)
Executes the logic for when AvailablePorts just changed.
Declaration
private void OnAvailablePortsChanged(ObservableCollection<string>? oldValue, ObservableCollection<string> newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<string> | oldValue | The previous property value that was replaced. |
| ObservableCollection<string> | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of AvailablePorts is changed.
OnAvailablePortsChanging(ObservableCollection<string>)
Executes the logic for when AvailablePorts is changing.
Declaration
private void OnAvailablePortsChanging(ObservableCollection<string> value)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<string> | value | The new property value being set. |
Remarks
This method is invoked right before the value of AvailablePorts is changed.
OnAvailablePortsChanging(ObservableCollection<string>?, ObservableCollection<string>)
Executes the logic for when AvailablePorts is changing.
Declaration
private void OnAvailablePortsChanging(ObservableCollection<string>? oldValue, ObservableCollection<string> newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| ObservableCollection<string> | oldValue | The previous property value that is being replaced. |
| ObservableCollection<string> | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of AvailablePorts is changed.
OnFlagChanged(string)
Executes the logic for when Flag just changed.
Declaration
private void OnFlagChanged(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of Flag is changed.
OnFlagChanged(string?, string)
Executes the logic for when Flag just changed.
Declaration
private void OnFlagChanged(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of Flag is changed.
OnFlagChanging(string)
Executes the logic for when Flag is changing.
Declaration
private void OnFlagChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of Flag is changed.
OnFlagChanging(string?, string)
Executes the logic for when Flag is changing.
Declaration
private void OnFlagChanging(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of Flag is changed.
OnFrameErrorsChanged(int)
Executes the logic for when FrameErrors just changed.
Declaration
private void OnFrameErrorsChanged(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value that was set. |
Remarks
This method is invoked right after the value of FrameErrors is changed.
OnFrameErrorsChanged(int, int)
Executes the logic for when FrameErrors just changed.
Declaration
private void OnFrameErrorsChanged(int oldValue, int newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | oldValue | The previous property value that was replaced. |
| int | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of FrameErrors is changed.
OnFrameErrorsChanging(int)
Executes the logic for when FrameErrors is changing.
Declaration
private void OnFrameErrorsChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of FrameErrors is changed.
OnFrameErrorsChanging(int, int)
Executes the logic for when FrameErrors is changing.
Declaration
private void OnFrameErrorsChanging(int oldValue, int newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | oldValue | The previous property value that is being replaced. |
| int | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of FrameErrors is changed.
OnFrameRateHzChanged(double)
Executes the logic for when FrameRateHz just changed.
Declaration
private void OnFrameRateHzChanged(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value that was set. |
Remarks
This method is invoked right after the value of FrameRateHz is changed.
OnFrameRateHzChanged(double, double)
Executes the logic for when FrameRateHz just changed.
Declaration
private void OnFrameRateHzChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that was replaced. |
| double | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of FrameRateHz is changed.
OnFrameRateHzChanging(double)
Executes the logic for when FrameRateHz is changing.
Declaration
private void OnFrameRateHzChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of FrameRateHz is changed.
OnFrameRateHzChanging(double, double)
Executes the logic for when FrameRateHz is changing.
Declaration
private void OnFrameRateHzChanging(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that is being replaced. |
| double | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of FrameRateHz is changed.
OnFramesProcessedChanged(int)
Executes the logic for when FramesProcessed just changed.
Declaration
private void OnFramesProcessedChanged(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value that was set. |
Remarks
This method is invoked right after the value of FramesProcessed is changed.
OnFramesProcessedChanged(int, int)
Executes the logic for when FramesProcessed just changed.
Declaration
private void OnFramesProcessedChanged(int oldValue, int newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | oldValue | The previous property value that was replaced. |
| int | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of FramesProcessed is changed.
OnFramesProcessedChanging(int)
Executes the logic for when FramesProcessed is changing.
Declaration
private void OnFramesProcessedChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of FramesProcessed is changed.
OnFramesProcessedChanging(int, int)
Executes the logic for when FramesProcessed is changing.
Declaration
private void OnFramesProcessedChanging(int oldValue, int newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| int | oldValue | The previous property value that is being replaced. |
| int | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of FramesProcessed is changed.
OnHasRecentErrorsChanged(bool)
Executes the logic for when HasRecentErrors just changed.
Declaration
private void OnHasRecentErrorsChanged(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value that was set. |
Remarks
This method is invoked right after the value of HasRecentErrors is changed.
OnHasRecentErrorsChanged(bool, bool)
Executes the logic for when HasRecentErrors just changed.
Declaration
private void OnHasRecentErrorsChanged(bool oldValue, bool newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | oldValue | The previous property value that was replaced. |
| bool | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of HasRecentErrors is changed.
OnHasRecentErrorsChanging(bool)
Executes the logic for when HasRecentErrors is changing.
Declaration
private void OnHasRecentErrorsChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of HasRecentErrors is changed.
OnHasRecentErrorsChanging(bool, bool)
Executes the logic for when HasRecentErrors is changing.
Declaration
private void OnHasRecentErrorsChanging(bool oldValue, bool newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | oldValue | The previous property value that is being replaced. |
| bool | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of HasRecentErrors is changed.
OnIsReceivingChanged(bool)
Executes the logic for when IsReceiving just changed.
Declaration
private void OnIsReceivingChanged(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value that was set. |
Remarks
This method is invoked right after the value of IsReceiving is changed.
OnIsReceivingChanged(bool, bool)
Executes the logic for when IsReceiving just changed.
Declaration
private void OnIsReceivingChanged(bool oldValue, bool newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | oldValue | The previous property value that was replaced. |
| bool | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of IsReceiving is changed.
OnIsReceivingChanging(bool)
Executes the logic for when IsReceiving is changing.
Declaration
private void OnIsReceivingChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of IsReceiving is changed.
OnIsReceivingChanging(bool, bool)
Executes the logic for when IsReceiving is changing.
Declaration
private void OnIsReceivingChanging(bool oldValue, bool newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | oldValue | The previous property value that is being replaced. |
| bool | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of IsReceiving is changed.
OnPublishRateHzChanged(double)
Executes the logic for when PublishRateHz just changed.
Declaration
private void OnPublishRateHzChanged(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value that was set. |
Remarks
This method is invoked right after the value of PublishRateHz is changed.
OnPublishRateHzChanged(double, double)
Executes the logic for when PublishRateHz just changed.
Declaration
private void OnPublishRateHzChanged(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that was replaced. |
| double | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of PublishRateHz is changed.
OnPublishRateHzChanging(double)
Executes the logic for when PublishRateHz is changing.
Declaration
private void OnPublishRateHzChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of PublishRateHz is changed.
OnPublishRateHzChanging(double, double)
Executes the logic for when PublishRateHz is changing.
Declaration
private void OnPublishRateHzChanging(double oldValue, double newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldValue | The previous property value that is being replaced. |
| double | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of PublishRateHz is changed.
OnSelectedPortChanged(string?)
Executes the logic for when SelectedPort just changed.
Declaration
private void OnSelectedPortChanged(string? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedPort is changed.
OnSelectedPortChanged(string?, string?)
Executes the logic for when SelectedPort just changed.
Declaration
private void OnSelectedPortChanged(string? oldValue, string? newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of SelectedPort is changed.
OnSelectedPortChanging(string?)
Executes the logic for when SelectedPort is changing.
Declaration
private void OnSelectedPortChanging(string? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedPort is changed.
OnSelectedPortChanging(string?, string?)
Executes the logic for when SelectedPort is changing.
Declaration
private void OnSelectedPortChanging(string? oldValue, string? newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedPort is changed.
OnStatusMessageChanged(string)
Executes the logic for when StatusMessage just changed.
Declaration
private void OnStatusMessageChanged(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value that was set. |
Remarks
This method is invoked right after the value of StatusMessage is changed.
OnStatusMessageChanged(string?, string)
Executes the logic for when StatusMessage just changed.
Declaration
private void OnStatusMessageChanged(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that was replaced. |
| string | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of StatusMessage is changed.
OnStatusMessageChanging(string)
Executes the logic for when StatusMessage is changing.
Declaration
private void OnStatusMessageChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of StatusMessage is changed.
OnStatusMessageChanging(string?, string)
Executes the logic for when StatusMessage is changing.
Declaration
private void OnStatusMessageChanging(string? oldValue, string newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | The previous property value that is being replaced. |
| string | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of StatusMessage is changed.
Reconnect()
Closes and reopens the port, re-sending the configuration commands.
Declaration
[RelayCommand]
private void Reconnect()
RefreshLive()
Samples every live signal and recomputes the derived state. Called from the view on a shared 10 Hz tick; see the card's code-behind.
Declaration
public void RefreshLive()
RefreshPorts()
Re-enumerates the machine's COM ports.
Declaration
[RelayCommand]
private void RefreshPorts()