Skip to content

Allow a single FastCS server to have multiple top level Controllers with different prefixes #120

Open

Description

@coretl

For PandA the heirarchy of Controllers fits with FastCS:

  • Top level Controller with PandABlocks-client connection, with PV prefix e.g. "BLxxI-EA-PANDA-01"
    • It creates SubControllers for each Block within it, appending suffix e.g. "PULSE1"
      • It has Attributes within it for each Field in the Block, appending the suffix e.g. "WIDTH"

For CATio we would like a different heirarchy

  • Top level Controller with ADS connection, for status monitor and bus capture, with PV prefix e.g. "BLxxI-EA-ECAT-01"
  • Peer Controllers for each coupler, e.g. "BLxxI-EA-ERIO-01"
    • SubControllers for each module attached to it, e.g. "ADC1"
      • Attributes for each parameter and channel of the module, e.g. "CHAN1"

We would need this if we ever did a PMAC in FastCS:

  • Top level Controller with SSH connection, e.g. "BLxxI-MO-PMAC-01"
    • SubController per CS, e.g. "CS2"
  • Peer Controllers for each axis, e.g. "BLxxI-MO-DCM-01:ROLL"
    • Attributes for it's parameters, e.g. "SETPOINT"

We need this top level PV heirarchy to be stable through axis moves so that we keep archiving and GUI build consistent.

Acceptance Criteria

  • We can make multiple Controllers with completely different PV prefixes

Activity

  1. GDYendell commented on Jan 8, 2026

    @GDYendell
    Contributor

    @coretl do we want to do this in the CATio sprint?

  2. GDYendell commented on Jan 14, 2026

    @GDYendell
    Contributor

    We need to decide how the PV prefixes for each controller would be configured in the transport in the config file. The obvious way is a list of prefixes with indexes that match the list of Controllers, but that is pretty horrible. Maybe we could change to a dictionary of name -> Controller? I am not sure what we would actually use the name for other than correlating config, but it could be useful.

  3. coretl commented on Jan 16, 2026

    @coretl
    ContributorAuthor

    Can we do something with anchors and aliases?

    controllers:
      - &pmac type: pmac.ssh_connection
        ip: 172.23.245.56
      - &pitch type: pmac.axis
        axis: 1
      - &roll type: pmac.axis
        axis: 2
    transports:
      - type: CATransport
        pv_prefixes:
          "BLxxI-MO-PMAC-01": *pmac
          "BLxxI-MO-DCM-01:PITCH": *pitch
          "BLxxI-MO-DCM-01:ROLL": *roll
      - type: RESTTransport
        routes:
          pmac: *pmac
          pitch: *pitch
          roll: *roll

    Then each transport would have a method called serialized_controllers that would have to match the top level controllers to make sure there are no missing ones

    Alternatively you put a set of transport specific params under the controllers:

    controllers:
      - type: pmac.ssh_connection
        ip: 172.23.245.56
        transport_params:
        - pv_prefix:  "BLxxI-MO-PMAC-01"
        - rest_route: pmac
      - type: pmac.axis
        axis: 1
        transport_params:
        - pv_prefix:  "BLxxI-MO-DCM-01:PITCH"
        - rest_route: pitch
      - type: pmac.axis
        axis: 2
        transport_params:
        - pv_prefix:  "BLxxI-MO-DCM-01:ROLL"
        - rest_route: roll
    transports:
      - type: CATransport
      - type: RESTTransport

    Then you have to make sure that you have transports that can handle the given transport parameters

  4. GDYendell commented on Jan 19, 2026

    @GDYendell
    Contributor

    I don't love either of these 😅

    Another possible option (that I am also not sure I like). We have multiple config files, one per controller with the transports we want it to be served over. These are all loaded and combined programmatically so that there is no concern of lists of controllers and lists of pv prefixes being in the wrong order. There would still only be one instance of each transport.

    This would mean the simple case of one Controller still looks nice and we don't have lists of controllers and pv_prefixes of length one. I think it would also the GUI config a bit easier.

  5. coretl commented on Jan 19, 2026

    @coretl
    ContributorAuthor

    Is there anything shared between all transports? I'd be loath to have to repeat N lines of the same variables in each file to save typing 1 unique string...

    Do anchors and aliases work across documents in one file?

    E.g.

    controller: ...
    transport:
       type: CATransport
       prefix: PREFIX1
       screen_stuff: &screen_stuff
          ...
    ---
    controller: ...
    transport:
       type: CATransport
       prefix: PREFIX2
       screen_stuff: *screen_stuff
  6. GDYendell commented on Jan 21, 2026

    @GDYendell
    Contributor

    That would be neat, but I don't think you can't use anchors and aliases across documents in one file.

    If you did have GUI for both transports, they would have to be different anyway because otherwise they would clash. I imagine it would look something like this:

    controller:
      ip_settings:
        ip: "localhost"
        port: 25565
      num_ramp_controllers: 4
    transport:
      - graphql:
          host: localhost
          port: 8083
          log_level: info
      - epicsca:
          pv_prefix: GARYDEMO
        gui:
          title: Temperature Controller Demo (CA)
          output_path: ./demo_ca.bob
      - epicspva:
          pv_prefix: GARYDEMO
        gui:
          title: Temperature Controller Demo (PVA)
          output_path: ./demo_pva.bob
    ---
    controller:
      ip_settings:
        ip: "localhost"
        port: 25566
      num_ramp_controllers: 4
    transport:
      - graphql:
          host: localhost
          port: 8083
          log_level: info
      - epicsca:
          pv_prefix: GARYDEMO2
        gui:
          title: Temperature Controller Demo 2 (CA)
          output_path: ./demo2_ca.bob
      - epicspva:
          pv_prefix: GARYDEMO2
        gui:
          title: Temperature Controller Demo 2 (PVA)
          output_path: ./demo2_pva.bob

    There is a complication that for graphql the config would have to be match, whereas you want the config to be different for CA...

  7. coretl commented on Jan 21, 2026

    @coretl
    ContributorAuthor

    Hmm, how about merging all the files into a list then, and allowing per-controller overrides?

    # Common transport setup
    transport:
      - graphql:
          host: localhost
          port: 8083
          log_level: info
      - epicsca:
      - epicspva:
    # Per controller setup
    controllers:
      - ip_settings:
          ip: "localhost"
          port: 25565
        num_ramp_controllers: 4
      transport_overrides:
        - epicsca:
            pv_prefix: GARYDEMO
          gui:
            title: Temperature Controller Demo (CA)
            output_path: ./demo_ca.bob
        - epicspva:
            pv_prefix: GARYDEMO
          gui:
            title: Temperature Controller Demo (PVA)
            output_path: ./demo_pva.bob
      - ip_settings:
          ip: "localhost"
          port: 25566
        num_ramp_controllers: 4
      transport_overrides:
        - epicsca:
            pv_prefix: GARYDEMO2
          gui:
            title: Temperature Controller Demo 2 (CA)
            output_path: ./demo2_ca.bob
        - epicspva:
            pv_prefix: GARYDEMO2
          gui:
            title: Temperature Controller Demo 2 (PVA)
            output_path: ./demo2_pva.bob
  8. GDYendell commented on Jan 27, 2026

    @GDYendell
    Contributor

    Controller taking transport_overrides would also mean ControllerAPI taking transport_overrides and then Transport.connect checking for fields its own key. I think this would be OK... but in the schema transport_overrides would have to allow anything, so it would be easy to make a typo and potentially it would silently fail.

    In terms of the code, gql, rest and tango could all easily iterate over lists of controller apis. They don't have an equivalent of pv prefix that would need to be different. For epicsca and epicspva, the simplest thing would be to zip lists of ioc options, gui options and apis here and here. Having to search through the controller apis to find overrides would add complexity.

  9. coretl commented on Jan 28, 2026

    @coretl
    ContributorAuthor

    Maybe we could go back to what we have at the moment, but give every controller an ID that could be used as the PV prefix or the GQL reference?

  10. GDYendell commented on Feb 2, 2026

    @GDYendell
    Contributor

    This seems like a good compromise. It will be less clear for controls engineers, but if we just explain that this field on the controller will get turned into the PV prefix I think that's fine. It is the same as sub controller path getting turned into the PV name. Maybe this is just the root controller having a path rather than it being empty.

  11. gilesknap commented on May 5, 2026

    @gilesknap
    Contributor

    What I think I'm implementing (@coretl to verify this is what you want!)

    • fastcs will allow multiple root controllers
      • each controller has an id which becomes the PV prefix
      • transports therefore no longer need PV prefix
    • Thus the config file will become fastcs.yaml instead of controller.yaml and may container multiple controller definitions
      • This will become the preferred way to configure fastcs IOCs
    • To this end the tutorial will be updated to a nice example using fastcs.yaml
      • I'll also take this as an oportunity to make the tutorial look more compelling with more sexy code.
    • Additiona features to make use of yaml easier:-
      • Useful defaults such that the yaml can be kept to a minimum
      • e.g. Addition of a default CA/PVA transport with minimal config
  12. gilesknap commented on May 5, 2026

    @gilesknap
    Contributor

    Tom and I have agreed that it should look like this

      controllers:                                                                                                                                                       
        - id: BLxxI-EA-ECAT-01                                                                                                                                     
          controller: { ... }                                                                                                                                            
        - id: BLxxI-EA-ERIO-01                                                                                                                                      
          controller: { ... }                                                                             
      transport:                          
        - epicsca:
        - epicspva:
        - rest:
    • So id goes in the path for all transport types and represents the PV prefix for epics transports.
    • Transports are responsible for making sure that all paths are unique
    • controllers will also know their 'id' for reporting in logging etc.
  13. gilesknap commented on May 5, 2026

    @gilesknap
    Contributor

    @coretl

    A revision while planning: switching from list-with-id-field to dict-keyed-by-id for the controllers: block:

      controllers:                        
        BLxxI-EA-ECAT-01:            
          type: ECATController    
          controller: { ... }             
        BLxxI-EA-ERIO-01:                                                                                        
          type: ERIOController  
          controller: { ... }             

    Reasoning:

    • YAML structurally enforces id uniqueness — no manual check needed.
    • Maps 1:1 to the runtime shell context (controllers: dict[str, Controller]).
    • Removes the id: boilerplate.
    • Insertion order is preserved.
  14. gilesknap commented on May 5, 2026

    @gilesknap
    Contributor

    Small revision while planning: switching from list-with-id-field to dict-keyed-by-id for the controllers: block:

    controllers:
      BLxxI-EA-ECAT-01:
        type: ECATController
        controller: { ... }
      BLxxI-EA-ERIO-01:
        type: ERIOController
        controller: { ... }

    instead of:

    controllers:
      - id: BLxxI-EA-ECAT-01
        type: ECATController
        controller: { ... }
      - id: BLxxI-EA-ERIO-01
        ...

    Reasoning:

    • YAML structurally enforces id uniqueness — no manual check needed.
    • Maps 1:1 to the runtime shell context (controllers: dict[str, Controller]).
    • Removes the id: boilerplate.
    • Insertion order is preserved (ruamel safe loader returns ordered dicts).

    Other outcomes from today's design pass that aren't in writing yet:

    • launch() takes a list of Controller classes; YAML entries pick the class via a type: field (defaults to class __name__); single-class registrations can elide type:.
    • The id lives on the Controller instance (set after construction by the launcher) and becomes the first segment of every transport path. EPICS-style PV prefixes via path[0] verbatim, sub-controller path segments still go through snake_to_pascal.
    • Each transport validates id against its own naming rules at connect() time and fails fast on illegal characters — no silent name mangling. Acknowledged limitation: mixing transports with incompatible naming rules forces a lowest-common-denominator id.
    • EpicsIOCOptions.pv_prefix (and the EpicsIOCOptions dataclass) gets removed entirely.
    • One softioc per process, N PVI roots — EpicsCAIOC (and PVA equivalent) takes the full list of ControllerAPIs and iterates.
    • Single Controller still works as a list-of-one. No backwards-compat path for the old singular controller: YAML form — clean break, single schema.
    • Shell context: controllers: dict[id, Controller], with a Controller.api back-pointer so controllers["BLxxI-EA-ECAT-01"].api.path works without a parallel controller_apis dict.

    Full PRD with user stories, implementation decisions, and testing plan: #351

    Shout if any of this looks wrong before I start writing code.

  15. coretl commented on May 5, 2026

    @coretl
    ContributorAuthor

    I agree with N PVI roots, but we still need to make index.bob with buttons for BLxxI-EA-ECAT-01 and BLxxI-EA-ERIO-01 in the same way as a C++ IOC.

  16. gilesknap commented on May 13, 2026

    @gilesknap
    Contributor

    @coretl do you mean that if we change the path in a given subcontroller, that needs to then be promoted to a button in index.bob. (if we use the default path then its part of the pre-existing bob file hierarchy). Am I understanding you?

  17. coretl commented on May 13, 2026

    @coretl
    ContributorAuthor

    Yes, the path heirarchy should be the button heirarchy on the screens and the PVI heirarchy.

    E.g. for ethercat, the controller heirarchy would be something like:

    - ECATController(path=["BLxxI-EA-ECAT-01"])
      # Populated at runtime
      - ERIOController(path=["BLxxI-EA-ERIO-01"])
      - ENodeController(path=["BLxxI-EA-ERIO-01", "adc1"])
      - ERIOController(path=["BLxxI-EA-ERIO-02"])
      - ENodeController(path=["BLxxI-EA-ERIO-02", "dac1"])
      ...
    

    which would make a PVI hierarchy:

    BLxxI-EA-ECAT-01:PVI:
    
    BLxxI-EA-ERIO-01:PVI:
        adc1: BLxxI-EA-ERIO-01:ADC1:PVI
    
    BLxxI-EA-ERIO-02:PVI:
        adc1: BLxxI-EA-ERIO-02:DAC1:PVI
    

    which would make a screen hierarchy:

    index.bob:
      BLxxI-EA-ECAT-01:
      BLxxI-EA-ERIO-01:
        ADC1:
      BLxxI-EA-ERIO-02:
        DAC1:
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions