Class MccDaqBoardViewModel
ViewModel for the MccDaqBoard device card.
Inherited Members
Namespace: MOSAIC.ViewModels.Devices
Assembly: MOSAIC.dll
Syntax
public class MccDaqBoardViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Remarks
Configuration binds straight to the block — those properties are only ever written from the UI thread, and the block reads them once, at Connect(). Only the packet counter is mirrored, because it advances on the pipeline thread at the clock rate; RefreshLive() samples it on the card's 10 Hz tick.
Constructors
MccDaqBoardViewModel(MccDaqBoard)
Creates a ViewModel bound to block.
Declaration
public MccDaqBoardViewModel(MccDaqBoard block)
Parameters
| Type | Name | Description |
|---|---|---|
| MccDaqBoard | block |
Fields
_availableBoards
Boards InstaCal has configured, as "number: name".
Declaration
[ObservableProperty]
private ObservableCollection<string> _availableBoards
Field Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
_block
Declaration
private readonly MccDaqBoard _block
Field Value
| Type | Description |
|---|---|
| MccDaqBoard |
_isReceiving
Whether packets are actually arriving, as opposed to merely being connected.
Declaration
[ObservableProperty]
private bool _isReceiving
Field Value
| Type | Description |
|---|---|
| bool |
_lastPacketCount
Declaration
private long _lastPacketCount
Field Value
| Type | Description |
|---|---|
| long |
_lastSampledAt
Declaration
private DateTime _lastSampledAt
Field Value
| Type | Description |
|---|---|
| DateTime |
_packetRateHz
Smoothed rate at which real packets come off the board, in Hz.
Declaration
[ObservableProperty]
private double _packetRateHz
Field Value
| Type | Description |
|---|---|
| double |
Remarks
The block publishes on every clock tick whether or not a packet was ready, so this being lower than the clock rate means that share of published packets are repeats.
_packetsAcquired
Packets acquired, sampled on the card's tick.
Declaration
[ObservableProperty]
private long _packetsAcquired
Field Value
| Type | Description |
|---|---|
| long |
_scanSummary
What the current settings would ask the board for.
Declaration
[ObservableProperty]
private string _scanSummary
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 |
refreshBoardsCommand
The backing field for RefreshBoardsCommand.
Declaration
private RelayCommand? refreshBoardsCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
Properties
AvailableBoards
Boards InstaCal has configured, as "number: name".
Declaration
[ExcludeFromCodeCoverage]
public ObservableCollection<string> AvailableBoards { get; set; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
Block
Direct access to the model for configuration bindings.
Declaration
public MccDaqBoard Block { get; }
Property Value
| Type | Description |
|---|---|
| MccDaqBoard |
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 |
IsReceiving
Whether packets are actually arriving, as opposed to merely being connected.
Declaration
[ExcludeFromCodeCoverage]
public bool IsReceiving { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
KnownRanges
Input ranges offered by the range picker.
Declaration
public string[] KnownRanges { get; }
Property Value
| Type | Description |
|---|---|
| string[] |
PacketRateHz
Smoothed rate at which real packets come off the board, in Hz.
Declaration
[ExcludeFromCodeCoverage]
public double PacketRateHz { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
The block publishes on every clock tick whether or not a packet was ready, so this being lower than the clock rate means that share of published packets are repeats.
PacketsAcquired
Packets acquired, sampled on the card's tick.
Declaration
[ExcludeFromCodeCoverage]
public long PacketsAcquired { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
ReconnectCommand
Gets an IRelayCommand instance wrapping Reconnect().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ReconnectCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
RefreshBoardsCommand
Gets an IRelayCommand instance wrapping RefreshBoards().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand RefreshBoardsCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
ScanSummary
What the current settings would ask the board for.
Declaration
[ExcludeFromCodeCoverage]
public string ScanSummary { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Viz
Live plot of the published packet.
Declaration
public BlockVisualization Viz { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Methods
Connect()
Starts the background scan.
Declaration
[RelayCommand]
private void Connect()
Disconnect()
Stops the scan and frees the driver buffer.
Declaration
[RelayCommand]
private void Disconnect()
OnAvailableBoardsChanged(ObservableCollection<string>)
Executes the logic for when AvailableBoards just changed.
Declaration
private void OnAvailableBoardsChanged(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 AvailableBoards is changed.
OnAvailableBoardsChanged(ObservableCollection<string>?, ObservableCollection<string>)
Executes the logic for when AvailableBoards just changed.
Declaration
private void OnAvailableBoardsChanged(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 AvailableBoards is changed.
OnAvailableBoardsChanging(ObservableCollection<string>)
Executes the logic for when AvailableBoards is changing.
Declaration
private void OnAvailableBoardsChanging(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 AvailableBoards is changed.
OnAvailableBoardsChanging(ObservableCollection<string>?, ObservableCollection<string>)
Executes the logic for when AvailableBoards is changing.
Declaration
private void OnAvailableBoardsChanging(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 AvailableBoards 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.
OnPacketRateHzChanged(double)
Executes the logic for when PacketRateHz just changed.
Declaration
private void OnPacketRateHzChanged(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 PacketRateHz is changed.
OnPacketRateHzChanged(double, double)
Executes the logic for when PacketRateHz just changed.
Declaration
private void OnPacketRateHzChanged(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 PacketRateHz is changed.
OnPacketRateHzChanging(double)
Executes the logic for when PacketRateHz is changing.
Declaration
private void OnPacketRateHzChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of PacketRateHz is changed.
OnPacketRateHzChanging(double, double)
Executes the logic for when PacketRateHz is changing.
Declaration
private void OnPacketRateHzChanging(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 PacketRateHz is changed.
OnPacketsAcquiredChanged(long)
Executes the logic for when PacketsAcquired just changed.
Declaration
private void OnPacketsAcquiredChanged(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The new property value that was set. |
Remarks
This method is invoked right after the value of PacketsAcquired is changed.
OnPacketsAcquiredChanged(long, long)
Executes the logic for when PacketsAcquired just changed.
Declaration
private void OnPacketsAcquiredChanged(long oldValue, long newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| long | oldValue | The previous property value that was replaced. |
| long | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of PacketsAcquired is changed.
OnPacketsAcquiredChanging(long)
Executes the logic for when PacketsAcquired is changing.
Declaration
private void OnPacketsAcquiredChanging(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The new property value being set. |
Remarks
This method is invoked right before the value of PacketsAcquired is changed.
OnPacketsAcquiredChanging(long, long)
Executes the logic for when PacketsAcquired is changing.
Declaration
private void OnPacketsAcquiredChanging(long oldValue, long newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| long | oldValue | The previous property value that is being replaced. |
| long | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of PacketsAcquired is changed.
OnScanSummaryChanged(string)
Executes the logic for when ScanSummary just changed.
Declaration
private void OnScanSummaryChanged(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 ScanSummary is changed.
OnScanSummaryChanged(string?, string)
Executes the logic for when ScanSummary just changed.
Declaration
private void OnScanSummaryChanged(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 ScanSummary is changed.
OnScanSummaryChanging(string)
Executes the logic for when ScanSummary is changing.
Declaration
private void OnScanSummaryChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of ScanSummary is changed.
OnScanSummaryChanging(string?, string)
Executes the logic for when ScanSummary is changing.
Declaration
private void OnScanSummaryChanging(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 ScanSummary is changed.
Reconnect()
Restarts the scan, picking up changed configuration.
Declaration
[RelayCommand]
private void Reconnect()
RefreshBoards()
Re-enumerates the boards InstaCal has configured.
Declaration
[RelayCommand]
private void RefreshBoards()
RefreshLive()
Samples the packet counter and derives the acquisition rate. Called from the view on a shared 10 Hz tick; see the card's code-behind.
Declaration
public void RefreshLive()
UpdateSummary()
Recomputes the line describing what the current settings would acquire.
Declaration
public void UpdateSummary()
Remarks
The scan rate is a product of clock rate, scans per packet and channel count, and getting it wrong is the likeliest misconfiguration of this block. Showing the derived figure means it gets checked before Connect, rather than inferred afterwards from a signal that is subtly wrong.