Class BaseBlock
Base class for processing blocks in the MOSAIC pipeline.
Inheritance
Implements
Inherited Members
Namespace: MOSAIC.Components.Basics
Assembly: MOSAIC.dll
Syntax
public abstract class BaseBlock : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, ISubscriber, IPublisher, IBaseBlockProps, IJsonExportable, IDisposable, IAsyncDisposable
Remarks
A BaseBlock represents one node in a processing graph. Blocks are typically created and linked based on a JSON configuration (pipeline definition).
Two Rate Properties:
| Property | Purpose |
|---|---|
| DesiredRate | Emission / display rate in Hz. Determines how often a block publishes output. Modified by windowing blocks (e.g. SlidingWindow: input rows/s divided by stride). Used for status monitoring and tick rate display. |
| SignalRate | True sample rate of the underlying signal in Hz. Used for DSP coefficient design (filter cutoffs, FFT bins, spectral resolution). Passes through windowing blocks unchanged — a SlidingWindow with stride 100 at 2000 Hz input still outputs data whose samples are at 2000 Hz, even though the windows arrive at 20 Hz. |
Rate Inheritance: Both rates propagate downstream automatically via TryInheritRate(BaseBlock). Publication rates initially fill unset values; use UpdateAndPropagateRate(double, bool) for runtime changes. Sample rates refresh downstream unless a block declares that it derives its own rate.
Publishing: The Publish(object) method is thread-safe and non-blocking. If a publish call is already in progress, the new value is dropped and the block enters a "stumbling" state reflected in Status.
Automatic CSV Logging: Every successful Publish(object) call feeds
Dumper whenever one is open. A dumper opens either because the config named a
Path — BlockFactory calls
InitDumper(IServiceProvider, string?) for every block it builds — or because IsRecording was
switched on, which writes to the shared session folder instead. Either way the file is named by
DumpFilePrefix. A block whose Path means something other than a recording
folder overrides PathIsDumpFolder.
Constructors
BaseBlock()
Registers publication-based status monitoring with the shared 250 ms timer.
Declaration
protected BaseBlock()
BaseBlock(string, double)
Initializes a new BaseBlock with the specified name and optional desired rate.
Declaration
protected BaseBlock(string name, double desiredRate = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| double | desiredRate |
Fields
_activeReceivers
Declaration
private int _activeReceivers
Field Value
| Type | Description |
|---|---|
| int |
_cleanupTasks
Declaration
private readonly List<Task> _cleanupTasks
Field Value
| Type | Description |
|---|---|
| List<Task> |
_desiredRate
Backing field for DesiredRate.
Declaration
private double _desiredRate
Field Value
| Type | Description |
|---|---|
| double |
_dispatcher
Fans published values out to subscribers, one queue per subscriber.
Declaration
private readonly IOutputDispatcher _dispatcher
Field Value
| Type | Description |
|---|---|
| IOutputDispatcher |
_disposeTask
Declaration
private Task? _disposeTask
Field Value
| Type | Description |
|---|---|
| Task |
_disposed
Guard making Dispose(bool) idempotent.
Declaration
private bool _disposed
Field Value
| Type | Description |
|---|---|
| bool |
_dumperClosing
A close still in flight. Held so a reopen can wait for the file handle to be released.
Declaration
private Task? _dumperClosing
Field Value
| Type | Description |
|---|---|
| Task |
_explicitDumpFolder
Folder and file name an explicit Path opened this block's dumper with, or null when the block records to the shared session folder.
Declaration
private string? _explicitDumpFolder
Field Value
| Type | Description |
|---|---|
| string |
Remarks
Held so the toggle reopens the file the config named. Without it, switching a Path-configured block off and back on silently relocated the rest of the session into the shared folder under a different file name, splitting one block's data across two places.
_frequencyText
Human-readable frequency string (e.g. "125.0 Hz") for the UI.
Declaration
[ObservableProperty]
private string _frequencyText
Field Value
| Type | Description |
|---|---|
| string |
_inputConnections
Names of the upstream blocks this one was wired to, kept for JSON round-trip.
Declaration
private IReadOnlyList<string>? _inputConnections
Field Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
_inputRate
Backing field for InputRate.
Declaration
private double _inputRate
Field Value
| Type | Description |
|---|---|
| double |
_isRecording
Whether this block is writing every published value to CSV. Safe to flip while the pipeline is running: turning it on opens a file in the current session folder, turning it off flushes and closes it.
Declaration
[ObservableProperty]
private bool _isRecording
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Setting this to true with no destination configured leaves it false — a block must never appear to be recording when nothing is on disk.
_isStumbling
Set when a publish was dropped because the previous one was still dispatching.
Declaration
private volatile bool _isStumbling
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Volatile because Publish(object) writes it on the producing thread while the status timer reads it on another.
_lastError
Declaration
private string? _lastError
Field Value
| Type | Description |
|---|---|
| string |
_lastRecording
Declaration
private CsvDumper? _lastRecording
Field Value
| Type | Description |
|---|---|
| CsvDumper |
_lifetimeLock
Declaration
private readonly object _lifetimeLock
Field Value
| Type | Description |
|---|---|
| object |
_name
Display name of the block.
Declaration
[ObservableProperty]
private string _name
Field Value
| Type | Description |
|---|---|
| string |
_ownedResources
Declaration
private readonly Dictionary<Type, object> _ownedResources
Field Value
| Type | Description |
|---|---|
| Dictionary<Type, object> |
_receiversStopped
Declaration
private TaskCompletionSource? _receiversStopped
Field Value
| Type | Description |
|---|---|
| TaskCompletionSource |
_recordingDestination
Where a recording goes. Supplied by the factory; null for blocks built outside it.
Declaration
private IRecordingDestination? _recordingDestination
Field Value
| Type | Description |
|---|---|
| IRecordingDestination |
_reportedDiagnosticText
Declaration
private string _reportedDiagnosticText
Field Value
| Type | Description |
|---|---|
| string |
_reportedDiagnostics
Declaration
private (string? Error, string? RecordingError, long Dropped, int Queued, long Rejected, long Failures) _reportedDiagnostics
Field Value
| Type | Description |
|---|---|
| (string Error, string RecordingError, long Dropped, int Queued, long Rejected, long Failures) |
_reportedHasDiagnostics
Declaration
private bool _reportedHasDiagnostics
Field Value
| Type | Description |
|---|---|
| bool |
_sendLock
Guards Publish(object). Held rather than waited on, so a late value is dropped.
Declaration
private readonly object _sendLock
Field Value
| Type | Description |
|---|---|
| object |
_signalRate
Backing field for SignalRate.
Declaration
private double _signalRate
Field Value
| Type | Description |
|---|---|
| double |
_status
Publication activity, refreshed by the shared 250 ms status timer.
Declaration
[ObservableProperty]
private BlockStatus _status
Field Value
| Type | Description |
|---|---|
| BlockStatus |
_stopping
Declaration
private volatile bool _stopping
Field Value
| Type | Description |
|---|---|
| bool |
_subscriberLock
Guards _subscribers against concurrent traversal and mutation.
Declaration
private readonly object _subscriberLock
Field Value
| Type | Description |
|---|---|
| object |
_subscribers
Downstream blocks, held weakly, used only for rate propagation.
Declaration
private readonly List<WeakReference<BaseBlock>> _subscribers
Field Value
| Type | Description |
|---|---|
| List<WeakReference<BaseBlock>> |
Remarks
Separate from the dispatcher's subscriber list, which is what values actually travel through. This one exists because rate inheritance needs the concrete BaseBlock rather than the ISubscriber the dispatcher stores, and it is weak so a block downstream cannot keep its publisher alive. Dead entries are pruned during traversal.
_tickTracker
Measures publish cadence, which drives Status and FrequencyText.
Declaration
private readonly ITickTracker _tickTracker
Field Value
| Type | Description |
|---|---|
| ITickTracker |
Properties
AllowableBlocks
Type names this block accepts as inputs, or an empty array when it accepts any.
Declaration
public virtual string[] AllowableBlocks { get; }
Property Value
| Type | Description |
|---|---|
| string[] | Upstream runtime class names, as checked by BlockConstraints. Empty means unrestricted. |
Remarks
Advisory metadata for the pipeline builder, which uses it to grey out incompatible sources while a connection is being dragged. Not enforced at run time — a config that wires an unlisted block in still builds.
CanRecord
True when a recording destination has been chosen, so IsRecording can actually be turned on. Bind menu items to this rather than offering a toggle that silently fails.
Declaration
public bool CanRecord { get; }
Property Value
| Type | Description |
|---|---|
| bool |
DesiredRate
Emission / display rate in Hz. Modified by windowing blocks.
Declaration
public double DesiredRate { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
If not explicitly set (0), the rate is automatically inherited from upstream blocks. Once set, it propagates to all downstream blocks that don't have a rate yet. Override OnDesiredRateChanged(double, double) to react (e.g. rebuild filters).
DiagnosticText
Declaration
public string DiagnosticText { get; }
Property Value
| Type | Description |
|---|---|
| string |
DownstreamFailures
Declaration
public long DownstreamFailures { get; }
Property Value
| Type | Description |
|---|---|
| long |
DumpFilePrefix
File name (without extension) this block records under. Defaults to Name, which is unique within a pipeline; override only where a block writes something the block name does not describe.
Declaration
protected virtual string DumpFilePrefix { get; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
This is the single file-name authority for configuration-driven and UI-driven recording, ensuring both paths write the block to the same destination.
Dumper
Optional CSV dumper for automatic publish logging. Non-null exactly while the block is recording; Publish(object) feeds it on every value.
Declaration
protected CsvDumper? Dumper { get; set; }
Property Value
| Type | Description |
|---|---|
| CsvDumper |
EffectiveSampleRate
Effective sample rate for DSP coefficient design. Prefers SignalRate, falls back to DesiredRate, then 1000 Hz as a safe default.
Declaration
public double EffectiveSampleRate { get; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
Convenience property for blocks that need a sample rate (filters, FFT, etc.). Avoids repeating the fallback chain in every DSP block.
FrequencyText
Human-readable frequency string (e.g. "125.0 Hz") for the UI.
Declaration
[ExcludeFromCodeCoverage]
public string FrequencyText { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
HasDiagnostics
Declaration
public bool HasDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| bool |
InputRate
Input rate received from upstream blocks. Set automatically by TryInheritRate(BaseBlock).
Declaration
public double InputRate { get; protected set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
Useful for blocks that calculate their output rate from the input rate
(e.g. SlidingWindow: InputRate / Stride).
Inputs
Input connections from JSON configuration. Used for round-trip JSON export.
Declaration
public IReadOnlyList<string>? Inputs { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> |
IsRecording
Whether this block is writing every published value to CSV. Safe to flip while the pipeline is running: turning it on opens a file in the current session folder, turning it off flushes and closes it.
Declaration
[ExcludeFromCodeCoverage]
public bool IsRecording { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Setting this to true with no destination configured leaves it false — a block must never appear to be recording when nothing is on disk.
JsonTypeName
Block type identifier for JSON serialization. Override for a custom name.
Declaration
protected virtual string JsonTypeName { get; }
Property Value
| Type | Description |
|---|---|
| string |
LastError
Last processing fault; activity monitoring never overwrites it.
Declaration
public string? LastError { get; }
Property Value
| Type | Description |
|---|---|
| string |
MaxInputs
Gets the maximum number of input connections allowed for this block.
Declaration
public virtual int MaxInputs { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Override in derived classes to specify input requirements. Default is 1 (most blocks accept exactly one input). Use MaxValue for blocks that accept unlimited inputs (e.g., Joiner).
MinInputs
Gets the minimum number of input connections required for this block.
Declaration
public virtual int MinInputs { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
Override in derived classes to specify input requirements. Default is 1 (most blocks require exactly one input). Source blocks (devices, generators) should return 0.
Name
Display name of the block.
Declaration
[ExcludeFromCodeCoverage]
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
PathIsDumpFolder
Whether Path means "record CSV here" for this block. True for every
block but the handful that read Path as something else.
Declaration
protected virtual bool PathIsDumpFolder { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
The explicit opt-out makes alternate Path semantics visible to callers and reviewers.
Override this to false only where Path addresses something else,
such as the model directory of a predictor.
QueuedOutputValues
Declaration
public int QueuedOutputValues { get; }
Property Value
| Type | Description |
|---|---|
| int |
RecordingDroppedRows
Declaration
public long RecordingDroppedRows { get; }
Property Value
| Type | Description |
|---|---|
| long |
RecordingError
Declaration
public string? RecordingError { get; }
Property Value
| Type | Description |
|---|---|
| string |
RejectedOutputValues
Declaration
public long RejectedOutputValues { get; }
Property Value
| Type | Description |
|---|---|
| long |
SignalRate
True sample rate of the signal in Hz. Used for DSP coefficient design.
Declaration
public double SignalRate { get; set; }
Property Value
| Type | Description |
|---|---|
| double |
Remarks
Propagates independently of DesiredRate. Windowing blocks (e.g. SlidingWindow) change DesiredRate to reflect the output window rate but leave SignalRate unchanged, because the samples inside each window are still at the original rate.
For simple pipelines without windowing, SignalRate and DesiredRate will be equal. Blocks that need a sample rate for DSP (filters, FFT, adaptive filters) should prefer SignalRate and fall back to DesiredRate if it's zero:
double fs = SignalRate > 0 ? SignalRate : DesiredRate > 0 ? DesiredRate : 1000;
Source blocks (device drivers) should set this to the true hardware sample rate in their connect/start method.
Status
Publication activity, refreshed by the shared 250 ms status timer.
Declaration
[ExcludeFromCodeCoverage]
public BlockStatus Status { get; set; }
Property Value
| Type | Description |
|---|---|
| BlockStatus |
TransformsPublicationRate
True when this block computes its own output cadence from its input.
Declaration
protected virtual bool TransformsPublicationRate { get; }
Property Value
| Type | Description |
|---|---|
| bool |
TransformsSignalRate
True when this block produces a new sample spacing (for example resampling).
Declaration
protected virtual bool TransformsSignalRate { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Visualization
This block's visualization, or null when it has none.
Declaration
protected virtual BlockVisualization? Visualization { get; }
Property Value
| Type | Description |
|---|---|
| BlockVisualization |
Remarks
Blocks own their scope as a public Viz property rather than inheriting one, so the
base class has no way to reach it. Overriding this is what lets the rate below be wired up
automatically. With correct publication metadata, the bundle derives the time axis for
one vector per publication or fixed-size contiguous sample packets from the feed shape.
When a plot needs a rate that publication frequency and feed shape cannot express (for
example, variable-sized packets or overlapping windows), declare it with
Viz.UpdateSignalRate. An explicit declaration wins over the derived rate. A block
with several bundles must configure each one; this hook exposes only one bundle.
Methods
AddSubscriber(ISubscriber)
Registers a subscriber so it will receive values produced by this publisher.
Declaration
public void AddSubscriber(ISubscriber subscriber)
Parameters
| Type | Name | Description |
|---|---|---|
| ISubscriber | subscriber | The subscriber (block) instance to register. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
AttachRecording(IRecordingDestination?)
Wires the block to the shared recording destination. Called by the factory once
ConfigureInput has run.
Declaration
public void AttachRecording(IRecordingDestination? destination)
Parameters
| Type | Name | Description |
|---|---|---|
| IRecordingDestination | destination | The shared destination, or null to disable recording. |
Remarks
The config says nothing about recording beyond the long-standing Path,
so the starting state is read from whether ConfigureInput actually opened a dumper. That
is deliberately not read from Path itself: for the predictor blocks Path is where
a trained model is saved, and treating it as a dump folder would drop CSV into it.
A block whose dumper came from Path keeps that folder for the rest of the session: the
toggle stops and resumes the same file rather than relocating it.
ClearError()
Declaration
public void ClearError()
CloseDumper()
Detaches the dumper from the publish path, then flushes and closes it in the background.
Declaration
private void CloseDumper()
CompleteDisposalAsync(TaskCompletionSource)
Declaration
private Task CompleteDisposalAsync(TaskCompletionSource completion)
Parameters
| Type | Name | Description |
|---|---|---|
| TaskCompletionSource | completion |
Returns
| Type | Description |
|---|---|
| Task |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
Dispose(bool)
Releases managed resources: status subscription, output dispatcher, CSV dumper, subscriber references.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing | true when called from Dispose(). There is no finalizer, so a false pass has nothing to release. |
DisposeAsync()
Stops processing, releases model/card resources, and waits for recording closure.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask |
DisposeBlockAsync()
Declaration
private Task DisposeBlockAsync()
Returns
| Type | Description |
|---|---|
| Task |
ForcePropagateDesiredRate()
Force-propagates this block's current DesiredRate to the entire downstream chain, overriding rates that downstream blocks latched on a previous run. Use from a source block whose rate is changed at runtime so the change reaches already-initialised consumers (the default DesiredRate setter propagates softly and a latched downstream rate would otherwise block it).
Declaration
protected void ForcePropagateDesiredRate()
GetJsonParams()
Block-specific parameters for JSON. Override to provide custom parameters.
Declaration
protected virtual IReadOnlyList<object>? GetJsonParams()
Returns
| Type | Description |
|---|---|
| IReadOnlyList<object> | The values for Params, in the order this block's |
GetJsonPath()
Overrides what this block writes to Path.
Declaration
protected virtual string? GetJsonPath()
Returns
| Type | Description |
|---|---|
| string | The path to export, or null to fall back to the block's own recording folder. |
Remarks
Only for blocks that read Path as something other than a recording folder — a
predictor's model directory, say. Such a block also overrides
PathIsDumpFolder; without this override it would export null
and saving the pipeline would silently drop the directory.
GetOrCreateOwned<T>(Func<T>)
Returns one shared resource per type for this block and disposes it with the block. Card templates use this to retain the same ViewModel across grouping and pop-out views.
Declaration
internal T GetOrCreateOwned<T>(Func<T> create) where T : class
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T> | create |
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T |
InitDumper(IServiceProvider, string?)
Opens this block's dumper on an explicit Path, if the config named one and PathIsDumpFolder allows it.
Declaration
protected internal void InitDumper(IServiceProvider sp, string? path)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | sp | Service provider, passed through to the dumper. |
| string | path | The config's |
Remarks
Called once by BlockFactory for every block, so that
"a Path in the config means the block records there" holds structurally rather than by
each ConfigureInput remembering to ask for it. It is deliberately not
public: blocks declare intent by overriding PathIsDumpFolder
and DumpFilePrefix, not by calling this.
This is also what marks the block as having a per-block destination, so the toggle and the JSON round-trip both keep pointing at the same folder.
OnDesiredRateChanged(double, double)
Called when DesiredRate changes. Override to react (e.g. rebuild filters).
Declaration
protected virtual void OnDesiredRateChanged(double oldRate, double newRate)
Parameters
| Type | Name | Description |
|---|---|---|
| double | oldRate | The previous rate in Hz; |
| double | newRate | The new rate in Hz. Always greater than |
OnFrequencyTextChanged(string)
Executes the logic for when FrequencyText just changed.
Declaration
private void OnFrequencyTextChanged(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 FrequencyText is changed.
OnFrequencyTextChanged(string?, string)
Executes the logic for when FrequencyText just changed.
Declaration
private void OnFrequencyTextChanged(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 FrequencyText is changed.
OnFrequencyTextChanging(string)
Executes the logic for when FrequencyText is changing.
Declaration
private void OnFrequencyTextChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of FrequencyText is changed.
OnFrequencyTextChanging(string?, string)
Executes the logic for when FrequencyText is changing.
Declaration
private void OnFrequencyTextChanging(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 FrequencyText is changed.
OnInputRateChanged(double)
Called when InputRate changes. Override to recalculate output rate.
Declaration
protected virtual void OnInputRateChanged(double newInputRate)
Parameters
| Type | Name | Description |
|---|---|---|
| double | newInputRate | The rate in Hz at which the upstream block now publishes. |
OnIsRecordingChanged(bool)
Opens or closes the dumper when IsRecording is set.
Declaration
private void OnIsRecordingChanged(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new switch state. true opens a file, false flushes and closes the current one. |
Remarks
Generated by the MVVM Toolkit as the partial hook for the IsRecording property. Turning
the switch on with nowhere to write puts it straight back to false, so the
UI can never show a block as recording while nothing reaches disk.
OnIsRecordingChanged(bool, bool)
Executes the logic for when IsRecording just changed.
Declaration
private void OnIsRecordingChanged(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 IsRecording is changed.
OnIsRecordingChanging(bool)
Executes the logic for when IsRecording is changing.
Declaration
private void OnIsRecordingChanging(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The new property value being set. |
Remarks
This method is invoked right before the value of IsRecording is changed.
OnIsRecordingChanging(bool, bool)
Executes the logic for when IsRecording is changing.
Declaration
private void OnIsRecordingChanging(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 IsRecording is changed.
OnNameChanged(string)
Executes the logic for when Name just changed.
Declaration
private void OnNameChanged(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 Name is changed.
OnNameChanged(string?, string)
Executes the logic for when Name just changed.
Declaration
private void OnNameChanged(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 Name is changed.
OnNameChanging(string)
Executes the logic for when Name is changing.
Declaration
private void OnNameChanging(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The new property value being set. |
Remarks
This method is invoked right before the value of Name is changed.
OnNameChanging(string?, string)
Executes the logic for when Name is changing.
Declaration
private void OnNameChanging(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 Name is changed.
OnReceive(object, object)
Processes incoming data from an upstream block. Must be implemented by derived classes.
Declaration
protected abstract void OnReceive(object sender, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The publishing block, or whatever else delivered the value. |
| object | value | The payload. Blocks are wired by config rather than by type, so an implementation has to check the run-time type and reject or handle a shape it cannot use. Status is updated automatically from publication activity; it is not a per-value validation result. |
Remarks
Called on the dispatching thread, not the UI thread.
OnSignalRateChanged(double)
Called when SignalRate changes. Override to rebuild DSP coefficients.
Declaration
protected virtual void OnSignalRateChanged(double newRate)
Parameters
| Type | Name | Description |
|---|---|---|
| double | newRate | The new true sample rate in Hz. |
OnStatusChanged(BlockStatus)
Executes the logic for when Status just changed.
Declaration
private void OnStatusChanged(BlockStatus value)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockStatus | value | The new property value that was set. |
Remarks
This method is invoked right after the value of Status is changed.
OnStatusChanged(BlockStatus, BlockStatus)
Executes the logic for when Status just changed.
Declaration
private void OnStatusChanged(BlockStatus oldValue, BlockStatus newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockStatus | oldValue | The previous property value that was replaced. |
| BlockStatus | newValue | The new property value that was set. |
Remarks
This method is invoked right after the value of Status is changed.
OnStatusChanging(BlockStatus)
Executes the logic for when Status is changing.
Declaration
private void OnStatusChanging(BlockStatus value)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockStatus | value | The new property value being set. |
Remarks
This method is invoked right before the value of Status is changed.
OnStatusChanging(BlockStatus, BlockStatus)
Executes the logic for when Status is changing.
Declaration
private void OnStatusChanging(BlockStatus oldValue, BlockStatus newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockStatus | oldValue | The previous property value that is being replaced. |
| BlockStatus | newValue | The new property value being set. |
Remarks
This method is invoked right before the value of Status is changed.
OpenDumper()
Opens the dumper in this block's recording folder.
Declaration
private bool OpenDumper()
Returns
| Type | Description |
|---|---|
| bool | true if a dumper is open when this returns, whether it was already open or newly created; false if no folder is available or it could not be opened. |
PropagateRatesToSubscribers(bool)
Propagates both DesiredRate and SignalRate to downstream subscribers. Cleans up stale weak references during traversal.
Declaration
private void PropagateRatesToSubscribers(bool force = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | force | When true, overrides existing DesiredRate on downstream blocks. Sample-rate metadata refreshes unless the receiver derives its own sample rate. |
PropagateSignalRateToSubscribers()
Propagates SignalRate to downstream subscribers that do not derive their own rate. Called from the SignalRate setter.
Declaration
private void PropagateSignalRateToSubscribers()
Publish(object)
Publishes an output value to all registered subscribers. Thread-safe and non-blocking — drops the value if the previous dispatch is still running.
Declaration
public void Publish(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The payload to hand downstream, and to the CSV recording when one is open. |
Remarks
The producer must never mutate a published payload again. Consumers must treat it as read-only; a consumer that needs to change it must make its own copy. Delivery queues retain references. Dropping rather than queueing is deliberate: a block that cannot keep up should shed load, not accumulate latency. A dropped value puts the block into Stumbling, which is what the card's status light reports.
ReceiveInput(object, object)
Receives an input value from a publisher or dispatcher.
Declaration
public void ReceiveInput(object sender, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| object | sender | The originator of the value (typically the publishing block). |
| object | value | The value payload delivered to this subscriber. |
RefreshDiagnostics()
Declaration
private void RefreshDiagnostics()
RefreshStatus()
Declaration
private void RefreshStatus()
RefreshVisualizationRate()
Keeps Visualization told how often this block publishes. Called automatically on every rate change; a block whose visualization is assigned from outside (its ViewModel owns the scope) must also call this from that setter, because the rate was pushed before the scope existed.
Declaration
protected void RefreshVisualizationRate()
Remarks
The scope needs rows per second, which is this rate times the rows each feed carries — a count only the visualization can see, so it does the multiplication. Doing it here means a block gets a correct time axis without knowing the scope exists: before this, 30 of the 37 blocks that plot never declared any rate and every one of them was drawn against a fixed 5 ms period that had nothing to do with their signal.
ReleaseBaseResources()
Declaration
private void ReleaseBaseResources()
RemoveSubscriber(ISubscriber)
Unregisters a subscriber so it no longer receives values produced by this publisher.
Declaration
public void RemoveSubscriber(ISubscriber subscriber)
Parameters
| Type | Name | Description |
|---|---|---|
| ISubscriber | subscriber | The subscriber (block) instance to unregister. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
ReportError(string, Exception?)
Records a processing fault separately from activity and makes it visible on the card.
Declaration
public void ReportError(string message, Exception? exception = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message | |
| Exception | exception |
SetInputsFromConfig(JsonModel)
Stores the original input connections for later JSON export. Called during pipeline construction.
Declaration
public void SetInputsFromConfig(JsonModel model)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonModel | model | The config entry this block was built from. |
SetRateAndPropagate(double, bool)
Sets this block's rate and continues propagation down the subscriber chain.
Declaration
private void SetRateAndPropagate(double newRate, bool force)
Parameters
| Type | Name | Description |
|---|---|---|
| double | newRate | The rate in Hz to adopt. |
| bool | force | Passed straight on, so the whole chain propagates the same way. See PropagateRatesToSubscribers(bool). |
StopProcessingAsync()
Rejects further input/publication and waits for callbacks already executing and output pumps. Queued inputs to stopping blocks are discarded. This is teardown, not a lossless graph flush.
Declaration
internal Task StopProcessingAsync()
Returns
| Type | Description |
|---|---|
| Task |
ToJsonModel()
Exports the block configuration to a JsonModel.
Declaration
public virtual JsonModel ToJsonModel()
Returns
| Type | Description |
|---|---|
| JsonModel | A model equivalent to the config entry this block was built from. |
TrackCleanup(Task)
Includes a device disconnect or extra recording close in asynchronous disposal.
Declaration
protected void TrackCleanup(Task cleanup)
Parameters
| Type | Name | Description |
|---|---|---|
| Task | cleanup |
TryInheritRate(BaseBlock)
Refreshes inherited sample metadata and fills an unset publication rate. Also updates InputRate unconditionally for tracking.
Declaration
private void TryInheritRate(BaseBlock source)
Parameters
| Type | Name | Description |
|---|---|---|
| BaseBlock | source | The upstream block that delivered the value. Ignored when it has no rate. |
UpdateAndPropagateRate(double, bool)
Forces propagation of a new DesiredRate to the entire downstream chain.
Declaration
protected void UpdateAndPropagateRate(double newRate, bool force = true)
Parameters
| Type | Name | Description |
|---|---|---|
| double | newRate | The new emission rate in Hz. Values of |
| bool | force | true to overwrite rates downstream blocks have already latched. |
Remarks
Use when the block's output rate changes dynamically (e.g. SlidingWindow stride change). Unlike normal propagation, this overrides latched rates on all downstream blocks. The current SignalRate propagates alongside, respecting sample-rate transformers.
UpdateAndPropagateSignalRate(double)
Sets this block's sample rate and refreshes downstream sample metadata. Propagation stops at blocks that derive their own output sample spacing.
Declaration
protected void UpdateAndPropagateSignalRate(double newRate)
Parameters
| Type | Name | Description |
|---|---|---|
| double | newRate | The new true sample rate in Hz. Values of |
WaitForPendingClose()
Blocks until a close started earlier has released the file, so a reopen can take the handle.
Declaration
private void WaitForPendingClose()
Remarks
Switching a recording off is deliberately non-blocking. The dumper owns its FileStream until asynchronous disposal finishes, so reopening the same file must wait for that handle. The wait occurs only during an immediate user-driven reopen, not on the data path.
Events
Disposing
Declaration
internal event EventHandler? Disposing
Event Type
| Type | Description |
|---|---|
| EventHandler |