Class WulpusViewModel
ViewModel for the Wulpus ultrasound dongle card.
Inherited Members
Namespace: MOSAIC.ViewModels.Devices
Assembly: MOSAIC.dll
Syntax
public class WulpusViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Remarks
Bridges the Wulpus pipeline block and the Avalonia UI. All settable JSON parameters (USS config path, RX/TX config path, data sending mode, append metadata) are exposed as two-way bindable properties. Device control (scan, open, close, stream start/stop) and config file browsing are exposed as RelayCommand/AsyncRelayCommand instances.
File picker dialogs are accessed via IFilePickerService, resolved from the application's DI container at construction time.
Constructors
WulpusViewModel(Wulpus)
Creates a new ViewModel wrapping the given Wulpus block.
Declaration
public WulpusViewModel(Wulpus wulpus)
Parameters
| Type | Name | Description |
|---|---|---|
| Wulpus | wulpus | The pipeline block to wrap. |
Fields
_filePicker
Declaration
private readonly IFilePickerService _filePicker
Field Value
| Type | Description |
|---|---|
| IFilePickerService |
_selectedDeviceIndex
Index of the device selected in the device list ComboBox.
Declaration
[ObservableProperty]
private int _selectedDeviceIndex
Field Value
| Type | Description |
|---|---|
| int |
_wulpus
Declaration
private readonly Wulpus _wulpus
Field Value
| Type | Description |
|---|---|
| Wulpus |
browseRxTxConfigCommand
The backing field for BrowseRxTxConfigCommand.
Declaration
private AsyncRelayCommand? browseRxTxConfigCommand
Field Value
| Type | Description |
|---|---|
| AsyncRelayCommand |
browseUssConfigCommand
The backing field for BrowseUssConfigCommand.
Declaration
private AsyncRelayCommand? browseUssConfigCommand
Field Value
| Type | Description |
|---|---|
| AsyncRelayCommand |
closeCommand
The backing field for CloseCommand.
Declaration
private RelayCommand? closeCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
openCommand
The backing field for OpenCommand.
Declaration
private RelayCommand? openCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
scanCommand
The backing field for ScanCommand.
Declaration
private RelayCommand? scanCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
startStreamCommand
The backing field for StartStreamCommand.
Declaration
private RelayCommand? startStreamCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
stopStreamCommand
The backing field for StopStreamCommand.
Declaration
private RelayCommand? stopStreamCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
Properties
BrowseRxTxConfigCommand
Gets an IAsyncRelayCommand instance wrapping BrowseRxTxConfigAsync().
Declaration
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand BrowseRxTxConfigCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand |
BrowseUssConfigCommand
Gets an IAsyncRelayCommand instance wrapping BrowseUssConfigAsync().
Declaration
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand BrowseUssConfigCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand |
CloseCommand
Gets an IRelayCommand instance wrapping Close().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand CloseCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
OpenCommand
Gets an IRelayCommand instance wrapping Open().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand OpenCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
ScanCommand
Gets an IRelayCommand instance wrapping Scan().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ScanCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
SelectedDeviceIndex
Index of the device selected in the device list ComboBox.
Declaration
[ExcludeFromCodeCoverage]
public int SelectedDeviceIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
SendingModes
Available data sending modes for the ComboBox.
Declaration
public Wulpus.DataSendingMode[] SendingModes { get; }
Property Value
| Type | Description |
|---|---|
| DataSendingMode[] |
StartStreamCommand
Gets an IRelayCommand instance wrapping StartStream().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StartStreamCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
StopStreamCommand
Gets an IRelayCommand instance wrapping StopStream().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StopStreamCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
Wulpus
Exposes the underlying block for direct binding from the view.
Declaration
public Wulpus Wulpus { get; }
Property Value
| Type | Description |
|---|---|
| Wulpus |
Methods
BrowseRxTxConfigAsync()
Opens a file picker for the RX/TX configuration JSON and applies it.
Declaration
[RelayCommand]
private Task BrowseRxTxConfigAsync()
Returns
| Type | Description |
|---|---|
| Task |
BrowseUssConfigAsync()
Opens a file picker for the USS configuration JSON and applies it.
Declaration
[RelayCommand]
private Task BrowseUssConfigAsync()
Returns
| Type | Description |
|---|---|
| Task |
CanClose()
Declaration
private bool CanClose()
Returns
| Type | Description |
|---|---|
| bool |
CanOpen()
Declaration
private bool CanOpen()
Returns
| Type | Description |
|---|---|
| bool |
CanStartStream()
Declaration
private bool CanStartStream()
Returns
| Type | Description |
|---|---|
| bool |
CanStopStream()
Declaration
private bool CanStopStream()
Returns
| Type | Description |
|---|---|
| bool |
Close()
Closes the active COM connection.
Declaration
[RelayCommand(CanExecute = "CanClose")]
private void Close()
NotifyCommandsChanged()
Declaration
private void NotifyCommandsChanged()
OnSelectedDeviceIndexChanged(int)
Executes the logic for when SelectedDeviceIndex just changed.
Declaration
private void OnSelectedDeviceIndexChanged(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 SelectedDeviceIndex is changed.
OnSelectedDeviceIndexChanged(int, int)
Executes the logic for when SelectedDeviceIndex just changed.
Declaration
private void OnSelectedDeviceIndexChanged(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 SelectedDeviceIndex is changed.
OnSelectedDeviceIndexChanging(int)
Executes the logic for when SelectedDeviceIndex is changing.
Declaration
private void OnSelectedDeviceIndexChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedDeviceIndex is changed.
OnSelectedDeviceIndexChanging(int, int)
Executes the logic for when SelectedDeviceIndex is changing.
Declaration
private void OnSelectedDeviceIndexChanging(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 SelectedDeviceIndex is changed.
Open()
Opens the COM port for the currently selected device.
Declaration
[RelayCommand(CanExecute = "CanOpen")]
private void Open()
Scan()
Scans for available Wulpus dongles.
Declaration
[RelayCommand]
private void Scan()
StartStream()
Starts data streaming from the dongle.
Declaration
[RelayCommand(CanExecute = "CanStartStream")]
private void StartStream()
StopStream()
Stops data streaming.
Declaration
[RelayCommand(CanExecute = "CanStopStream")]
private void StopStream()