Moving-Coil Ammeter

A moving-coil DC panel ammeter, 0 to 5 A on a 90° scale with a mirror band, reading a product's supply current as its stages switch on; the needle overshoots and settles like a damped movement.

STATIONCLI/PROCEDUREMoving-Coil Ammeter

Supply current

PASS00:17.94Supply current (1/1)Passed

Run It

Every instrument is mocked, so the example runs without hardware.

bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run panel-ammeter

The procedure

procedure.yaml
name: Moving-Coil Ammeterversion: 1.0.0plugs:  - key: load_ammeter    name: Panel ammeter    python: plugs.load_ammeter:LoadAmmetermain:  - key: current    name: Supply current    python: phases.panel_ammeter:supply_current    measurements:      - key: standby_current        name: Standby current        unit: "A"        validators:          - operator: ">="            expected_value: 0.5          - operator: "<="            expected_value: 1.0      - key: load_current        name: Full-load current        unit: "A"        validators:          - operator: ">="            expected_value: 2.5          - operator: "<="            expected_value: 3.5    ui:      panel: panels/ammeter.html

The panel

panels/ammeter.html
<div class="inst"><svg viewBox="0 0 320 210" role="img"><defs><linearGradient id="mirror" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#9aa3ab"/><stop offset=".3" stop-color="#eef2f5"/><stop offset=".55" stop-color="#a7b0b8"/><stop offset=".8" stop-color="#f2f5f7"/><stop offset="1" stop-color="#8f989f"/></linearGradient><linearGradient id="mface" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#fbfaf6"/><stop offset="1" stop-color="#ecebe5"/></linearGradient><clipPath id="mwin"><rect x="22" y="14" width="276" height="182" rx="6"/></clipPath></defs><rect x="2" y="2" width="316" height="206" rx="8" fill="#16191d" stroke="#0a0b0d" stroke-width="2"/><circle cx="11" cy="11" r="3.2" fill="#3a4048" stroke="#0a0b0d"/><path d="M9 11h4" stroke="#0a0b0d"/><circle cx="309" cy="11" r="3.2" fill="#3a4048" stroke="#0a0b0d"/><path d="M307 11h4" stroke="#0a0b0d"/><circle cx="11" cy="199" r="3.2" fill="#3a4048" stroke="#0a0b0d"/><path d="M9 199h4" stroke="#0a0b0d"/><circle cx="309" cy="199" r="3.2" fill="#3a4048" stroke="#0a0b0d"/><path d="M307 199h4" stroke="#0a0b0d"/><rect x="22" y="14" width="276" height="182" rx="6" fill="url(#mface)"/><g clip-path="url(#mwin)"><path d="M80.9 101.6A110 110 0 0 1 239.1 101.6" fill="none" stroke="url(#mirror)" stroke-width="7"/><path d="M69.5 87.5A128 128 0 0 1 250.5 87.5" fill="none" stroke="#14171b" stroke-width="1"/><path d="M79.4 97.4L69.5 87.5" stroke="#14171b" stroke-width="1.5"/><text x="62.4" y="84.4" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">0</text><path d="M77.2 89.8L72.4 84.7" stroke="#14171b" stroke-width="0.7"/><path d="M80.0 87.2L75.4 82.0" stroke="#14171b" stroke-width="0.7"/><path d="M82.9 84.8L78.4 79.4" stroke="#14171b" stroke-width="0.7"/><path d="M85.8 82.4L81.5 76.9" stroke="#14171b" stroke-width="0.7"/><path d="M90.6 82.5L84.8 74.4" stroke="#14171b" stroke-width="0.7"/><path d="M92.0 77.9L88.1 72.1" stroke="#14171b" stroke-width="0.7"/><path d="M95.2 75.8L91.4 69.9" stroke="#14171b" stroke-width="0.7"/><path d="M98.4 73.9L94.8 67.8" stroke="#14171b" stroke-width="0.7"/><path d="M101.7 72.0L98.3 65.8" stroke="#14171b" stroke-width="0.7"/><path d="M108.2 76.4L101.9 64.0" stroke="#14171b" stroke-width="1.5"/><text x="97.3" y="59.0" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">1</text><path d="M108.5 68.5L105.5 62.2" stroke="#14171b" stroke-width="0.7"/><path d="M111.9 67.0L109.2 60.5" stroke="#14171b" stroke-width="0.7"/><path d="M115.5 65.5L112.9 59.0" stroke="#14171b" stroke-width="0.7"/><path d="M119.0 64.2L116.6 57.6" stroke="#14171b" stroke-width="0.7"/><path d="M123.5 65.8L120.4 56.3" stroke="#14171b" stroke-width="0.7"/><path d="M126.2 61.8L124.3 55.1" stroke="#14171b" stroke-width="0.7"/><path d="M129.9 60.8L128.2 54.0" stroke="#14171b" stroke-width="0.7"/><path d="M133.6 59.9L132.1 53.1" stroke="#14171b" stroke-width="0.7"/><path d="M137.3 59.1L136.0 52.3" stroke="#14171b" stroke-width="0.7"/><path d="M142.2 65.4L140.0 51.6" stroke="#14171b" stroke-width="1.5"/><text x="138.4" y="45.7" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">2</text><path d="M144.8 58.0L144.0 51.0" stroke="#14171b" stroke-width="0.7"/><path d="M148.6 57.5L148.0 50.6" stroke="#14171b" stroke-width="0.7"/><path d="M152.4 57.2L152.0 50.3" stroke="#14171b" stroke-width="0.7"/><path d="M156.2 57.1L156.0 50.1" stroke="#14171b" stroke-width="0.7"/><path d="M160.0 60.0L160.0 50.0" stroke="#14171b" stroke-width="0.7"/><path d="M163.8 57.1L164.0 50.1" stroke="#14171b" stroke-width="0.7"/><path d="M167.6 57.2L168.0 50.3" stroke="#14171b" stroke-width="0.7"/><path d="M171.4 57.5L172.0 50.6" stroke="#14171b" stroke-width="0.7"/><path d="M175.2 58.0L176.0 51.0" stroke="#14171b" stroke-width="0.7"/><path d="M177.8 65.4L180.0 51.6" stroke="#14171b" stroke-width="1.5"/><text x="181.6" y="45.7" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">3</text><path d="M182.7 59.1L184.0 52.3" stroke="#14171b" stroke-width="0.7"/><path d="M186.4 59.9L187.9 53.1" stroke="#14171b" stroke-width="0.7"/><path d="M190.1 60.8L191.8 54.0" stroke="#14171b" stroke-width="0.7"/><path d="M193.8 61.8L195.7 55.1" stroke="#14171b" stroke-width="0.7"/><path d="M196.5 65.8L199.6 56.3" stroke="#14171b" stroke-width="0.7"/><path d="M201.0 64.2L203.4 57.6" stroke="#14171b" stroke-width="0.7"/><path d="M204.5 65.5L207.1 59.0" stroke="#14171b" stroke-width="0.7"/><path d="M208.1 67.0L210.8 60.5" stroke="#14171b" stroke-width="0.7"/><path d="M211.5 68.5L214.5 62.2" stroke="#14171b" stroke-width="0.7"/><path d="M211.8 76.4L218.1 64.0" stroke="#14171b" stroke-width="1.5"/><text x="222.7" y="59.0" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">4</text><path d="M218.3 72.0L221.7 65.8" stroke="#14171b" stroke-width="0.7"/><path d="M221.6 73.9L225.2 67.8" stroke="#14171b" stroke-width="0.7"/><path d="M224.8 75.8L228.6 69.9" stroke="#14171b" stroke-width="0.7"/><path d="M228.0 77.9L231.9 72.1" stroke="#14171b" stroke-width="0.7"/><path d="M229.4 82.5L235.2 74.4" stroke="#14171b" stroke-width="0.7"/><path d="M234.2 82.4L238.5 76.9" stroke="#14171b" stroke-width="0.7"/><path d="M237.1 84.8L241.6 79.4" stroke="#14171b" stroke-width="0.7"/><path d="M240.0 87.2L244.6 82.0" stroke="#14171b" stroke-width="0.7"/><path d="M242.8 89.8L247.6 84.7" stroke="#14171b" stroke-width="0.7"/><path d="M240.6 97.4L250.5 87.5" stroke="#14171b" stroke-width="1.5"/><text x="257.6" y="84.4" text-anchor="middle" style="font: 600 12px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">5</text><text x="160" y="116" text-anchor="middle" style="font: 600 22px "Arial Narrow", "Roboto Condensed", system-ui, sans-serif; fill: #14171b">A</text><text x="44" y="186" text-anchor="start" style="font: 600 9px system-ui, sans-serif; fill: #14171b">⎓  1.5  ⊥</text><g class="needle" data-bind="ui.amps"><path d="M160 178L160 48" stroke="#14171b" stroke-width="1.4"/></g><rect x="130" y="172" width="60" height="24" rx="3" fill="#16191d"/></g><rect x="22" y="14" width="276" height="182" rx="6" fill="none" stroke="#000" stroke-opacity=".5" stroke-width="2"/></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); }  .needle { transform-origin: 160px 178px; transform: rotate(calc(-45deg + clamp(0, var(--value, 0), 5) * 18deg)); transition: transform .9s cubic-bezier(.3, 1.45, .55, 1); }</style>

The phase

phases/panel_ammeter.py
"""Reads the product's supply current while its stages switch on and shows iton the moving-coil ammeter: `ui.amps` turns the needle. The run records thestandby current and the full-load current."""import timedef supply_current(ui, measurements, load_ammeter):    for _ in range(load_ammeter.length()):        stage, amps = load_ammeter.read()        ui.amps = round(amps, 2)        if stage == 2:            standby = amps        if stage == 6:            load = amps        time.sleep(0.1)    measurements.standby_current = standby    measurements.load_current = load    time.sleep(1.5)

The mocked instrument

plugs/load_ammeter.py
"""Mock DC supply current into the product as its stages switch on: standby,the main board, the motor drive, then the steady load. Replace it with yourshunt or current meter's driver."""STAGES = [0.0, 0.82, 0.82, 2.35, 2.35, 3.1, 3.1, 2.84, 2.84, 2.84, 0.0, 0.0]class LoadAmmeter:    def __init__(self):        self.k = 0    def length(self):        return len(STAGES) * 13    def read(self):        """[stage index, amps]"""        stage = min(self.k // 13, len(STAGES) - 1)        self.k += 1        return [stage, STAGES[stage]]

Run your first test in minutes