lightfall 0.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lightfall/__init__.py +8 -0
- lightfall/__main__.py +10 -0
- lightfall/_version.py +24 -0
- lightfall/acquire/__init__.py +74 -0
- lightfall/acquire/buffer.py +363 -0
- lightfall/acquire/device_wrapper.py +416 -0
- lightfall/acquire/engine/__init__.py +155 -0
- lightfall/acquire/engine/base.py +587 -0
- lightfall/acquire/engine/bluesky.py +358 -0
- lightfall/acquire/engine/mock.py +165 -0
- lightfall/acquire/engine/plugins/__init__.py +9 -0
- lightfall/acquire/engine/plugins/bluesky_plugin.py +56 -0
- lightfall/acquire/engine/plugins/mock_plugin.py +55 -0
- lightfall/acquire/engine/protocol.py +145 -0
- lightfall/acquire/engine/registry.py +152 -0
- lightfall/acquire/engine/state.py +32 -0
- lightfall/acquire/engine/waiting_hook.py +225 -0
- lightfall/acquire/nats_bridge.py +62 -0
- lightfall/acquire/plan_ui.py +78 -0
- lightfall/acquire/plans/__init__.py +38 -0
- lightfall/acquire/plans/adaptive.py +288 -0
- lightfall/acquire/plans/example_plans.py +995 -0
- lightfall/acquire/plans/lightfall_plans.py +587 -0
- lightfall/acquire/plans/registry.py +543 -0
- lightfall/acquire/plans/standard_plans.py +186 -0
- lightfall/acquire/plans/user_plans.py +470 -0
- lightfall/acquire/runengine.py +36 -0
- lightfall/acquire/signals.py +452 -0
- lightfall/acquire/triggers/__init__.py +16 -0
- lightfall/acquire/triggers/base.py +25 -0
- lightfall/acquire/triggers/filter.py +37 -0
- lightfall/acquire/triggers/manager.py +73 -0
- lightfall/acquire/triggers/manual.py +36 -0
- lightfall/acquire/triggers/run_end.py +74 -0
- lightfall/acquire/triggers/run_start.py +52 -0
- lightfall/auth/__init__.py +38 -0
- lightfall/auth/policy.py +518 -0
- lightfall/auth/providers/__init__.py +30 -0
- lightfall/auth/providers/base.py +124 -0
- lightfall/auth/providers/keycloak.py +1017 -0
- lightfall/auth/providers/local.py +319 -0
- lightfall/auth/providers/pam.py +250 -0
- lightfall/auth/service_key.py +173 -0
- lightfall/auth/service_key_auth.py +79 -0
- lightfall/auth/session.py +656 -0
- lightfall/claude/__init__.py +52 -0
- lightfall/claude/_internal/__init__.py +1 -0
- lightfall/claude/_internal/serialization.py +195 -0
- lightfall/claude/_internal/threading.py +61 -0
- lightfall/claude/_internal/worker.py +757 -0
- lightfall/claude/_session_assembly.py +124 -0
- lightfall/claude/agent.py +596 -0
- lightfall/claude/lightfall_core_tools.py +410 -0
- lightfall/claude/markdown.py +103 -0
- lightfall/claude/permission_manager.py +588 -0
- lightfall/claude/tools/__init__.py +45 -0
- lightfall/claude/tools/controller.py +143 -0
- lightfall/claude/tools/interaction.py +177 -0
- lightfall/claude/tools/introspection.py +127 -0
- lightfall/claude/tools/logs.py +155 -0
- lightfall/claude/tools/screenshot.py +87 -0
- lightfall/claude/widget.py +851 -0
- lightfall/claude/widgets/__init__.py +5 -0
- lightfall/claude/widgets/permission_request.py +282 -0
- lightfall/claude/widgets/question_request.py +227 -0
- lightfall/claude/widgets/task_card.py +223 -0
- lightfall/config/__init__.py +23 -0
- lightfall/config/layers.py +317 -0
- lightfall/config/manager.py +244 -0
- lightfall/config/schema.py +154 -0
- lightfall/core/__init__.py +23 -0
- lightfall/core/application.py +727 -0
- lightfall/core/services.py +235 -0
- lightfall/devices/__init__.py +53 -0
- lightfall/devices/backends/__init__.py +17 -0
- lightfall/devices/backends/bcs.py +448 -0
- lightfall/devices/backends/happi.py +986 -0
- lightfall/devices/backends/mock.py +646 -0
- lightfall/devices/base.py +338 -0
- lightfall/devices/catalog.py +1039 -0
- lightfall/devices/connection_manager.py +676 -0
- lightfall/devices/model.py +290 -0
- lightfall/devices/monitoring.py +442 -0
- lightfall/devices/sim/__init__.py +26 -0
- lightfall/devices/sim/areadetector.py +436 -0
- lightfall/devices/sim/generators.py +223 -0
- lightfall/devices/sim/plugins.py +116 -0
- lightfall/epics/__init__.py +28 -0
- lightfall/epics/ca/__init__.py +10 -0
- lightfall/epics/ca/context.py +100 -0
- lightfall/epics/ca/pv.py +303 -0
- lightfall/epics/widgets/__init__.py +49 -0
- lightfall/epics/widgets/areadetector/__init__.py +16 -0
- lightfall/epics/widgets/areadetector/areadetector.py +281 -0
- lightfall/epics/widgets/areadetector/controls.py +478 -0
- lightfall/epics/widgets/areadetector/image_view.py +447 -0
- lightfall/epics/widgets/auto.py +319 -0
- lightfall/epics/widgets/base.py +404 -0
- lightfall/epics/widgets/checkbox.py +239 -0
- lightfall/epics/widgets/combobox.py +202 -0
- lightfall/epics/widgets/label.py +176 -0
- lightfall/epics/widgets/lineedit.py +253 -0
- lightfall/epics/widgets/motor.py +694 -0
- lightfall/epics/widgets/ophyd_base.py +469 -0
- lightfall/epics/widgets/ophyd_combobox.py +86 -0
- lightfall/epics/widgets/ophyd_label.py +54 -0
- lightfall/epics/widgets/ophyd_lineedit.py +170 -0
- lightfall/epics/widgets/ophyd_spinbox.py +79 -0
- lightfall/epics/widgets/slider.py +272 -0
- lightfall/epics/widgets/status_indicator.py +98 -0
- lightfall/epics/widgets/style.py +188 -0
- lightfall/exporter/__init__.py +1 -0
- lightfall/exporter/cli.py +67 -0
- lightfall/exporter/converters/__init__.py +26 -0
- lightfall/exporter/converters/base.py +39 -0
- lightfall/exporter/converters/noop.py +39 -0
- lightfall/exporter/converters/nxsas.py +73 -0
- lightfall/exporter/service.py +200 -0
- lightfall/exporter/tiled_utils.py +92 -0
- lightfall/ipc/__init__.py +6 -0
- lightfall/ipc/service.py +701 -0
- lightfall/ipc/trust.py +144 -0
- lightfall/logbook/__init__.py +46 -0
- lightfall/logbook/action_dialog.py +207 -0
- lightfall/logbook/action_logger.py +432 -0
- lightfall/logbook/block_mapper.py +562 -0
- lightfall/logbook/client.py +799 -0
- lightfall/logbook/converter.py +273 -0
- lightfall/logbook/editors/__init__.py +19 -0
- lightfall/logbook/editors/highlighter.py +305 -0
- lightfall/logbook/editors/markdown_editor.py +319 -0
- lightfall/logbook/editors/richtext_editor.py +1397 -0
- lightfall/logbook/entry_widget.py +1065 -0
- lightfall/logbook/event_listener.py +221 -0
- lightfall/logbook/fragment_widgets.py +925 -0
- lightfall/logbook/position_mapper.py +320 -0
- lightfall/logbook/protection.py +402 -0
- lightfall/logbook/style.py +394 -0
- lightfall/logbook/url.py +29 -0
- lightfall/logbook/visual_protection.py +330 -0
- lightfall/logbook/widget.py +680 -0
- lightfall/main.py +1091 -0
- lightfall/pipelines/__init__.py +4 -0
- lightfall/pipelines/client.py +148 -0
- lightfall/plugins/__init__.py +119 -0
- lightfall/plugins/agent_plugin.py +106 -0
- lightfall/plugins/agents/__init__.py +10 -0
- lightfall/plugins/agents/_mcp_helpers.py +52 -0
- lightfall/plugins/agents/alignment.py +94 -0
- lightfall/plugins/agents/autonomous_experiment/__init__.py +12 -0
- lightfall/plugins/agents/autonomous_experiment/nats_tools.py +210 -0
- lightfall/plugins/agents/autonomous_experiment/plugin.py +60 -0
- lightfall/plugins/agents/autonomous_experiment/prompts.py +164 -0
- lightfall/plugins/agents/current_esaf.py +435 -0
- lightfall/plugins/agents/device_tools.py +1043 -0
- lightfall/plugins/agents/engine_tools.py +720 -0
- lightfall/plugins/agents/ipython_tools.py +444 -0
- lightfall/plugins/agents/panel_builder.py +637 -0
- lightfall/plugins/agents/panel_design/references/cross_panel_patterns.md +95 -0
- lightfall/plugins/agents/panel_design/references/panel_design.md +680 -0
- lightfall/plugins/agents/panel_design.py +94 -0
- lightfall/plugins/agents/plan_design/references/plan_design.md +398 -0
- lightfall/plugins/agents/plan_design.py +90 -0
- lightfall/plugins/agents/plan_tools.py +878 -0
- lightfall/plugins/agents/scan_planning.py +101 -0
- lightfall/plugins/builtin_manifest.py +348 -0
- lightfall/plugins/controller_plugin.py +162 -0
- lightfall/plugins/engine_plugin.py +124 -0
- lightfall/plugins/errors.py +104 -0
- lightfall/plugins/info.py +112 -0
- lightfall/plugins/loader.py +878 -0
- lightfall/plugins/manifest.py +150 -0
- lightfall/plugins/panel_plugin.py +119 -0
- lightfall/plugins/plan_plugin.py +163 -0
- lightfall/plugins/registry.py +309 -0
- lightfall/plugins/settings_plugin.py +226 -0
- lightfall/plugins/statusbar_plugin.py +289 -0
- lightfall/plugins/theme_plugin.py +165 -0
- lightfall/plugins/types.py +136 -0
- lightfall/plugins/user_plugins.py +764 -0
- lightfall/project/__init__.py +37 -0
- lightfall/project/model.py +375 -0
- lightfall/project/service.py +427 -0
- lightfall/project/welcome.py +106 -0
- lightfall/resources/__init__.py +126 -0
- lightfall/resources/images/__init__.py +1 -0
- lightfall/resources/images/icon.ico +0 -0
- lightfall/resources/images/icon.png +0 -0
- lightfall/resources/images/logo.png +0 -0
- lightfall/services/__init__.py +33 -0
- lightfall/services/_alshub_client.py +73 -0
- lightfall/services/access_stamper.py +240 -0
- lightfall/services/als_beam_status.py +347 -0
- lightfall/services/ca_tunnel.py +325 -0
- lightfall/services/threaded_tiled_writer.py +174 -0
- lightfall/services/tiled_auth.py +21 -0
- lightfall/services/tiled_service.py +971 -0
- lightfall/services/tiled_writer_patch.py +301 -0
- lightfall/settings/__init__.py +1 -0
- lightfall/settings/image_helpers.py +30 -0
- lightfall/settings/user_settings_client.py +232 -0
- lightfall/ui/__init__.py +28 -0
- lightfall/ui/annotations.py +208 -0
- lightfall/ui/common/__init__.py +7 -0
- lightfall/ui/dialogs/__init__.py +26 -0
- lightfall/ui/dialogs/about_dialog.py +131 -0
- lightfall/ui/dialogs/add_trigger_dialog.py +152 -0
- lightfall/ui/dialogs/base.py +44 -0
- lightfall/ui/dialogs/bug_report_dialog.py +353 -0
- lightfall/ui/dialogs/create_plan_dialog.py +189 -0
- lightfall/ui/dialogs/device_edit_dialog.py +183 -0
- lightfall/ui/dialogs/export_dialog.py +565 -0
- lightfall/ui/dialogs/go_to_position_dialog.py +192 -0
- lightfall/ui/dialogs/login_dialog.py +756 -0
- lightfall/ui/dialogs/oauth_browser_dialog.py +305 -0
- lightfall/ui/dialogs/run_pipeline_dialog.py +131 -0
- lightfall/ui/dialogs/sample_metadata_dialog.py +316 -0
- lightfall/ui/docking/__init__.py +22 -0
- lightfall/ui/docking/icon_sidebar.py +806 -0
- lightfall/ui/docking/manager.py +682 -0
- lightfall/ui/docking/state.py +113 -0
- lightfall/ui/docking/theme.py +399 -0
- lightfall/ui/docking/widget.py +214 -0
- lightfall/ui/events.py +75 -0
- lightfall/ui/mainwindow.py +1006 -0
- lightfall/ui/models/__init__.py +49 -0
- lightfall/ui/models/device_selection.py +389 -0
- lightfall/ui/models/device_tree.py +1095 -0
- lightfall/ui/models/thread_model.py +667 -0
- lightfall/ui/models/tiled_model.py +384 -0
- lightfall/ui/panels/__init__.py +28 -0
- lightfall/ui/panels/base.py +525 -0
- lightfall/ui/panels/bluesky_panel.py +619 -0
- lightfall/ui/panels/claude/__init__.py +9 -0
- lightfall/ui/panels/claude/agent_registry.py +168 -0
- lightfall/ui/panels/claude_panel.py +887 -0
- lightfall/ui/panels/device_panel.py +370 -0
- lightfall/ui/panels/documents_panel.py +166 -0
- lightfall/ui/panels/ipython_panel.py +580 -0
- lightfall/ui/panels/logbook_entries_panel.py +84 -0
- lightfall/ui/panels/logbook_panel.py +627 -0
- lightfall/ui/panels/logging_panel.py +587 -0
- lightfall/ui/panels/pipeline_jobs_panel.py +160 -0
- lightfall/ui/panels/pipeline_triggers_panel.py +170 -0
- lightfall/ui/panels/plugins/__init__.py +34 -0
- lightfall/ui/panels/plugins/bluesky_plugin.py +27 -0
- lightfall/ui/panels/plugins/claude_plugin.py +29 -0
- lightfall/ui/panels/plugins/device_plugin.py +27 -0
- lightfall/ui/panels/plugins/documents_plugin.py +26 -0
- lightfall/ui/panels/plugins/ipython_plugin.py +27 -0
- lightfall/ui/panels/plugins/logbook_entries_plugin.py +23 -0
- lightfall/ui/panels/plugins/logbook_plugin.py +27 -0
- lightfall/ui/panels/plugins/logging_plugin.py +27 -0
- lightfall/ui/panels/plugins/pipeline_jobs_plugin.py +23 -0
- lightfall/ui/panels/plugins/pipeline_triggers_plugin.py +25 -0
- lightfall/ui/panels/plugins/queue_plugin.py +29 -0
- lightfall/ui/panels/plugins/synoptic_plugin.py +38 -0
- lightfall/ui/panels/plugins/threads_plugin.py +27 -0
- lightfall/ui/panels/plugins/tiled_browser_plugin.py +27 -0
- lightfall/ui/panels/plugins/visualization_plugin.py +27 -0
- lightfall/ui/panels/queue.py +754 -0
- lightfall/ui/panels/registry.py +483 -0
- lightfall/ui/panels/synoptic/__init__.py +27 -0
- lightfall/ui/panels/synoptic/editors.py +481 -0
- lightfall/ui/panels/synoptic/items.py +556 -0
- lightfall/ui/panels/synoptic/models.py +336 -0
- lightfall/ui/panels/synoptic/panel.py +889 -0
- lightfall/ui/panels/synoptic/serialization.py +300 -0
- lightfall/ui/panels/synoptic/view.py +504 -0
- lightfall/ui/panels/threads_panel.py +621 -0
- lightfall/ui/panels/tiled_browser_panel.py +854 -0
- lightfall/ui/panels/visualization_panel.py +508 -0
- lightfall/ui/preferences/__init__.py +24 -0
- lightfall/ui/preferences/backend.py +148 -0
- lightfall/ui/preferences/builtin.py +220 -0
- lightfall/ui/preferences/claude_settings.py +762 -0
- lightfall/ui/preferences/device_settings.py +461 -0
- lightfall/ui/preferences/dialog.py +234 -0
- lightfall/ui/preferences/editor_settings.py +227 -0
- lightfall/ui/preferences/ipc_settings.py +226 -0
- lightfall/ui/preferences/logbook_settings.py +232 -0
- lightfall/ui/preferences/login_settings.py +183 -0
- lightfall/ui/preferences/manager.py +562 -0
- lightfall/ui/preferences/plugin_settings.py +392 -0
- lightfall/ui/preferences/proxy_settings.py +561 -0
- lightfall/ui/preferences/skill_settings.py +28 -0
- lightfall/ui/preferences/tiled_settings.py +469 -0
- lightfall/ui/preferences/tool_settings.py +393 -0
- lightfall/ui/preferences/user_portable_backend.py +131 -0
- lightfall/ui/preferences/user_profile_settings.py +316 -0
- lightfall/ui/preferences/visualization_settings.py +159 -0
- lightfall/ui/resources/__init__.py +1 -0
- lightfall/ui/resources/logo.png +0 -0
- lightfall/ui/statusbar/__init__.py +11 -0
- lightfall/ui/statusbar/manager.py +379 -0
- lightfall/ui/statusbar/plugins/__init__.py +28 -0
- lightfall/ui/statusbar/plugins/als_beam_status.py +218 -0
- lightfall/ui/statusbar/plugins/auth_status.py +116 -0
- lightfall/ui/statusbar/plugins/connection_status.py +100 -0
- lightfall/ui/statusbar/plugins/thread_status.py +556 -0
- lightfall/ui/statusbar/plugins/tiled_status.py +179 -0
- lightfall/ui/statusbar/plugins/user_status.py +84 -0
- lightfall/ui/theater/__init__.py +28 -0
- lightfall/ui/theater/manager.py +124 -0
- lightfall/ui/theater/overlay.py +279 -0
- lightfall/ui/theater/proxy.py +111 -0
- lightfall/ui/theme/__init__.py +18 -0
- lightfall/ui/theme/builtin.py +1015 -0
- lightfall/ui/theme/manager.py +875 -0
- lightfall/ui/theme/registry.py +195 -0
- lightfall/ui/toast.py +221 -0
- lightfall/ui/tutorial.py +1100 -0
- lightfall/ui/widgets/__init__.py +110 -0
- lightfall/ui/widgets/base_control.py +259 -0
- lightfall/ui/widgets/camera/__init__.py +36 -0
- lightfall/ui/widgets/camera/base.py +815 -0
- lightfall/ui/widgets/camera/dark_frames.py +213 -0
- lightfall/ui/widgets/camera/image_view.py +649 -0
- lightfall/ui/widgets/camera/panels/__init__.py +14 -0
- lightfall/ui/widgets/camera/panels/cooler.py +320 -0
- lightfall/ui/widgets/camera/panels/temperature.py +192 -0
- lightfall/ui/widgets/camera/plan_based.py +202 -0
- lightfall/ui/widgets/compact_motor.py +522 -0
- lightfall/ui/widgets/controller_matcher.py +278 -0
- lightfall/ui/widgets/controller_registry.py +144 -0
- lightfall/ui/widgets/device_control.py +411 -0
- lightfall/ui/widgets/device_selector.py +438 -0
- lightfall/ui/widgets/device_tree_tab.py +461 -0
- lightfall/ui/widgets/document_stream.py +1028 -0
- lightfall/ui/widgets/favorites_tab.py +191 -0
- lightfall/ui/widgets/motor_control.py +1120 -0
- lightfall/ui/widgets/observers/__init__.py +8 -0
- lightfall/ui/widgets/observers/camera.py +48 -0
- lightfall/ui/widgets/observers/image_view.py +130 -0
- lightfall/ui/widgets/plan_config.py +954 -0
- lightfall/ui/widgets/plan_edit_dialog.py +294 -0
- lightfall/ui/widgets/plan_selector.py +452 -0
- lightfall/ui/widgets/profile_avatar.py +128 -0
- lightfall/ui/widgets/queue_view.py +647 -0
- lightfall/ui/widgets/runengine_control.py +549 -0
- lightfall/ui/widgets/signal_control.py +793 -0
- lightfall/ui/widgets/skill_trigger_button.py +183 -0
- lightfall/ui/widgets/tiled_filter_widget.py +314 -0
- lightfall/ui/widgets/tiled_status.py +149 -0
- lightfall/ui/widgets/warning_banner.py +185 -0
- lightfall/utils/__init__.py +53 -0
- lightfall/utils/crash_diagnostics.py +454 -0
- lightfall/utils/data_migration.py +22 -0
- lightfall/utils/editor_launcher.py +594 -0
- lightfall/utils/error_collector.py +245 -0
- lightfall/utils/git_tracker.py +197 -0
- lightfall/utils/log_buffer.py +233 -0
- lightfall/utils/logging.py +229 -0
- lightfall/utils/module_resolver.py +70 -0
- lightfall/utils/sentry.py +722 -0
- lightfall/utils/threads.py +991 -0
- lightfall/utils/tiled_helpers.py +96 -0
- lightfall/visualization/__init__.py +50 -0
- lightfall/visualization/base.py +5 -0
- lightfall/visualization/base_visualization.py +74 -0
- lightfall/visualization/fitting/__init__.py +24 -0
- lightfall/visualization/fitting/base.py +267 -0
- lightfall/visualization/fitting/fitters.py +325 -0
- lightfall/visualization/fitting/panel.py +265 -0
- lightfall/visualization/memory.py +392 -0
- lightfall/visualization/motor_mixin.py +524 -0
- lightfall/visualization/pg.py +156 -0
- lightfall/visualization/registry.py +144 -0
- lightfall/visualization/spec.py +79 -0
- lightfall/visualization/theme.py +266 -0
- lightfall/visualization/widgets/__init__.py +28 -0
- lightfall/visualization/widgets/adaptive/__init__.py +1 -0
- lightfall/visualization/widgets/adaptive/heatmap.py +655 -0
- lightfall/visualization/widgets/adaptive/plot.py +233 -0
- lightfall/visualization/widgets/heatmap.py +264 -0
- lightfall/visualization/widgets/image_stack.py +316 -0
- lightfall/visualization/widgets/image_view_toolbar.py +227 -0
- lightfall/visualization/widgets/lazy_image_view.py +590 -0
- lightfall/visualization/widgets/plot_1d.py +262 -0
- lightfall/visualization/widgets/scatter.py +247 -0
- lightfall/visualization/widgets/table.py +221 -0
- lightfall/visualization/widgets/time_axis.py +93 -0
- lightfall-0.1.1.dist-info/METADATA +223 -0
- lightfall-0.1.1.dist-info/RECORD +388 -0
- lightfall-0.1.1.dist-info/WHEEL +4 -0
- lightfall-0.1.1.dist-info/entry_points.txt +6 -0
- lightfall-0.1.1.dist-info/licenses/LEGAL.md +13 -0
- lightfall-0.1.1.dist-info/licenses/LICENSE.md +33 -0
|
@@ -0,0 +1,694 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PVMotor widget - specialized UI for EPICS motor records.
|
|
3
|
+
|
|
4
|
+
Provides a comprehensive motor control interface with:
|
|
5
|
+
- Absolute and relative positioning
|
|
6
|
+
- Setpoint and readback display
|
|
7
|
+
- Status indicators (moving, limits, direction)
|
|
8
|
+
- Stop and enable controls
|
|
9
|
+
- Progressive disclosure with advanced section
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from typing import Any, ClassVar
|
|
15
|
+
|
|
16
|
+
from PySide6.QtCore import Property, QEvent, QTimer, Signal, Slot
|
|
17
|
+
from PySide6.QtWidgets import (
|
|
18
|
+
QGridLayout,
|
|
19
|
+
QGroupBox,
|
|
20
|
+
QHBoxLayout,
|
|
21
|
+
QLabel,
|
|
22
|
+
QPushButton,
|
|
23
|
+
QVBoxLayout,
|
|
24
|
+
QWidget,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
from lightfall.epics.widgets.label import PVLabel
|
|
28
|
+
from lightfall.epics.widgets.lineedit import PVLineEdit
|
|
29
|
+
from lightfall.epics.widgets.status_indicator import StatusIndicator
|
|
30
|
+
from lightfall.epics.widgets.style import (
|
|
31
|
+
get_error_color,
|
|
32
|
+
get_success_color,
|
|
33
|
+
get_warning_color,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class PVMotor(QWidget):
|
|
38
|
+
"""
|
|
39
|
+
A comprehensive motor control widget for EPICS motor records.
|
|
40
|
+
|
|
41
|
+
The widget provides a simple, focused interface with:
|
|
42
|
+
- Current position readback (RBV)
|
|
43
|
+
- Setpoint entry (VAL)
|
|
44
|
+
- Tweak buttons for relative motion (TWF/TWR)
|
|
45
|
+
- Status indicators for moving, limits, and direction
|
|
46
|
+
- Stop button
|
|
47
|
+
- Units display
|
|
48
|
+
|
|
49
|
+
An expandable "Advanced" section provides:
|
|
50
|
+
- Velocity control
|
|
51
|
+
- Acceleration settings
|
|
52
|
+
- Soft limit display/control
|
|
53
|
+
- Additional status information
|
|
54
|
+
|
|
55
|
+
Attributes:
|
|
56
|
+
prefix: The motor record PV prefix (e.g., "IOC:m1").
|
|
57
|
+
connected: Whether all essential PVs are connected.
|
|
58
|
+
|
|
59
|
+
Signals:
|
|
60
|
+
connection_changed: Emitted when overall connection state changes.
|
|
61
|
+
motion_started: Emitted when motor starts moving.
|
|
62
|
+
motion_finished: Emitted when motor stops moving.
|
|
63
|
+
limit_hit: Emitted when a limit switch is triggered.
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
>>> motor = PVMotor("IOC:m1")
|
|
67
|
+
>>> motor.show()
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
widget_type: ClassVar[str] = "PVMotor"
|
|
71
|
+
widget_description: ClassVar[str] = "Motor record control with position, status, and tweak controls"
|
|
72
|
+
|
|
73
|
+
connection_changed = Signal(bool)
|
|
74
|
+
motion_started = Signal()
|
|
75
|
+
motion_finished = Signal()
|
|
76
|
+
limit_hit = Signal(str) # "high" or "low"
|
|
77
|
+
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
prefix: str = "",
|
|
81
|
+
parent: QWidget | None = None,
|
|
82
|
+
) -> None:
|
|
83
|
+
"""
|
|
84
|
+
Initialize the motor widget.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
prefix: The EPICS motor record prefix (e.g., "IOC:m1").
|
|
88
|
+
parent: Optional Qt parent widget.
|
|
89
|
+
"""
|
|
90
|
+
super().__init__(parent)
|
|
91
|
+
self._prefix = prefix
|
|
92
|
+
self._pvs: dict[str, Any] = {}
|
|
93
|
+
self._values: dict[str, Any] = {}
|
|
94
|
+
self._connected_pvs: set[str] = set()
|
|
95
|
+
self._was_moving = False
|
|
96
|
+
|
|
97
|
+
self._setup_ui()
|
|
98
|
+
self.setToolTip(prefix)
|
|
99
|
+
|
|
100
|
+
# Defer PV connection to allow GUI to show first
|
|
101
|
+
if prefix:
|
|
102
|
+
QTimer.singleShot(0, self._connect_pvs)
|
|
103
|
+
|
|
104
|
+
@Property(str)
|
|
105
|
+
def prefix(self) -> str:
|
|
106
|
+
"""The motor record PV prefix."""
|
|
107
|
+
return self._prefix
|
|
108
|
+
|
|
109
|
+
@prefix.setter
|
|
110
|
+
def prefix(self, value: str) -> None:
|
|
111
|
+
if value != self._prefix:
|
|
112
|
+
self._disconnect_pvs()
|
|
113
|
+
self._prefix = value
|
|
114
|
+
self.setToolTip(value)
|
|
115
|
+
if value:
|
|
116
|
+
self._connect_pvs()
|
|
117
|
+
|
|
118
|
+
def _setup_ui(self) -> None:
|
|
119
|
+
"""Create the widget UI."""
|
|
120
|
+
main_layout = QVBoxLayout(self)
|
|
121
|
+
main_layout.setContentsMargins(8, 8, 8, 8)
|
|
122
|
+
main_layout.setSpacing(8)
|
|
123
|
+
|
|
124
|
+
# === Top Status Bar ===
|
|
125
|
+
status_bar = QHBoxLayout()
|
|
126
|
+
status_bar.setSpacing(12)
|
|
127
|
+
|
|
128
|
+
# Connection indicator
|
|
129
|
+
self._conn_indicator = StatusIndicator(size=16)
|
|
130
|
+
self._conn_label = QLabel("Disconnected")
|
|
131
|
+
status_bar.addWidget(self._conn_indicator)
|
|
132
|
+
status_bar.addWidget(self._conn_label)
|
|
133
|
+
status_bar.addStretch()
|
|
134
|
+
|
|
135
|
+
# Direction indicator
|
|
136
|
+
self._dir_label = QLabel("\u2b24") # Will show arrow
|
|
137
|
+
self._dir_label.setToolTip("Direction of travel")
|
|
138
|
+
status_bar.addWidget(self._dir_label)
|
|
139
|
+
|
|
140
|
+
# Moving indicator
|
|
141
|
+
self._moving_indicator = StatusIndicator(size=16)
|
|
142
|
+
self._moving_label = QLabel("Idle")
|
|
143
|
+
status_bar.addWidget(self._moving_indicator)
|
|
144
|
+
status_bar.addWidget(self._moving_label)
|
|
145
|
+
|
|
146
|
+
main_layout.addLayout(status_bar)
|
|
147
|
+
|
|
148
|
+
# === Position Display ===
|
|
149
|
+
pos_group = QGroupBox("Position")
|
|
150
|
+
pos_layout = QGridLayout(pos_group)
|
|
151
|
+
pos_layout.setSpacing(8)
|
|
152
|
+
|
|
153
|
+
# Readback (RBV) - prominent display
|
|
154
|
+
pos_layout.addWidget(QLabel("Readback:"), 0, 0)
|
|
155
|
+
self._rbv_display = PVLabel(show_units=True)
|
|
156
|
+
self._rbv_display.setStyleSheet("""
|
|
157
|
+
QLabel {
|
|
158
|
+
font-size: 18pt;
|
|
159
|
+
font-weight: bold;
|
|
160
|
+
font-family: monospace;
|
|
161
|
+
padding: 4px 8px;
|
|
162
|
+
}
|
|
163
|
+
""")
|
|
164
|
+
pos_layout.addWidget(self._rbv_display, 0, 1, 1, 2)
|
|
165
|
+
|
|
166
|
+
# Setpoint (VAL) - editable
|
|
167
|
+
pos_layout.addWidget(QLabel("Setpoint:"), 1, 0)
|
|
168
|
+
self._setpoint_edit = PVLineEdit(
|
|
169
|
+
show_units=False, write_on_enter=True,
|
|
170
|
+
)
|
|
171
|
+
self._setpoint_edit._line_edit.setPlaceholderText("Enter position")
|
|
172
|
+
self._setpoint_edit._line_edit.returnPressed.connect(self._on_setpoint_enter)
|
|
173
|
+
pos_layout.addWidget(self._setpoint_edit, 1, 1)
|
|
174
|
+
|
|
175
|
+
# Go button
|
|
176
|
+
self._go_btn = QPushButton("Go")
|
|
177
|
+
self._go_btn.setFixedWidth(50)
|
|
178
|
+
self._go_btn.clicked.connect(self._on_go_clicked)
|
|
179
|
+
pos_layout.addWidget(self._go_btn, 1, 2)
|
|
180
|
+
|
|
181
|
+
main_layout.addWidget(pos_group)
|
|
182
|
+
|
|
183
|
+
# === Tweak Controls (Relative Motion) ===
|
|
184
|
+
tweak_group = QGroupBox("Relative Motion")
|
|
185
|
+
tweak_layout = QHBoxLayout(tweak_group)
|
|
186
|
+
tweak_layout.setSpacing(8)
|
|
187
|
+
|
|
188
|
+
# Tweak reverse button
|
|
189
|
+
self._twr_btn = QPushButton("\u25c0")
|
|
190
|
+
self._twr_btn.setToolTip("Tweak Reverse (TWR)")
|
|
191
|
+
self._twr_btn.setFixedWidth(40)
|
|
192
|
+
self._twr_btn.clicked.connect(self._on_tweak_reverse)
|
|
193
|
+
tweak_layout.addWidget(self._twr_btn)
|
|
194
|
+
|
|
195
|
+
# Tweak step size
|
|
196
|
+
self._tweak_edit = PVLineEdit(
|
|
197
|
+
show_units=False, write_on_enter=True, write_on_focus_out=True,
|
|
198
|
+
)
|
|
199
|
+
self._tweak_edit.setToolTip("Tweak step size (TWV)")
|
|
200
|
+
self._tweak_edit.setMaximumWidth(80)
|
|
201
|
+
tweak_layout.addWidget(self._tweak_edit)
|
|
202
|
+
|
|
203
|
+
# Tweak forward button
|
|
204
|
+
self._twf_btn = QPushButton("\u25b6")
|
|
205
|
+
self._twf_btn.setToolTip("Tweak Forward (TWF)")
|
|
206
|
+
self._twf_btn.setFixedWidth(40)
|
|
207
|
+
self._twf_btn.clicked.connect(self._on_tweak_forward)
|
|
208
|
+
tweak_layout.addWidget(self._twf_btn)
|
|
209
|
+
|
|
210
|
+
tweak_layout.addStretch()
|
|
211
|
+
|
|
212
|
+
main_layout.addWidget(tweak_group)
|
|
213
|
+
|
|
214
|
+
# === Limit Indicators ===
|
|
215
|
+
limit_layout = QHBoxLayout()
|
|
216
|
+
limit_layout.setSpacing(16)
|
|
217
|
+
|
|
218
|
+
# Low limit
|
|
219
|
+
self._lls_indicator = StatusIndicator(size=16)
|
|
220
|
+
lls_label = QLabel("Low Limit")
|
|
221
|
+
limit_layout.addWidget(self._lls_indicator)
|
|
222
|
+
limit_layout.addWidget(lls_label)
|
|
223
|
+
|
|
224
|
+
limit_layout.addStretch()
|
|
225
|
+
|
|
226
|
+
# High limit
|
|
227
|
+
self._hls_indicator = StatusIndicator(size=16)
|
|
228
|
+
hls_label = QLabel("High Limit")
|
|
229
|
+
limit_layout.addWidget(self._hls_indicator)
|
|
230
|
+
limit_layout.addWidget(hls_label)
|
|
231
|
+
|
|
232
|
+
main_layout.addLayout(limit_layout)
|
|
233
|
+
|
|
234
|
+
# === Control Buttons ===
|
|
235
|
+
btn_layout = QHBoxLayout()
|
|
236
|
+
btn_layout.setSpacing(8)
|
|
237
|
+
|
|
238
|
+
# Stop button (prominent)
|
|
239
|
+
self._stop_btn = QPushButton("STOP")
|
|
240
|
+
self._stop_btn.setStyleSheet(f"""
|
|
241
|
+
QPushButton {{
|
|
242
|
+
background-color: {get_error_color()};
|
|
243
|
+
color: white;
|
|
244
|
+
font-weight: bold;
|
|
245
|
+
padding: 8px 16px;
|
|
246
|
+
border-radius: 4px;
|
|
247
|
+
}}
|
|
248
|
+
QPushButton:hover {{
|
|
249
|
+
background-color: #ff0000;
|
|
250
|
+
}}
|
|
251
|
+
QPushButton:pressed {{
|
|
252
|
+
background-color: #990000;
|
|
253
|
+
}}
|
|
254
|
+
""")
|
|
255
|
+
self._stop_btn.clicked.connect(self._on_stop_clicked)
|
|
256
|
+
btn_layout.addWidget(self._stop_btn)
|
|
257
|
+
|
|
258
|
+
btn_layout.addStretch()
|
|
259
|
+
|
|
260
|
+
# Enable checkbox (using button for clarity)
|
|
261
|
+
self._enable_btn = QPushButton("Enabled")
|
|
262
|
+
self._enable_btn.setCheckable(True)
|
|
263
|
+
self._enable_btn.setChecked(True)
|
|
264
|
+
self._enable_btn.clicked.connect(self._on_enable_toggled)
|
|
265
|
+
btn_layout.addWidget(self._enable_btn)
|
|
266
|
+
|
|
267
|
+
main_layout.addLayout(btn_layout)
|
|
268
|
+
|
|
269
|
+
# === Advanced Section (Progressive Disclosure) ===
|
|
270
|
+
self._advanced_btn = QPushButton("\u25b6 Advanced")
|
|
271
|
+
self._advanced_btn.setFlat(True)
|
|
272
|
+
self._advanced_btn.setCheckable(True)
|
|
273
|
+
self._advanced_btn.clicked.connect(self._toggle_advanced)
|
|
274
|
+
main_layout.addWidget(self._advanced_btn)
|
|
275
|
+
|
|
276
|
+
self._advanced_group = QGroupBox()
|
|
277
|
+
self._advanced_group.setVisible(False)
|
|
278
|
+
advanced_layout = QGridLayout(self._advanced_group)
|
|
279
|
+
advanced_layout.setSpacing(8)
|
|
280
|
+
|
|
281
|
+
# Velocity
|
|
282
|
+
advanced_layout.addWidget(QLabel("Velocity:"), 0, 0)
|
|
283
|
+
self._velo_edit = PVLineEdit(
|
|
284
|
+
show_units=False, write_on_enter=True, write_on_focus_out=True,
|
|
285
|
+
)
|
|
286
|
+
advanced_layout.addWidget(self._velo_edit, 0, 1)
|
|
287
|
+
self._velo_units = QLabel("units/s")
|
|
288
|
+
advanced_layout.addWidget(self._velo_units, 0, 2)
|
|
289
|
+
|
|
290
|
+
# Acceleration
|
|
291
|
+
advanced_layout.addWidget(QLabel("Accel Time:"), 1, 0)
|
|
292
|
+
self._accl_edit = PVLineEdit(
|
|
293
|
+
show_units=False, write_on_enter=True, write_on_focus_out=True,
|
|
294
|
+
)
|
|
295
|
+
advanced_layout.addWidget(self._accl_edit, 1, 1)
|
|
296
|
+
advanced_layout.addWidget(QLabel("sec"), 1, 2)
|
|
297
|
+
|
|
298
|
+
# Soft limits (display only in basic mode)
|
|
299
|
+
advanced_layout.addWidget(QLabel("Low Limit:"), 2, 0)
|
|
300
|
+
self._llm_display = QLabel("---")
|
|
301
|
+
advanced_layout.addWidget(self._llm_display, 2, 1)
|
|
302
|
+
|
|
303
|
+
advanced_layout.addWidget(QLabel("High Limit:"), 3, 0)
|
|
304
|
+
self._hlm_display = QLabel("---")
|
|
305
|
+
advanced_layout.addWidget(self._hlm_display, 3, 1)
|
|
306
|
+
|
|
307
|
+
# Motor status (MSTA) breakdown
|
|
308
|
+
advanced_layout.addWidget(QLabel("Status:"), 4, 0)
|
|
309
|
+
self._msta_display = QLabel("---")
|
|
310
|
+
self._msta_display.setWordWrap(True)
|
|
311
|
+
advanced_layout.addWidget(self._msta_display, 4, 1, 1, 2)
|
|
312
|
+
|
|
313
|
+
main_layout.addWidget(self._advanced_group)
|
|
314
|
+
|
|
315
|
+
main_layout.addStretch()
|
|
316
|
+
|
|
317
|
+
# Initial state
|
|
318
|
+
self._update_connection_display(False)
|
|
319
|
+
self._set_controls_enabled(False)
|
|
320
|
+
|
|
321
|
+
def _toggle_advanced(self) -> None:
|
|
322
|
+
"""Toggle the advanced section visibility."""
|
|
323
|
+
visible = self._advanced_btn.isChecked()
|
|
324
|
+
self._advanced_group.setVisible(visible)
|
|
325
|
+
self._advanced_btn.setText("\u25bc Advanced" if visible else "\u25b6 Advanced")
|
|
326
|
+
|
|
327
|
+
def _connect_pvs(self) -> None:
|
|
328
|
+
"""Connect to all motor record PVs."""
|
|
329
|
+
if not self._prefix:
|
|
330
|
+
return
|
|
331
|
+
|
|
332
|
+
from lightfall.epics.ca.pv import PV
|
|
333
|
+
|
|
334
|
+
# PV widgets handle their own connections
|
|
335
|
+
self._rbv_display.pv_name = f"{self._prefix}.RBV"
|
|
336
|
+
self._setpoint_edit.pv_name = f"{self._prefix}.VAL"
|
|
337
|
+
self._tweak_edit.pv_name = f"{self._prefix}.TWV"
|
|
338
|
+
self._velo_edit.pv_name = f"{self._prefix}.VELO"
|
|
339
|
+
self._accl_edit.pv_name = f"{self._prefix}.ACCL"
|
|
340
|
+
|
|
341
|
+
# Listen for widget connection changes to update overall status
|
|
342
|
+
self._rbv_display.connection_changed.connect(self._on_widget_connection_changed)
|
|
343
|
+
self._setpoint_edit.connection_changed.connect(self._on_widget_connection_changed)
|
|
344
|
+
|
|
345
|
+
# Manually managed PVs for status, limits, and control
|
|
346
|
+
pv_fields = {
|
|
347
|
+
"TWF": "tweak_fwd", # Tweak forward
|
|
348
|
+
"TWR": "tweak_rev", # Tweak reverse
|
|
349
|
+
"MOVN": "moving", # Motor is moving
|
|
350
|
+
"DMOV": "done_moving", # Done moving
|
|
351
|
+
"HLS": "high_limit", # At high limit switch
|
|
352
|
+
"LLS": "low_limit", # At low limit switch
|
|
353
|
+
"TDIR": "direction", # Direction of travel
|
|
354
|
+
"STOP": "stop", # Stop motor
|
|
355
|
+
"SPMG": "spmg", # Stop/Pause/Move/Go
|
|
356
|
+
# Advanced
|
|
357
|
+
"HLM": "high_lim_val", # High soft limit
|
|
358
|
+
"LLM": "low_lim_val", # Low soft limit
|
|
359
|
+
"MSTA": "msta", # Motor status word
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
for field, name in pv_fields.items():
|
|
363
|
+
pv_name = f"{self._prefix}.{field}"
|
|
364
|
+
pv = PV(pv_name, parent=self)
|
|
365
|
+
pv.value_changed.connect(lambda v, n=name: self._on_pv_value(n, v))
|
|
366
|
+
pv.connection_changed.connect(lambda c, n=name: self._on_pv_connection(n, c))
|
|
367
|
+
pv.connect_pv()
|
|
368
|
+
self._pvs[name] = pv
|
|
369
|
+
|
|
370
|
+
def _disconnect_pvs(self) -> None:
|
|
371
|
+
"""Disconnect all PVs."""
|
|
372
|
+
# Disconnect widget connection signals
|
|
373
|
+
try:
|
|
374
|
+
self._rbv_display.connection_changed.disconnect(self._on_widget_connection_changed)
|
|
375
|
+
self._setpoint_edit.connection_changed.disconnect(self._on_widget_connection_changed)
|
|
376
|
+
except RuntimeError:
|
|
377
|
+
pass # Already disconnected
|
|
378
|
+
|
|
379
|
+
# Disconnect PV widgets
|
|
380
|
+
self._rbv_display.pv_name = ""
|
|
381
|
+
self._setpoint_edit.pv_name = ""
|
|
382
|
+
self._tweak_edit.pv_name = ""
|
|
383
|
+
self._velo_edit.pv_name = ""
|
|
384
|
+
self._accl_edit.pv_name = ""
|
|
385
|
+
|
|
386
|
+
# Disconnect manually managed PVs
|
|
387
|
+
for pv in self._pvs.values():
|
|
388
|
+
pv.disconnect_pv()
|
|
389
|
+
pv.deleteLater()
|
|
390
|
+
self._pvs.clear()
|
|
391
|
+
self._connected_pvs.clear()
|
|
392
|
+
self._values.clear()
|
|
393
|
+
self._update_connection_display(False)
|
|
394
|
+
|
|
395
|
+
@Slot(str, object)
|
|
396
|
+
def _on_pv_value(self, name: str, value: Any) -> None:
|
|
397
|
+
"""Handle PV value updates for manually managed PVs."""
|
|
398
|
+
if hasattr(value, "__len__") and not isinstance(value, (str, bytes)):
|
|
399
|
+
if len(value) == 1:
|
|
400
|
+
value = value[0]
|
|
401
|
+
|
|
402
|
+
self._values[name] = value
|
|
403
|
+
|
|
404
|
+
if name == "moving":
|
|
405
|
+
self._update_moving_status()
|
|
406
|
+
elif name == "done_moving":
|
|
407
|
+
self._update_done_moving()
|
|
408
|
+
elif name == "high_limit":
|
|
409
|
+
self._update_limit_indicators()
|
|
410
|
+
elif name == "low_limit":
|
|
411
|
+
self._update_limit_indicators()
|
|
412
|
+
elif name == "direction":
|
|
413
|
+
self._update_direction()
|
|
414
|
+
elif name == "high_lim_val":
|
|
415
|
+
self._hlm_display.setText(f"{value:.3f}")
|
|
416
|
+
elif name == "low_lim_val":
|
|
417
|
+
self._llm_display.setText(f"{value:.3f}")
|
|
418
|
+
elif name == "msta":
|
|
419
|
+
self._update_msta_display()
|
|
420
|
+
elif name == "spmg":
|
|
421
|
+
self._update_enable_button()
|
|
422
|
+
|
|
423
|
+
@Slot(bool)
|
|
424
|
+
def _on_widget_connection_changed(self, _connected: bool) -> None:
|
|
425
|
+
"""Handle connection changes from PV widgets."""
|
|
426
|
+
self._check_overall_connection()
|
|
427
|
+
|
|
428
|
+
@Slot(str, bool)
|
|
429
|
+
def _on_pv_connection(self, name: str, connected: bool) -> None:
|
|
430
|
+
"""Handle PV connection state changes for manually managed PVs."""
|
|
431
|
+
if connected:
|
|
432
|
+
self._connected_pvs.add(name)
|
|
433
|
+
else:
|
|
434
|
+
self._connected_pvs.discard(name)
|
|
435
|
+
|
|
436
|
+
self._check_overall_connection()
|
|
437
|
+
|
|
438
|
+
def _check_overall_connection(self) -> None:
|
|
439
|
+
"""Check that essential PVs are connected (both widget-managed and manual)."""
|
|
440
|
+
widgets_connected = (
|
|
441
|
+
self._rbv_display.connected
|
|
442
|
+
and self._setpoint_edit.connected
|
|
443
|
+
)
|
|
444
|
+
manual_connected = "moving" in self._connected_pvs
|
|
445
|
+
is_connected = widgets_connected and manual_connected
|
|
446
|
+
self._update_connection_display(is_connected)
|
|
447
|
+
self._set_controls_enabled(is_connected)
|
|
448
|
+
|
|
449
|
+
def _update_connection_display(self, connected: bool) -> None:
|
|
450
|
+
"""Update connection status display."""
|
|
451
|
+
if connected:
|
|
452
|
+
self._conn_indicator.set_state("on")
|
|
453
|
+
self._conn_label.setText("Connected")
|
|
454
|
+
else:
|
|
455
|
+
self._conn_indicator.set_state("off")
|
|
456
|
+
self._conn_label.setText("Disconnected")
|
|
457
|
+
self.connection_changed.emit(connected)
|
|
458
|
+
|
|
459
|
+
def _set_controls_enabled(self, enabled: bool) -> None:
|
|
460
|
+
"""Enable/disable control widgets."""
|
|
461
|
+
# PV widgets use readonly property
|
|
462
|
+
self._setpoint_edit.readonly = not enabled
|
|
463
|
+
self._tweak_edit.readonly = not enabled
|
|
464
|
+
self._velo_edit.readonly = not enabled
|
|
465
|
+
self._accl_edit.readonly = not enabled
|
|
466
|
+
|
|
467
|
+
# Regular Qt widgets use setEnabled
|
|
468
|
+
self._go_btn.setEnabled(enabled)
|
|
469
|
+
self._twf_btn.setEnabled(enabled)
|
|
470
|
+
self._twr_btn.setEnabled(enabled)
|
|
471
|
+
self._stop_btn.setEnabled(enabled)
|
|
472
|
+
self._enable_btn.setEnabled(enabled)
|
|
473
|
+
|
|
474
|
+
def _update_moving_status(self) -> None:
|
|
475
|
+
moving = bool(self._values.get("moving", 0))
|
|
476
|
+
if moving:
|
|
477
|
+
self._moving_indicator.set_state("on")
|
|
478
|
+
self._moving_label.setText("Moving")
|
|
479
|
+
if not self._was_moving:
|
|
480
|
+
self.motion_started.emit()
|
|
481
|
+
else:
|
|
482
|
+
self._moving_indicator.set_state("off")
|
|
483
|
+
self._moving_label.setText("Idle")
|
|
484
|
+
if self._was_moving:
|
|
485
|
+
self.motion_finished.emit()
|
|
486
|
+
self._was_moving = moving
|
|
487
|
+
|
|
488
|
+
def _update_done_moving(self) -> None:
|
|
489
|
+
dmov = bool(self._values.get("done_moving", 1))
|
|
490
|
+
if dmov and self._was_moving:
|
|
491
|
+
self._moving_indicator.set_state("off")
|
|
492
|
+
self._moving_label.setText("Idle")
|
|
493
|
+
self._was_moving = False
|
|
494
|
+
self.motion_finished.emit()
|
|
495
|
+
|
|
496
|
+
def _update_limit_indicators(self) -> None:
|
|
497
|
+
hls = bool(self._values.get("high_limit", 0))
|
|
498
|
+
lls = bool(self._values.get("low_limit", 0))
|
|
499
|
+
self._hls_indicator.set_state("error" if hls else "off")
|
|
500
|
+
self._lls_indicator.set_state("error" if lls else "off")
|
|
501
|
+
if hls:
|
|
502
|
+
self.limit_hit.emit("high")
|
|
503
|
+
if lls:
|
|
504
|
+
self.limit_hit.emit("low")
|
|
505
|
+
|
|
506
|
+
def _update_direction(self) -> None:
|
|
507
|
+
tdir = self._values.get("direction", 0)
|
|
508
|
+
if tdir:
|
|
509
|
+
self._dir_label.setText("\u25b2")
|
|
510
|
+
self._dir_label.setStyleSheet(f"color: {get_success_color()};")
|
|
511
|
+
else:
|
|
512
|
+
self._dir_label.setText("\u25bc")
|
|
513
|
+
self._dir_label.setStyleSheet(f"color: {get_warning_color()};")
|
|
514
|
+
|
|
515
|
+
def _update_msta_display(self) -> None:
|
|
516
|
+
msta = self._values.get("msta", 0)
|
|
517
|
+
if isinstance(msta, (list, tuple)):
|
|
518
|
+
msta = msta[0] if msta else 0
|
|
519
|
+
status_bits = []
|
|
520
|
+
if msta & 0x0001:
|
|
521
|
+
status_bits.append("Direction")
|
|
522
|
+
if msta & 0x0002:
|
|
523
|
+
status_bits.append("Done")
|
|
524
|
+
if msta & 0x0004:
|
|
525
|
+
status_bits.append("+Limit")
|
|
526
|
+
if msta & 0x0008:
|
|
527
|
+
status_bits.append("Home")
|
|
528
|
+
if msta & 0x0020:
|
|
529
|
+
status_bits.append("Closed-loop")
|
|
530
|
+
if msta & 0x0040:
|
|
531
|
+
status_bits.append("Slip/Stall")
|
|
532
|
+
if msta & 0x0080:
|
|
533
|
+
status_bits.append("Home switch")
|
|
534
|
+
if msta & 0x0100:
|
|
535
|
+
status_bits.append("Encoder")
|
|
536
|
+
if msta & 0x0200:
|
|
537
|
+
status_bits.append("Problem")
|
|
538
|
+
if msta & 0x0400:
|
|
539
|
+
status_bits.append("Moving")
|
|
540
|
+
if msta & 0x0800:
|
|
541
|
+
status_bits.append("Gain support")
|
|
542
|
+
if msta & 0x1000:
|
|
543
|
+
status_bits.append("Comm error")
|
|
544
|
+
if msta & 0x2000:
|
|
545
|
+
status_bits.append("-Limit")
|
|
546
|
+
if msta & 0x4000:
|
|
547
|
+
status_bits.append("Homed")
|
|
548
|
+
self._msta_display.setText(", ".join(status_bits) if status_bits else "OK")
|
|
549
|
+
|
|
550
|
+
def _update_enable_button(self) -> None:
|
|
551
|
+
spmg = self._values.get("spmg", 3)
|
|
552
|
+
enabled = spmg >= 2
|
|
553
|
+
self._enable_btn.blockSignals(True)
|
|
554
|
+
self._enable_btn.setChecked(enabled)
|
|
555
|
+
self._enable_btn.setText("Enabled" if enabled else "Disabled")
|
|
556
|
+
self._enable_btn.blockSignals(False)
|
|
557
|
+
|
|
558
|
+
# === User Actions ===
|
|
559
|
+
|
|
560
|
+
def _on_setpoint_enter(self) -> None:
|
|
561
|
+
self._on_go_clicked()
|
|
562
|
+
|
|
563
|
+
def _on_go_clicked(self) -> None:
|
|
564
|
+
try:
|
|
565
|
+
value = float(self._setpoint_edit._line_edit.text())
|
|
566
|
+
self._setpoint_edit.write_value(value)
|
|
567
|
+
except (ValueError, RuntimeError):
|
|
568
|
+
pass
|
|
569
|
+
|
|
570
|
+
def _on_tweak_forward(self) -> None:
|
|
571
|
+
if "tweak_fwd" in self._pvs:
|
|
572
|
+
self._pvs["tweak_fwd"].put(1)
|
|
573
|
+
self._do_relative_move(1)
|
|
574
|
+
|
|
575
|
+
def _on_tweak_reverse(self) -> None:
|
|
576
|
+
if "tweak_rev" in self._pvs:
|
|
577
|
+
self._pvs["tweak_rev"].put(1)
|
|
578
|
+
self._do_relative_move(-1)
|
|
579
|
+
|
|
580
|
+
def _do_relative_move(self, direction: int) -> None:
|
|
581
|
+
try:
|
|
582
|
+
tweak_val = float(self._tweak_edit._line_edit.text())
|
|
583
|
+
except ValueError:
|
|
584
|
+
tweak_val = 1.0
|
|
585
|
+
current = self._rbv_display._value
|
|
586
|
+
if current is None:
|
|
587
|
+
current = 0.0
|
|
588
|
+
new_pos = current + (direction * tweak_val)
|
|
589
|
+
try:
|
|
590
|
+
self._setpoint_edit.write_value(new_pos)
|
|
591
|
+
except RuntimeError:
|
|
592
|
+
pass
|
|
593
|
+
|
|
594
|
+
def _on_stop_clicked(self) -> None:
|
|
595
|
+
if "stop" in self._pvs:
|
|
596
|
+
self._pvs["stop"].put(1)
|
|
597
|
+
|
|
598
|
+
def _on_enable_toggled(self, checked: bool) -> None:
|
|
599
|
+
if "spmg" in self._pvs:
|
|
600
|
+
self._pvs["spmg"].put(3 if checked else 0)
|
|
601
|
+
|
|
602
|
+
# === Public API ===
|
|
603
|
+
|
|
604
|
+
def move_to(self, position: float) -> None:
|
|
605
|
+
try:
|
|
606
|
+
self._setpoint_edit.write_value(position)
|
|
607
|
+
except RuntimeError:
|
|
608
|
+
pass
|
|
609
|
+
|
|
610
|
+
def move_relative(self, distance: float) -> None:
|
|
611
|
+
current = self._rbv_display._value
|
|
612
|
+
if current is None:
|
|
613
|
+
current = 0.0
|
|
614
|
+
self.move_to(current + distance)
|
|
615
|
+
|
|
616
|
+
def stop(self) -> None:
|
|
617
|
+
self._on_stop_clicked()
|
|
618
|
+
|
|
619
|
+
def tweak_forward(self) -> None:
|
|
620
|
+
self._on_tweak_forward()
|
|
621
|
+
|
|
622
|
+
def tweak_reverse(self) -> None:
|
|
623
|
+
self._on_tweak_reverse()
|
|
624
|
+
|
|
625
|
+
@property
|
|
626
|
+
def position(self) -> float | None:
|
|
627
|
+
return self._rbv_display._value
|
|
628
|
+
|
|
629
|
+
@property
|
|
630
|
+
def setpoint(self) -> float | None:
|
|
631
|
+
return self._setpoint_edit._value
|
|
632
|
+
|
|
633
|
+
@property
|
|
634
|
+
def is_moving(self) -> bool:
|
|
635
|
+
return bool(self._values.get("moving", 0))
|
|
636
|
+
|
|
637
|
+
@property
|
|
638
|
+
def at_high_limit(self) -> bool:
|
|
639
|
+
return bool(self._values.get("high_limit", 0))
|
|
640
|
+
|
|
641
|
+
@property
|
|
642
|
+
def at_low_limit(self) -> bool:
|
|
643
|
+
return bool(self._values.get("low_limit", 0))
|
|
644
|
+
|
|
645
|
+
def get_introspection_data(self) -> dict[str, Any]:
|
|
646
|
+
return {
|
|
647
|
+
"widget_type": self.widget_type,
|
|
648
|
+
"widget_description": self.widget_description,
|
|
649
|
+
"prefix": self._prefix,
|
|
650
|
+
"connected_pvs": list(self._connected_pvs),
|
|
651
|
+
"position": self.position,
|
|
652
|
+
"setpoint": self.setpoint,
|
|
653
|
+
"is_moving": self.is_moving,
|
|
654
|
+
"at_high_limit": self.at_high_limit,
|
|
655
|
+
"at_low_limit": self.at_low_limit,
|
|
656
|
+
"units": self._rbv_display._units,
|
|
657
|
+
"values": dict(self._values),
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
def closeEvent(self, event) -> None:
|
|
661
|
+
self._disconnect_pvs()
|
|
662
|
+
super().closeEvent(event)
|
|
663
|
+
|
|
664
|
+
# -- Tooltip forwarding ---------------------------------------------------
|
|
665
|
+
# Forward ToolTip events from child widgets (which have no tooltip of
|
|
666
|
+
# their own) so hovering any part of the motor widget shows the motor
|
|
667
|
+
# prefix. Child widgets with their own tooltip (e.g. "Tweak Forward")
|
|
668
|
+
# take precedence.
|
|
669
|
+
|
|
670
|
+
def childEvent(self, event) -> None:
|
|
671
|
+
super().childEvent(event)
|
|
672
|
+
if event.type() == QEvent.Type.ChildAdded:
|
|
673
|
+
child = event.child()
|
|
674
|
+
if isinstance(child, QWidget):
|
|
675
|
+
child.installEventFilter(self)
|
|
676
|
+
|
|
677
|
+
def eventFilter(self, obj, event) -> bool:
|
|
678
|
+
if (
|
|
679
|
+
event.type() == QEvent.Type.ToolTip
|
|
680
|
+
and isinstance(obj, QWidget)
|
|
681
|
+
and obj is not self
|
|
682
|
+
and not obj.toolTip()
|
|
683
|
+
):
|
|
684
|
+
tip = self.toolTip()
|
|
685
|
+
if tip:
|
|
686
|
+
from PySide6.QtWidgets import QToolTip
|
|
687
|
+
|
|
688
|
+
try:
|
|
689
|
+
pos = event.globalPos()
|
|
690
|
+
except AttributeError:
|
|
691
|
+
pos = event.globalPosition().toPoint()
|
|
692
|
+
QToolTip.showText(pos, tip, obj)
|
|
693
|
+
return True
|
|
694
|
+
return super().eventFilter(obj, event)
|