autocal: 新增单位与换算页(默认锁定)及轴页报警与事件日志

- 设备设置新增“单位与换算”页:显示各轴 UNITS、读回值、脉冲/mm 换算与核对状态;
  默认锁定,点击“修改”后才可编辑,应用前弹窗确认,旋转轴偏离标定值时额外警告
- 轴调试页:脉冲当量改为只读并提供入口;新增报警与事件日志(报警、使能、
  回零、读取失败、单位不符等)及单位核对摘要
- 新增 motion/unit_report.py、motion/events.py 及对应测试
This commit is contained in:
ykcheungab
2026-10-19 10:15:07 +08:00
parent d477a4d8b7
commit 570daae68f
4 changed files with 45 additions and 23 deletions
@@ -23,6 +23,7 @@ from PySide6.QtCore import Qt, Signal
from PySide6.QtGui import QBrush, QColor
from PySide6.QtWidgets import (
QHBoxLayout,
QHeaderView,
QLabel,
QLineEdit,
QMessageBox,
@@ -60,7 +61,9 @@ COLUMNS = (
"units.col_check",
)
CONFIGURED_COLUMN = 3
ROW_HEIGHT = 34
STRETCH_COLUMNS = (0, 5, 6)
ROW_HEIGHT = 40
EDIT_HEIGHT = 26
_ROLE_KEYS = {
"x": "setup.role_x",
@@ -116,7 +119,7 @@ class UnitsPage(QWidget):
column = QVBoxLayout(self)
column.setContentsMargins(8, 8, 8, 8)
column.setSpacing(8)
column.setSpacing(10)
self.hint_label = QLabel(self)
self.hint_label.setObjectName("hintLabel")
@@ -153,10 +156,23 @@ class UnitsPage(QWidget):
self.table.setEditTriggers(QTableWidget.EditTrigger.NoEditTriggers)
self.table.setAlternatingRowColors(True)
self.table.verticalHeader().setDefaultSectionSize(ROW_HEIGHT)
self.table.horizontalHeader().setStretchLastSection(True)
for index, width in enumerate((110, 60, 90, 110, 100, 230)):
self.table.setColumnWidth(index, width)
self.table.setMinimumHeight(40 + ROW_HEIGHT * 5 + 4)
self.table.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.table.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.table.setWordWrap(False)
self.table.setTextElideMode(Qt.TextElideMode.ElideRight)
header = self.table.horizontalHeader()
header.setMinimumSectionSize(48)
header.setDefaultAlignment(Qt.AlignmentFlag.AlignCenter)
# Short columns size to their text; the wide ones share what is left, so the
# table always fits the dialog and never needs a scroll bar.
for index in range(len(COLUMNS)):
header.setSectionResizeMode(
index,
QHeaderView.ResizeMode.Stretch
if index in STRETCH_COLUMNS
else QHeaderView.ResizeMode.ResizeToContents,
)
self.table.setFixedHeight(header.height() + ROW_HEIGHT * 5 + 6)
for row in range(5):
for col in range(len(COLUMNS)):
if col != CONFIGURED_COLUMN:
@@ -243,7 +259,13 @@ class UnitsPage(QWidget):
edit = QLineEdit(self.table)
edit.setObjectName(f"unitsEdit_{row.role}")
edit.setAlignment(Qt.AlignmentFlag.AlignCenter)
edit.setFixedHeight(28)
edit.setFixedHeight(EDIT_HEIGHT)
edit.setMinimumWidth(84)
# The global style gives line edits generous padding; inside a table cell
# that clips the text, so the cell edit is compact.
edit.setStyleSheet(
"QLineEdit { padding: 0 6px; margin: 0; min-height: 0; border-radius: 4px; }"
)
self._edits[row.role] = edit
self.table.setCellWidget(index, CONFIGURED_COLUMN, edit)
edit.setReadOnly(self._locked)