Table of Contents |
---|
Overview
This page summarizes the design & implementation of the interface between the live FACET-II controls system and the FACET2E Bmad model. The infrastructure consists of the following two layers:
BmadLiveModel
: a python class responsible for watching the accelerator and updating a live instance of PyTao based on extant machine settings- The live model PVA service: a process that runs it's own
BmadLiveModel
and publishes data to table PVs
This document outlines the design of the modeling infrastructure.Source code can be viewed on GitHub, and API documentation is available online.
- GitHub mirror: F2_live_model.git
- API documentation: f2-live-model.readthedocs.io/
BmadLiveModel
The goal of this class is to provide access to an instance of Tao
that can view/manipulate the FACET2 Bmad model with settings that match those of the actual production accelerator.
The BmadLiveModel
python class loads the FACET2E lattice and runs a local copy of pytao.SubprocessTao
This object connects to the production controls system via EPICS Channel Access, and connects callback functions to each live quantity (PV) of interest. When live quantities change, these callbacks will submit update instructions to a shared queue. Additionally, a daemon thread (model-update) will periodically empty the queue and execute all the scheduled update commands and then update the BmadLiveModel.live
data structure.
Modes of use
The BmadLiveModel
can be used operates in three distinct modes, depending on the input flags at construction:
Mode | kw arg | Code snippet | Notes |
---|---|---|---|
design model only | design_only | f2m = BmadLiveModel(design_only=True) | static data only, BmadLiveModel.live is not defined |
live model data data with manual updates | instanced | f2m = BmadLiveModel(instanced=True) | This mode is designed for making lattice tweaks in Tao relative to extant machine settings. The refresh_all() function is used to update model data. |
live model data data with real-time streaming | f2m = BmadLiveModel() or: with BmadLiveModel() as f2m: | Use of the context manager is the " most pythonic " practice, but manual start() and stop() functions are also defined. |
Daemon process design
This class makes use of both thread-level and process-level parallelism. Controls system monitoring, processing of update requests and data structure changes are handled asynchronously by callback functions and a model-update
daemon thread. The Tao instance itself is contained in a separate subprocess via pytao.SubprocessTao
. Controls monitoring and device update management are handled asynchronously to optimize performance and minimize delays between changes being broadcast over the network and being mirrored in the model. Tao itself is wrapped in a subprocess for handling Fortran errors, and calls to BmadLiveModel.tao
will still block the main python executable
...