Class StimulusViewModel
ViewModel for the Stimulus block. Exposes FSM state, task progress, and start/stop controls for the card UI.
Inherited Members
Namespace: MOSAIC.ViewModels.Devices
Assembly: MOSAIC.dll
Syntax
public class StimulusViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, IDisposable
Constructors
StimulusViewModel(Stimulus)
Initializes a new StimulusViewModel and wires it to the given block.
Declaration
public StimulusViewModel(Stimulus block)
Parameters
| Type | Name | Description |
|---|---|---|
| Stimulus | block | The Stimulus block to bind to. |
Fields
_block
Declaration
private readonly Stimulus _block
Field Value
| Type | Description |
|---|---|
| Stimulus |
_captureDuration
Capture duration in seconds.
Declaration
[ObservableProperty]
private double _captureDuration
Field Value
| Type | Description |
|---|---|
| double |
_currentTaskName
Name of the current task.
Declaration
[ObservableProperty]
private string _currentTaskName
Field Value
| Type | Description |
|---|---|
| string |
_isRunning
Whether the FSM is running.
Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("IsNotRunning")]
private bool _isRunning
Field Value
| Type | Description |
|---|---|
| bool |
_shuffleEnabled
Whether shuffle mode is enabled.
Declaration
[ObservableProperty]
private bool _shuffleEnabled
Field Value
| Type | Description |
|---|---|
| bool |
_state
Current FSM state name.
Declaration
[ObservableProperty]
private string _state
Field Value
| Type | Description |
|---|---|
| string |
_targetValueText
Current target vector as formatted string.
Declaration
[ObservableProperty]
private string _targetValueText
Field Value
| Type | Description |
|---|---|
| string |
_tasksRemaining
Tasks remaining in the current run.
Declaration
[ObservableProperty]
private int _tasksRemaining
Field Value
| Type | Description |
|---|---|
| int |
resetCommand
The backing field for ResetCommand.
Declaration
private RelayCommand? resetCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
startCommand
The backing field for StartCommand.
Declaration
private RelayCommand? startCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
stopCommand
The backing field for StopCommand.
Declaration
private RelayCommand? stopCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
Properties
Block
Underlying block reference.
Declaration
public Stimulus Block { get; }
Property Value
| Type | Description |
|---|---|
| Stimulus |
CaptureDuration
Capture duration in seconds.
Declaration
[ExcludeFromCodeCoverage]
public double CaptureDuration { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
CurrentTaskName
Name of the current task.
Declaration
[ExcludeFromCodeCoverage]
public string CurrentTaskName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
FrequencyText
Formatted rate string.
Declaration
public string FrequencyText { get; }
Property Value
| Type | Description |
|---|---|
| string |
IsNotRunning
Inverse of IsRunning for XAML binding (Avalonia lacks negation syntax).
Declaration
public bool IsNotRunning { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsRunning
Whether the FSM is running.
Declaration
[ExcludeFromCodeCoverage]
public bool IsRunning { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Name
Block display name.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
ResetCommand
Gets an IRelayCommand instance wrapping Reset().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ResetCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
ShuffleEnabled
Whether shuffle mode is enabled.
Declaration
[ExcludeFromCodeCoverage]
public bool ShuffleEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
StartCommand
Gets an IRelayCommand instance wrapping Start().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StartCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
State
Current FSM state name.
Declaration
[ExcludeFromCodeCoverage]
public string State { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
StopCommand
Gets an IRelayCommand instance wrapping Stop().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StopCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
TargetValueText
Current target vector as formatted string.
Declaration
[ExcludeFromCodeCoverage]
public string TargetValueText { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
TaskCount
Total number of tasks.
Declaration
public int TaskCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
TaskNames
Task names for display.
Declaration
public ObservableCollection<string> TaskNames { get; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<string> |
TasksRemaining
Tasks remaining in the current run.
Declaration
[ExcludeFromCodeCoverage]
public int TasksRemaining { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Viz
Visualization bundle for the target output waveform.
Declaration
public BlockVisualization Viz { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
FormatVector(Vector<double>)
Formats a vector for compact display.
Declaration
private static string FormatVector(Vector<double> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector<double> | v |
Returns
| Type | Description |
|---|---|
| string |
HandleCompleted()
Handles FSM completion.
Declaration
private void HandleCompleted()
HandleStateChanged(string, string?)
Handles FSM state transitions.
Declaration
private void HandleStateChanged(string newState, string? taskName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | newState | |
| string | taskName |
OnBlockPropertyChanged(object?, PropertyChangedEventArgs)
Relays observable property changes from the block.
Declaration
private void OnBlockPropertyChanged(object? sender, PropertyChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| PropertyChangedEventArgs | e |
OnCaptureDurationChanged(double)
Executes the logic for when CaptureDuration just changed.
Declaration
private void OnCaptureDurationChanged(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 CaptureDuration is changed.
OnCaptureDurationChanged(double, double)
Executes the logic for when CaptureDuration just changed.
Declaration
private void OnCaptureDurationChanged(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 CaptureDuration is changed.
OnCaptureDurationChanging(double)
Executes the logic for when CaptureDuration is changing.
Declaration
private void OnCaptureDurationChanging(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The new property value being set. |
Remarks
This method is invoked right before the value of CaptureDuration is changed.
OnCaptureDurationChanging(double, double)
Executes the logic for when CaptureDuration is changing.
Declaration
private void OnCaptureDurationChanging(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 CaptureDuration is changed.
OnCurrentTaskNameChanged(string)
Executes the logic for when CurrentTaskName just changed.
Declaration
private void OnCurrentTaskNameChanged(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 CurrentTaskName is changed.
OnCurrentTaskNameChanged(string?, string)
Executes the logic for when CurrentTaskName just changed.
Declaration
private void OnCurrentTaskNameChanged(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 CurrentTaskName is changed.
OnCurrentTaskNameChanging(string)
Executes the logic for when CurrentTaskName is changing.
Declaration
private void OnCurrentTaskNameChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of CurrentTaskName is changed.
OnCurrentTaskNameChanging(string?, string)
Executes the logic for when CurrentTaskName is changing.
Declaration
private void OnCurrentTaskNameChanging(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 CurrentTaskName is changed.
OnIsRunningChanged(bool)
Executes the logic for when IsRunning just changed.
Declaration
private void OnIsRunningChanged(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 IsRunning is changed.
OnIsRunningChanged(bool, bool)
Executes the logic for when IsRunning just changed.
Declaration
private void OnIsRunningChanged(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 IsRunning is changed.
OnIsRunningChanging(bool)
Executes the logic for when IsRunning is changing.
Declaration
private void OnIsRunningChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of IsRunning is changed.
OnIsRunningChanging(bool, bool)
Executes the logic for when IsRunning is changing.
Declaration
private void OnIsRunningChanging(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 IsRunning is changed.
OnShuffleEnabledChanged(bool)
Executes the logic for when ShuffleEnabled just changed.
Declaration
private void OnShuffleEnabledChanged(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 ShuffleEnabled is changed.
OnShuffleEnabledChanged(bool, bool)
Executes the logic for when ShuffleEnabled just changed.
Declaration
private void OnShuffleEnabledChanged(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 ShuffleEnabled is changed.
OnShuffleEnabledChanging(bool)
Executes the logic for when ShuffleEnabled is changing.
Declaration
private void OnShuffleEnabledChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of ShuffleEnabled is changed.
OnShuffleEnabledChanging(bool, bool)
Executes the logic for when ShuffleEnabled is changing.
Declaration
private void OnShuffleEnabledChanging(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 ShuffleEnabled is changed.
OnStateChanged(string)
Executes the logic for when State just changed.
Declaration
private void OnStateChanged(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 State is changed.
OnStateChanged(string?, string)
Executes the logic for when State just changed.
Declaration
private void OnStateChanged(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 State is changed.
OnStateChanging(string)
Executes the logic for when State is changing.
Declaration
private void OnStateChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of State is changed.
OnStateChanging(string?, string)
Executes the logic for when State is changing.
Declaration
private void OnStateChanging(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 State is changed.
OnTargetValueTextChanged(string)
Executes the logic for when TargetValueText just changed.
Declaration
private void OnTargetValueTextChanged(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 TargetValueText is changed.
OnTargetValueTextChanged(string?, string)
Executes the logic for when TargetValueText just changed.
Declaration
private void OnTargetValueTextChanged(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 TargetValueText is changed.
OnTargetValueTextChanging(string)
Executes the logic for when TargetValueText is changing.
Declaration
private void OnTargetValueTextChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of TargetValueText is changed.
OnTargetValueTextChanging(string?, string)
Executes the logic for when TargetValueText is changing.
Declaration
private void OnTargetValueTextChanging(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 TargetValueText is changed.
OnTasksRemainingChanged(int)
Executes the logic for when TasksRemaining just changed.
Declaration
private void OnTasksRemainingChanged(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 TasksRemaining is changed.
OnTasksRemainingChanged(int, int)
Executes the logic for when TasksRemaining just changed.
Declaration
private void OnTasksRemainingChanged(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 TasksRemaining is changed.
OnTasksRemainingChanging(int)
Executes the logic for when TasksRemaining is changing.
Declaration
private void OnTasksRemainingChanging(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The new property value being set. |
Remarks
This method is invoked right before the value of TasksRemaining is changed.
OnTasksRemainingChanging(int, int)
Executes the logic for when TasksRemaining is changing.
Declaration
private void OnTasksRemainingChanging(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 TasksRemaining is changed.
Reset()
Resets the FSM to initial state (same as Stop, clears task progress).
Declaration
[RelayCommand]
private void Reset()
Start()
Starts the FSM.
Declaration
[RelayCommand]
private void Start()
Stop()
Stops the FSM.
Declaration
[RelayCommand]
private void Stop()