Why is something the way it is

digraph pvi_flowchart { bgcolor=transparent rankdir=LR node [fontname=Arial fontsize=10 shape=box style=filled fillcolor="#8BC4E9"] edge [fontname=Arial fontsize=10 arrowhead=vee] { rank=same; "pilatus.pvi.yaml" "pilatus.cpp" "pilatus.h" } PVI [shape=doublecircle] "pilatus.local.yaml" -> PVI "pilatus.pvi.yaml" -> PVI PVI -> "pilatus_parameters.h" PVI -> "pilatus_parameters.template" PVI -> "pilatus_parameters.opi" PVI -> "pilatus_parameters.adl" PVI -> "pilatus_parameters.edl" PVI -> "pilatus_parameters.csv" "pilatus_parameters.template" -> "pilatus.template" [label="included in"] "pilatus_parameters.h" -> "pilatus.h" [label="included in"] "pilatus.cpp" -> "libPilatus.so" "pilatus.h" -> "libPilatus.so" "pilatus_parameters.csv" -> "pilatus.rst" [label="included in"] "pilatus_parameters.adl" -> "pilatus.adl" [label="linked from"] "pilatus_parameters.edl" -> "pilatus.edl" [label="linked from"] "pilatus_parameters.opi" -> "pilatus.opi" [label="linked from"] }

Aims of PVI

Aim

Description

Reduce boilerplate

At the moment you can write a simple asyn port driver in code, but there is a lot of boilerplate to connect it to the outside world. The createParam section, the database template records, and the lowest level screens are all quite repetitive and each layer looks like it could be autogenerated without much extra information

Reduce copy paste errors

At the moment it is easy to create screens and database templates via copy and paste, but not changing a record name or parameter leads to hard to track down errors

Support site specific styles for screens

Each site has their own style for screens, and many sites have their own site specific display manager. Rather than start with one display manager and convert, PVI takes a cut down Channel description (just a type, pv and widget), and lets the site specific template generate the screen according to local styles

How it works

The YAML file contains information about each asyn parameter that will be exposed by the driver, it’s name, type, description, initial value, which record type it uses, whether it is writeable or read only, which widget should be used, etc. PVI reads these and passes them to Producer that creates intermediate Record, Channel and AsynParam objects. These are passed to a site specific Formatter which takes the tree of intermediate objects and writes a parameter CPP file, database template, and site specific screens to disk.

YAML file

The YAML file is formed of a number of sections:

Section

Description

includes

The YAML files to use as base classes for superclasses

local

A local override YAML file for site specific changes

producer

Producer that knows how to create Records and Channels from the Components

formatter

Site specific Formatter which can format the output files

components

Tree of Components for each logical asyn parameter arranged in logical GUI groups

The Components are created from the YAML file with local overrides (also incorporating the base classes for screens). These are passed to the Producer which produces AsynParameters, Records and Channels. These are then passed to the Formatter which outputs them to file:

digraph pvi_products { bgcolor=transparent node [fontname=Arial fontsize=10 shape=box style=filled fillcolor="#8BC4E9"] edge [fontname=Arial fontsize=10 arrowhead=vee] Intermediate [label="[Record(),\n Channel(),\n AsynParameter()]"] Products [label="Template\nScreens\nDriver Params\nDocumentation"] {rank=same; Components -> Producer -> Intermediate -> Formatter -> Products} }

Here’s a cut down pilatus.yaml file that might describe a parameter in a detector:

type: AsynProducer
prefix: $(P)$(R)
label: pilatus
asyn_port: $(PORT)
address: $(ADDR)
timeout: $(TIMEOUT)
parent: ADDriver
parameters:
  - type: Group
    name: ComponentGroupOne
    layout:
      type: Grid
    children:
      - type: AsynBinary
        name: ResetPower
        description: ResetPower
        index_name: PilatusResetPower
        drv_info: RESET_POWER
        access: W
        record_fields:
          ZNAM: Done
          ONAM: Reset

      - type: AsynBusy
        name: ThresholdApply
        description: ThresholdApply
        index_name: PilatusThresholdApply
        drv_info: THRESHOLD_APPLY
        access: W
        initial: "0"
        record_fields:
          ZNAM: Done
          ONAM: Apply

      - type: AsynFloat64
        name: ImageFileTmot
        description: Timeout for image file
        index_name: PilatusImageFileTmot
        drv_info: IMAGE_FILE_TMOT
        access: W
        initial: "20"
        record_fields:
          PREC: "3"
          EGU: s

      - type: AsynFloat64
        name: Wavelength
        description: Wavelength
        index_name: PilatusWavelength
        drv_info: WAVELENGTH
        access: W
        initial: "1.54"
        record_fields:
          PREC: "4"
          EGU: Angstroms

      - type: AsynFloat64
        name: EnergyLow
        description: EnergyLow
        index_name: PilatusEnergyLow
        drv_info: ENERGY_LOW
        access: W
        initial: "0"
        record_fields:
          PREC: "3"
          EGU: eV

      - type: AsynFloat64
        name: EnergyHigh
        description: EnergyHigh
        index_name: PilatusEnergyHigh
        drv_info: ENERGY_HIGH
        access: W
        initial: "0"
        record_fields:
          PREC: "3"
          EGU: eV

      - type: AsynFloat64
        name: DetDist
        description: DetDist
        index_name: PilatusDetDist
        drv_info: DET_DIST
        access: W
        initial: "1000"
        record_fields:
          PREC: "3"
          EGU: mm

      - type: AsynFloat64
        name: DetVOffset
        description: DetVOffset
        index_name: PilatusDetVOffset
        drv_info: DET_VOFFSET
        access: W
        initial: "0"
        record_fields:
          PREC: "3"
          EGU: mm

      - type: AsynFloat64
        name: BeamX
        description: BeamX
        index_name: PilatusBeamX
        drv_info: BEAM_X
        access: W
        initial: "0"
        record_fields:
          PREC: "3"
          EGU: pixels

      - type: AsynFloat64
        name: BeamY
        description: BeamY
        index_name: PilatusBeamY
        drv_info: BEAM_Y
        access: W
        initial: "0"
        record_fields:
          PREC: "3"
          EGU: pixels

      - type: AsynFloat64
        name: Flux
        description: Flux
        index_name: PilatusFlux
        drv_info: FLUX
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: ph/s

      - type: AsynFloat64
        name: FilterTransm
        description: FilterTransm
        index_name: PilatusFilterTransm
        drv_info: FILTER_TRANSM
        access: W
        initial: "1.0"
        record_fields:
          PREC: "4"

      - type: AsynFloat64
        name: StartAngle
        description: StartAngle
        index_name: PilatusStartAngle
        drv_info: START_ANGLE
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: AngleIncr
        description: AngleIncr
        index_name: PilatusAngleIncr
        drv_info: ANGLE_INCR
        access: W
        initial: "0.1"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Det2theta
        description: Det2theta
        index_name: PilatusDet2theta
        drv_info: DET_2THETA
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Polarization
        description: Polarization
        index_name: PilatusPolarization
        drv_info: POLARIZATION
        access: W
        initial: "0.99"
        record_fields:
          PREC: "4"

      - type: AsynFloat64
        name: Alpha
        description: Alpha
        index_name: PilatusAlpha
        drv_info: ALPHA
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Kappa
        description: Kappa
        index_name: PilatusKappa
        drv_info: KAPPA
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Phi
        description: Phi
        index_name: PilatusPhi
        drv_info: PHI
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: PhiIncr
        description: PhiIncr
        index_name: PilatusPhiIncr
        drv_info: PHI_INCR
        access: W
        initial: "0.1"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Chi
        description: Chi
        index_name: PilatusChi
        drv_info: CHI
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: ChiIncr
        description: ChiIncr
        index_name: PilatusChiIncr
        drv_info: CHI_INCR
        access: W
        initial: "0.1"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: Omega
        description: Omega
        index_name: PilatusOmega
        drv_info: OMEGA
        access: W
        initial: "0"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynFloat64
        name: OmegaIncr
        description: OmegaIncr
        index_name: PilatusOmegaIncr
        drv_info: OMEGA_INCR
        access: W
        initial: "0.1"
        record_fields:
          PREC: "4"
          EGU: deg

      - type: AsynString
        name: OscillAxis
        description: OscillAxis
        index_name: PilatusOscillAxis
        drv_info: OSCILL_AXIS
        access: W
        initial: X, CW

      - type: AsynLong
        name: NumOscill
        description: NumOscill
        index_name: PilatusNumOscill
        drv_info: NUM_OSCILL
        access: W
        initial: "1"

      - type: AsynWaveform
        name: BadPixelFile
        description: BadPixelFile
        index_name: PilatusBadPixelFile
        drv_info: BAD_PIXEL_FILE
        access: W
        record_fields:
          NELM: "256"
          FTVL: CHAR

      - type: AsynWaveform
        name: FlatFieldFile
        description: FlatFieldFile
        index_name: PilatusFlatFieldFile
        drv_info: FLAT_FIELD_FILE
        access: W
        record_fields:
          NELM: "256"
          FTVL: CHAR

      - type: AsynWaveform
        name: CbfTemplateFile
        description: CbfTemplateFile
        index_name: PilatusCbfTemplateFile
        drv_info: CBFTEMPLATEFILE
        access: W
        record_fields:
          NELM: "256"
          FTVL: CHAR

      - type: AsynWaveform
        name: HeaderString
        description: HeaderString
        index_name: PilatusHeaderString
        drv_info: HEADERSTRING
        access: W
        record_fields:
          NELM: "68"
          FTVL: CHAR

      - type: AsynBinary
        name: Armed
        description: Armed
        index_name: PilatusArmed
        drv_info: ARMED
        access: R
        read_record_suffix: Armed
        record_fields:
          SCAN: I/O Intr
          ZNAM: Unarmed
          ONAM: Armed

      - type: AsynLong
        name: NumBadPixels
        description: Number of bad pixels
        index_name: PilatusNumBadPixels
        drv_info: NUM_BAD_PIXELS
        access: R
        read_record_suffix: NumBadPixels
        record_fields:
          SCAN: I/O Intr

      - type: AsynBinary
        name: FlatFieldValid
        description: Flat field valid
        index_name: PilatusFlatFieldValid
        drv_info: FLAT_FIELD_VALID
        access: R
        read_record_suffix: FlatFieldValid
        record_fields:
          SCAN: I/O Intr
          ZNAM: No
          ONAM: Yes

      - type: AsynInt32
        name: PixelCutOff
        description: PixelCutOff_RBV
        index_name: PilatusPixelCutOff
        drv_info: PIXEL_CUTOFF
        access: R
        record_fields:
          SCAN: I/O Intr
          EGU: counts

      - type: AsynFloat64
        name: Temp0
        description: Temp0_RBV
        index_name: PilatusThTemp0
        drv_info: TH_TEMP_0
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: C

      - type: AsynFloat64
        name: Temp1
        description: Temp1_RBV
        index_name: PilatusThTemp1
        drv_info: TH_TEMP_1
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: C

      - type: AsynFloat64
        name: Temp2
        description: Temp2_RBV
        index_name: PilatusThTemp2
        drv_info: TH_TEMP_2
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: C

      - type: AsynFloat64
        name: Humid0
        description: Humid0_RBV
        index_name: PilatusThHumid0
        drv_info: TH_HUMID_0
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: "%"

      - type: AsynFloat64
        name: Humid1
        description: Humid1_RBV
        index_name: PilatusThHumid1
        drv_info: TH_HUMID_1
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: "%"

      - type: AsynFloat64
        name: Humid2
        description: Humid2_RBV
        index_name: PilatusThHumid2
        drv_info: TH_HUMID_2
        access: R
        record_fields:
          SCAN: I/O Intr
          PREC: "1"
          EGU: "%"

      - type: AsynString
        name: TVXVersion
        description: TVXVersion_RBV
        index_name: PilatusTvxVersion
        drv_info: TVXVERSION
        access: R
        record_fields:
          SCAN: I/O Intr

      - type: AsynLong
        name: ResetPowerTime
        description: Reset module power wait time
        index_name: PilatusResetPowerTime
        drv_info: RESET_POWER_TIME
        initial: "1"
        record_fields:
          SCAN: I/O Intr
          EGU: Seconds

      - type: AsynFloat64
        name: DelayTime
        description: DelayTime
        index_name: PilatusDelayTime
        drv_info: DELAY_TIME
        initial: "0"
        record_fields:
          SCAN: I/O Intr
          PREC: "6"
          EGU: s

      - type: AsynFloat64
        name: ThresholdEnergy
        description: Energy threshold
        index_name: PilatusThreshold
        drv_info: THRESHOLD
        initial: "10.000"
        record_fields:
          SCAN: I/O Intr
          PREC: "3"
          EGU: keV

      - type: AsynBinary
        name: ThresholdAutoApply
        description: ThresholdAutoApply
        index_name: PilatusThresholdAutoApply
        drv_info: THRESHOLD_AUTO_APPLY
        initial: "1"
        record_fields:
          SCAN: I/O Intr
          ZNAM: No
          ONAM: Yes

      - type: AsynFloat64
        name: Energy
        description: X-ray Energy
        index_name: PilatusEnergy
        drv_info: ENERGY
        initial: "20.000"
        record_fields:
          SCAN: I/O Intr
          PREC: "3"
          EGU: keV

      - type: AsynLong
        name: MinFlatField
        description: Minimum flat field value
        index_name: PilatusMinFlatField
        drv_info: MIN_FLAT_FIELD
        initial: "100"
        record_fields:
          SCAN: I/O Intr
          EGU: Counts

      - type: AsynMultiBitBinary
        name: GapFill
        description: GapFill
        index_name: PilatusGapFill
        drv_info: GAP_FILL
        initial: "0"
        record_fields:
          SCAN: I/O Intr
          ZRVL: "2"
          ONVL: "0"
          TWVL: "-1"
          ZRST: N.A.
          ONST: "0"
          TWST: "-1"

      - type: AsynFloat64
        name: ProgressBarTest
        description: ProgressBar
        drv_info: PROGRESS
        access: R
        read_widget:
          type: ProgressBar
        initial: 50.0
        record_fields:
          EGU: deg
          PREC: 4
        index_name: ProgressBarTest

Screen files

The intermediate objects are a number of Channel instances. These contain basic types (like Combo, TextInput, TextUpdate, LED, Group) and some creation hints (like label, grouping, description, display_form), but no X, Y, Width, Height or colour information. They may represent either a single widget or pair of demand/readback widgets.

The site-specific Formatter consumes these Channel objects, then produces a screen with style, sizing and layout that can be customized to the site. This means that the default layout (big screen with lots of widgets arranged in group boxes) could be produced for one site, then another site could make lots of little screens with one group per screen. Styling is also covered, so the blue/grey MEDM screens and green/grey EDM screens can be customized to fit the site style guide.

HTML Documentation

The Parameter and record sections of the existing documentation could be reproduced, in tabular form as a csv file that can be included in rst docs:

Pilatus Parameters

Parameter Index Variable

Asyn Interface

Access

drvInfo String

Record Names

Record Types

Description

ComponentGroupOne

PilatusResetPower

asynInt32

W

RESET_POWER

$(P)$(R)ResetPower

bo

ResetPower

PilatusThresholdApply

asynInt32

W

THRESHOLD_APPLY

$(P)$(R)ThresholdApply

busy

ThresholdApply

PilatusImageFileTmot

asynFloat64

W

IMAGE_FILE_TMOT

$(P)$(R)ImageFileTmot

ao

Timeout for image file

PilatusWavelength

asynFloat64

W

WAVELENGTH

$(P)$(R)Wavelength

ao

Wavelength

PilatusEnergyLow

asynFloat64

W

ENERGY_LOW

$(P)$(R)EnergyLow

ao

EnergyLow

PilatusEnergyHigh

asynFloat64

W

ENERGY_HIGH

$(P)$(R)EnergyHigh

ao

EnergyHigh

PilatusDetDist

asynFloat64

W

DET_DIST

$(P)$(R)DetDist

ao

DetDist

PilatusDetVOffset

asynFloat64

W

DET_VOFFSET

$(P)$(R)DetVOffset

ao

DetVOffset

PilatusBeamX

asynFloat64

W

BEAM_X

$(P)$(R)BeamX

ao

BeamX

PilatusBeamY

asynFloat64

W

BEAM_Y

$(P)$(R)BeamY

ao

BeamY

PilatusFlux

asynFloat64

W

FLUX

$(P)$(R)Flux

ao

Flux

PilatusFilterTransm

asynFloat64

W

FILTER_TRANSM

$(P)$(R)FilterTransm

ao

FilterTransm

PilatusStartAngle

asynFloat64

W

START_ANGLE

$(P)$(R)StartAngle

ao

StartAngle

PilatusAngleIncr

asynFloat64

W

ANGLE_INCR

$(P)$(R)AngleIncr

ao

AngleIncr

PilatusDet2theta

asynFloat64

W

DET_2THETA

$(P)$(R)Det2theta

ao

Det2theta

PilatusPolarization

asynFloat64

W

POLARIZATION

$(P)$(R)Polarization

ao

Polarization

PilatusAlpha

asynFloat64

W

ALPHA

$(P)$(R)Alpha

ao

Alpha

PilatusKappa

asynFloat64

W

KAPPA

$(P)$(R)Kappa

ao

Kappa

PilatusPhi

asynFloat64

W

PHI

$(P)$(R)Phi

ao

Phi

PilatusPhiIncr

asynFloat64

W

PHI_INCR

$(P)$(R)PhiIncr

ao

PhiIncr

PilatusChi

asynFloat64

W

CHI

$(P)$(R)Chi

ao

Chi

PilatusChiIncr

asynFloat64

W

CHI_INCR

$(P)$(R)ChiIncr

ao

ChiIncr

PilatusOmega

asynFloat64

W

OMEGA

$(P)$(R)Omega

ao

Omega

PilatusOmegaIncr

asynFloat64

W

OMEGA_INCR

$(P)$(R)OmegaIncr

ao

OmegaIncr

PilatusOscillAxis

asynOctetWrite

W

OSCILL_AXIS

$(P)$(R)OscillAxis

stringout

OscillAxis

PilatusNumOscill

asynInt32

W

NUM_OSCILL

$(P)$(R)NumOscill

longout

NumOscill

PilatusBadPixelFile

asynOctetWrite

W

BAD_PIXEL_FILE

$(P)$(R)BadPixelFile

waveform

BadPixelFile

PilatusFlatFieldFile

asynOctetWrite

W

FLAT_FIELD_FILE

$(P)$(R)FlatFieldFile

waveform

FlatFieldFile

PilatusCbfTemplateFile

asynOctetWrite

W

CBFTEMPLATEFILE

$(P)$(R)CbfTemplateFile

waveform

CbfTemplateFile

PilatusHeaderString

asynOctetWrite

W

HEADERSTRING

$(P)$(R)HeaderString

waveform

HeaderString

PilatusArmed

asynInt32

R

ARMED

$(P)$(R)Armed

bi

Armed

PilatusNumBadPixels

asynInt32

R

NUM_BAD_PIXELS

$(P)$(R)NumBadPixels

longin

Number of bad pixels

PilatusFlatFieldValid

asynInt32

R

FLAT_FIELD_VALID

$(P)$(R)FlatFieldValid

bi

Flat field valid

PilatusPixelCutOff

asynInt32

R

PIXEL_CUTOFF

$(P)$(R)PixelCutOff_RBV

ai

PixelCutOff_RBV

PilatusThTemp0

asynFloat64

R

TH_TEMP_0

$(P)$(R)Temp0_RBV

ai

Temp0_RBV

PilatusThTemp1

asynFloat64

R

TH_TEMP_1

$(P)$(R)Temp1_RBV

ai

Temp1_RBV

PilatusThTemp2

asynFloat64

R

TH_TEMP_2

$(P)$(R)Temp2_RBV

ai

Temp2_RBV

PilatusThHumid0

asynFloat64

R

TH_HUMID_0

$(P)$(R)Humid0_RBV

ai

Humid0_RBV

PilatusThHumid1

asynFloat64

R

TH_HUMID_1

$(P)$(R)Humid1_RBV

ai

Humid1_RBV

PilatusThHumid2

asynFloat64

R

TH_HUMID_2

$(P)$(R)Humid2_RBV

ai

Humid2_RBV

PilatusTvxVersion

asynOctetRead

R

TVXVERSION

$(P)$(R)TVXVersion_RBV

stringin

TVXVersion_RBV

PilatusResetPowerTime

asynInt32

RW

RESET_POWER_TIME

$(P)$(R)ResetPowerTime, $(P)$(R)ResetPowerTime_RBV

longout, longin

Reset module power wait time

PilatusDelayTime

asynFloat64

RW

DELAY_TIME

$(P)$(R)DelayTime, $(P)$(R)DelayTime_RBV

ao, ai

DelayTime

PilatusThreshold

asynFloat64

RW

THRESHOLD

$(P)$(R)ThresholdEnergy, $(P)$(R)ThresholdEnergy_RBV

ao, ai

Energy threshold

PilatusThresholdAutoApply

asynInt32

RW

THRESHOLD_AUTO_APPLY

$(P)$(R)ThresholdAutoApply, $(P)$(R)ThresholdAutoApply_RBV

bo, bi

ThresholdAutoApply

PilatusEnergy

asynFloat64

RW

ENERGY

$(P)$(R)Energy, $(P)$(R)Energy_RBV

ao, ai

X-ray Energy

PilatusMinFlatField

asynInt32

RW

MIN_FLAT_FIELD

$(P)$(R)MinFlatField, $(P)$(R)MinFlatField_RBV

longout, longin

Minimum flat field value

PilatusGapFill

asynInt32

RW

GAP_FILL

$(P)$(R)GapFill, $(P)$(R)GapFill_RBV

mbbo, mbbi

GapFill

ProgressBarTest

asynFloat64

R

PROGRESS

$(P)$(R)ProgressBarTest_RBV

ai

ProgressBar

Questions

I am fairly happy with the scheme set out above, but there are a lot of implementation questions. Here are the most pressing:

One-time generation and checked into source control or generated by Makefile?

The process would probably be:

  • If pvi cli tool available, build products as part of make

  • Check in products to source control

  • End users will only regenerate build products if pvi tool installed

ADGenICam would be supported by building a GenICamProducer which took no components, just a path to a GenICam XML file

Which screen tools to support?

I suggest creating adl and edl files initially, following the example of makeAdl.py in ADGenICam, then expanding to support opi, bob and ui files natively. This would avoid needing screen converters installed