Trends and signals

Scope <smart-scope>

Scope is an oscilloscope display for time-domain signals.

<smart-scope> · 25 properties, 11 methods, 2 events · source/modules/smart.scope.js

Usage in Blazor

The Razor component is <Scope> in Smart.Blazor.Industrial: every property is a parameter in PascalCase, every event an EventCallback<Event> named On<Event> whose ev["Detail"] is the typed detail class, and the methods are called on the @ref. String choices are enums. In a Blazor Web App (.NET 8 and later) the page needs an interactive render mode, for example @rendermode InteractiveServer; a statically rendered component stays empty.

@using Smart.Blazor.Industrial
@* .NET 8 and later: an interactive render mode, on the page or for the whole app *@
@rendermode InteractiveServer

<Scope @ref="scope" SampleRate="42"
    OnChannelVisibilityChange="OnChannelVisibilityChange" />

@code {
    Scope scope;

    void OnChannelVisibilityChange(Event ev)
    {
        ScopeChannelVisibilityChangeEventDetail detail = ev["Detail"];
    }

    // Task<bool> Push(object block)
    void Call() => scope.Push(new { });
}

Properties

ParameterType, defaultDescription
Channels
channels
IEnumerable<object>Sets or retrieves the channels as [{ field, label, unit, color, voltsPerDivision, offset, visible }]. field is the key under which a pushed block carries the samples of the channel. A voltsPerDivision of null autoscales the channel; offset is in divisions from the centre line. Assign a new array to update the component.
SampleRate
sampleRate
double
1
Sets or retrieves the sample rate in samples per second. The timebase, the trigger's holdoff and every measurement follow from it. A value that is not a positive, finite number is taken as 1, with one console warning.
TimePerDivision
timePerDivision
double
0.001
Sets or retrieves the timebase in seconds per horizontal division. One screen is this times horizontalDivisions. A value that is not a positive, finite number is taken as 1 ms, with one console warning. A screen holds at most 2 000 000 samples; a longer timebase at the sample rate is shortened to fit, and the header shows the timebase drawn.
HorizontalDivisions
horizontalDivisions
int
10
Sets or retrieves how many divisions the graticule has across. From 1 to 100: a larger value draws 100, and NaN, Infinity or a value below 1 draws the default 10, with one console warning.
VerticalDivisions
verticalDivisions
int
8
Sets or retrieves how many divisions the graticule has down. From 1 to 100: a larger value draws 100, and NaN, Infinity or a value below 1 draws the default 8, with one console warning.
TriggerSource
triggerSource
stringSets or retrieves the field the trigger watches. Empty triggers on the first channel.
TriggerLevel
triggerLevel
double
0
Sets or retrieves the level the source has to cross, in the source's units. Drawn as an arrow at the right edge and a dotted line.
TriggerEdge
triggerEdge
ScopeTriggerEdge
rising
Sets or retrieves which way the source has to cross the level.
TriggerMode
triggerMode
ScopeTriggerMode
auto
Sets or retrieves the behaviour without a trigger. auto free-runs and captures the newest screen when nothing has triggered for about two screens; normal keeps the last capture until the next trigger; single captures once and stops until run or single arms the trigger again.
TriggerPosition
triggerPosition
double
0.1
Sets or retrieves the horizontal position of the trigger point on the screen, from 0 at the left edge to 1 at the right edge. 0.1 leaves one division of pre-trigger data, which shows what happened before the edge.
Holdoff
holdoff
double
0
Sets or retrieves how long after a trigger, in seconds, another is ignored, for a burst or a pulse train where only the first edge should trigger.
TriggerHysteresis
triggerHysteresis
double
0
Sets or retrieves how far past the level, in the source's units, the signal has to have been on the near side and has to reach on the far side for a crossing to count. A spike that pokes through the level and falls back is not an edge. The trigger point stays at the level crossing.
HistoryLength
historyLength
int
0
Sets or retrieves how many samples each channel's ring keeps. 0 keeps four screens' worth. A block larger than the ring keeps only its newest samples. At most 8 000 000 samples per channel; a larger value (Infinity included) holds 8 000 000.
Mode
mode
ScopeMode
yt
Sets or retrieves the display mode. yt draws every channel against time; xy draws the second channel against the first, for Lissajous figures and I-V curves.
CursorA
cursorA
doubleSets or retrieves the first time cursor, in seconds from the trigger. null hides it. With both cursors set the readout shows their interval, its reciprocal, and each channel's value at each cursor.
CursorB
cursorB
doubleSets or retrieves the second time cursor, in seconds from the trigger. null hides it.
Measurements
measurements
IEnumerable<object>
["vpp","vrms","frequency"]
Sets or retrieves the automatic measurements shown in the readout for each visible channel: vpp, vrms, vmean, vmax, vmin, frequency, period, riseTime, fallTime and dutyCycle. The frequency is measured from mid-level crossings with hysteresis, averaged over every full period in the record; rise and fall times are measured from 10% to 90% on the first edge.
ShowGrid
showGrid
bool
true
Determines whether the graticule is drawn.
ShowLegend
showLegend
bool
true
Determines whether the channel legend is shown. The legend has one button per channel with its scale, which shows or hides the channel.
ShowMeasurements
showMeasurements
bool
true
Determines whether the measurement readout is shown.
ShowTriggerMarkers
showTriggerMarkers
bool
true
Determines whether the trigger level and trigger time are marked on the graticule.
Paused
paused
bool
false
Determines whether pushed blocks are dropped. The display holds its last capture.
Label
label
stringSets or retrieves the scope's name, shown in the header and in the accessible name.
PrecisionDigits
precisionDigits
int
3
Sets or retrieves how many significant figures a value is printed with in the readouts. Clamped to 1-21 when formatting; a value that is not a number shows 3.
LineWidth
lineWidth
double
1.4
Sets or retrieves the width of a trace in pixels.

Methods

MethodDescription
Task<bool> Push(object block)Appends a block of samples per channel and runs the trigger over it. Returns false when the scope is paused, has no channels, or the block is empty. A null, empty, non-numeric or infinite sample is no reading: a gap in the trace and in every measurement, never 0.
block object { field: samples, .. } with an array or typed array per channel, or a plain array for a single-channel scope, which goes to the first channel.
void Clear()Removes every sample and the capture.
void Run()Re-arms the trigger and resumes after stop or a single capture.
void Stop()Stops capturing until run or single is called.
void Single()Arms the trigger for one capture and then stops.
Task<bool> ForceTrigger()Captures the newest screen regardless of the trigger. Returns false when there is nothing to capture.
void AutoSet()Sets the timebase to show two or three cycles of the trigger source and the scale of every channel to fill about six divisions, based on the record on screen. This is the Auto Set function of an oscilloscope. The timebase is set only from a frequency measure() accepts, on the source's new scale - from the screen, or else from the whole ring; with none (DC, noise, a single transient) the timebase is left unchanged.
Task<object> Capture()Returns the record on screen as { time, sampleRate, triggerIndex, triggered, channels }, where channels maps each field to a copy of its samples and time is the start of the record relative to the trigger, in seconds. Returns null before the first capture.
Task<object> Measure()Returns the automatic measurements of the captured record for one channel as { vmax, vmin, vpp, vmean, vrms, frequency, period, riseTime, fallTime, dutyCycle }, with NaN where a measurement is undefined. Frequency, period and duty cycle are measured from rising mid-level crossings with hysteresis and are NaN (shown as "--") unless the swing is at least a fifth of a division on the channel's scale, the record holds at least two full periods, and the periods agree within 25 % - so DC, noise and a single transient have no frequency. The duty cycle is taken over the whole periods. Rise and fall time are NaN when the swing is too small to have edges. Returns null before any capture.
field string The channel's field. Defaults to the trigger source.
void ToggleChannel(int index)Shows or hides one channel and raises the channelVisibilityChange event.
index number Which channel.
visible boolean Force a state instead of toggling.
void Invalidate()Redraws the plot on the next animation frame, so that many pushes between two frames cost one draw.

Events

Every event is an EventCallback<Event>; Event is a dictionary and ev["Detail"] converts to the detail class named under the event.

EventDescription and detail
OnTrigger
trigger
ScopeTriggerEventDetail
This event is triggered on every capture, on a trigger, or on an auto free-run.
Triggered bool True for a real trigger, false for an auto free-run capture.
Source string The field triggered on.
Level double The trigger level.
Time double The record's start relative to the trigger, in seconds.
OnChannelVisibilityChange
channelVisibilityChange
ScopeChannelVisibilityChangeEventDetail
This event is triggered when a channel is shown or hidden from the legend or through toggleChannel.
Index int Which channel.
Field string The channel's field.
Visible bool Whether it is now drawn.

Types

enum ScopeTriggerEdge

ScopeTriggerEdge.Rising "rising" ScopeTriggerEdge.Falling "falling"

enum ScopeTriggerMode

ScopeTriggerMode.Auto "auto" ScopeTriggerMode.Normal "normal" ScopeTriggerMode.Single "single"

enum ScopeMode

ScopeMode.Yt "yt" ScopeMode.Xy "xy"

CSS variables

The component declares 4 CSS variables; the CSS page shows how to set them.

--smart-scope-height --smart-scope-plot-background --smart-scope-grid-color --smart-scope-axis-color