Class ScopeMonitor
Real-time multi-channel scope backed by ScottPlot. Ingest, flush coalescing, channel
reconfigure, pause/resume and the monotonic clock live in ChannelRingMonitorBase;
this class supplies only the ScottPlot rendering, axis management and stacked/overlapped logic.
Assembly: MOSAIC.dll
Syntax
public class ScopeMonitor : ChannelRingMonitorBase, INotifyPropertyChanged, INotifyPropertyChanging, IMonitor, IDisposable
Fields
AutoOffsetSettleFlushes
Declaration
private const int AutoOffsetSettleFlushes = 5
Field Value
AutoOffsetSpacing
Declaration
private const double AutoOffsetSpacing = 1.3
Field Value
ChannelColors
Declaration
public static readonly SKColor[] ChannelColors
Field Value
DefaultDataPoints
Declaration
private const int DefaultDataPoints = 2000
Field Value
MaxDataPointsCap
Declaration
private const int MaxDataPointsCap = 10000
Field Value
MaxPaletteChannels
Palette size (also the effective max channel count).
Declaration
private const int MaxPaletteChannels = 128
Field Value
MinDataPoints
Declaration
private const int MinDataPoints = 200
Field Value
YEaseFactor
Fraction of the remaining gap the Y axis closes per flush when tightening.
Declaration
private const double YEaseFactor = 0.15
Field Value
YEaseSettled
Per-frame movement, as a fraction of span, below which a tighten counts as arrived.
Declaration
private const double YEaseSettled = 0.002
Field Value
YRescaleDeadband
Fractional Y-range change below which the axis is held steady (anti-jitter deadband).
Declaration
private const double YRescaleDeadband = 0.12
Field Value
YShrinkEveryNFlushes
Declaration
private const int YShrinkEveryNFlushes = 60
Field Value
YShrinkFactor
Declaration
private const double YShrinkFactor = 0.92
Field Value
_autoOffsetLocked
Declaration
private bool _autoOffsetLocked
Field Value
_batchYMax
Declaration
private double _batchYMax
Field Value
_batchYMin
Declaration
private double _batchYMin
Field Value
_channelOffset
Declaration
[ObservableProperty]
private double _channelOffset
Field Value
_currentXMax
Declaration
private double _currentXMax
Field Value
_flushCount
Declaration
Field Value
_growYMax
Declaration
Field Value
_growYMin
Declaration
Field Value
_isReading
Declaration
[ObservableProperty]
private bool _isReading
Field Value
_lastTickInterval
Declaration
private double _lastTickInterval
Field Value
_lastTickXMax
Declaration
private double _lastTickXMax
Field Value
_lastXMax
Declaration
Field Value
_lastXMin
Declaration
Field Value
_lastYMax
Declaration
Field Value
_lastYMin
Declaration
Field Value
_manualDataPoints
Declaration
private bool _manualDataPoints
Field Value
_numberOfDataPoints
Declaration
private int _numberOfDataPoints
Field Value
_plot
Declaration
Field Value
_refreshCallback
Declaration
private Action? _refreshCallback
Field Value
_settleFlushCount
Declaration
private int _settleFlushCount
Field Value
_settleMax
Declaration
private double[]? _settleMax
Field Value
_settleMin
Declaration
private double[]? _settleMin
Field Value
_signalRate
Declaration
private double _signalRate
Field Value
_streamers
Declaration
private readonly List<DataStreamer> _streamers
Field Value
| Type |
Description |
| List<DataStreamer> |
|
_suppressViewModeHandler
Declaration
private volatile bool _suppressViewModeHandler
Field Value
_viewMode
Declaration
[ObservableProperty]
private ScopeViewMode _viewMode
Field Value
_window
Declaration
Field Value
_yAutoScale
Declaration
Field Value
_yFixedMax
Declaration
private double _yFixedMax
Field Value
_yFixedMin
Declaration
private double _yFixedMin
Field Value
_yTightening
True while a tighten is in progress, so it is allowed to finish. See the gate below.
Declaration
private bool _yTightening
Field Value
Properties
AcceptInterval
Declaration
protected override TimeSpan? AcceptInterval { get; }
Property Value
Overrides
AutoOffset
Declaration
public bool AutoOffset { get; set; }
Property Value
ChannelOffset
Declaration
[ExcludeFromCodeCoverage]
public double ChannelOffset { get; set; }
Property Value
IsAutoScale
Declaration
public bool IsAutoScale { get; }
Property Value
IsReading
Declaration
[ExcludeFromCodeCoverage]
public bool IsReading { get; set; }
Property Value
IsRenderReady
Whether the render surface is ready to draw. The base skips flushing while false.
Declaration
protected override bool IsRenderReady { get; }
Property Value
Overrides
MaxChannels
Upper bound on channel count. Defaults to 128.
Declaration
protected override int MaxChannels { get; }
Property Value
Overrides
MaxDataPoints
Buffer size per channel. Setting this disables rate-based auto-scaling.
Declaration
public int MaxDataPoints { get; set; }
Property Value
SampleAcceptInterval
Decimation gate for per-sample ingest (window / dataPoints, floored at 1 ms).
Declaration
private TimeSpan SampleAcceptInterval { get; }
Property Value
SamplePeriodSec
True sample period for the time axis; sub-millisecond at high signal rates.
Declaration
private double SamplePeriodSec { get; }
Property Value
SamplePeriodSeconds
Seconds the x-axis advances per plotted row — the value handed to every streamer's
ScottPlot.Plottables.DataStreamer.Period.
Declaration
public double SamplePeriodSeconds { get; }
Property Value
SignalRate
The upstream signal rate (Hz) this scope is currently sized for, or 0 if unknown.
Declaration
public double SignalRate { get; }
Property Value
ViewMode
Declaration
[ExcludeFromCodeCoverage]
public ScopeViewMode ViewMode { get; set; }
Property Value
Window
Declaration
public TimeSpan Window { get; set; }
Property Value
Methods
ApplyPeriodToStreamers()
Retargets the live streamers' time base, keeping the samples already buffered.
Declaration
private void ApplyPeriodToStreamers()
AttachPlot(Plot, Action)
Declaration
public void AttachPlot(Plot plot, Action refreshCallback)
Parameters
| Type |
Name |
Description |
| Plot |
plot |
|
| Action |
refreshCallback |
|
Declaration
private void ConfigurePlotAppearance()
DetachPlot()
Declaration
GenerateColorPalette(int)
Declaration
private static SKColor[] GenerateColorPalette(int count)
Parameters
| Type |
Name |
Description |
| int |
count |
|
Returns
GetChannelColor(int)
Declaration
public static SKColor GetChannelColor(int index)
Parameters
| Type |
Name |
Description |
| int |
index |
|
Returns
GetChannelColorHex(int)
Declaration
public static string GetChannelColorHex(int index)
Parameters
| Type |
Name |
Description |
| int |
index |
|
Returns
HslToSkColor(float, float, float)
Declaration
private static SKColor HslToSkColor(float h, float s, float l)
Parameters
Returns
NotifyChartReady()
No-op — kept for API compatibility; still invoked by VisualizationPanel.
Declaration
public void NotifyChartReady()
OnChannelOffsetChanged(double)
Declaration
private void OnChannelOffsetChanged(double value)
Parameters
| Type |
Name |
Description |
| double |
value |
The new property value that was set.
|
OnChannelOffsetChanged(double, double)
Declaration
private void OnChannelOffsetChanged(double oldValue, double newValue)
Parameters
| Type |
Name |
Description |
| double |
oldValue |
The previous property value that was replaced.
|
| double |
newValue |
The new property value that was set.
|
OnChannelOffsetChanging(double)
Declaration
private void OnChannelOffsetChanging(double value)
Parameters
| Type |
Name |
Description |
| double |
value |
The new property value being set.
|
OnChannelOffsetChanging(double, double)
Declaration
private void OnChannelOffsetChanging(double oldValue, double newValue)
Parameters
| Type |
Name |
Description |
| double |
oldValue |
The previous property value that is being replaced.
|
| double |
newValue |
The new property value being set.
|
OnDispose()
Release surface references on dispose. Optional.
Declaration
protected override void OnDispose()
Overrides
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 override void OnFlush(SampleRingBuffer ring, int n)
Parameters
Overrides
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.
|
OnRebuild()
(Re)build the render surface for the current ChannelCount. Runs on the UI
thread after the ring is (re)allocated.
Declaration
protected override void OnRebuild()
Overrides
OnResetData()
Reset display state and rebuild after a data reset. Runs on the UI thread; the ring is
already cleared.
Declaration
protected override void OnResetData()
Overrides
OnResumed()
Reset transient display state on resume (e.g. auto-scale extremes). Optional.
Declaration
protected override void OnResumed()
Overrides
OnViewModeChanged(ScopeViewMode)
Executes the logic for when ViewMode just changed.
Declaration
private void OnViewModeChanged(ScopeViewMode value)
Parameters
| Type |
Name |
Description |
| ScopeViewMode |
value |
The new property value that was set.
|
OnViewModeChanged(ScopeViewMode, ScopeViewMode)
Executes the logic for when ViewMode just changed.
Declaration
private void OnViewModeChanged(ScopeViewMode oldValue, ScopeViewMode newValue)
Parameters
| Type |
Name |
Description |
| ScopeViewMode |
oldValue |
The previous property value that was replaced.
|
| ScopeViewMode |
newValue |
The new property value that was set.
|
OnViewModeChanging(ScopeViewMode)
Executes the logic for when ViewMode is changing.
Declaration
private void OnViewModeChanging(ScopeViewMode value)
Parameters
| Type |
Name |
Description |
| ScopeViewMode |
value |
The new property value being set.
|
OnViewModeChanging(ScopeViewMode, ScopeViewMode)
Executes the logic for when ViewMode is changing.
Declaration
private void OnViewModeChanging(ScopeViewMode oldValue, ScopeViewMode newValue)
Parameters
| Type |
Name |
Description |
| ScopeViewMode |
oldValue |
The previous property value that is being replaced.
|
| ScopeViewMode |
newValue |
The new property value being set.
|
RebuildStreamers()
Declaration
private void RebuildStreamers()
ResetAutoOffset()
Declaration
private void ResetAutoOffset()
ResetAutoOffsetPublic()
Declaration
public void ResetAutoOffsetPublic()
ScopeInit(int)
Declaration
public void ScopeInit(int count = 0)
Parameters
| Type |
Name |
Description |
| int |
count |
|
SetAutoScale()
Declaration
public void SetAutoScale()
SetFixedRange(double, double)
Declaration
public void SetFixedRange(double min, double max)
Parameters
SetViewModeSilent(ScopeViewMode)
Declaration
public void SetViewModeSilent(ScopeViewMode mode)
Parameters
SetWindow(TimeSpan)
Sets the visible time span. Recomputes the buffer size from the current signal rate (unless
MaxDataPoints was set manually) and rebuilds the streamers so the change is
visible immediately. Used by the aggregate Scope Monitor window to show more history.
Declaration
public void SetWindow(TimeSpan window)
Parameters
ToggleViewMode()
Declaration
public void ToggleViewMode()
UpdateAutoOffset(SampleRingBuffer, int)
Declaration
private void UpdateAutoOffset(SampleRingBuffer ring, int n)
Parameters
UpdateSignalRate(double)
Informs the scope of the upstream signal rate so it can auto-scale the buffer size for
smooth rendering. No-op if MaxDataPoints was set manually.
Declaration
public void UpdateSignalRate(double signalRate)
Parameters
| Type |
Name |
Description |
| double |
signalRate |
|
UpdateThemeColors()
Re-applies theme-dependent colours to the monitor's paints.
Declaration
public override void UpdateThemeColors()
Overrides
UpdateTimeAxisTicksStable()
Declaration
private void UpdateTimeAxisTicksStable()
UpdateYAxisFromData()
Declaration
private void UpdateYAxisFromData()
Implements