Class SpiderMonitor

Real-time polar (spider/radar) monitor: renders the latest multichannel sample as a closed polar trace, with optional EMA smoothing, per-channel normalization, and a decaying peak envelope. The newest sample is handed off via a lock-free LatestFrameSlot and one snapshot is flushed per timer tick. Lifecycle is Pause() / Resume() / ResetData() / Dispose().

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

Constructors

SpiderMonitor()

Declaration
public SpiderMonitor()

Fields

_angleAxes

Declaration
[ObservableProperty]
private PolarAxis[] _angleAxes
Field Value
Type Description
PolarAxis[]

_autoScale

Declaration
private bool _autoScale
Field Value
Type Description
bool

_chartReady

Declaration
private volatile bool _chartReady
Field Value
Type Description
bool

_consumerFrame

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

_disposed

Declaration
private volatile bool _disposed
Field Value
Type Description
bool

_emaAlpha

Declaration
private double _emaAlpha
Field Value
Type Description
double

_emaState

Declaration
private double[]? _emaState
Field Value
Type Description
double[]

_fixedMax

Declaration
private double _fixedMax
Field Value
Type Description
double

_fixedMin

Declaration
private double _fixedMin
Field Value
Type Description
double

_flushScheduled

Declaration
private int _flushScheduled
Field Value
Type Description
int

_isActive

Declaration
private volatile bool _isActive
Field Value
Type Description
bool

_isReading

Declaration
[ObservableProperty]
private bool _isReading
Field Value
Type Description
bool

_isUpdating

Declaration
private volatile bool _isUpdating
Field Value
Type Description
bool

_lastRadiusMax

Declaration
private double _lastRadiusMax
Field Value
Type Description
double

_normalizePerChannel

Declaration
private bool _normalizePerChannel
Field Value
Type Description
bool

_numberOfChannels

Declaration
private int _numberOfChannels
Field Value
Type Description
int

_peakCollection

Declaration
private BatchObservableCollection<double> _peakCollection
Field Value
Type Description
BatchObservableCollection<double>

_peakDecay

Declaration
private double _peakDecay
Field Value
Type Description
double

_peakValues

Declaration
private double[]? _peakValues
Field Value
Type Description
double[]

_pendingChannelCount

Declaration
private int _pendingChannelCount
Field Value
Type Description
int

_producerScratch

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

_radiusAxes

Declaration
[ObservableProperty]
private PolarAxis[] _radiusAxes
Field Value
Type Description
PolarAxis[]

_reconfigureScheduled

Declaration
private int _reconfigureScheduled
Field Value
Type Description
int

_runningMax

Declaration
private double[]? _runningMax
Field Value
Type Description
double[]

_runningMin

Declaration
private double[]? _runningMin
Field Value
Type Description
double[]

_series

Declaration
[ObservableProperty]
private List<ISeries> _series
Field Value
Type Description
List<ISeries>

_showPeakEnvelope

Declaration
private bool _showPeakEnvelope
Field Value
Type Description
bool

_slot

Declaration
private LatestFrameSlot? _slot
Field Value
Type Description
LatestFrameSlot

_tickRate

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

_timerCallback

Declaration
private readonly Action _timerCallback
Field Value
Type Description
Action

_values

Declaration
private BatchObservableCollection<double> _values
Field Value
Type Description
BatchObservableCollection<double>

Properties

AngleAxes

Declaration
[ExcludeFromCodeCoverage]
public PolarAxis[] AngleAxes { get; set; }
Property Value
Type Description
PolarAxis[]

ChannelCount

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

EmaAlpha

EMA smoothing factor. 0 = no smoothing (raw samples), higher = smoother. Good range is 0.1–0.5 for 30fps display. Default 0.3.

Declaration
public double EmaAlpha { get; set; }
Property Value
Type Description
double

IsActive

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

IsAutoScale

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

IsReading

Declaration
[ExcludeFromCodeCoverage]
public bool IsReading { get; set; }
Property Value
Type Description
bool

NormalizePerChannel

Enable per-channel normalization. Each channel is independently scaled to [0, 1] based on its observed running min/max. Useful when channels have vastly different amplitudes (e.g., filtered vs unfiltered EMG).

Declaration
public bool NormalizePerChannel { get; set; }
Property Value
Type Description
bool

PeakDecay

Peak decay factor per flush. 0.97 ≈ 1 second hold at 30fps, 0.90 ≈ fast decay.

Declaration
public double PeakDecay { get; set; }
Property Value
Type Description
double

RadiusAxes

Declaration
[ExcludeFromCodeCoverage]
public PolarAxis[] RadiusAxes { get; set; }
Property Value
Type Description
PolarAxis[]

Series

Declaration
[ExcludeFromCodeCoverage]
public List<ISeries> Series { get; set; }
Property Value
Type Description
List<ISeries>

ShowPeakEnvelope

Show/hide the decaying peak envelope behind the main trace.

Declaration
public bool ShowPeakEnvelope { get; set; }
Property Value
Type Description
bool

Sync

Declaration
public object Sync { get; }
Property Value
Type Description
object

TickRate

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

Methods

ApplyChannelCountInternal(int)

Declaration
private void ApplyChannelCountInternal(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()

EnqueueData(Vector<double>)

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

FlushToChart()

Reads the latest sample from the slot into the display collection. Uses lock(Sync) + BeginBatch/EndBatch to prevent LiveCharts from measuring mid-mutation. Only the latest sample matters for a spider chart (snapshot display).

Declaration
private void FlushToChart()

FormatAxisLabel(double)

Declaration
private static string FormatAxisLabel(double value)
Parameters
Type Name Description
double value
Returns
Type Description
string

GetAngleLabelSize()

Angle axis label font size: 14 at 1 ch → 7 at 64 ch.

Declaration
private float GetAngleLabelSize()
Returns
Type Description
float

GetAxisLabelColor()

Declaration
private SKColor GetAxisLabelColor()
Returns
Type Description
SKColor

GetGeometryFill(SKColor)

Declaration
private SolidColorPaint? GetGeometryFill(SKColor traceColor)
Parameters
Type Name Description
SKColor traceColor
Returns
Type Description
SolidColorPaint

GetGeometrySize()

Geometry dot size: 6.0 at 1 ch → 0 at 28 ch.

Declaration
private float GetGeometrySize()
Returns
Type Description
float

GetGridColor()

Declaration
private SKColor GetGridColor()
Returns
Type Description
SKColor

GetPeakEnvelopeColor()

Declaration
private SKColor GetPeakEnvelopeColor()
Returns
Type Description
SKColor

GetPeakFill(SKColor)

Declaration
private SolidColorPaint? GetPeakFill(SKColor peakColor)
Parameters
Type Name Description
SKColor peakColor
Returns
Type Description
SolidColorPaint

GetPeakStrokeThickness()

Peak envelope stroke: 1.5 at 1 ch → 0.5 at 64 ch.

Declaration
private float GetPeakStrokeThickness()
Returns
Type Description
float

GetRadiusLabelSize()

Radius axis label font size: 12 at 1 ch → 9 at 64 ch.

Declaration
private float GetRadiusLabelSize()
Returns
Type Description
float

GetTraceColor()

Declaration
private SKColor GetTraceColor()
Returns
Type Description
SKColor

GetTraceFill(SKColor)

Declaration
private SolidColorPaint? GetTraceFill(SKColor traceColor)
Parameters
Type Name Description
SKColor traceColor
Returns
Type Description
SolidColorPaint

GetTraceThickness()

Main trace line thickness: 3.0 at 1 ch → 1.0 at 64 ch.

Declaration
private float GetTraceThickness()
Returns
Type Description
float

InitializeAxes()

Declaration
private void InitializeAxes()

NotifyChartReady()

Called by SpiderMonitorView from the LiveChartsCore.SkiaSharpView.Avalonia.PolarChart AttachedToVisualTree event (at Loaded priority), confirming LiveCharts has completed at least one Measure() pass and its internal state is safe. This is the single global gate against premature flush crashes.

Declaration
public void NotifyChartReady()

OnAngleAxesChanged(PolarAxis[])

Executes the logic for when AngleAxes just changed.

Declaration
private void OnAngleAxesChanged(PolarAxis[] value)
Parameters
Type Name Description
PolarAxis[] value

The new property value that was set.

Remarks

This method is invoked right after the value of AngleAxes is changed.

OnAngleAxesChanged(PolarAxis[]?, PolarAxis[])

Executes the logic for when AngleAxes just changed.

Declaration
private void OnAngleAxesChanged(PolarAxis[]? oldValue, PolarAxis[] newValue)
Parameters
Type Name Description
PolarAxis[] oldValue

The previous property value that was replaced.

PolarAxis[] newValue

The new property value that was set.

Remarks

This method is invoked right after the value of AngleAxes is changed.

OnAngleAxesChanging(PolarAxis[])

Executes the logic for when AngleAxes is changing.

Declaration
private void OnAngleAxesChanging(PolarAxis[] value)
Parameters
Type Name Description
PolarAxis[] value

The new property value being set.

Remarks

This method is invoked right before the value of AngleAxes is changed.

OnAngleAxesChanging(PolarAxis[]?, PolarAxis[])

Executes the logic for when AngleAxes is changing.

Declaration
private void OnAngleAxesChanging(PolarAxis[]? oldValue, PolarAxis[] newValue)
Parameters
Type Name Description
PolarAxis[] oldValue

The previous property value that is being replaced.

PolarAxis[] newValue

The new property value being set.

Remarks

This method is invoked right before the value of AngleAxes is changed.

OnIsReadingChanged(bool)

Executes the logic for when IsReading just changed.

Declaration
private void OnIsReadingChanged(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 IsReading is changed.

OnIsReadingChanged(bool, bool)

Executes the logic for when IsReading just changed.

Declaration
private void OnIsReadingChanged(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 IsReading is changed.

OnIsReadingChanging(bool)

Executes the logic for when IsReading is changing.

Declaration
private void OnIsReadingChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of IsReading is changed.

OnIsReadingChanging(bool, bool)

Executes the logic for when IsReading is changing.

Declaration
private void OnIsReadingChanging(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 IsReading is changed.

OnRadiusAxesChanged(PolarAxis[])

Executes the logic for when RadiusAxes just changed.

Declaration
private void OnRadiusAxesChanged(PolarAxis[] value)
Parameters
Type Name Description
PolarAxis[] value

The new property value that was set.

Remarks

This method is invoked right after the value of RadiusAxes is changed.

OnRadiusAxesChanged(PolarAxis[]?, PolarAxis[])

Executes the logic for when RadiusAxes just changed.

Declaration
private void OnRadiusAxesChanged(PolarAxis[]? oldValue, PolarAxis[] newValue)
Parameters
Type Name Description
PolarAxis[] oldValue

The previous property value that was replaced.

PolarAxis[] newValue

The new property value that was set.

Remarks

This method is invoked right after the value of RadiusAxes is changed.

OnRadiusAxesChanging(PolarAxis[])

Executes the logic for when RadiusAxes is changing.

Declaration
private void OnRadiusAxesChanging(PolarAxis[] value)
Parameters
Type Name Description
PolarAxis[] value

The new property value being set.

Remarks

This method is invoked right before the value of RadiusAxes is changed.

OnRadiusAxesChanging(PolarAxis[]?, PolarAxis[])

Executes the logic for when RadiusAxes is changing.

Declaration
private void OnRadiusAxesChanging(PolarAxis[]? oldValue, PolarAxis[] newValue)
Parameters
Type Name Description
PolarAxis[] oldValue

The previous property value that is being replaced.

PolarAxis[] newValue

The new property value being set.

Remarks

This method is invoked right before the value of RadiusAxes is changed.

OnSeriesChanged(List<ISeries>)

Executes the logic for when Series just changed.

Declaration
private void OnSeriesChanged(List<ISeries> value)
Parameters
Type Name Description
List<ISeries> value

The new property value that was set.

Remarks

This method is invoked right after the value of Series is changed.

OnSeriesChanged(List<ISeries>?, List<ISeries>)

Executes the logic for when Series just changed.

Declaration
private void OnSeriesChanged(List<ISeries>? oldValue, List<ISeries> newValue)
Parameters
Type Name Description
List<ISeries> oldValue

The previous property value that was replaced.

List<ISeries> newValue

The new property value that was set.

Remarks

This method is invoked right after the value of Series is changed.

OnSeriesChanging(List<ISeries>)

Executes the logic for when Series is changing.

Declaration
private void OnSeriesChanging(List<ISeries> value)
Parameters
Type Name Description
List<ISeries> value

The new property value being set.

Remarks

This method is invoked right before the value of Series is changed.

OnSeriesChanging(List<ISeries>?, List<ISeries>)

Executes the logic for when Series is changing.

Declaration
private void OnSeriesChanging(List<ISeries>? oldValue, List<ISeries> newValue)
Parameters
Type Name Description
List<ISeries> oldValue

The previous property value that is being replaced.

List<ISeries> newValue

The new property value being set.

Remarks

This method is invoked right before the value of Series is changed.

Pause()

Stops data flow and rendering updates.

Declaration
public void Pause()

RequestChannelReconfigure(int)

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

RequestFlush()

Declaration
private void RequestFlush()

ResetData()

Clears buffered data and any accumulated display state.

Declaration
public void ResetData()

ResetDataCore()

Declaration
private void ResetDataCore()

Resume()

Resumes data flow and rendering updates.

Declaration
public void Resume()

ScaleByChannels(float, float, int, int)

Clamped lerp: returns from at nLow channels, to at nHigh channels, linearly interpolated between.

Declaration
private float ScaleByChannels(float from, float to, int nLow, int nHigh)
Parameters
Type Name Description
float from
float to
int nLow
int nHigh
Returns
Type Description
float

SetAutoScale()

Enable autoscaling radius axis from data (default).

Declaration
public void SetAutoScale()

SetFixedRange(double, double)

Fix radius axis to a specific range. Data outside is clipped visually.

Declaration
public void SetFixedRange(double min, double max)
Parameters
Type Name Description
double min
double max

SpiderInit(int)

Declaration
public void SpiderInit(int count = 0)
Parameters
Type Name Description
int count

UpdateRadiusAxisFromData(double[])

Declaration
private void UpdateRadiusAxisFromData(double[] values)
Parameters
Type Name Description
double[] values

UpdateThemeColors()

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

Declaration
public void UpdateThemeColors()

Implements

INotifyPropertyChanged
INotifyPropertyChanging
IDisposable
IMonitor

Search documentation

Start typing to search the documentation.