Skip to content

added hints dictionaries to manage default channel call attributes and write caching

Lee McCuller requested to merge (removed):hintsNcache into master

Here are the changes that I am using in the SQZ guardian code. There are essentially two things but they overlap a bit so I didn't do separate commits/branches.

Option dictionaries

The first, which I think should definitely be accepted are some module-level dictionaries which can store the default values of some of the read/write/log keyword arguments on a per-channel basis. This allows users to ALWAYS use the dictionary interface and to globally change logging and waiting options for certain channels. For channels which need a single calls or different options, that is still supported through the function-call interface.

Logging Option

I added an option and hint dictionary to disable write logging for certain channels. I use the guardian to update some non-essential PV's that report the OPO power budget W.R.T nominal operation. These are hosted in the RCG epics, but calculated from Beckhoff epics variables by the guardian code, so it is approprate for guardian to update them. They have write wait=false as they are non-essential (extra-soft realtime), and they would pollute the logs since they are written every cycle. This pattern is nice to allow the guardian code to do extra reporting of synthetic variables. The code could also be in a separate script, but since the workflow for guardian is already well-known this seemed like a good place to put it.

Write caching

For well-behaved guardian code that always executes in its cycle time, The external PV state is essentially frozen within each 16Hz cycle, and so there is no point in eager writes/reads from network PV's. I added a context manager to do deferred writes so that a more efficient batch-call may be used.

  1. Existing well-behaved code won't be able to tell the difference.
  2. It rewards good guardian patterns with network efficiency
  3. opt-in via "with" statement or decorator
  4. maybe nicer than other batch-call interfaces (PVs are already attached and you get SPM compared to burt-dump methods).

Merge request reports