Skip to content

feat: allow aliased enum PVs to map values to underlying fastcs PVs - #417

Open
shihab-dls wants to merge 11 commits into
mainfrom
add_enum_mapping
Open

shihab-dls wants to merge 11 commits into
mainfrom
add_enum_mapping

Conversation

@shihab-dls

@shihab-dls shihab-dls commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added support for EPICS aliases backed by enum mappings.
    • Enum mappings translate read, write, and command values between EPICS and application fields.
    • Enum command aliases activate commands only for mapped true values.
    • Controller IDs may now include colons.
  • Bug Fixes
    • Invalid or unmapped enum values now trigger a major alarm without applying the update.
    • Invalid EPICS puts are ignored.
    • Connection state now correctly reports success after connecting.
    • Successful commands clear previously raised alarms.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5dfb0ead-d052-4f5c-abfb-4b0141ebc4c3

📥 Commits

Reviewing files that changed from the base of the PR and between 614ef18 and 5bcb2b7.


📒 Files selected for processing (8)
  • src/fastcs/demo/controllers.py
  • src/fastcs/demo/schema.json
  • src/fastcs/transports/epics/ca/ioc.py
  • src/fastcs/transports/epics/options.py
  • tests/data/schema.json
  • tests/example_softioc.py
  • tests/transports/epics/ca/test_softioc.py
  • tests/transports/epics/ca/test_softioc_system.py


No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f7e13a9-30ec-4044-a4ff-d692365540a1

📥 Commits

Reviewing files that changed from the base of the PR and between e38ae41 and 614ef18.


⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock

📒 Files selected for processing (10)
  • pyproject.toml
  • src/fastcs/transports/epics/ca/ioc.py
  • src/fastcs/transports/epics/ca/util.py
  • src/fastcs/transports/epics/gui.py
  • src/fastcs/transports/epics/pva/util.py
  • src/fastcs/transports/epics/util.py
  • tests/transports/epics/ca/test_ca_util.py
  • tests/transports/epics/ca/test_softioc.py
  • tests/transports/epics/ca/test_softioc_system.py
  • tests/transports/epics/pva/test_pva_util.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

EPICS CA aliases accept structured enum mappings for read, write, and command PVs. The IOC validates PV names and puts, and tests cover mapping behavior and alarms. EPICS ID validation now accepts colons. The demo temperature controller marks successful connections.

Changes

EPICS CA enum aliases

Layer / File(s) Summary
Enum mapping contracts and configuration
src/fastcs/transports/epics/options.py, src/fastcs/demo/schema.json, tests/data/schema.json, tests/example_softioc.py, pyproject.toml
Defines structured enum mappings in options and schemas. Configures enum attributes and aliases in the example SoftIOC. Updates the pvi requirement in both EPICS extras.
IOC PV creation and enum translation
src/fastcs/transports/epics/ca/ioc.py
Creates enum-backed read, write, and command aliases. Validates PV names and mapping values, synchronizes attributes and PVs, and ignores invalid puts with a MAJOR alarm. PVA initialization and PVI metadata creation are removed.
Enum alias and IOC integration tests
tests/transports/epics/ca/test_softioc.py, tests/transports/epics/ca/test_softioc_system.py, src/fastcs/transports/epics/gui.py
Tests mapping validation, value conversion, command behavior, and alarms. System tests exercise CA alias reads and writes. GUI component extraction uses ResolvedTree in its return type.

EPICS controller ID validation

Layer / File(s) Summary
Colon support in EPICS IDs
src/fastcs/transports/epics/ca/util.py, src/fastcs/transports/epics/pva/util.py, src/fastcs/transports/epics/util.py, tests/transports/epics/ca/test_ca_util.py, tests/transports/epics/pva/test_pva_util.py
CA and PVA ID validation accept colons. The error message and rejection tests reflect the expanded character set.

Temperature controller connection state

Layer / File(s) Summary
Connection state update
src/fastcs/demo/controllers.py
Sets _connected to True after a successful connection.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant EPICS_CA_Client
  participant EpicsCAIOC
  participant Controller_Attribute
  EPICS_CA_Client->>EpicsCAIOC: Put mapped enum value
  EpicsCAIOC->>Controller_Attribute: Convert and apply mapped value
  Controller_Attribute-->>EpicsCAIOC: Attribute update
  EpicsCAIOC-->>EPICS_CA_Client: Synchronize alias PV value
Loading

Suggested reviewers: niamhdougan


Merge Risk: ⚪ Minimal · up to 614ef

The CA alias changes appear mergeable after normal checks; no supported CA workflow was found to depend on the removed PVI endpoint.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 9.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 10 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: support aliased enum PVs that map values to underlying FastCS PVs.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 9.23% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 10 files. (1 skipped: 1 unsupported.)



✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch add_enum_mapping

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR



Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.30556% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.68%. Comparing base (f70c58a) to head (5bcb2b7).

Files with missing lines Patch % Lines
src/fastcs/transports/epics/ca/ioc.py 99.26% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
+ Coverage   91.37%   91.68%   +0.30%     
==========================================
  Files          72       72              
  Lines        2923     3044     +121     
==========================================
+ Hits         2671     2791     +120     
- Misses        252      253       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shihab-dls
shihab-dls marked this pull request as ready for review August 6, 2026 13:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fastcs/transports/epics/ca/ioc.py`:
- Around line 40-45: Validate structured alias PV values from EnumMapping.pv
against EPICS_MAX_NAME_LENGTH before IOC record creation, just as _add_alias
validates string aliases. Update the record-creation paths around the affected
alias handling so oversized structured aliases are rejected or skipped
consistently before they are used.
- Around line 483-515: Update _add_write_enum_alias so successful writes through
enum_attr also synchronize the alias record created for alias.pv, while
preventing the update from invoking convert_to_value recursively. Ensure the
alias record reflects the underlying enum value after direct writes to the
original PV, and preserve the existing alias-to-underlying conversion and alarm
handling.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e74ed54-6c70-4cde-879d-a01bb35df28b

📥 Commits

Reviewing files that changed from the base of the PR and between a2e77b6 and a06629a.

📒 Files selected for processing (8)
  • src/fastcs/demo/controllers.py
  • src/fastcs/demo/schema.json
  • src/fastcs/transports/epics/ca/ioc.py
  • src/fastcs/transports/epics/options.py
  • tests/data/schema.json
  • tests/example_softioc.py
  • tests/transports/epics/ca/test_softioc.py
  • tests/transports/epics/ca/test_softioc_system.py

Comment thread src/fastcs/transports/epics/ca/ioc.py
Comment thread src/fastcs/transports/epics/ca/ioc.py
@shihab-dls
shihab-dls force-pushed the add_enum_mapping branch 2 times, most recently from 614ef18 to e38ae41 Compare October 9, 2026 15:34

This branch has not been deployed

No deployments
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