Test and measurement

Digital Waveform <smart-digital-waveform>

DigitalWaveform displays digital lines against time, one row per line, with lines grouped into buses whose words are written in hex, binary or decimal: the view of a logic analyser.

<smart-digital-waveform> · 15 properties, 6 methods, 3 events · source/modules/smart.digitalwaveform.js

Usage in TypeScript

The package ships its definitions: DigitalWaveform is the element type and DigitalWaveformProperties the properties, both exported from smart-industrial/source/typescript/smart.industrial. document.querySelector('smart-digital-waveform') is typed as DigitalWaveform.

import { DigitalWaveform, DigitalWaveformProperties } from 'smart-industrial/source/typescript/smart.industrial';

const digitalWaveform = document.querySelector('smart-digital-waveform') as DigitalWaveform;

digitalWaveform.xLabel = 'Time';
digitalWaveform.addEventListener('cursorChange', (event: CustomEvent) => console.log(event.detail));
digitalWaveform.valueAt('value', 42);

Properties

PropertyType, defaultDescription
signalsarraySets or retrieves the lines. Each is an object with id, label, color, visible and either samples (0/1 or booleans on a fixed interval, with t0 and dt) or edges (an array of [time, level] pairs, with end for the end of the record). A sample holds its level for dt, so a sampled record runs from t0 to t0 + samples.length × dt and the last sample is drawn and read. A level may also be 'x' (unknown, drawn as a band across both levels) or 'z' (high impedance, drawn between them).
busesarraySets or retrieves the buses. Each is an object with id, label, lines (the ids of its signals, most significant first), format (hex, bin or dec), color and visible. A bus is drawn as a row of stable words with a transition wherever the word changes. Any number of lines is exact: a bus of more than 53 lines is read as a BigInt. The word reads X while any line is unknown and Z while any line is high impedance.
xLabelstringSets or retrieves the name of the time axis.
xUnitstring
s
Sets or retrieves the unit of the time axis, written in engineering notation.
xMinnumber?Sets or retrieves the start of the time axis. With xMax, fixes the axis; null follows the data.
xMaxnumber?Sets or retrieves the end of the time axis. With xMin, fixes the axis; null follows the data.
cursorsarraySets or retrieves the cursors. Each is an object with id, label, x, color and visible. The cursor legend reads every line and bus at each cursor and the time between the first two.
rowHeightnumber
26
Sets or retrieves the height of a row in pixels. The plot is as tall as its rows.
labelWidthnumber
110
Sets or retrieves the width of the names column in pixels.
showGridboolean
true
Shows the time grid and the row separators.
showCursorLegendboolean
true
Shows the cursor legend under the plot.
showLinesboolean
true
Shows the lines of a bus under its row. When false, a bus is one row and its lines are left out.
interactiveboolean
true
Enables panning by dragging, zooming with the wheel, box zoom with Shift and drag, and placing and dragging cursors.
labelstringSets or retrieves the title shown above the plot and used in the accessible name.
precisionDigitsnumber
4
Sets or retrieves the number of significant digits in times.

Methods

MethodDescription
valueAt(id: string, time: number): anyReturns a line's level at a time: 1, 0, 'x' (unknown), 'z' (high impedance), or NaN outside the record.
id string The signal.
time number The time.
busValueAt(id: string, time: number): anyReturns a bus's word at a time, most significant line first: a number, or a BigInt for a bus of more than 53 lines, which a number cannot hold exactly; 'x' when any line is unknown, 'z' when any line is high impedance, or NaN where any line is outside its record.
id string The bus.
time number The time.
fit(): voidShows the whole record again.
zoomTo(from: number, to: number): voidShows a range of time.
from number The start.
to number The end.
zoom(factor: number): voidZooms about the centre of the view.
factor number Above 1 zooms in, below 1 zooms out.
describe(): stringReturns a sentence describing what the graph shows, as used in its accessible name.

Events

The data of an event is in event.detail. While interactive is true, the digital waveform moves a cursor in cursors and then raises cursorChange, and pans or zooms its own view and then raises zoom; fit() and zoomTo() also raise zoom. rowClick reports the row and the time under a click.

EventDescription and detail
cursorChangeThis event is triggered when a cursor is moved by the operator, with the pointer or the keyboard.
id string The cursor.
x number Its time.
zoomThis event is triggered when the view changes: a zoom, a pan, a box zoom or a fit.
xMin number The start of the view.
xMax number The end of the view.
fitted boolean True when the view shows the whole record.
rowClickThis event is triggered when a row is clicked without dragging.
time number The time under the pointer.
id string The line or bus clicked, or null below the rows.
kind string line or bus.

CSS variables

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

--smart-digital-label-background --smart-digital-plot-background --smart-digital-grid-color --smart-digital-axis-color