在单位回退时就近提示缺少可用标定

让实时和回放的原始单位回退原因出现在力曲线单位按钮旁。相关定向测试与 lint gate 通过。
This commit is contained in:
ykcheungab
2026-10-10 15:05:09 +08:00
parent cf86bd0702
commit 48de5b74e6
7 changed files with 42 additions and 3 deletions
@@ -3,6 +3,7 @@
from __future__ import annotations
import numpy as np
from orisys_app_shared.i18n import t
from orisys_studio.ui.force_plots import ForcePlotsPanel, _nice_ticks
@@ -28,6 +29,19 @@ def _curve(panel: ForcePlotsPanel, channel: int) -> np.ndarray:
# ------------------------------------------------------------- force output
def test_missing_calibration_notice_sits_beside_unit_button(qt_app):
panel = _panel("raw")
assert not panel.unit_notice.isVisible()
panel.show_unit_fallback()
assert panel.unit_notice.text() == t("status.units_raw_fallback")
assert not panel.unit_notice.isHidden()
header = panel.layout().itemAt(0).layout()
assert header.itemAt(header.count() - 2).widget() is panel.unit_notice
assert header.itemAt(header.count() - 1).widget() is panel.unit_badge
panel.set_units("N")
assert panel.unit_notice.isHidden()
def test_raw_threshold_and_precision_match_cards_and_curve(qt_app):
panel = _panel("raw")
panel.set_deadband_floors(raw=50.0)
@@ -111,6 +111,7 @@ class _Charts:
self.followed = 0
self.shown = 0
self.cleared = 0
self.unit_fallbacks = 0
def unit(self) -> str:
return self._unit
@@ -134,6 +135,9 @@ class _Charts:
def show_all(self) -> None:
self.shown += 1
def show_unit_fallback(self) -> None:
self.unit_fallbacks += 1
class _ImagePanel:
def __init__(self) -> None:
@@ -584,6 +588,7 @@ def test_the_charts_fall_back_to_raw_when_a_recording_has_no_newtons(qt_app):
assert engine.units[-1] == "raw"
assert host.units[-1] == "raw"
assert t("status.units_raw_fallback") in host.notes
assert parts[1].unit_fallbacks == 1
engine._reader = _Reader(newtons=[1.0, 2.0, 3.0])
controller.apply_source(True)