Skip to content

feat: centralize INPUT_CHANNEL, fix CA blocking, and consolidate UI theming#70

Merged
pecomyint merged 17 commits into
mainfrom
dev-peco
May 18, 2026
Merged

feat: centralize INPUT_CHANNEL, fix CA blocking, and consolidate UI theming#70
pecomyint merged 17 commits into
mainfrom
dev-peco

Conversation

@pecomyint

@pecomyint pecomyint commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Centralize PV input channel with cross-process persistence. INPUT_CHANNEL is now derived from DETECTOR_PREFIX (e.g. {prefix}:Pva1:Image) and persisted across viewer processes via a state file. Stats and ROI PVs are constructed from the same prefix. Once set — whether from TOML, DB profile, or typed manually — the channel persists across all viewers without retyping.

  • Move CA monitors to a background thread. ROI, Stats, and Metadata CA monitors previously ran sequentially on the main GUI thread, causing 8+ second freezes when PVs were unreachable. They now run in a CaMonitorWorker(QThread) so the GUI remains responsive during connection.

  • Consolidate UI colors into a centralized theme system. Introduced theme_colors.py as the single source of truth and theme.qss as the global stylesheet. Replaced hardcoded hex values and CSS color keywords ("red", "green", "gray", "orange") across 12+ files with shared constants. ROI overlays use a soft modern palette (coral #E05A5A, ocean #4A90D9, teal #3EAF8E, violet #A878D0) — distinct and readable on dark detector images without the harshness of pure primaries.

  • Improve launcher readability. Renamed "Streaming" section to "Stream Live". Improved contrast on section headers, buttons, and status labels by replacing palette(mid) with palette(dark) / palette(window-text).

  • Fix font sizing and path resolution. Replaced all px font sizes with pt to avoid macOS high-DPI warnings. Fixed sim server and processor file paths after the src/ layout restructure. Fixed /proc/stat error spam on macOS.

Test plan

  • Open launcher — sections say "STREAM LIVE", all text/buttons clearly readable
  • Load TOML → open Area Detector 2D → input channel shows {DETECTOR_PREFIX}:Pva1:Image
  • Type a different channel → close → reopen → channel persisted
  • Start Live View → GUI does not freeze (CA monitors run in background)
  • ROI overlays and Stats buttons show soft modern colors (coral/blue/teal/violet)
  • PVA Workflow Setup → processor file dropdowns show correct src/dashpva/... paths
  • Sim server launches without "can't open file" error
  • Workbench → no /proc/stat error spam in logs on macOS
  • pytest tests/ — 119 tests pass

pecomyint added 10 commits May 13, 2026 15:58
Replace 72 scattered setStyleSheet() calls across 23 files with a
single global stylesheet and shared color/font constants. Standardizes
the palette (6 greens → 1, 7 reds → 1, etc.), establishes a 5-tier
font hierarchy, and uses palette() for dark mode awareness. Strips
hardcoded styles from 4 .ui files. Preserves semantic ROI identity
and HKL axis colors as instrument conventions.
… files

Strip ~50 redundant pointsize declarations from imageshow.ui (all
inherited from root), ~40 from hkl_3d_slice_window.ui, and child
font blocks from 3 other .ui files. Remove restrictive maximumSize
on scroll area (was 425px), stats labels, and Plot Stats buttons.
Relax Start/Stop Live View button minimumSize to prevent text
cropping on resize. Reduce HKL 3D viewer minimum width from 1125
to 600. Total: -641 lines of redundant layout constraints.
Replace all px font-size values with pt in theme.qss and
theme_colors.py to fix QFont::setPointSizeF warnings on macOS
high-DPI displays. Add spacer to exit/shutdown QMessageBox
dialogs to prevent text cropping.
Eliminates QFont::setPointSizeF warnings on macOS high-DPI by
converting every font-size from px to pt in launcher.ui, dashpva.ui,
update_dialog.ui, settings_dialog.ui, workbench.ui, workflow.ui,
bayesian_viewer.py, and documentation/dialog.py.
- Add INPUT_CHANNEL to settings.py with get_input_channel() that
  derives from DETECTOR_PREFIX when not explicitly set
- Add save_input_channel() to persist overrides to active config
- Persist locator to .dashpva_locator so sibling subprocesses
  (launcher → workflow → viewer) share the active config
- Fix DbProfileConfigSource.save() to merge instead of replace
- Wire ConfigDialog in area_det_viewer and hkl_3d_viewer to
  read/save channel via settings
- Update vit_viewer and scan_view to use settings fallback
- Clear hardcoded default in pv_config.ui
- Fix launcher exit to kill process groups via os.killpg
- Resolve sim server path relative to PROJECT_ROOT and use
  sys.executable instead of bare 'python'
- Add 9 new tests for state file fallback, get_input_channel,
  and save_input_channel round-trip persistence
- Fix test isolation: neutralize _STATE_FILE and DB fallback
  in isolated_settings fixture
ROI, Stats, and Metadata CA monitors now execute in a CaMonitorWorker
QThread instead of blocking the main thread during start_live_view.
- Rename Streaming → Stream Live in launcher registry
- Improve launcher text/button contrast (palette(mid) → palette(dark))
- Add ROI_COLORS, ROI_STATS_COLORS, LOG_* to theme_colors.py
- Soften ROI palette (coral/ocean/teal/violet) across theme.qss and Python
- Replace hardcoded color keywords (green/red/gray/orange) with constants
- Reuse status palette for log and workflow output formatting
- Wrap /proc/stat read in try/except so workbench doesn't spam errors on macOS
- Fix processor file combo paths to include src/dashpva/ prefix so launches
  resolve correctly from PROJECT_ROOT after the src layout restructure
@pecomyint pecomyint requested a review from Osayi-ANL May 14, 2026 03:43

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice change

@Osayi-ANL Osayi-ANL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • ROI and Stats does not get plotted in the area detector or being calculated
  • The channel input persistence for the HKL3D and Area Detector are connected so it updates both. Disconnect it so that one doesnt update the other
  • The analysis processor gives an error
    2026-05-14 17:15:50,316 HpcRsmProcessor ERROR: Frame processing error Traceback (most recent call last): File "/home/beams0/OODIASEIGIEHON/DashPVA/src/dashpva/consumers/hpc/analysis/hpc_rsm_consumer.py", line 397, in process 'parameters': self.codec_parameters}, ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'HpcRsmProcessor' object has no attribute 'codec_parameters'
  • The HKL3D Start and Stop Live View text in the buttons are still cut off - All the buttons and UI colors are good and updated

pecomyint added 6 commits May 15, 2026 13:38
Area Detector dialog now shows "Detector Prefix" instead of "Input Channel",
pre-populates from TOML/DB, and derives the PVA channel automatically.
Prefix changes rewrite ROI/STATS PV names and persist to the config source.
HKL 3D dialog unchanged — keeps asking for Input Channel separately.
@pecomyint

pecomyint commented May 15, 2026

Copy link
Copy Markdown
Collaborator Author

Review Items Addressed

1. ROI/Stats not plotting: ConfigDialog now asks for Detector Prefix (not Input Channel). It pre-populates from the loaded profile and auto-derives the PVA channel. ROI/Stats PV names update when prefix changes.

2. HKL3D/Area Detector channel linked: Separated — each has its own persisted channel. Changing one no longer affects the other.

3. HpcRsmProcessor AttributeError: Initialized all codec attributes in __init__ with safe defaults.

4. HKL3D button text cut off: Removed fixed widths so buttons expand to fit text.

To test

  • Launch Area Detector → dialog should show "Detector Prefix" pre-filled from your profile
  • Click Stats buttons → should connect to the correct PVs
  • Launch HKL 3D separately → should have its own independent channel
  • Run RSM processor → no more codec_parameters error
  • Check HKL 3D buttons → text fully visible

@pecomyint pecomyint requested a review from Osayi-ANL May 15, 2026 20:59

@Osayi-ANL Osayi-ANL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • hpc_rsm_analysis.pywhen I try to run the analysis

2026-05-15 17:09:30,495 HpcRsmProcessor ERROR: Frame processing error Traceback (most recent call last): File "/path/to/user/DashPVA/src/dashpva/consumers/hpc/analysis/hpc_rsm_consumer.py", line 421, in process rsm_object = {'name': 'RSM', 'value': PvObject({'value': self.type_dict_compressed}, {'value': rsm_data})} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pvaccess.pvaccess.InvalidDataType: Inconsistent data type: expected uint8, found object.

  • Race Condition in area_detector_veiwer.py that doesn't allow for plotting.
    We want to get the ROI's and then draw the rectangles, but sometimes the rectangles are drawn before the ROI values are gotten because the thread didn't finish fast enough, but the add_roi() doesn't get called again to then draw the rectangles again.
    This results in roi not being plotted(my case)

Guard create_rsm() None returns to prevent np.ravel(None) producing
object-dtype arrays. Skip frames before codec/qx are initialized.
Re-add ROIs after CaMonitorWorker finishes fetching values via CA.
@pecomyint

Copy link
Copy Markdown
Collaborator Author

Fixed in cb62a67.

InvalidDataType: Added None guards after create_rsm() and before RSM output — matches your dev-osayi implementation. Frames with missing HKL attributes now skip gracefully instead of hitting np.ravel(None).

ROI race condition: _on_ca_monitors_ready() now re-calls add_rois() after CaMonitorWorker finishes, so rectangles draw with actual values.

@pecomyint pecomyint requested a review from Osayi-ANL May 15, 2026 23:48

@Osayi-ANL Osayi-ANL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice!

@pecomyint pecomyint merged commit 4f5e0d6 into main May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants