Skip to content

Scan sync from FNAL: comparison/tolerance semantics, PV-reference evaluation, and while-command updates - #4033

Open
zongweiyuan wants to merge 4 commits into
ControlSystemStudio:masterfrom
zongweiyuan:scan-sync-fnal-20261117
Open

zongweiyuan wants to merge 4 commits into
ControlSystemStudio:masterfrom
zongweiyuan:scan-sync-fnal-20261117

Conversation

@zongweiyuan

Copy link
Copy Markdown

Description

This PR syncs scan model/server changes from the FNAL branch into upstream scan modules, with focus on condition evaluation behavior and runtime consistency.

Why

  • Bring scan command behavior in line with FNAL updates.
  • Improve conditional execution correctness for numeric and string comparisons.
  • Ensure tolerance handling is consistent and explicit across model and server runtime evaluation.

What Changed

  • Added/updated command support and runtime handling for scan condition flow (including while-style execution and related command updates).
  • Extended command model persistence so comparison and tolerance are carried through save/load and shown consistently.
  • Updated server-side condition evaluation paths to support numeric, text, and PV-reference-backed desired values at runtime.
  • Synced related resources and preferences needed by the scan-server-client behavior updates.

Comparison and Tolerance Behavior (explicit)

  • Equals comparison now uses tolerance deadband: condition passes when value is within plus/minus tolerance.
  • Unequal comparison is the inverse: condition passes when value is outside tolerance.
  • Greater/equal/smaller style comparisons are handled explicitly:
    • Greater-than style checks (above) require crossing beyond desired value plus tolerance.
    • Greater-or-equal style checks (at-least) allow desired value minus tolerance as acceptable boundary.
    • Smaller-than style checks (below) require crossing below desired value minus tolerance.
    • Smaller-or-equal style checks (at-most) allow desired value plus tolerance as acceptable boundary.
  • List-membership comparisons (in and not-in) do not apply numeric tolerance.
  • Tolerance is clamped non-negative and represented consistently in command serialization and display strings.

Runtime Semantics Improvements

  • Desired values can be resolved from PV references at runtime for conditional evaluation.
  • Loop/while execution paths were aligned with dynamic values and condition checks so stop/progress behavior is consistent with configured comparisons.

Validation

  • Build/test run performed with JDK 25 for relevant modules.
  • Command used:
    • $env:JAVA_HOME="C:...[userLocalDir]...\jdks\jdk-25.0.2"
    • $env:Path="$env:JAVA_HOME\bin;" + $env:Path
    • mvn -pl app/scan/model,services/scan-server -am clean test -DskipITs

PR Checklist

Scope and Intent

  • Scope is limited to scan-related modules and resources (no unrelated refactors).
  • Comparison/tolerance behavior changes are explicitly documented (greater/equal/smaller semantics).

Functional Behavior

  • IfCommand supports configured comparison mode at runtime.
  • WaitCommand supports configured comparison mode at runtime.
  • WhileCommand uses configured comparison mode correctly during loop condition checks.
  • Numeric desired values are evaluated correctly for all comparison types.
  • String desired values are evaluated correctly for equals/unequal and ordering comparisons.
  • IN / NOT_IN behavior works as list-membership checks.
  • PV-reference desired values are resolved at runtime and used in comparisons.

Tolerance Semantics

  • Tolerance is non-negative (clamped as needed).
  • EQUALS uses tolerance deadband (within $ \pm tolerance $).
  • UNEQUAL is the inverse of tolerance deadband.
  • AT_LEAST / AT_MOST include tolerance-adjusted boundary logic.
  • ABOVE / BELOW require crossing beyond tolerance boundary.
  • Tolerance is not applied to IN / NOT_IN.

Model, Serialization, and UX

  • Comparison property is persisted in XML and restored correctly.
  • Tolerance property is persisted in XML and restored correctly.
  • Command toString() output reflects comparison/tolerance accurately.
  • UI/property metadata exposes comparison and tolerance fields as intended.

Loop/While Runtime Consistency

  • Loop start/end/step handling works with numeric literals and PV references.
  • Reverse/direction behavior remains correct for loop stepping.
  • Loop/while stop conditions behave consistently with comparison settings.
  • No regressions in readback/wait/completion behavior.

Tests

  • Existing unit tests pass for app/scan/model and services/scan-server.
  • Added/updated tests cover comparison boundary cases (greater/equal/smaller).
  • Added/updated tests cover tolerance-sensitive edge cases.
  • Added/updated tests cover PV-reference desired value evaluation.
  • Added/updated tests cover IN / NOT_IN string-list behavior.

Build and Environment

  • Build/test executed with JDK 25.
  • Command used and outcome recorded in PR description:
    • mvn -pl app/scan/model,services/scan-server -am clean test -DskipITs
  • No new warnings/errors introduced in modified modules.

Notes

  • This PR intentionally preserves upstream-compatible module layout and POM structure while bringing over FNAL behavior changes.
  • Scope is limited to synchronized scan functionality and related condition/comparison logic.

Zongwei Yuan x6878 13046N added 4 commits November 17, 2026 12:20
Port scan model/client/ui and scan-server changes from fermi-ad/phoebus-fnal.

Includes PVReference and While command support, scan-server command/runtime updates, and resource/script updates.

Removes scan-server test sources not present in the FNAL source module.
- Apply Sonar/style fixes across While/Loop command and impl classes
- Clean unused imports, naming, commented code, and logging formatting
- Refactor methods flagged for complexity and modernize instanceof patterns
- Update PVReferenceTest method visibility for JUnit 5 style
- Keep behavior intact; build/test already passed with JDK 25
- Apply final naming/instanceof/style cleanups in model and server command classes
- Clean Derby/RDB logger formatting and variable naming issues
- Keep behavior unchanged and preserve runtime logic
- Verified compile and clean test success with JDK 25 for target modules
- Fix final naming/style warnings in WhileCommand and WhileCommandImpl
- Guard DerbyDataLogger startup log evaluation by log level
- Rename local variable in RDBDataLogger to avoid field shadowing
- Preserve behavior; build/test verified by user with JDK 25
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
5.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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.

1 participant