Class BlockVisualization

All-in-one visualization bundle for any processing block. Owns a ScopeMonitor, SpiderMonitor, and HeatMapMonitor, and provides a single Feed(Vector<double>?) call to update all of them.

Inheritance
BlockVisualization
Implements
Namespace: MOSAIC.Visualization
Assembly: MOSAIC.dll
Syntax
public sealed class BlockVisualization : IDisposable

Constructors

BlockVisualization()

Declaration
public BlockVisualization()

Fields

Enabled

Global switch for whether new BlockVisualization instances build their underlying chart monitors. Always true in the running app. Unit tests set this to false (from an [AssemblyInitialize]) so that constructing a block does not spin up LiveCharts UI controls — which are pointless without a window and whose one-time global initialization is not thread-safe under parallel test execution.

Declaration
public static bool Enabled
Field Value
Type Description
bool

_attachedCount

Declaration
private int _attachedCount
Field Value
Type Description
int

_derivedRate

Declaration
private double _derivedRate
Field Value
Type Description
double

_desiredRate

Declaration
private double _desiredRate
Field Value
Type Description
double

_disposed

Declaration
private bool _disposed
Field Value
Type Description
bool

_enabled

Declaration
private readonly bool _enabled
Field Value
Type Description
bool

_heatmap

Declaration
private volatile HeatMapMonitor? _heatmap
Field Value
Type Description
HeatMapMonitor

_monitorLock

Declaration
private readonly object _monitorLock
Field Value
Type Description
object

_publishRate

Declaration
private double _publishRate
Field Value
Type Description
double

_rowsPerFeed

Declaration
private int _rowsPerFeed
Field Value
Type Description
int

_scope

Declaration
private volatile ScopeMonitor? _scope
Field Value
Type Description
ScopeMonitor

_signalRate

Declaration
private double _signalRate
Field Value
Type Description
double

_spider

Declaration
private volatile SpiderMonitor? _spider
Field Value
Type Description
SpiderMonitor

Properties

DerivedSignalRate

The rate worked out from the publish rate and the feed size, or 0 before both are known.

Declaration
public double DerivedSignalRate { get; }
Property Value
Type Description
double

DesiredRate

The publish rate last declared through UpdateDesiredRate(double), or 0 if none was.

Declaration
public double DesiredRate { get; }
Property Value
Type Description
double

EffectiveSignalRate

The rate the scope is actually running on — the explicit declaration when a block made one, otherwise the derived rate.

Declaration
public double EffectiveSignalRate { get; }
Property Value
Type Description
double
Remarks

Kept separate from SignalRate so "a block declared this" and "we worked it out" stay distinguishable: only the former suppresses the derivation.

Heatmap

Declaration
public HeatMapMonitor? Heatmap { get; }
Property Value
Type Description
HeatMapMonitor

IsVisible

Declaration
public bool IsVisible { get; }
Property Value
Type Description
bool

PublishRate

The rate the owning block publishes at, pushed automatically by BaseBlock.

Declaration
public double PublishRate { get; }
Property Value
Type Description
double
Remarks

Not the same thing as the rate the scope needs: the scope advances its x-axis once per row written, and one publish may carry many rows. See RefreshDerivedRate(int).

Scope

Created on first UI request, never as a side effect of feeding data.

Declaration
public ScopeMonitor? Scope { get; }
Property Value
Type Description
ScopeMonitor

SignalRate

The sample rate last declared through UpdateSignalRate(double), or 0 if none was.

Declaration
public double SignalRate { get; }
Property Value
Type Description
double
Remarks

This is the explicit declaration only. A value of 0 is normal when publication rate and feed shape supply the time base automatically. Read EffectiveSignalRate to check either path, including without a chart attached. If neither path supplies a positive rate, the scope falls back to its display window and buffer size.

Spider

Declaration
public SpiderMonitor? Spider { get; }
Property Value
Type Description
SpiderMonitor

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()

Feed(Matrix<double>?)

Feed an entire batch matrix [rows × channels]. When signal rate and desired rate are known, only the non-overlapping tail of the matrix is sent to the scope so that overlapping windows from a SlidingWindow don't produce jagged re-plots. Spider and Heatmap receive only the last row — they're envelope-style displays where intermediate frames within one 30 fps tick aren't meaningful.

Declaration
public void Feed(Matrix<double>? matrix)
Parameters
Type Name Description
Matrix<double> matrix

Feed(Vector<double>?)

Feed one sample (Vector) to all three monitors.

Declaration
public void Feed(Vector<double>? data)
Parameters
Type Name Description
Vector<double> data

Feed(ReadOnlySpan<double>)

Feed one sample (ReadOnlySpan) to all three monitors.

Declaration
public void Feed(ReadOnlySpan<double> data)
Parameters
Type Name Description
ReadOnlySpan<double> data

NoteFeedShape(int)

Records how many rows a feed carries, so the time base can be derived from it.

Declaration
private void NoteFeedShape(int rows)
Parameters
Type Name Description
int rows
Remarks

Called before the visibility check: a scope that is not on screen yet still needs the right period the moment it is shown, and the shape is known now. Costs a comparison per feed once the shape has settled, which it does after the first one.

NotifyAttached()

Declaration
public void NotifyAttached()

NotifyDetached()

Declaration
public void NotifyDetached()

RefreshDerivedRate(int)

Derives the scope's time base from the publish rate and the size of each feed, for blocks that never declare a sample rate of their own.

Declaration
private void RefreshDerivedRate(int rows)
Parameters
Type Name Description
int rows
Remarks

The scope advances its x-axis by one sample period per row written, so the rate it needs is rows per second: publishRate × rowsPerFeed. One row per publish makes that the publish rate; a block emitting a matrix of N rows per publish makes it N times higher.

This exists because almost nothing declared a rate. Without it the scope fell back to a period derived from its own window and buffer size — a fixed 5 ms, i.e. an assumed 200 Hz — which is unrelated to the signal and wrong in both directions: a 2 kHz source raced ten times too fast, while a SlopeSignChanges behind a stride-25 window at 8 Hz crawled, taking 25 seconds of wall clock to draw one second of trace.

An explicit UpdateSignalRate(double) always wins. Some packetized sources publish batches whose row count varies with transport coalescing, so those declare their hardware sample rate directly.

UpdateDesiredRate(double)

Sets the block's output rate (Hz). Used together with the signal rate to extract only the non-overlapping tail from windowed matrices in Feed(Matrix<double>?).

Declaration
public void UpdateDesiredRate(double desiredRate)
Parameters
Type Name Description
double desiredRate

UpdatePublishRate(double)

Tells this visualization how often its block publishes. Pushed automatically by BaseBlock whenever the block's rate changes; blocks do not call this themselves.

Declaration
public void UpdatePublishRate(double publishRate)
Parameters
Type Name Description
double publishRate
Remarks

Deliberately separate from UpdateDesiredRate(double), which means the block's output rate for the overlap trim in Feed(Matrix<double>?) and has only a handful of callers. Feeding every block's rate into that instead would arm the trim across the whole catalogue and start discarding rows that are currently plotted.

UpdateSignalRate(double)

Informs the scope monitor of the upstream signal rate so it can size its internal buffers and time-axis correctly. A non-positive value restores automatic derivation from publication rate and feed shape.

Declaration
public void UpdateSignalRate(double signalRate)
Parameters
Type Name Description
double signalRate

Implements

IDisposable

Search documentation

Start typing to search the documentation.