Run It
Every instrument is mocked, so the example runs without hardware.
bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run digital-multimeterThe procedure
procedure.yaml
name: Digital Multimeterversion: 1.0.0plugs: - key: multimeter name: Multimeter python: plugs.multimeter:Multimetermain: - key: rails name: Rails python: phases.digital_multimeter:rails measurements: - key: vbus name: VBUS unit: "V" validators: - operator: ">=" expected_value: 4.871 - operator: "<=" expected_value: 5.172 - key: v3v3 name: 3.3 V rail unit: "V" validators: - operator: ">=" expected_value: 3.2 - operator: "<=" expected_value: 3.399 - key: usb1_vbus name: USB1 VBUS unit: "V" validators: - operator: ">=" expected_value: 4.871 - operator: "<=" expected_value: 5.172 - key: vbat name: VBAT unit: "V" validators: - operator: ">=" expected_value: 3.2 - operator: "<=" expected_value: 3.399 ui: panel: panels/multimeter.htmlThe panel
panels/multimeter.html
<div class="inst"><svg viewBox="0 0 320 210" role="img"><rect x="1" y="1" width="318" height="208" rx="10" fill="#03100d" stroke="#20262c" stroke-width="1.5"/><g class="vfd"><text class="t" x="18" y="30" text-anchor="start" data-bind="ui.chn" style="font: 700 10px ui-monospace, Menlo, monospace; letter-spacing: .06em">CH 101 VBUS</text><text class="t" x="302" y="30" text-anchor="end" style="font: 700 9px ui-monospace, Menlo, monospace; letter-spacing: .06em">DCV 10 V RMT</text><text class="t" x="14" y="104" text-anchor="start" style="font: 600 30px ui-monospace, Menlo, monospace; letter-spacing: .14em">+</text><g class="d7" data-bind="ui.v0" transform="translate(40.0 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v1" transform="translate(71.2 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v2" transform="translate(102.4 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v3" transform="translate(133.6 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v4" transform="translate(164.8 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v5" transform="translate(196.0 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="d7" data-bind="ui.v6" transform="translate(227.2 70.0) skewX(-7)"><rect class="sa" x="3.4" y="0.0" width="14.8" height="4.8" rx="2.4"/><rect class="sd" x="3.4" y="35.2" width="14.8" height="4.8" rx="2.4"/><rect class="sg" x="3.4" y="17.6" width="14.8" height="4.8" rx="2.4"/><rect class="sf" x="0.0" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="se" x="0.0" y="21.0" width="4.8" height="15.6" rx="2.4"/><rect class="sb" x="16.8" y="3.4" width="4.8" height="15.6" rx="2.4"/><rect class="sc" x="16.8" y="21.0" width="4.8" height="15.6" rx="2.4"/></g><g class="dp on" transform="translate(94.4 70.0) skewX(-7)"><rect x="0" y="35.2" width="4.8" height="4.8" rx="1.6"/></g><text class="t" x="302" y="152" text-anchor="end" style="font: 700 18px system-ui, sans-serif; letter-spacing: 0">VDC</text><path d="M18 168H302" stroke="#12342c"/><text class="t" x="18" y="190" text-anchor="start" data-bind="ui.lim" style="font: 600 10px ui-monospace, Menlo, monospace; letter-spacing: 0"></text></g><text class="res" x="302" y="190" text-anchor="end" data-bind="ui.res" style="font: 700 10px ui-monospace, Menlo, monospace; letter-spacing: 0"></text></svg></div><style> .inst { width: min(560px, 100%); margin: 0 auto; } .inst svg { display: block; width: 100%; height: auto; } .inst text { font-family: system-ui, sans-serif; } .dp rect { fill: var(--off); } .dp.on rect, .dp[data-value=true] rect { fill: var(--on); } .led circle { fill: #2a2f35; transition: fill .15s; } .led[data-value=true] circle { fill: var(--led, #38e07a); } .ann text { fill: var(--off); transition: fill .15s; } .ann[data-value=true] text { fill: var(--on); } .d7 rect { fill: var(--off); transition: fill .08s; } .d7[data-value="0"] :is(.sa, .sb, .sc, .sd, .se, .sf) { fill: var(--on); } .d7[data-value="1"] :is(.sb, .sc) { fill: var(--on); } .d7[data-value="2"] :is(.sa, .sb, .sd, .se, .sg) { fill: var(--on); } .d7[data-value="3"] :is(.sa, .sb, .sc, .sd, .sg) { fill: var(--on); } .d7[data-value="4"] :is(.sb, .sc, .sf, .sg) { fill: var(--on); } .d7[data-value="5"] :is(.sa, .sc, .sd, .sf, .sg) { fill: var(--on); } .d7[data-value="6"] :is(.sa, .sc, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="7"] :is(.sa, .sb, .sc) { fill: var(--on); } .d7[data-value="8"] :is(.sa, .sb, .sc, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="9"] :is(.sa, .sb, .sc, .sd, .sf, .sg) { fill: var(--on); } .d7[data-value="-"] :is(.sg) { fill: var(--on); } .d7[data-value="E"] :is(.sa, .sd, .se, .sf, .sg) { fill: var(--on); } .d7[data-value="U"] :is(.sb, .sc, .sd, .se, .sf) { fill: var(--on); } .d7[data-value="r"] :is(.se, .sg) { fill: var(--on); } .vfd { --on: #6ff7d6; --off: #0b221d; } .t { fill: #6ff7d6; } .res { fill: #7cf0aa; } .res[data-value=FAIL] { fill: #ff8a8c; }</style>The phase
phases/digital_multimeter.py
"""Steps the multimeter's scanner through the board's four rails. `ui.v*`drive the seven glyphs of the 6 1/2-digit reading, `ui.chn`, `ui.lim` and`ui.res` the channel, the limit and the verdict. The run records each rail."""import timedef show(ui, prefix, text): """One 7-segment glyph per character, decimal points left to the panel.""" for k, ch in enumerate(c for c in text if c != "."): setattr(ui, f"{prefix}{k}", "_" if ch == " " else ch)RAILS = [(101, "VBUS", "vbus", 5.0), (102, "3V3", "v3v3", 3.3), (103, "USB1_VBUS", "usb1_vbus", 5.0), (104, "VBAT", "vbat", 3.3)]def rails(ui, measurements, multimeter): for channel, name, key, nominal in RAILS: low, high = nominal * 0.97, nominal * 1.03 ui.chn = f"CH {channel} {name}" ui.lim = f"LIMIT {low:.3f} … {high:.3f} V" for _ in range(40): volts = multimeter.read_dc(channel) show(ui, "v", f"{volts:08.5f}") ui.res = "PASS" if low <= volts <= high else "FAIL" time.sleep(0.1) setattr(measurements, key, round(volts, 5)) time.sleep(1.5)The mocked instrument
plugs/multimeter.py
"""Mock 6 1/2-digit multimeter behind a scanner card, reading the GreatFETOne's rails on channels 101 to 104. Replace it with your multimeter's driver(SCPI: ROUT:CLOS (@101), then MEAS:VOLT:DC? 10)."""import mathRAILS = {101: 5.0213, 102: 3.2987, 103: 5.0105, 104: 3.2961}class Multimeter: def __init__(self): self.k = 0 def read_dc(self, channel): """Volts on a scanner channel, 10 V range.""" self.k += 1 return RAILS[channel] * (1 + 0.00004 * math.sin(self.k * 0.7) + 0.00002 * math.sin(self.k * 2.3))