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
Assembly: MOSAIC.dll
Syntax
public class SpiderMonitor : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, IDisposable, IMonitor
Constructors
SpiderMonitor()
Declaration
Fields
_angleAxes
Declaration
[ObservableProperty]
private PolarAxis[] _angleAxes
Field Value
| Type |
Description |
| PolarAxis[] |
|
_autoScale
Declaration
Field Value
_chartReady
Declaration
private volatile bool _chartReady
Field Value
_consumerFrame
Declaration
private double[] _consumerFrame
Field Value
_disposed
Declaration
private volatile bool _disposed
Field Value
_emaAlpha
Declaration
Field Value
_emaState
Declaration
private double[]? _emaState
Field Value
_fixedMax
Declaration
Field Value
_fixedMin
Declaration
Field Value
_flushScheduled
Declaration
private int _flushScheduled
Field Value
_isActive
Declaration
private volatile bool _isActive
Field Value
_isReading
Declaration
[ObservableProperty]
private bool _isReading
Field Value
_isUpdating
Declaration
private volatile bool _isUpdating
Field Value
_lastRadiusMax
Declaration
private double _lastRadiusMax
Field Value
_normalizePerChannel
Declaration
private bool _normalizePerChannel
Field Value
_numberOfChannels
Declaration
private int _numberOfChannels
Field Value
_peakCollection
Declaration
private BatchObservableCollection<double> _peakCollection
Field Value
_peakDecay
Declaration
private double _peakDecay
Field Value
_peakValues
Declaration
private double[]? _peakValues
Field Value
_pendingChannelCount
Declaration
private int _pendingChannelCount
Field Value
_producerScratch
Declaration
private double[] _producerScratch
Field Value
_radiusAxes
Declaration
[ObservableProperty]
private PolarAxis[] _radiusAxes
Field Value
| Type |
Description |
| PolarAxis[] |
|
Declaration
private int _reconfigureScheduled
Field Value
_runningMax
Declaration
private double[]? _runningMax
Field Value
_runningMin
Declaration
private double[]? _runningMin
Field Value
_series
Declaration
[ObservableProperty]
private List<ISeries> _series
Field Value
| Type |
Description |
| List<ISeries> |
|
_showPeakEnvelope
Declaration
private bool _showPeakEnvelope
Field Value
_slot
Declaration
private LatestFrameSlot? _slot
Field Value
_tickRate
Declaration
private VisualizationTimer.TickRate _tickRate
Field Value
_timerCallback
Declaration
private readonly Action _timerCallback
Field Value
_values
Declaration
private BatchObservableCollection<double> _values
Field Value
Properties
AngleAxes
Declaration
[ExcludeFromCodeCoverage]
public PolarAxis[] AngleAxes { get; set; }
Property Value
| Type |
Description |
| PolarAxis[] |
|
ChannelCount
Declaration
public int ChannelCount { get; }
Property Value
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
IsActive
Declaration
public bool IsActive { get; }
Property Value
IsAutoScale
Declaration
public bool IsAutoScale { get; }
Property Value
IsReading
Declaration
[ExcludeFromCodeCoverage]
public bool IsReading { get; set; }
Property Value
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
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
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
Sync
Declaration
public object Sync { get; }
Property Value
TickRate
Declaration
public VisualizationTimer.TickRate TickRate { get; set; }
Property Value
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
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()
Declaration
private static string FormatAxisLabel(double value)
Parameters
| Type |
Name |
Description |
| double |
value |
|
Returns
GetAngleLabelSize()
Angle axis label font size: 14 at 1 ch → 7 at 64 ch.
Declaration
private float GetAngleLabelSize()
Returns
GetAxisLabelColor()
Declaration
private SKColor GetAxisLabelColor()
Returns
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
GetGridColor()
Declaration
private SKColor GetGridColor()
Returns
GetPeakEnvelopeColor()
Declaration
private SKColor GetPeakEnvelopeColor()
Returns
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
GetRadiusLabelSize()
Radius axis label font size: 12 at 1 ch → 9 at 64 ch.
Declaration
private float GetRadiusLabelSize()
Returns
GetTraceColor()
Declaration
private SKColor GetTraceColor()
Returns
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
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
Pause()
Stops data flow and rendering updates.
Declaration
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
ResetDataCore()
Declaration
private void ResetDataCore()
Resume()
Resumes data flow and rendering updates.
Declaration
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
Returns
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
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