Class StreamTrigger
Streams a continuous label vector from an upstream source (dataglove, BodyRig, SinGenerator, etc.) into the TriggerBuffer as per-frame regression targets. Where the classic Trigger publishes one Vector per click and holds it constant for the whole capture, StreamTrigger publishes whichever Vector arrived most recently from upstream — so the buffer sees a time-varying label stream paired with data, which is what regression on continuous activations actually needs.
JSON configuration
Use these block entries inside a pipeline configuration. Input names must match other blocks in that pipeline; device addresses and file paths must match your setup.
JSON configuration:
{
"ActivationSource": {
"Type": "SinGenerator",
"Inputs": ["Clock"],
"DesiredRate": 30,
"Params": [5, 1.0, 0.5, 0.0, 1.2566]
},
"StreamTrigger": {
"Type": "StreamTrigger",
"Inputs": ["ActivationSource"]
}
}
How Type, Inputs and Params work · Block catalogue and parameter reference
Implements
Inherited Members
Namespace: MOSAIC.Models.FlowControl
Assembly: MOSAIC.dll
Syntax
public sealed class StreamTrigger : BaseBlock, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks
Trigger-protocol compatibility. The class name contains "Trigger", which
is what TriggerBuffer.OnReceive checks to decide whether to treat the sender
as a trigger or as data. So this block plugs into existing buffer wiring with no
modifications: the buffer interprets every published Vector as "update current target",
every null as "end segment".
Upstream input. Expects a single input that publishes MathNet.Numerics.LinearAlgebra.Vector<T>s
— typically a SinGenerator (for testing), a future DataGlove block,
or any other vector-emitting source. The latest vector is cached in
_latestLabel and republished on each tick while streaming is active.
If the upstream rate is slower than the data rate, the cached value acts as
hold-last interpolation.
UI control. StartStreamCommand begins emission; the buffer
receives a non-null Vector and starts a segment. StopStreamCommand
publishes null, ending the segment. The streamer doesn't auto-start —
the user must explicitly hit "Start" to begin recording.
Constructors
StreamTrigger(string, double)
Declaration
public StreamTrigger(string name, double desiredRate)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| double | desiredRate |
Fields
_isStreaming
When true, every upstream label received is forwarded to downstream
consumers (i.e. the buffer). When false, upstream labels are still
cached but nothing is published — so toggling to true resumes from
the latest known value rather than waiting for the next upstream tick.
Declaration
[ObservableProperty]
[NotifyPropertyChangedFor("StatusText")]
private bool _isStreaming
Field Value
| Type | Description |
|---|---|
| bool |
_latestLabel
Most recently received upstream label. Held across upstream ticks so that downstream consumers always see the latest known target, even if the upstream rate differs from the data rate (hold-last semantics).
Declaration
private Vector<double>? _latestLabel
Field Value
| Type | Description |
|---|---|
| Vector<double> |
_latestLabelText
Most recent label values for the live readout, as a comma-separated string.
Declaration
[ObservableProperty]
private string _latestLabelText
Field Value
| Type | Description |
|---|---|
| string |
_publishedCount
Number of vectors published since streaming started (for UI counter).
Declaration
[ObservableProperty]
private long _publishedCount
Field Value
| Type | Description |
|---|---|
| long |
_receivedCount
Number of upstream labels received (regardless of streaming state).
Declaration
[ObservableProperty]
private long _receivedCount
Field Value
| Type | Description |
|---|---|
| long |
_sessionName
Human-readable identifier for the current recording session, written into the buffer's per-segment Label field. Useful for distinguishing sessions in the buffer's CSV export.
Declaration
[ObservableProperty]
private string _sessionName
Field Value
| Type | Description |
|---|---|
| string |
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 |
toggleStreamCommand
The backing field for ToggleStreamCommand.
Declaration
private RelayCommand? toggleStreamCommand
Field Value
| Type | Description |
|---|---|
| RelayCommand |
Properties
DumpFilePrefix
Recordings from this block are named <block>_stream.csv.
Declaration
protected override string DumpFilePrefix { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
IsStreaming
When true, every upstream label received is forwarded to downstream
consumers (i.e. the buffer). When false, upstream labels are still
cached but nothing is published — so toggling to true resumes from
the latest known value rather than waiting for the next upstream tick.
Declaration
[ExcludeFromCodeCoverage]
public bool IsStreaming { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
JsonTypeName
Block type identifier for JSON serialization. Override for a custom name.
Declaration
protected override string JsonTypeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
LatestLabel
Current cached upstream label (read-only snapshot for inspection).
Declaration
public Vector<double>? LatestLabel { get; }
Property Value
| Type | Description |
|---|---|
| Vector<double> |
LatestLabelText
Most recent label values for the live readout, as a comma-separated string.
Declaration
[ExcludeFromCodeCoverage]
public string LatestLabelText { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
PublishedCount
Number of vectors published since streaming started (for UI counter).
Declaration
[ExcludeFromCodeCoverage]
public long PublishedCount { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
ReceivedCount
Number of upstream labels received (regardless of streaming state).
Declaration
[ExcludeFromCodeCoverage]
public long ReceivedCount { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
SessionName
Human-readable identifier for the current recording session, written into the buffer's per-segment Label field. Useful for distinguishing sessions in the buffer's CSV export.
Declaration
[ExcludeFromCodeCoverage]
public string SessionName { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
StartStreamCommand
Gets an IRelayCommand instance wrapping StartStream().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StartStreamCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
StatusText
Computed status string for the card badge.
Declaration
public string StatusText { get; }
Property Value
| Type | Description |
|---|---|
| string |
StopStreamCommand
Gets an IRelayCommand instance wrapping StopStream().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand StopStreamCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
ToggleStreamCommand
Gets an IRelayCommand instance wrapping ToggleStream().
Declaration
[ExcludeFromCodeCoverage]
public IRelayCommand ToggleStreamCommand { get; }
Property Value
| Type | Description |
|---|---|
| IRelayCommand |
Methods
ConfigureInput(IServiceProvider, JsonModel)
Declaration
public static StreamTrigger ConfigureInput(IServiceProvider sp, JsonModel m)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | sp | |
| JsonModel | m |
Returns
| Type | Description |
|---|---|
| StreamTrigger |
FormatVector(Vector<double>)
Declaration
private static string FormatVector(Vector<double> v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector<double> | v |
Returns
| Type | Description |
|---|---|
| string |
GetJsonParams()
Block-specific parameters for JSON. Override to provide custom parameters.
Declaration
protected override IReadOnlyList<object>? GetJsonParams()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<object> | The values for Params, in the order this block's |
Overrides
OnIsStreamingChanged(bool)
Executes the logic for when IsStreaming just changed.
Declaration
private void OnIsStreamingChanged(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 IsStreaming is changed.
OnIsStreamingChanged(bool, bool)
Executes the logic for when IsStreaming just changed.
Declaration
private void OnIsStreamingChanged(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 IsStreaming is changed.
OnIsStreamingChanging(bool)
Executes the logic for when IsStreaming is changing.
Declaration
private void OnIsStreamingChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of IsStreaming is changed.
OnIsStreamingChanging(bool, bool)
Executes the logic for when IsStreaming is changing.
Declaration
private void OnIsStreamingChanging(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 IsStreaming is changed.
OnLatestLabelTextChanged(string)
Executes the logic for when LatestLabelText just changed.
Declaration
private void OnLatestLabelTextChanged(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 LatestLabelText is changed.
OnLatestLabelTextChanged(string?, string)
Executes the logic for when LatestLabelText just changed.
Declaration
private void OnLatestLabelTextChanged(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 LatestLabelText is changed.
OnLatestLabelTextChanging(string)
Executes the logic for when LatestLabelText is changing.
Declaration
private void OnLatestLabelTextChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of LatestLabelText is changed.
OnLatestLabelTextChanging(string?, string)
Executes the logic for when LatestLabelText is changing.
Declaration
private void OnLatestLabelTextChanging(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 LatestLabelText is changed.
OnPublishedCountChanged(long)
Executes the logic for when PublishedCount just changed.
Declaration
private void OnPublishedCountChanged(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 PublishedCount is changed.
OnPublishedCountChanged(long, long)
Executes the logic for when PublishedCount just changed.
Declaration
private void OnPublishedCountChanged(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 PublishedCount is changed.
OnPublishedCountChanging(long)
Executes the logic for when PublishedCount is changing.
Declaration
private void OnPublishedCountChanging(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The new property value being set. |
Remarks
This method is invoked right before the value of PublishedCount is changed.
OnPublishedCountChanging(long, long)
Executes the logic for when PublishedCount is changing.
Declaration
private void OnPublishedCountChanging(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 PublishedCount is changed.
OnReceive(object, object?)
Receives a Vector from upstream and forwards it as a trigger-protocol message when streaming. Non-Vector inputs are ignored — this block only makes sense as a label-source proxy.
Declaration
protected override void OnReceive(object sender, object? data)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | |
| object | data |
Overrides
OnReceivedCountChanged(long)
Executes the logic for when ReceivedCount just changed.
Declaration
private void OnReceivedCountChanged(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 ReceivedCount is changed.
OnReceivedCountChanged(long, long)
Executes the logic for when ReceivedCount just changed.
Declaration
private void OnReceivedCountChanged(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 ReceivedCount is changed.
OnReceivedCountChanging(long)
Executes the logic for when ReceivedCount is changing.
Declaration
private void OnReceivedCountChanging(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The new property value being set. |
Remarks
This method is invoked right before the value of ReceivedCount is changed.
OnReceivedCountChanging(long, long)
Executes the logic for when ReceivedCount is changing.
Declaration
private void OnReceivedCountChanging(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 ReceivedCount is changed.
OnSessionNameChanged(string)
Executes the logic for when SessionName just changed.
Declaration
private void OnSessionNameChanged(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 SessionName is changed.
OnSessionNameChanged(string?, string)
Executes the logic for when SessionName just changed.
Declaration
private void OnSessionNameChanged(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 SessionName is changed.
OnSessionNameChanging(string)
Executes the logic for when SessionName is changing.
Declaration
private void OnSessionNameChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of SessionName is changed.
OnSessionNameChanging(string?, string)
Executes the logic for when SessionName is changing.
Declaration
private void OnSessionNameChanging(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 SessionName is changed.
StartStream()
Begin streaming. Publishes the cached latest label immediately so the buffer can open a segment without waiting for the next upstream tick; if no upstream label has been seen yet, the buffer will start once the first one arrives.
Declaration
[RelayCommand]
private void StartStream()
StopStream()
Stop streaming. Publishes null so the buffer finalises the current
segment and writes it to dB.
Declaration
[RelayCommand]
private void StopStream()
ToggleStream()
Toggle convenience for the card's single Start/Stop button.
Declaration
[RelayCommand]
private void ToggleStream()