Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

147 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lume-pva

Lume-PVA is a Python library that serves or consumes EPICS PVs based on a LUMEModel subclass and its supported variables.

Features:

  • Model outputs served over PVAccess (PVA) and/or ChannelAccess (CA).
    • PVA PVs support a subset of the EPICS NormativeTypes metadata.
    • CA PVs support a subset of the standard EPICS CA meta, such as alarms, display limits and control limits.
  • Inputs can be served as standalone PVs over PVA, or configured as clients for remote PVs.
  • Automatic discovery of remote PV protocols.
  • Snapshot mode for remote PVs.

Basic Usage

from lume_pva.runner import Runner

myModel = MyLUMEModel()
r = Runner(model=myModel)
r.run()

Operational Description

Model Outputs

Model outputs can be served served over PVA and/or CA. If the output is solely an output, it will be configured as a read-only PV.

Model Inputs

Model inputs can be configured as remote or local PVs. Local PVs are served by the Runner class and can be interacted with using pvput, caput or other CA/PVA tools on the command line.

Like model outputs, standalone inputs can be served over CA or PVA, depending on the Runner configuration.

In the remote mode, the input is setup as a client. In this mode, both PVA and CA are supported transparently. It's not necessary to specify the protocol of the remote PV; the pvua library will automatically detect which protocol to use. pvua prefers the more modern protocol (PVA), if available.

Snapshot Mode

When configured in snapshot mode, the Runner will only fetch values from remote PVs when a snapshot is triggered by a write to {prefix}SNAPSHOT.

Control PVs

The runner always exposes a small set of control PVs:

  • {prefix}SNAPSHOT: triggers a snapshot pull for remote inputs in snapshot mode.
  • {prefix}RESET: any write requests model.reset() and publishes the reset state to output PVs.

Control PVs are served over PVA, and are also available over CA when protocol includes "ca".

prefix is passed to the constructor of the Runner class and defines a prefix to prepend to the start of PV names.

Configuration

Runner.generate_config() can be used to generate a dict describing the default configuration for the model. You can either edit this on the fly, or serialize it and edit it by hand later.

print(Runner.generate_config(model=myModel))

An example configuration:

{
    'remote_model_mode': 'continuous', # Set to 'snapshot' for snapshot mode
    'prefix': 'MY_PV_PREFIX:',
    'update_rate': 0.1, # Update period under which PVs will be batched together into one model.set(). Set to 0 to disable the window.
    'protocol': ['ca', 'pva'] # Serve this as both CA and PVA (the default)
    'variables': {
        'input_a': {
            'name': 'input_a',
            'pv': 'input_a_pv',
            'mode': 'rw' # 'rw' means we can read and write this PV. It's served by the Runner class
        },
        'input_b': {
            'name': 'input_b',
            'pv': 'SOME:REMOTE:PV',
            'mode': 'remote' # 'remote' means this PV will be configured as a client and fetched from a remote
        }
    }
}

Supported Variables

Supported variable types and their metadata fields.

ScalarVariable and IntVariable

Represented as NTScalar with a double or int value field (depending on variable type).

Supported metadata:

  • timestamp
  • display.units
    • ScalarVariable.unit
  • control.limitLow
    • ScalarVariable.value_range[0]
  • control.limitHigh
    • ScalarVariable.value_range[1]
  • alarm.severity and alarm.status
    • Set based on the value in relation to value_range. Out of range values trigger alarms.

NDVariable

Represented as NTNDArray with data representation matching the numpy shape and dtype.

Supported metadata:

  • timestamp

TorchScalarVariable

Requires the torch extra (pip install lume-pva[torch]).

Represented as NTScalar with a double value field.

Supported metadata:

  • timestamp

TorchNDVariable

Requires the torch extra (pip install lume-pva[torch]).

Represented as NTNDArray with data representation matching the Tensor shape and dtype.

Supported metadata:

  • timestamp

BoolVariable

Represented as NTScalar with a bool value field.

Supported metadata:

  • timestamp

StrVariable

Represented as NTScalar with a str value field.

Supported metadata:

  • timestamp

About

EPICS CA and PVA Interface to LUME Models

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages