Class SifiViewModel
ViewModel for the SiFi device block card.
Inherited Members
Namespace: MOSAIC.ViewModels.Devices
Assembly: MOSAIC.dll
Syntax
public class SifiViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Remarks
Sensor toggles (EmgEnabled, ImuEnabled, etc.) are editable before connecting. On connect, they are combined into EnabledSensors flags. After connecting, the toggles are read-only.
Constructors
SifiViewModel(SiFi)
Declaration
public SifiViewModel(SiFi block)
Parameters
| Type | Name | Description |
|---|---|---|
| SiFi | block |
Fields
_ecgEnabled
Declaration
[ObservableProperty]
private bool _ecgEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_edaEnabled
Declaration
[ObservableProperty]
private bool _edaEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_emgEnabled
Declaration
[ObservableProperty]
private bool _emgEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_imuEnabled
Declaration
[ObservableProperty]
private bool _imuEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_isBusy
Whether a long-running operation is in progress.
Declaration
[ObservableProperty]
private bool _isBusy
Field Value
| Type | Description |
|---|---|
| bool |
_lastError
Last error message for UI display.
Declaration
[ObservableProperty]
private string _lastError
Field Value
| Type | Description |
|---|---|
| string |
_ppgEnabled
Declaration
[ObservableProperty]
private bool _ppgEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_selectedDevice
Currently selected device in the ComboBox.
Declaration
[ObservableProperty]
private string? _selectedDevice
Field Value
| Type | Description |
|---|---|
| string |
refreshStatusCommand
The backing field for RefreshStatusCommand.
Declaration
private AsyncRelayCommand? refreshStatusCommand
Field Value
| Type | Description |
|---|---|
| AsyncRelayCommand |
startScanCommand
The backing field for StartScanCommand.
Declaration
private AsyncRelayCommand? startScanCommand
Field Value
| Type | Description |
|---|---|
| AsyncRelayCommand |
toggleConnectCommand
The backing field for ToggleConnectCommand.
Declaration
private AsyncRelayCommand? toggleConnectCommand
Field Value
| Type | Description |
|---|---|
| AsyncRelayCommand |
Properties
BatteryLevel
Declaration
public int BatteryLevel { get; }
Property Value
| Type | Description |
|---|---|
| int |
Block
The underlying Sifi block.
Declaration
public SiFi Block { get; }
Property Value
| Type | Description |
|---|---|
| SiFi |
DeviceStatus
Declaration
public string DeviceStatus { get; }
Property Value
| Type | Description |
|---|---|
| string |
EcgEnabled
Declaration
[ExcludeFromCodeCoverage]
public bool EcgEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
EdaEnabled
Declaration
[ExcludeFromCodeCoverage]
public bool EdaEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
EmgEnabled
Declaration
[ExcludeFromCodeCoverage]
public bool EmgEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
FoundDevices
Discovered BLE devices.
Declaration
public ObservableCollection<string> FoundDevices { get; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
HasBattery
Declaration
public bool HasBattery { get; }
Property Value
| Type | Description |
|---|---|
| bool |
ImuEnabled
Declaration
[ExcludeFromCodeCoverage]
public bool ImuEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsBusy
Whether a long-running operation is in progress.
Declaration
[ExcludeFromCodeCoverage]
public bool IsBusy { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsConnected
Declaration
public bool IsConnected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsStreaming
Declaration
public bool IsStreaming { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LastError
Last error message for UI display.
Declaration
[ExcludeFromCodeCoverage]
public string LastError { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
PpgEnabled
Declaration
[ExcludeFromCodeCoverage]
public bool PpgEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
RefreshStatusCommand
Gets an IAsyncRelayCommand instance wrapping RefreshStatus().
Declaration
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand RefreshStatusCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand |
ScopeEcg
Declaration
public ScopeMonitor ScopeEcg { get; }
Property Value
| Type | Description |
|---|---|
| ScopeMonitor |
ScopeEda
Declaration
public ScopeMonitor ScopeEda { get; }
Property Value
| Type | Description |
|---|---|
| ScopeMonitor |
ScopeImu
Declaration
public ScopeMonitor ScopeImu { get; }
Property Value
| Type | Description |
|---|---|
| ScopeMonitor |
ScopePpg
Declaration
public ScopeMonitor ScopePpg { get; }
Property Value
| Type | Description |
|---|---|
| ScopeMonitor |
SelectedDevice
Currently selected device in the ComboBox.
Declaration
[ExcludeFromCodeCoverage]
public string? SelectedDevice { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
StartScanCommand
Gets an IAsyncRelayCommand instance wrapping StartScan().
Declaration
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand StartScanCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand |
ToggleConnectCommand
Gets an IAsyncRelayCommand instance wrapping ToggleConnect().
Declaration
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ToggleConnectCommand { get; }
Property Value
| Type | Description |
|---|---|
| IAsyncRelayCommand |
Methods
CanToggleConnect()
Declaration
private bool CanToggleConnect()
Returns
| Type | Description |
|---|---|
| bool |
OnEcgEnabledChanged(bool)
Executes the logic for when EcgEnabled just changed.
Declaration
private void OnEcgEnabledChanged(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 EcgEnabled is changed.
OnEcgEnabledChanged(bool, bool)
Executes the logic for when EcgEnabled just changed.
Declaration
private void OnEcgEnabledChanged(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 EcgEnabled is changed.
OnEcgEnabledChanging(bool)
Executes the logic for when EcgEnabled is changing.
Declaration
private void OnEcgEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of EcgEnabled is changed.
OnEcgEnabledChanging(bool, bool)
Executes the logic for when EcgEnabled is changing.
Declaration
private void OnEcgEnabledChanging(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 EcgEnabled is changed.
OnEdaEnabledChanged(bool)
Executes the logic for when EdaEnabled just changed.
Declaration
private void OnEdaEnabledChanged(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 EdaEnabled is changed.
OnEdaEnabledChanged(bool, bool)
Executes the logic for when EdaEnabled just changed.
Declaration
private void OnEdaEnabledChanged(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 EdaEnabled is changed.
OnEdaEnabledChanging(bool)
Executes the logic for when EdaEnabled is changing.
Declaration
private void OnEdaEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of EdaEnabled is changed.
OnEdaEnabledChanging(bool, bool)
Executes the logic for when EdaEnabled is changing.
Declaration
private void OnEdaEnabledChanging(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 EdaEnabled is changed.
OnEmgEnabledChanged(bool)
Executes the logic for when EmgEnabled just changed.
Declaration
private void OnEmgEnabledChanged(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 EmgEnabled is changed.
OnEmgEnabledChanged(bool, bool)
Executes the logic for when EmgEnabled just changed.
Declaration
private void OnEmgEnabledChanged(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 EmgEnabled is changed.
OnEmgEnabledChanging(bool)
Executes the logic for when EmgEnabled is changing.
Declaration
private void OnEmgEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of EmgEnabled is changed.
OnEmgEnabledChanging(bool, bool)
Executes the logic for when EmgEnabled is changing.
Declaration
private void OnEmgEnabledChanging(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 EmgEnabled is changed.
OnImuEnabledChanged(bool)
Executes the logic for when ImuEnabled just changed.
Declaration
private void OnImuEnabledChanged(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 ImuEnabled is changed.
OnImuEnabledChanged(bool, bool)
Executes the logic for when ImuEnabled just changed.
Declaration
private void OnImuEnabledChanged(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 ImuEnabled is changed.
OnImuEnabledChanging(bool)
Executes the logic for when ImuEnabled is changing.
Declaration
private void OnImuEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of ImuEnabled is changed.
OnImuEnabledChanging(bool, bool)
Executes the logic for when ImuEnabled is changing.
Declaration
private void OnImuEnabledChanging(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 ImuEnabled is changed.
OnIsBusyChanged(bool)
Executes the logic for when IsBusy just changed.
Declaration
private void OnIsBusyChanged(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 IsBusy is changed.
OnIsBusyChanged(bool, bool)
Executes the logic for when IsBusy just changed.
Declaration
private void OnIsBusyChanged(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 IsBusy is changed.
OnIsBusyChanging(bool)
Executes the logic for when IsBusy is changing.
Declaration
private void OnIsBusyChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of IsBusy is changed.
OnIsBusyChanging(bool, bool)
Executes the logic for when IsBusy is changing.
Declaration
private void OnIsBusyChanging(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 IsBusy is changed.
OnLastErrorChanged(string)
Executes the logic for when LastError just changed.
Declaration
private void OnLastErrorChanged(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 LastError is changed.
OnLastErrorChanged(string?, string)
Executes the logic for when LastError just changed.
Declaration
private void OnLastErrorChanged(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 LastError is changed.
OnLastErrorChanging(string)
Executes the logic for when LastError is changing.
Declaration
private void OnLastErrorChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of LastError is changed.
OnLastErrorChanging(string?, string)
Executes the logic for when LastError is changing.
Declaration
private void OnLastErrorChanging(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 LastError is changed.
OnPpgEnabledChanged(bool)
Executes the logic for when PpgEnabled just changed.
Declaration
private void OnPpgEnabledChanged(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 PpgEnabled is changed.
OnPpgEnabledChanged(bool, bool)
Executes the logic for when PpgEnabled just changed.
Declaration
private void OnPpgEnabledChanged(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 PpgEnabled is changed.
OnPpgEnabledChanging(bool)
Executes the logic for when PpgEnabled is changing.
Declaration
private void OnPpgEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of PpgEnabled is changed.
OnPpgEnabledChanging(bool, bool)
Executes the logic for when PpgEnabled is changing.
Declaration
private void OnPpgEnabledChanging(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 PpgEnabled is changed.
OnSelectedDeviceChanged(string?)
Executes the logic for when SelectedDevice just changed.
Declaration
private void OnSelectedDeviceChanged(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 SelectedDevice is changed.
OnSelectedDeviceChanged(string?, string?)
Executes the logic for when SelectedDevice just changed.
Declaration
private void OnSelectedDeviceChanged(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 SelectedDevice is changed.
OnSelectedDeviceChanging(string?)
Executes the logic for when SelectedDevice is changing.
Declaration
private void OnSelectedDeviceChanging(string? value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of SelectedDevice is changed.
OnSelectedDeviceChanging(string?, string?)
Executes the logic for when SelectedDevice is changing.
Declaration
private void OnSelectedDeviceChanging(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 SelectedDevice is changed.
RefreshStatus()
Requests battery/status update.
Declaration
[RelayCommand]
private Task RefreshStatus()
Returns
| Type | Description |
|---|---|
| Task |
StartScan()
Scans for nearby SiFi BLE devices.
Declaration
[RelayCommand]
private Task StartScan()
Returns
| Type | Description |
|---|---|
| Task |
SyncSensorFlags()
Syncs toggle booleans → block's EnabledSensors flags.
Declaration
private void SyncSensorFlags()
ToggleConnect()
Connects or disconnects.
Declaration
[RelayCommand(CanExecute = "CanToggleConnect")]
private Task ToggleConnect()
Returns
| Type | Description |
|---|---|
| Task |