Class ChannelRingMonitorBase

Shared data engine for the time-series (ring-backed) monitors. It centralizes:

A subclass supplies only its rendering: OnFlush(SampleRingBuffer, int), OnRebuild(), OnResetData(), UpdateThemeColors(), and (optionally) state-reset and readiness hooks.

Inheritance
ChannelRingMonitorBase
Namespace: MOSAIC.Visualization
Assembly: MOSAIC.dll
Syntax
public abstract class ChannelRingMonitorBase : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, IMonitor, IDisposable

Constructors

ChannelRingMonitorBase()

Declaration
protected ChannelRingMonitorBase()

Fields

IsActive

Declaration
protected volatile bool IsActive
Field Value
Type Description
bool

IsDisposed

Declaration
protected volatile bool IsDisposed
Field Value
Type Description
bool

IsUpdating

Declaration
protected volatile bool IsUpdating
Field Value
Type Description
bool

_flushScheduled

Declaration
private int _flushScheduled
Field Value
Type Description
int

_lastAcceptedUtc

Declaration
private DateTime _lastAcceptedUtc
Field Value
Type Description
DateTime

_lastMonotonicTicks

Declaration
private long _lastMonotonicTicks
Field Value
Type Description
long

_mirrorLock

Declaration
private readonly object _mirrorLock
Field Value
Type Description
object

_mirrors

Declaration
private volatile ChannelRingMonitorBase[] _mirrors
Field Value
Type Description
ChannelRingMonitorBase[]

_numberOfChannels

Declaration
private int _numberOfChannels
Field Value
Type Description
int

_pendingChannelCount

Declaration
private int _pendingChannelCount
Field Value
Type Description
int

_reconfigureScheduled

Declaration
private int _reconfigureScheduled
Field Value
Type Description
int

_ring

Declaration
private SampleRingBuffer? _ring
Field Value
Type Description
SampleRingBuffer

_scratch

Declaration
private double[] _scratch
Field Value
Type Description
double[]

_t0Stamp

Declaration
private readonly long _t0Stamp
Field Value
Type Description
long

_t0UtcTicks

Declaration
private readonly long _t0UtcTicks
Field Value
Type Description
long

_tickRate

Declaration
private VisualizationTimer.TickRate _tickRate
Field Value
Type Description
VisualizationTimer.TickRate

_timerCallback

Declaration
private readonly Action _timerCallback
Field Value
Type Description
Action

Properties

AcceptInterval

When non-null, EnqueueData(Vector<double>) drops samples that arrive closer together than this interval (decimation gate). EnqueueBatch(Matrix<double>, int) is never throttled.

Declaration
protected virtual TimeSpan? AcceptInterval { get; }
Property Value
Type Description
TimeSpan?

AcceptsData

Declaration
internal bool AcceptsData { get; }
Property Value
Type Description
bool

ChannelCount

Current channel count (frame width). Set on the UI thread via reconfigure / configure.

Declaration
public int ChannelCount { get; }
Property Value
Type Description
int

IsRenderReady

Whether the render surface is ready to draw. The base skips flushing while false.

Declaration
protected virtual bool IsRenderReady { get; }
Property Value
Type Description
bool

MaxChannels

Upper bound on channel count. Defaults to 128.

Declaration
protected virtual int MaxChannels { get; }
Property Value
Type Description
int

Mirrors

The currently registered mirror sinks (snapshot; safe to read off-thread).

Declaration
protected ChannelRingMonitorBase[] Mirrors { get; }
Property Value
Type Description
ChannelRingMonitorBase[]

Ring

The ingest ring for the current channel count, or null when there are no channels.

Declaration
protected SampleRingBuffer? Ring { get; }
Property Value
Type Description
SampleRingBuffer

RingCapacityFrames

Frames of ingest headroom. Must exceed (rate / flushRate) and the largest EnqueueBatch.

Declaration
protected virtual int RingCapacityFrames { get; }
Property Value
Type Description
int

TickRate

Display refresh rate. Pauses/resumes the timer subscription around the change.

Declaration
public VisualizationTimer.TickRate TickRate { get; set; }
Property Value
Type Description
VisualizationTimer.TickRate

Methods

AddMirror(ChannelRingMonitorBase)

Registers a monitor to receive a verbatim copy of this monitor's ingest. A mirror must not itself be a source with mirrors (no re-forwarding), which is the case for the aggregate window's leaf monitors.

Declaration
public void AddMirror(ChannelRingMonitorBase mirror)
Parameters
Type Name Description
ChannelRingMonitorBase mirror

ConfigureChannels(int)

UI-thread-safe channel-count set: (re)allocates the ring and rebuilds the surface.

Declaration
protected void ConfigureChannels(int count)
Parameters
Type Name Description
int count

Dispose()

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

Declaration
public void Dispose()

EnqueueBatch(Matrix<double>, int)

Enqueues a [rows × channels] matrix. Bypasses the throttle; decimates to maxRowsToKeep.

Declaration
public void EnqueueBatch(Matrix<double> matrix, int maxRowsToKeep = 4096)
Parameters
Type Name Description
Matrix<double> matrix
int maxRowsToKeep

EnqueueData(Vector<double>)

Enqueues one multi-channel sample. Safe to call from the producer thread.

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

NowMonotonicUtc()

Strictly-increasing UTC timestamp derived from a high-resolution stopwatch.

Declaration
protected DateTime NowMonotonicUtc()
Returns
Type Description
DateTime

OnDispose()

Release surface references on dispose. Optional.

Declaration
protected virtual void OnDispose()

OnFlush(SampleRingBuffer, int)

Render the frameCount fresh frames in ring (read via Peek(int, int)). The base brackets this with BeginRead/CommitRead and the IsUpdating guard — do not call those yourself.

Declaration
protected abstract void OnFlush(SampleRingBuffer ring, int frameCount)
Parameters
Type Name Description
SampleRingBuffer ring
int frameCount

OnPaused()

Extra teardown on pause. Optional.

Declaration
protected virtual void OnPaused()

OnRebuild()

(Re)build the render surface for the current ChannelCount. Runs on the UI thread after the ring is (re)allocated.

Declaration
protected abstract void OnRebuild()

OnResetData()

Reset display state and rebuild after a data reset. Runs on the UI thread; the ring is already cleared.

Declaration
protected abstract void OnResetData()

OnResumed()

Reset transient display state on resume (e.g. auto-scale extremes). Optional.

Declaration
protected virtual void OnResumed()

Pause()

Stops data flow and rendering updates.

Declaration
public virtual void Pause()

RemoveMirror(ChannelRingMonitorBase)

Unregisters a previously added mirror sink. Safe to call on a disposed monitor.

Declaration
public void RemoveMirror(ChannelRingMonitorBase mirror)
Parameters
Type Name Description
ChannelRingMonitorBase mirror

RequestChannelReconfigure(int)

Declaration
private void RequestChannelReconfigure(int newCount)
Parameters
Type Name Description
int newCount

RequestFlush()

Declaration
private void RequestFlush()

ResetCore()

Declaration
private void ResetCore()

ResetData()

Clears buffered data and any accumulated display state.

Declaration
public void ResetData()

Resume()

Resumes data flow and rendering updates.

Declaration
public virtual void Resume()

RunFlush()

Declaration
private void RunFlush()

SetChannelCountInternal(int)

Declaration
private void SetChannelCountInternal(int count)
Parameters
Type Name Description
int count

UpdateThemeColors()

Re-applies theme-dependent colours to the monitor's paints.

Declaration
public abstract void UpdateThemeColors()

Implements

INotifyPropertyChanged
INotifyPropertyChanging
IMonitor
IDisposable

Search documentation

Start typing to search the documentation.