Run It
Every instrument is mocked, so the example runs without hardware.
bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run thermal-controllerThe procedure
procedure.yaml
name: Thermal Controllerversion: 1.0.0plugs: - key: controller name: Thermal controller python: plugs.thermal_controller:ThermalControllermain: - key: cycle name: Thermal cycle python: phases.thermal_controller:thermal_cycle measurements: - key: cold_plateau name: Baseplate temperature in the cold dwell unit: "°C" validators: - operator: ">=" expected_value: -32 - operator: "<=" expected_value: -28 - key: hot_plateau name: Baseplate temperature in the hot dwell unit: "°C" validators: - operator: ">=" expected_value: 58 - operator: "<=" expected_value: 62 ui: panel: panels/controller.htmlThe panel
panels/controller.html
<div class="inst"><svg viewBox="0 0 320 210" role="img"><defs><linearGradient id="win" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#000" stop-opacity=".55"/><stop offset=".14" stop-color="#000" stop-opacity="0"/></linearGradient></defs><rect x="56" y="4" width="208" height="202" rx="10" fill="#1a1d21" stroke="#0a0b0d" stroke-width="2"/><circle cx="66" cy="14" r="3.2" fill="#2a2f35" stroke="#0a0b0d"/><path d="M64 14h4" stroke="#0a0b0d" stroke-width="1"/><circle cx="254" cy="14" r="3.2" fill="#2a2f35" stroke="#0a0b0d"/><path d="M252 14h4" stroke="#0a0b0d" stroke-width="1"/><circle cx="66" cy="196" r="3.2" fill="#2a2f35" stroke="#0a0b0d"/><path d="M64 196h4" stroke="#0a0b0d" stroke-width="1"/><circle cx="254" cy="196" r="3.2" fill="#2a2f35" stroke="#0a0b0d"/><path d="M252 196h4" stroke="#0a0b0d" stroke-width="1"/><text x="72" y="30" text-anchor="start" style="font: 700 7px system-ui, sans-serif; letter-spacing: .14em; fill: #d5dbe1">THERMAL PROGRAMMER</text><rect x="70" y="36" width="180" height="100" rx="4" fill="#050505"/><rect x="70" y="36" width="180" height="100" rx="4" fill="url(#win)"/><text x="78" y="50" text-anchor="start" style="font: 700 6.5px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #9aa8b6">PV</text><g class="pvd"><g class="d7" data-bind="ui.pv0" transform="translate(92.0 46.0) skewX(-7)"><rect class="sa" x="2.9" y="0.0" width="12.6" height="4.1" rx="2.0"/><rect class="sd" x="2.9" y="29.9" width="12.6" height="4.1" rx="2.0"/><rect class="sg" x="2.9" y="15.0" width="12.6" height="4.1" rx="2.0"/><rect class="sf" x="0.0" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="se" x="0.0" y="17.9" width="4.1" height="13.3" rx="2.0"/><rect class="sb" x="14.3" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="sc" x="14.3" y="17.9" width="4.1" height="13.3" rx="2.0"/></g><g class="d7" data-bind="ui.pv1" transform="translate(118.5 46.0) skewX(-7)"><rect class="sa" x="2.9" y="0.0" width="12.6" height="4.1" rx="2.0"/><rect class="sd" x="2.9" y="29.9" width="12.6" height="4.1" rx="2.0"/><rect class="sg" x="2.9" y="15.0" width="12.6" height="4.1" rx="2.0"/><rect class="sf" x="0.0" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="se" x="0.0" y="17.9" width="4.1" height="13.3" rx="2.0"/><rect class="sb" x="14.3" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="sc" x="14.3" y="17.9" width="4.1" height="13.3" rx="2.0"/></g><g class="d7" data-bind="ui.pv2" transform="translate(145.0 46.0) skewX(-7)"><rect class="sa" x="2.9" y="0.0" width="12.6" height="4.1" rx="2.0"/><rect class="sd" x="2.9" y="29.9" width="12.6" height="4.1" rx="2.0"/><rect class="sg" x="2.9" y="15.0" width="12.6" height="4.1" rx="2.0"/><rect class="sf" x="0.0" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="se" x="0.0" y="17.9" width="4.1" height="13.3" rx="2.0"/><rect class="sb" x="14.3" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="sc" x="14.3" y="17.9" width="4.1" height="13.3" rx="2.0"/></g><g class="d7" data-bind="ui.pv3" transform="translate(171.6 46.0) skewX(-7)"><rect class="sa" x="2.9" y="0.0" width="12.6" height="4.1" rx="2.0"/><rect class="sd" x="2.9" y="29.9" width="12.6" height="4.1" rx="2.0"/><rect class="sg" x="2.9" y="15.0" width="12.6" height="4.1" rx="2.0"/><rect class="sf" x="0.0" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="se" x="0.0" y="17.9" width="4.1" height="13.3" rx="2.0"/><rect class="sb" x="14.3" y="2.9" width="4.1" height="13.3" rx="2.0"/><rect class="sc" x="14.3" y="17.9" width="4.1" height="13.3" rx="2.0"/></g><g class="dp on" transform="translate(164.8 46.0) skewX(-7)"><rect x="0" y="29.9" width="4.1" height="4.1" rx="1.4"/></g></g><text x="242" y="78" text-anchor="end" style="font: 700 10px system-ui, sans-serif; letter-spacing: 0; fill: #ff3d2e">°C</text><text x="78" y="104" text-anchor="start" style="font: 700 6.5px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #9aa8b6">SV</text><g class="svd"><g class="d7" data-bind="ui.sv0" transform="translate(132.0 98.0) skewX(-7)"><rect class="sa" x="1.9" y="0.0" width="8.1" height="2.6" rx="1.3"/><rect class="sd" x="1.9" y="19.4" width="8.1" height="2.6" rx="1.3"/><rect class="sg" x="1.9" y="9.7" width="8.1" height="2.6" rx="1.3"/><rect class="sf" x="0.0" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="se" x="0.0" y="11.6" width="2.6" height="8.6" rx="1.3"/><rect class="sb" x="9.2" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="sc" x="9.2" y="11.6" width="2.6" height="8.6" rx="1.3"/></g><g class="d7" data-bind="ui.sv1" transform="translate(149.2 98.0) skewX(-7)"><rect class="sa" x="1.9" y="0.0" width="8.1" height="2.6" rx="1.3"/><rect class="sd" x="1.9" y="19.4" width="8.1" height="2.6" rx="1.3"/><rect class="sg" x="1.9" y="9.7" width="8.1" height="2.6" rx="1.3"/><rect class="sf" x="0.0" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="se" x="0.0" y="11.6" width="2.6" height="8.6" rx="1.3"/><rect class="sb" x="9.2" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="sc" x="9.2" y="11.6" width="2.6" height="8.6" rx="1.3"/></g><g class="d7" data-bind="ui.sv2" transform="translate(166.3 98.0) skewX(-7)"><rect class="sa" x="1.9" y="0.0" width="8.1" height="2.6" rx="1.3"/><rect class="sd" x="1.9" y="19.4" width="8.1" height="2.6" rx="1.3"/><rect class="sg" x="1.9" y="9.7" width="8.1" height="2.6" rx="1.3"/><rect class="sf" x="0.0" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="se" x="0.0" y="11.6" width="2.6" height="8.6" rx="1.3"/><rect class="sb" x="9.2" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="sc" x="9.2" y="11.6" width="2.6" height="8.6" rx="1.3"/></g><g class="d7" data-bind="ui.sv3" transform="translate(183.5 98.0) skewX(-7)"><rect class="sa" x="1.9" y="0.0" width="8.1" height="2.6" rx="1.3"/><rect class="sd" x="1.9" y="19.4" width="8.1" height="2.6" rx="1.3"/><rect class="sg" x="1.9" y="9.7" width="8.1" height="2.6" rx="1.3"/><rect class="sf" x="0.0" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="se" x="0.0" y="11.6" width="2.6" height="8.6" rx="1.3"/><rect class="sb" x="9.2" y="1.9" width="2.6" height="8.6" rx="1.3"/><rect class="sc" x="9.2" y="11.6" width="2.6" height="8.6" rx="1.3"/></g><g class="dp on" transform="translate(179.1 98.0) skewX(-7)"><rect x="0" y="19.4" width="2.6" height="2.6" rx="0.9"/></g></g><g class="led" data-bind="ui.op1" style="--led: #ffb02e"><circle cx="82" cy="148" r="3.3" stroke="#0c0e10"/></g><text x="89" y="150.5" text-anchor="start" style="font: 700 6.5px system-ui, sans-serif; letter-spacing: .08em; fill: #d5dbe1">OP1 HEAT</text><g class="led" data-bind="ui.op2" style="--led: #4aa8ff"><circle cx="140" cy="148" r="3.3" stroke="#0c0e10"/></g><text x="147" y="150.5" text-anchor="start" style="font: 700 6.5px system-ui, sans-serif; letter-spacing: .08em; fill: #d5dbe1">OP2 LN2</text><g class="led" data-bind="ui.al1" style="--led: #ff3d2e"><circle cx="196" cy="148" r="3.3" stroke="#0c0e10"/></g><text x="203" y="150.5" text-anchor="start" style="font: 700 6.5px system-ui, sans-serif; letter-spacing: .08em; fill: #d5dbe1">AL1</text><text x="160" y="176" text-anchor="middle" data-bind="ui.prog" style="font: 600 7.5px ui-monospace, Menlo, monospace; letter-spacing: .06em; fill: #9aa8b6">SEG 1 RAMP</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); } .pvd { --on: #ff3d2e; --off: #2a0d0a; } .svd { --on: #4dff7a; --off: #0d2414; }</style>The phase
phases/thermal_controller.py
"""Runs one protoflight thermal cycle on the chamber programmer. `ui.pv*`and `ui.sv*` drive the process value and setpoint digits; `ui.op1` and `ui.op2`light the heat and LN2 outputs, `ui.al1` the deviation alarm past ±2 °Cduring a dwell (GEVS temperature tolerance); `ui.prog` names the segment, a4 h dwell compressed in the replay. The run records each dwell's mean."""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)TOLERANCE_C, DWELL_MIN = 2.0, 240def digits4(c): return ("-" if c < 0 else " ") + f"{min(abs(c), 99.9):4.1f}"def thermal_cycle(ui, measurements, controller): dwell = {} for _ in range(controller.length()): seg, kind, u, setpoint, pv = controller.read() show(ui, "pv", digits4(pv)) show(ui, "sv", digits4(setpoint)) ui.op1 = setpoint > pv + 0.3 ui.op2 = setpoint < pv - 0.3 ui.al1 = kind == "DWELL" and abs(pv - setpoint) > TOLERANCE_C if kind == "DWELL": minutes = round(u * DWELL_MIN) ui.prog = f"SEG {seg} DWELL {minutes // 60}:{minutes % 60:02d} / 4:00" dwell.setdefault(setpoint, []).append(pv) else: ui.prog = f"SEG {seg} RAMP 1.0 °C/min" time.sleep(0.1) measurements.cold_plateau = round(sum(dwell[-30]) / len(dwell[-30]), 2) measurements.hot_plateau = round(sum(dwell[60]) / len(dwell[60]), 2) time.sleep(1.5)The mocked instrument
plugs/thermal_controller.py
"""Mock chamber thermal programmer: one protoflight cycle of a unit'sbaseplate, ramp to -30 °C, 4 h dwell, ramp to +60 °C, 4 h dwell, back toambient. Replace it with your controller's driver."""import mathPROFILE = [("RAMP", 22, -30, 44), ("DWELL", -30, -30, 40), ("RAMP", -30, 60, 52), ("DWELL", 60, 60, 40), ("RAMP", 60, 22, 24)]class ThermalController: def __init__(self): self.samples = [] for seg, (kind, t0, t1, steps) in enumerate(PROFILE, start=1): for i in range(steps): u = (i + 1) / steps eased = 0.5 - 0.5 * math.cos(math.pi * u) setpoint = t0 if kind == "DWELL" else t0 + (t1 - t0) * eased # The baseplate lags the setpoint on a ramp: below it heating, above it cooling. pv = setpoint - (1.2 if t1 > t0 else -1.2 if t1 < t0 else 0) * (kind == "RAMP") if kind == "DWELL": pv = t0 + (3.1 if t0 > 0 else -1.6) * math.exp(-6 * u) * math.cos(9 * u) pv += 0.12 * math.sin(len(self.samples) * 1.9) self.samples.append((seg, kind, u, setpoint, pv)) self.index = 0 def length(self): return len(self.samples) def read(self): """[program segment, RAMP or DWELL, fraction of the segment, setpoint °C, process value °C]""" sample = self.samples[min(self.index, len(self.samples) - 1)] self.index += 1 return list(sample)