Skip to content

Feature request: Support formulas in the Write PV action value field #3941

Open

Description

@rosstitmarsh

It would useful to be able to use formulas in the "Value" field of a "Write PV" action. This would simplify many use cases that would otherwise require scripting, which we aim to minimise at ISIS. Below are some examples of where we would find this feature helpful.

Assign the value of one PV to another

e.g. PV Name: destination, Value: =`source`

We have a display that shows suggested steering magnet setpoints calculated by some diagnostics next to the current magnet setpoints, then there are buttons to assign the suggested to the actual setpoints if the operator chooses to use them. This requires a short script to implement, but would be simpler with the requested feature.

Image

Custom increment buttons

e.g. PV Name: $(pv_name), Value: =`$(pv_name)` + 1

We have some displays where users are used to having more increment/decrement options than the spinner or thumbwheel widgets provide. Being able to do in-place addition, subtraction, multiplication, etc would make this possible without scripting.

Activity

  1. shroffk commented on Sep 29, 2026

    @shroffk
    Member

    This is broadly a good idea.

    • Ideally, I think there should be some indication of what is going to be written.
    • should the value only be calculate when the user presses the write button? ( in this case it might be more difficult to address the previous point cause the value is not know until it is written )

    I would like to add this as a codeathon project.

  2. kasemir commented on Sep 29, 2026

    @kasemir
    Collaborator

    In another view, the GUI shouldn't "do" anything. The GUI shouldn't try to figure out what an appropriate setpoint might be.
    Move that to the IOC. In this case, add something like this:

    record(ao, "CopySetpoint1")
    {
      field(OMSL, "closed_loop")
      field(DOL, "CalculatedSetpoint1")
      field(OUT, "Setpoint1 PP")
    }
    

    .. and in the GUI have the button write 1 to CopySetpoint1.PROC.
    If you need more than just a "copy", use the "calcout" record to compute the appropriate setpoint.

    That way, you can use EDM or MEDM or any other EPICS display tool, or caput from the command line.

  3. shroffk commented on Sep 29, 2026

    @shroffk
    Member

    Order of preferred solutions best to worse

    Doing it in the IOC ( as Kay showed ) > Doing it via formula functions > via some script ( what you are trying to avoid )

  4. rosstitmarsh commented on Sep 29, 2026

    @rosstitmarsh
    ContributorAuthor

    In my example the calculations are done by an IOC on a diagnostic device, I don't want the Phoebus screen to "do" anything. The GUI is just providing a simple mechanism to apply the value from one IOC to another. I could implement it with an extra record as shown but I prefer to keep my diagnostics IOCs as simple as possible. It could also be done by the magnet IOC at the other end but to keep it simple the magnet doesn't need to know that a particular diagnostic exists. To me the formula way is the simplest solution, this isn't business logic, just a nicety to save operators copying a value or making mistakes.

  5. georgweiss commented on Sep 30, 2026

    @georgweiss
    Collaborator

    ...apply the value from one IOC to another.

    Isn't that a classic EPICS pattern? I'd second @kasemir here.

    ...keep my diagnostics IOCs as simple as possible

    Wouldn't that put potential complications on the front end (=Phoebus)?

  6. kasemir commented on Sep 30, 2026

    @kasemir
    Collaborator

    As for magnet vs. diagnostics IOC, I assume your magnet IOC has the "Setpoint" and the diag IOC has the "CalculatedSetpoint".
    You now have at least 3 options:

    1. Place the "CopySetpoint" record in the magnet IOC so it can "pull" the calculated setpoint from the diag IOC
    2. Place the "CopySetpoint" record in the diagnostics IOC so it can "push" the calculated setpoint to the magnet IOC
    3. Place the "CopySetpoint" record in a new "automation" or "helper" IOC so it can "copy" the calculated setpoint from the diag IOC to the magnet IOC

    There are valid arguments for each option. EPICS really doesn't care. You can simply move that "Copy" record between IOCs, and database links will magically morph into network links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions