Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Overview

Image Added

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.

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.Image Removed

Modes of use

The BmadLiveModel can be used operates in three distinct modes, depending on the input flags at construction:

Modekw argCode snippetNotes
design model onlydesign_only
f2m = BmadLiveModel(design_only=True)
static data only, BmadLiveModel.live is not defined
live model data  data with manual updatesinstanced
f2m = BmadLiveModel(instanced=True)
f2m.refresh_all()
# --> your code here
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()
f2m.start()
# --> your code here
f2m.stop

or:

with BmadLiveModel() as f2m:
    # --> your code here
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

...