迁移 GUI 调用点
This commit is contained in:
@@ -250,17 +250,19 @@ class UCD323Device(IUcdDevice):
|
||||
|
||||
def set_pattern(self, pattern: PatternSpec) -> None:
|
||||
with self._lock:
|
||||
if self._state not in (UcdState.CONFIGURED, UcdState.APPLIED):
|
||||
raise UcdStateError(
|
||||
f"set_pattern 需要 CONFIGURED/APPLIED 状态,当前 {self._state.name}"
|
||||
)
|
||||
# Phase 2 过渡:允许从 OPENED 直接 set_pattern——遗留路径
|
||||
# (test_runner 等)通过旧 controller.apply_signal_format 写入
|
||||
# 信号格式,未经过本设备的 configure。此时 self._state 仍为
|
||||
# OPENED,但硬件实际已处于可接收 pattern 状态。
|
||||
if self._state == UcdState.CLOSED:
|
||||
raise UcdNotConnected("UCD 未连接,无法 set_pattern")
|
||||
self._curr_pattern = pattern
|
||||
# 仅本地暂存,真正写硬件在 apply()
|
||||
|
||||
def apply(self) -> None:
|
||||
with self._lock:
|
||||
if self._curr_signal is None or self._curr_timing is None:
|
||||
raise UcdStateError("apply 前必须先 configure")
|
||||
if self._state == UcdState.CLOSED:
|
||||
raise UcdNotConnected("UCD 未连接,无法 apply")
|
||||
if self._curr_pattern is None:
|
||||
raise UcdStateError("apply 前必须先 set_pattern")
|
||||
try:
|
||||
@@ -272,12 +274,15 @@ class UCD323Device(IUcdDevice):
|
||||
f"apply 失败: pattern={self._curr_pattern.kind.value}"
|
||||
)
|
||||
|
||||
changed = (self._curr_signal, self._curr_timing) != self._last_applied
|
||||
self._last_applied = (self._curr_signal, self._curr_timing)
|
||||
# SignalApplied 事件仅在通过新 API configure 过时发出;
|
||||
# 遗留路径下 self._curr_signal/_curr_timing 可能为 None。
|
||||
if self._curr_signal is not None and self._curr_timing is not None:
|
||||
changed = (self._curr_signal, self._curr_timing) != self._last_applied
|
||||
self._last_applied = (self._curr_signal, self._curr_timing)
|
||||
self._bus.publish(
|
||||
SignalApplied(self._curr_signal, self._curr_timing, changed)
|
||||
)
|
||||
self._state = UcdState.APPLIED
|
||||
self._bus.publish(
|
||||
SignalApplied(self._curr_signal, self._curr_timing, changed)
|
||||
)
|
||||
self._bus.publish(PatternApplied(self._curr_pattern))
|
||||
|
||||
# -- 查询 ----------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user