Skip to content

Add UI to configure Trigger mode#79

Draft
C-Achard wants to merge 9 commits into
cy/gentl-trigger-configfrom
cy/gentl-trigger-ui
Draft

Add UI to configure Trigger mode#79
C-Achard wants to merge 9 commits into
cy/gentl-trigger-configfrom
cy/gentl-trigger-ui

Conversation

@C-Achard
Copy link
Copy Markdown
Contributor

This pull request adds comprehensive support for configuring hardware trigger and synchronization settings for individual cameras in the camera configuration dialog. It introduces a new TriggerConfigDialog for editing per-camera trigger settings, updates the UI to display trigger roles, and ensures that trigger changes are properly handled and reflected in the camera preview and configuration.

Key changes include:

Hardware Trigger Configuration Support:

  • Added a new TriggerConfigDialog (trigger_config_dialog.py) that allows users to configure per-camera hardware trigger and synchronization settings, such as role, selector, source, activation, output line, output source, timeout, and strict mode. The dialog updates the camera's trigger configuration in a structured and user-friendly way.
  • Integrated the trigger settings dialog into the main camera configuration UI by adding a "Trigger Settings…" button (trigger_settings_btn) and connecting it to open the dialog for the selected camera. [1] [2] [3]

UI and Usability Improvements:

  • Updated the camera list labels to display the current trigger role (e.g., master, follower, external, off) for each camera, improving visibility into camera synchronization status.
  • Automatically initializes default trigger configuration for new and loaded cameras, ensuring consistent and predictable trigger settings. [1] [2] [3]

Configuration and Preview Handling:

  • Added logic to detect changes in trigger settings and require a preview restart if trigger configuration is modified, ensuring that hardware changes are applied immediately. [1] [2]
  • Extended the apply utility to support the new trigger settings button, maintaining consistent UI state management.

These changes collectively provide robust and user-friendly management of hardware trigger and synchronization settings for cameras in the application.

@C-Achard C-Achard requested a review from Copilot May 28, 2026 12:33
@C-Achard C-Achard self-assigned this May 28, 2026
@C-Achard C-Achard added camera Related to cameras and camera backends gui Related to the GUI itself : windows and fields bugs, UI, UX, ... config Related to user configs, oading, saving, etc labels May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds camera-level hardware trigger configuration to the camera configuration dialog, focused on GenTL-backed cameras and preview restart behavior when trigger settings change.

Changes:

  • Adds a new TriggerConfigDialog for editing trigger role, input/output lines, activation, timeout, and strict mode.
  • Adds a “Trigger Settings…” UI button and trigger role indicators in active camera labels.
  • Initializes default GenTL trigger settings and restarts previews when trigger configuration changes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
dlclivegui/gui/camera_config/ui_blocks.py Adds the trigger settings button to the camera settings form.
dlclivegui/gui/camera_config/trigger_config_dialog.py Implements the trigger configuration dialog and persistence into camera backend properties.
dlclivegui/gui/camera_config/camera_config_dialog.py Wires trigger settings into the dialog, labels, defaults, and preview restart logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dlclivegui/gui/camera_config/camera_config_dialog.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread dlclivegui/gui/camera_config/camera_config_dialog.py Outdated
Comment thread dlclivegui/gui/camera_config/trigger_config_dialog.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread dlclivegui/gui/camera_config/trigger_config_dialog.py Outdated
Comment thread dlclivegui/gui/camera_config/camera_config_dialog.py
C-Achard added 5 commits May 29, 2026 10:55
Introduce a TriggerConfigDialog to edit per-camera hardware trigger settings (CameraTriggerSettings). The dialog provides fields for role, selector, source, activation, output line/source, timeout and strict mode, and persists settings into camera.properties[<backend>]['trigger']. Also add a "Trigger Settings…" button to the camera settings UI (disabled by default) with tooltip and icon; wiring to open the dialog can be connected elsewhere.
Introduce support for per-camera hardware trigger configuration in the camera config dialog. Imports TriggerConfigDialog and CameraTriggerSettings, wires the trigger settings button to open a modal, and adds _open_trigger_settings_dialog to commit edits, show the dialog, apply updates, and restart the preview if needed. Adds helpers: _ensure_default_trigger_config to initialize gentl.trigger defaults, _trigger_role_for_label to show trigger role in camera list labels, and _trigger_dict_for_cam to compare trigger settings when deciding to restart previews. Also integrates the hardware trigger field into the settings summary and ensures new/loaded cameras get a default trigger config.
Replace direct checks of self._preview.state == PreviewState.ACTIVE with self._is_preview_live() in camera_config_dialog to centralize preview-active logic and ensure consistent behavior when restarting the preview after trigger or camera setting changes. In trigger_config_dialog, only set payload["timeout"] for external/follower roles when timeout > 0, and explicitly set payload["timeout"] = None when role == "off" to clear any stale timeout when disabling the trigger.
Allow pending preview restarts to proceed when the preview is ACTIVE (previously only IDLE) and return early to avoid double UI sync in camera_config_dialog.py. Also wrap CameraTriggerSettings loading in a try/except and fall back to a default instance when parsing fails, making trigger_config_dialog.py tolerant of malformed or missing trigger data.
@C-Achard C-Achard force-pushed the cy/gentl-trigger-ui branch from 279a952 to 1780065 Compare May 29, 2026 08:55
C-Achard added 4 commits May 29, 2026 11:10
Make trigger dialog friendlier and more robust: recommend using 'auto' for trigger source and switch default/fallback source from "Line0" to "auto", update source placeholder and info/timeout tooltips, and import QMessageBox. Wrap CameraTriggerSettings.from_any in a try/except to show a critical error dialog on failure and abort apply. Store trigger settings via trigger.to_properties() instead of model_dump(exclude_none=True). These changes provide clearer defaults and better error feedback when applying trigger settings.
Introduce WorkerTimingStats (utils/stats.py) to collect simple timing counters (per-named section totals, frame/timeouts/errors) and periodically emit debug logs. Integrate it into SingleCameraWorker: create a timing instance (configurable via new SINGLE_CAMERA_WORKER_DO_LOG_TIMING in config.py), wrap backend.read and frame emit calls with timed sections, and call note_frame/note_timeout/note_error + maybe_log to accumulate and flush stats. Also update imports accordingly and use a 1s default log interval.
Introduce MULTI_CAMERA_WORKER_DO_LOG_TIMING and disable single-worker timing by default (SINGLE_CAMERA_WORKER_DO_LOG_TIMING=false). Add per-camera WorkerTimingStats storage and a _timing_for_camera factory that respects the new config. Wrap _on_frame_captured processing in timed sections (total, apply_transforms, update_latest), call note_frame/maybe_log per camera, and emit frames as before. Also adjust SingleCameraWorker timing labels from GenTL.* to Single.* for clearer logs.
Introduce a human-readable representation for CameraSettings by adding a pretty() method and overriding __str__ and __repr__. The pretty output formats key fields (name, index, backend, enabled, fps, size, exposure, gain, rotation) and displays a readable crop region (showing 'none' or coordinate range with 'edge' fallbacks). This aids debugging and logging without changing existing validation or behavior.
@C-Achard C-Achard requested a review from deruyter92 May 29, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

camera Related to cameras and camera backends config Related to user configs, oading, saving, etc gui Related to the GUI itself : windows and fields bugs, UI, UX, ...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants