# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "BPMS:UNDH:1990:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:1990:URER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:1990:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:1990:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:1990:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:1990:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S6")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

##############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:UNDH:1990:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S0")
  field(EGU, "Nel")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:UNDH:1990:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UNDH:1990:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:1990:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:1990:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UNDH:1990:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UNDH:1990:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C0 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:1990:PRENV")
}

record(waveform, "BPMS:UNDH:1990:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C0 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
}

# Filter frequency response
# (updated/scanned by driver)
record(waveform, "BPMS:UNDH:1990:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C0 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UNDH:1990:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C0 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "BPMS:UNDH:1990:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UNDH:1990:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:1990:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UNDH:1990:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UNDH:1990:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "BPMS:UNDH:1990:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:UNDH:1990:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:1990:CHK.SEVR MS NPP")
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UNDH:1990:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:1990:FILT.B PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#field(VAL,  "0")
#field(UDF,  "0")
#field(STAT, "0")
#field(SEVR, "0")
#}
#record(ao,  "BPMS:UNDH:1990:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:1990:FILT.C PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#}
# Filter Parameters. 
# 
# B: fc; reference cavity
# C: bw; reference cavity
#
# E: fc; U cavity
# F: bw; U cavity
# G: ts; U cavity
# H: fc; V cavity
# I: bw; V cavity
# J: ts; V cavity
# K: fo; sampling freq.
#
# NOTE: Do NOT create other records to write
#       the fc or bw parameters w/o providing
#       proper logic to update those records
#       when the driver changes bw/fc (auto-set
#       feature if either of them is zero)
record(sub, "BPMS:UNDH:1990:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "0")
#field(INPB, "BPMS:UNDH:1990:FC_REF")
#field(INPC, "BPMS:UNDH:1990:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "BPMS:UNDH:1990:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:TS_U_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:1990:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:1990:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UNDH:1990:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:TS_V_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  field(ASLO, ".001")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:1990:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:1990:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "BPMS:UNDH:1990:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "BPMS:UNDH:1990:FILT.B NPP")
#field(LNK1, "BPMS:UNDH:1990:FC_REF NPP")
#field(DOL2, "BPMS:UNDH:1990:FILT.C NPP")
#field(LNK2, "BPMS:UNDH:1990:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "BPMS:UNDH:1990:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:1990:UPHAS_SEQ")
}

record(ao, "BPMS:UNDH:1990:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:1990:VPHAS_SEQ")
}

record(ao, "BPMS:UNDH:1990:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C0S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:1990:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "BPMS:UNDH:1990:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:1990:UPHAS_OUT")
  field(OUT, "BPMS:UNDH:1990:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:1990:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C0S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:1990:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "BPMS:UNDH:1990:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:1990:VPHAS_OUT")
  field(OUT, "BPMS:UNDH:1990:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:1990:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:1990:QSCL_SEQ")
}

record(ao, "BPMS:UNDH:1990:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:URSCL_SEQ")
}

record(ao, "BPMS:UNDH:1990:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:VRSCL_SEQ")
}

record(ao, "BPMS:UNDH:1990:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:1990:QRSCL_SEQ")
}

record(sub, "BPMS:UNDH:1990:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "0")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "BPMS:UNDH:1990:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "BPMS:UNDH:1990:REFR MS CA")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(FLNK, "BPMS:UNDH:1990:URER_SLOW")
}

record(ai, "BPMS:UNDH:1990:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:1990:URER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:1990:UIMR_SLOW")
}

record(ai, "BPMS:UNDH:1990:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:1990:UIMR MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:1990:VRER_SLOW")
}

record(ai, "BPMS:UNDH:1990:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:1990:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:1990:VIMR_SLOW")
}

record(ai, "BPMS:UNDH:1990:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:1990:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

######################################
# HEAD of main processing chain
######################################

record(ai, "BPMS:UNDH:1990:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:1990:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:1990:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S12")
  field(FLNK, "BPMS:UNDH:1990:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:1990:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UNDH:1990:EFX.PROC")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "BPMS:UNDH:1990:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C0 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "BPMS:UNDH:1990:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S8")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:1990:V")
}

record(ai, "BPMS:UNDH:1990:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:1990:PINC")
}

record(ai, "BPMS:UNDH:1990:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S10")
  field(SCAN, "Passive")
}

record(longin, "BPMS:UNDH:1990:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C0S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "BPMS:UNDH:1990:RSTA_ALH")
}


record(calc, "BPMS:UNDH:1990:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "BPMS:UNDH:1990:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "BPMS:UNDH:1990:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:1990:PHI_SEQ")
}

record(ao, "BPMS:UNDH:1990:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:1990:PSI_SEQ")
}

#record(dfanout, "BPMS:UNDH:1990:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "BPMS:UNDH:1990:USCL PP MS")
#  field(OUTB, "BPMS:UNDH:1990:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "BPMS:UNDH:1990:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:1990:UOFF_SEQ")
}

record(ao, "BPMS:UNDH:1990:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:1990:VOFF_SEQ")
}

record(ao, "BPMS:UNDH:1990:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:USCL_SEQ")
}

record(ao, "BPMS:UNDH:1990:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:VSCL_SEQ")
}


record(mbbo, "BPMS:UNDH:1990:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C0 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:UNDH:1990:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:UNDH:1990:FBCK")
{
  field(DESC, "Feedback State")
  field(PINI, "YES")
# Off - this device can be used in feedback but all feedback loops 
# using it are off.
  field(ZRST, "Off")
# On - this device is being used by one or more feedback loops.
  field(ONST, "On")
# Unavailable - this device is not used by any feedback loop.
  field(TWST, "Unavailable")
  info(autosaveFields, "RVAL")
}

# Convenience record holding the MAD name
record(stringin, "BPMS:UNDH:1990:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBHX19")
  field(PINI, "YES")
}

record(stringin, "RFBHX19:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UNDH:1990")
  field(PINI, "YES")
}

record(ai, "BPMS:UNDH:1990:X_SLOW") {
#alias("BPMS:UNDH:1990:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:1990:X MS")
  field(FLNK, "BPMS:UNDH:1990:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:1990:Y_SLOW") {
#alias("BPMS:UNDH:1990:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:1990:Y NPP MS")
  field(FLNK, "BPMS:UNDH:1990:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:1990:TMIT_SLOW") {
#alias("BPMS:UNDH:1990:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UNDH:1990:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "BPMS:UNDH:1990:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UNDH:1990:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UNDH:1990:SIMC PP")
}

record(calcout, "BPMS:UNDH:1990:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "0")
#CALC & VAL unused; the real calculation is done
#        in device support. The reason this is a
#        calcout rather than sub is that we want
#        to use the OUT link...
  field(CALC, "A")
  field(INPA, "BPMS:UNDH:1990:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UNDH:1990:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UNDH:1990:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UNDH:1990:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:UNDH:1990:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:1990:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:1990:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UNDH:1990:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:UNDH:1990:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "BPMS:UNDH:1990:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:1990:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "BPMS:UNDH:1990:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C0 S0")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32678")
  field(LOPR, "-32768")
# 16384 samples/channel * 4 channels
  field(NELM, "65536")
  field(PINI, "NO")
}

#Used by model/database folks to verify BPM

record(ao, "BPMS:UNDH:1990:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UNDH:1990:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x001")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:1990:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x001")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(calc, "BPMS:UNDH:1990:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UNDH:1990:TMIT")
  field(INPB, "BPMS:UNDH:1990:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UNDH:1990:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UNDH:1990:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
}

# Proxy records for users to set X.AOFF, Y.AOFF
# Placed CAS on X and Y for MPS 
# Feb 2010 - CAS has since been removed, but we'll keep 
# these proxy records as they're already in use

record(ao, "BPMS:UNDH:1990:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UNDH:1990:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:UNDH:1990:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "BPMS:UNDH:1990:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:1990:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "BPMS:UNDH:1990:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:1990:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:1990:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "BPMS:UNDH:1990:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:1990:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:1990:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "BPMS:UNDH:1990:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:1990:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:1990:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:1990:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:1990:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:1990:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C0 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bi, "BPMS:UNDH:1990:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:UNDH:1990:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:UNDH:1990:SIMCSEQ") {
  field(DESC, "BPM Sim Ctl Seq")
  field(SELM, "Mask")
  field(SELN, "0")

  field(DO1,  "1")
  field(DO2,  "0")
  field(DO3,  "0")
  field(DO4,  "0") #Passive

#  field(DO5,  "7") # .5 second
  field(DO5,  "9") # .1 second
  field(DO6,  "2")
  field(DO7,  "1")
  field(DO8,  "10")
  field(DO9,  "0")

# LNK 1, 2, 8, 9 only relevant for PADs
# Default macro values are set for PADs; other
# architectures must pass in "" for lnk1 and lnk2
  field(LNK1, "")
  field(LNK2, "")
  field(LNK3, "BPMS:UNDH:1990:SIM.L     PP")
  field(LNK4, "BPMS:UNDH:1990:SIM.SCAN  PP")

  field(LNK5, "BPMS:UNDH:1990:SIM.SCAN  PP")
  field(LNK6, "BPMS:UNDH:1990:SIM.L     PP")
  field(LNK7, "BPMS:UNDH:1990:SIM.L     PP")
  field(LNK8, "")
  field(LNK9, "")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:UOFF")
	field(DOL2, "BPMS:UNDH:1990:UOFF")
	field(DOL3, "BPMS:UNDH:1990:UOFF")
	field(DOL4, "BPMS:UNDH:1990:UOFF")
	field(DOL5, "BPMS:UNDH:1990:UOFF")
	field(DOL6, "BPMS:UNDH:1990:UOFF")
	field(DOL7, "BPMS:UNDH:1990:UOFF")
	field(DOL8, "BPMS:UNDH:1990:UOFF")
	field(DOL9, "BPMS:UNDH:1990:UOFF")
	field(DOLA, "BPMS:UNDH:1990:UOFF")
	field(LNK1, "BPMS:UNDH:1990:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:UOFF_SEL")
	field(OUTA, "BPMS:UNDH:1990:U.AOFF CA")
	field(OUTB, "BPMS:UNDH:1990:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:UOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:VOFF")
	field(DOL2, "BPMS:UNDH:1990:VOFF")
	field(DOL3, "BPMS:UNDH:1990:VOFF")
	field(DOL4, "BPMS:UNDH:1990:VOFF")
	field(DOL5, "BPMS:UNDH:1990:VOFF")
	field(DOL6, "BPMS:UNDH:1990:VOFF")
	field(DOL7, "BPMS:UNDH:1990:VOFF")
	field(DOL8, "BPMS:UNDH:1990:VOFF")
	field(DOL9, "BPMS:UNDH:1990:VOFF")
	field(DOLA, "BPMS:UNDH:1990:VOFF")
	field(LNK1, "BPMS:UNDH:1990:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:VOFF_SEL")
	field(OUTA, "BPMS:UNDH:1990:V.AOFF CA")
	field(OUTB, "BPMS:UNDH:1990:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:VOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:USCL")
	field(DOL2, "BPMS:UNDH:1990:USCL")
	field(DOL3, "BPMS:UNDH:1990:USCL")
	field(DOL4, "BPMS:UNDH:1990:USCL")
	field(DOL5, "BPMS:UNDH:1990:USCL")
	field(DOL6, "BPMS:UNDH:1990:USCL")
	field(DOL7, "BPMS:UNDH:1990:USCL")
	field(DOL8, "BPMS:UNDH:1990:USCL")
	field(DOL9, "BPMS:UNDH:1990:USCL")
	field(DOLA, "BPMS:UNDH:1990:USCL")
	field(LNK1, "BPMS:UNDH:1990:USCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:USCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:USCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:USCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:USCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:USCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:USCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:USCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:USCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:USCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:U.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:USCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:VSCL")
	field(DOL2, "BPMS:UNDH:1990:VSCL")
	field(DOL3, "BPMS:UNDH:1990:VSCL")
	field(DOL4, "BPMS:UNDH:1990:VSCL")
	field(DOL5, "BPMS:UNDH:1990:VSCL")
	field(DOL6, "BPMS:UNDH:1990:VSCL")
	field(DOL7, "BPMS:UNDH:1990:VSCL")
	field(DOL8, "BPMS:UNDH:1990:VSCL")
	field(DOL9, "BPMS:UNDH:1990:VSCL")
	field(DOLA, "BPMS:UNDH:1990:VSCL")
	field(LNK1, "BPMS:UNDH:1990:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:VSCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:V.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:VSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:PHI")
	field(DOL2, "BPMS:UNDH:1990:PHI")
	field(DOL3, "BPMS:UNDH:1990:PHI")
	field(DOL4, "BPMS:UNDH:1990:PHI")
	field(DOL5, "BPMS:UNDH:1990:PHI")
	field(DOL6, "BPMS:UNDH:1990:PHI")
	field(DOL7, "BPMS:UNDH:1990:PHI")
	field(DOL8, "BPMS:UNDH:1990:PHI")
	field(DOL9, "BPMS:UNDH:1990:PHI")
	field(DOLA, "BPMS:UNDH:1990:PHI")
	field(LNK1, "BPMS:UNDH:1990:PHI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:PHI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:PHI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:PHI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:PHI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:PHI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:PHI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:PHI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:PHI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:1990:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:PHI_SEL")
	field(OUTA, "BPMS:UNDH:1990:CALC.E CA")
	field(OUTB, "BPMS:UNDH:1990:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:PHI_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:PSI")
	field(DOL2, "BPMS:UNDH:1990:PSI")
	field(DOL3, "BPMS:UNDH:1990:PSI")
	field(DOL4, "BPMS:UNDH:1990:PSI")
	field(DOL5, "BPMS:UNDH:1990:PSI")
	field(DOL6, "BPMS:UNDH:1990:PSI")
	field(DOL7, "BPMS:UNDH:1990:PSI")
	field(DOL8, "BPMS:UNDH:1990:PSI")
	field(DOL9, "BPMS:UNDH:1990:PSI")
	field(DOLA, "BPMS:UNDH:1990:PSI")
	field(LNK1, "BPMS:UNDH:1990:PSI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:PSI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:PSI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:PSI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:PSI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:PSI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:PSI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:PSI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:PSI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:1990:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:PSI_SEL")
	field(OUTA, "BPMS:UNDH:1990:CALC.F CA")
	field(OUTB, "BPMS:UNDH:1990:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:PSI_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:PSI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:UPHAS")
	field(DOL2, "BPMS:UNDH:1990:UPHAS")
	field(DOL3, "BPMS:UNDH:1990:UPHAS")
	field(DOL4, "BPMS:UNDH:1990:UPHAS")
	field(DOL5, "BPMS:UNDH:1990:UPHAS")
	field(DOL6, "BPMS:UNDH:1990:UPHAS")
	field(DOL7, "BPMS:UNDH:1990:UPHAS")
	field(DOL8, "BPMS:UNDH:1990:UPHAS")
	field(DOL9, "BPMS:UNDH:1990:UPHAS")
	field(DOLA, "BPMS:UNDH:1990:UPHAS")
	field(LNK1, "BPMS:UNDH:1990:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:UPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:UPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:1990:UPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:UPHAS_SEL")
	field(OUTA, "BPMS:UNDH:1990:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:1990:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:UPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:UPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:VPHAS")
	field(DOL2, "BPMS:UNDH:1990:VPHAS")
	field(DOL3, "BPMS:UNDH:1990:VPHAS")
	field(DOL4, "BPMS:UNDH:1990:VPHAS")
	field(DOL5, "BPMS:UNDH:1990:VPHAS")
	field(DOL6, "BPMS:UNDH:1990:VPHAS")
	field(DOL7, "BPMS:UNDH:1990:VPHAS")
	field(DOL8, "BPMS:UNDH:1990:VPHAS")
	field(DOL9, "BPMS:UNDH:1990:VPHAS")
	field(DOLA, "BPMS:UNDH:1990:VPHAS")
	field(LNK1, "BPMS:UNDH:1990:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:VPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:VPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:1990:VPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:VPHAS_SEL")
	field(OUTA, "BPMS:UNDH:1990:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:1990:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:VPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:VPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:QSCL")
	field(DOL2, "BPMS:UNDH:1990:QSCL")
	field(DOL3, "BPMS:UNDH:1990:QSCL")
	field(DOL4, "BPMS:UNDH:1990:QSCL")
	field(DOL5, "BPMS:UNDH:1990:QSCL")
	field(DOL6, "BPMS:UNDH:1990:QSCL")
	field(DOL7, "BPMS:UNDH:1990:QSCL")
	field(DOL8, "BPMS:UNDH:1990:QSCL")
	field(DOL9, "BPMS:UNDH:1990:QSCL")
	field(DOLA, "BPMS:UNDH:1990:QSCL")
	field(LNK1, "BPMS:UNDH:1990:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:QSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:QSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:1990:QSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:QSCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:TMIT.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:QSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:QSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:URSCL")
	field(DOL2, "BPMS:UNDH:1990:URSCL")
	field(DOL3, "BPMS:UNDH:1990:URSCL")
	field(DOL4, "BPMS:UNDH:1990:URSCL")
	field(DOL5, "BPMS:UNDH:1990:URSCL")
	field(DOL6, "BPMS:UNDH:1990:URSCL")
	field(DOL7, "BPMS:UNDH:1990:URSCL")
	field(DOL8, "BPMS:UNDH:1990:URSCL")
	field(DOL9, "BPMS:UNDH:1990:URSCL")
	field(DOLA, "BPMS:UNDH:1990:URSCL")
	field(LNK1, "BPMS:UNDH:1990:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:URSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:URSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:URSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:URSCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:URMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:URSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:URSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:VRSCL")
	field(DOL2, "BPMS:UNDH:1990:VRSCL")
	field(DOL3, "BPMS:UNDH:1990:VRSCL")
	field(DOL4, "BPMS:UNDH:1990:VRSCL")
	field(DOL5, "BPMS:UNDH:1990:VRSCL")
	field(DOL6, "BPMS:UNDH:1990:VRSCL")
	field(DOL7, "BPMS:UNDH:1990:VRSCL")
	field(DOL8, "BPMS:UNDH:1990:VRSCL")
	field(DOL9, "BPMS:UNDH:1990:VRSCL")
	field(DOLA, "BPMS:UNDH:1990:VRSCL")
	field(LNK1, "BPMS:UNDH:1990:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:VRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:VRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:1990:VRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:VRSCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:VRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:VRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:VRSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:1990:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:1990:QRSCL")
	field(DOL2, "BPMS:UNDH:1990:QRSCL")
	field(DOL3, "BPMS:UNDH:1990:QRSCL")
	field(DOL4, "BPMS:UNDH:1990:QRSCL")
	field(DOL5, "BPMS:UNDH:1990:QRSCL")
	field(DOL6, "BPMS:UNDH:1990:QRSCL")
	field(DOL7, "BPMS:UNDH:1990:QRSCL")
	field(DOL8, "BPMS:UNDH:1990:QRSCL")
	field(DOL9, "BPMS:UNDH:1990:QRSCL")
	field(DOLA, "BPMS:UNDH:1990:QRSCL")
	field(LNK1, "BPMS:UNDH:1990:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:1990:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:1990:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:1990:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:1990:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:1990:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:1990:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:1990:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:1990:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:1990:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:1990:QRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:1990:QRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:1990:QRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:1990:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:1990:QRSCL_SEL")
	field(OUTA, "BPMS:UNDH:1990:RRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:1990:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:1990:QRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:1990:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:1990:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UNDH:1990:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UNDH:1990:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "BPMS:UNDH:2090:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2090:URER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2090:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2090:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2090:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2090:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S6")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

##############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:UNDH:2090:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S0")
  field(EGU, "Nel")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:UNDH:2090:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UNDH:2090:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2090:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2090:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UNDH:2090:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C1 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UNDH:2090:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C1 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2090:PRENV")
}

record(waveform, "BPMS:UNDH:2090:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C1 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
}

# Filter frequency response
# (updated/scanned by driver)
record(waveform, "BPMS:UNDH:2090:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C1 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UNDH:2090:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C1 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "BPMS:UNDH:2090:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UNDH:2090:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2090:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UNDH:2090:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UNDH:2090:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "BPMS:UNDH:2090:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:UNDH:2090:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2090:CHK.SEVR MS NPP")
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UNDH:2090:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2090:FILT.B PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#field(VAL,  "0")
#field(UDF,  "0")
#field(STAT, "0")
#field(SEVR, "0")
#}
#record(ao,  "BPMS:UNDH:2090:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2090:FILT.C PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#}
# Filter Parameters. 
# 
# B: fc; reference cavity
# C: bw; reference cavity
#
# E: fc; U cavity
# F: bw; U cavity
# G: ts; U cavity
# H: fc; V cavity
# I: bw; V cavity
# J: ts; V cavity
# K: fo; sampling freq.
#
# NOTE: Do NOT create other records to write
#       the fc or bw parameters w/o providing
#       proper logic to update those records
#       when the driver changes bw/fc (auto-set
#       feature if either of them is zero)
record(sub, "BPMS:UNDH:2090:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "1")
#field(INPB, "BPMS:UNDH:2090:FC_REF")
#field(INPC, "BPMS:UNDH:2090:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "BPMS:UNDH:2090:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:TS_U_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2090:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2090:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UNDH:2090:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:TS_V_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  field(ASLO, ".001")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2090:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2090:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "BPMS:UNDH:2090:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "BPMS:UNDH:2090:FILT.B NPP")
#field(LNK1, "BPMS:UNDH:2090:FC_REF NPP")
#field(DOL2, "BPMS:UNDH:2090:FILT.C NPP")
#field(LNK2, "BPMS:UNDH:2090:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "BPMS:UNDH:2090:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2090:UPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2090:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2090:VPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2090:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C1S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2090:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "BPMS:UNDH:2090:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2090:UPHAS_OUT")
  field(OUT, "BPMS:UNDH:2090:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2090:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C1S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2090:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "BPMS:UNDH:2090:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2090:VPHAS_OUT")
  field(OUT, "BPMS:UNDH:2090:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2090:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2090:QSCL_SEQ")
}

record(ao, "BPMS:UNDH:2090:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:URSCL_SEQ")
}

record(ao, "BPMS:UNDH:2090:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:VRSCL_SEQ")
}

record(ao, "BPMS:UNDH:2090:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2090:QRSCL_SEQ")
}

record(sub, "BPMS:UNDH:2090:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "1")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "BPMS:UNDH:2090:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "BPMS:UNDH:2090:REFR MS CA")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(FLNK, "BPMS:UNDH:2090:URER_SLOW")
}

record(ai, "BPMS:UNDH:2090:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2090:URER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2090:UIMR_SLOW")
}

record(ai, "BPMS:UNDH:2090:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2090:UIMR MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2090:VRER_SLOW")
}

record(ai, "BPMS:UNDH:2090:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2090:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2090:VIMR_SLOW")
}

record(ai, "BPMS:UNDH:2090:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2090:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

######################################
# HEAD of main processing chain
######################################

record(ai, "BPMS:UNDH:2090:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2090:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2090:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S12")
  field(FLNK, "BPMS:UNDH:2090:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2090:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UNDH:2090:EFX.PROC")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "BPMS:UNDH:2090:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C1 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "BPMS:UNDH:2090:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S8")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2090:V")
}

record(ai, "BPMS:UNDH:2090:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2090:PINC")
}

record(ai, "BPMS:UNDH:2090:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S10")
  field(SCAN, "Passive")
}

record(longin, "BPMS:UNDH:2090:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C1S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "BPMS:UNDH:2090:RSTA_ALH")
}


record(calc, "BPMS:UNDH:2090:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "BPMS:UNDH:2090:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "BPMS:UNDH:2090:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2090:PHI_SEQ")
}

record(ao, "BPMS:UNDH:2090:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2090:PSI_SEQ")
}

#record(dfanout, "BPMS:UNDH:2090:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "BPMS:UNDH:2090:USCL PP MS")
#  field(OUTB, "BPMS:UNDH:2090:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "BPMS:UNDH:2090:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2090:UOFF_SEQ")
}

record(ao, "BPMS:UNDH:2090:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2090:VOFF_SEQ")
}

record(ao, "BPMS:UNDH:2090:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:USCL_SEQ")
}

record(ao, "BPMS:UNDH:2090:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:VSCL_SEQ")
}


record(mbbo, "BPMS:UNDH:2090:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C1 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:UNDH:2090:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:UNDH:2090:FBCK")
{
  field(DESC, "Feedback State")
  field(PINI, "YES")
# Off - this device can be used in feedback but all feedback loops 
# using it are off.
  field(ZRST, "Off")
# On - this device is being used by one or more feedback loops.
  field(ONST, "On")
# Unavailable - this device is not used by any feedback loop.
  field(TWST, "Unavailable")
  info(autosaveFields, "RVAL")
}

# Convenience record holding the MAD name
record(stringin, "BPMS:UNDH:2090:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBHX20")
  field(PINI, "YES")
}

record(stringin, "RFBHX20:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UNDH:2090")
  field(PINI, "YES")
}

record(ai, "BPMS:UNDH:2090:X_SLOW") {
#alias("BPMS:UNDH:2090:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2090:X MS")
  field(FLNK, "BPMS:UNDH:2090:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2090:Y_SLOW") {
#alias("BPMS:UNDH:2090:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2090:Y NPP MS")
  field(FLNK, "BPMS:UNDH:2090:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2090:TMIT_SLOW") {
#alias("BPMS:UNDH:2090:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UNDH:2090:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "BPMS:UNDH:2090:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UNDH:2090:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UNDH:2090:SIMC PP")
}

record(calcout, "BPMS:UNDH:2090:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "1")
#CALC & VAL unused; the real calculation is done
#        in device support. The reason this is a
#        calcout rather than sub is that we want
#        to use the OUT link...
  field(CALC, "A")
  field(INPA, "BPMS:UNDH:2090:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UNDH:2090:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UNDH:2090:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UNDH:2090:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:UNDH:2090:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2090:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2090:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UNDH:2090:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:UNDH:2090:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "BPMS:UNDH:2090:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2090:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "BPMS:UNDH:2090:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C1 S0")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32678")
  field(LOPR, "-32768")
# 16384 samples/channel * 4 channels
  field(NELM, "65536")
  field(PINI, "NO")
}

#Used by model/database folks to verify BPM

record(ao, "BPMS:UNDH:2090:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UNDH:2090:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x002")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2090:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x002")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(calc, "BPMS:UNDH:2090:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UNDH:2090:TMIT")
  field(INPB, "BPMS:UNDH:2090:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UNDH:2090:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UNDH:2090:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
}

# Proxy records for users to set X.AOFF, Y.AOFF
# Placed CAS on X and Y for MPS 
# Feb 2010 - CAS has since been removed, but we'll keep 
# these proxy records as they're already in use

record(ao, "BPMS:UNDH:2090:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UNDH:2090:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:UNDH:2090:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "BPMS:UNDH:2090:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2090:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "BPMS:UNDH:2090:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2090:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2090:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "BPMS:UNDH:2090:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2090:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2090:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "BPMS:UNDH:2090:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2090:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2090:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2090:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2090:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2090:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C1 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bi, "BPMS:UNDH:2090:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:UNDH:2090:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:UNDH:2090:SIMCSEQ") {
  field(DESC, "BPM Sim Ctl Seq")
  field(SELM, "Mask")
  field(SELN, "0")

  field(DO1,  "1")
  field(DO2,  "0")
  field(DO3,  "0")
  field(DO4,  "0") #Passive

#  field(DO5,  "7") # .5 second
  field(DO5,  "9") # .1 second
  field(DO6,  "2")
  field(DO7,  "1")
  field(DO8,  "10")
  field(DO9,  "0")

# LNK 1, 2, 8, 9 only relevant for PADs
# Default macro values are set for PADs; other
# architectures must pass in "" for lnk1 and lnk2
  field(LNK1, "")
  field(LNK2, "")
  field(LNK3, "BPMS:UNDH:2090:SIM.L     PP")
  field(LNK4, "BPMS:UNDH:2090:SIM.SCAN  PP")

  field(LNK5, "BPMS:UNDH:2090:SIM.SCAN  PP")
  field(LNK6, "BPMS:UNDH:2090:SIM.L     PP")
  field(LNK7, "BPMS:UNDH:2090:SIM.L     PP")
  field(LNK8, "")
  field(LNK9, "")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:UOFF")
	field(DOL2, "BPMS:UNDH:2090:UOFF")
	field(DOL3, "BPMS:UNDH:2090:UOFF")
	field(DOL4, "BPMS:UNDH:2090:UOFF")
	field(DOL5, "BPMS:UNDH:2090:UOFF")
	field(DOL6, "BPMS:UNDH:2090:UOFF")
	field(DOL7, "BPMS:UNDH:2090:UOFF")
	field(DOL8, "BPMS:UNDH:2090:UOFF")
	field(DOL9, "BPMS:UNDH:2090:UOFF")
	field(DOLA, "BPMS:UNDH:2090:UOFF")
	field(LNK1, "BPMS:UNDH:2090:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:UOFF_SEL")
	field(OUTA, "BPMS:UNDH:2090:U.AOFF CA")
	field(OUTB, "BPMS:UNDH:2090:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:UOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:VOFF")
	field(DOL2, "BPMS:UNDH:2090:VOFF")
	field(DOL3, "BPMS:UNDH:2090:VOFF")
	field(DOL4, "BPMS:UNDH:2090:VOFF")
	field(DOL5, "BPMS:UNDH:2090:VOFF")
	field(DOL6, "BPMS:UNDH:2090:VOFF")
	field(DOL7, "BPMS:UNDH:2090:VOFF")
	field(DOL8, "BPMS:UNDH:2090:VOFF")
	field(DOL9, "BPMS:UNDH:2090:VOFF")
	field(DOLA, "BPMS:UNDH:2090:VOFF")
	field(LNK1, "BPMS:UNDH:2090:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:VOFF_SEL")
	field(OUTA, "BPMS:UNDH:2090:V.AOFF CA")
	field(OUTB, "BPMS:UNDH:2090:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:VOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:USCL")
	field(DOL2, "BPMS:UNDH:2090:USCL")
	field(DOL3, "BPMS:UNDH:2090:USCL")
	field(DOL4, "BPMS:UNDH:2090:USCL")
	field(DOL5, "BPMS:UNDH:2090:USCL")
	field(DOL6, "BPMS:UNDH:2090:USCL")
	field(DOL7, "BPMS:UNDH:2090:USCL")
	field(DOL8, "BPMS:UNDH:2090:USCL")
	field(DOL9, "BPMS:UNDH:2090:USCL")
	field(DOLA, "BPMS:UNDH:2090:USCL")
	field(LNK1, "BPMS:UNDH:2090:USCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:USCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:USCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:USCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:USCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:USCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:USCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:USCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:USCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:USCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:U.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:USCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:VSCL")
	field(DOL2, "BPMS:UNDH:2090:VSCL")
	field(DOL3, "BPMS:UNDH:2090:VSCL")
	field(DOL4, "BPMS:UNDH:2090:VSCL")
	field(DOL5, "BPMS:UNDH:2090:VSCL")
	field(DOL6, "BPMS:UNDH:2090:VSCL")
	field(DOL7, "BPMS:UNDH:2090:VSCL")
	field(DOL8, "BPMS:UNDH:2090:VSCL")
	field(DOL9, "BPMS:UNDH:2090:VSCL")
	field(DOLA, "BPMS:UNDH:2090:VSCL")
	field(LNK1, "BPMS:UNDH:2090:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:VSCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:V.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:VSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:PHI")
	field(DOL2, "BPMS:UNDH:2090:PHI")
	field(DOL3, "BPMS:UNDH:2090:PHI")
	field(DOL4, "BPMS:UNDH:2090:PHI")
	field(DOL5, "BPMS:UNDH:2090:PHI")
	field(DOL6, "BPMS:UNDH:2090:PHI")
	field(DOL7, "BPMS:UNDH:2090:PHI")
	field(DOL8, "BPMS:UNDH:2090:PHI")
	field(DOL9, "BPMS:UNDH:2090:PHI")
	field(DOLA, "BPMS:UNDH:2090:PHI")
	field(LNK1, "BPMS:UNDH:2090:PHI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:PHI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:PHI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:PHI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:PHI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:PHI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:PHI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:PHI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:PHI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2090:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:PHI_SEL")
	field(OUTA, "BPMS:UNDH:2090:CALC.E CA")
	field(OUTB, "BPMS:UNDH:2090:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:PHI_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:PSI")
	field(DOL2, "BPMS:UNDH:2090:PSI")
	field(DOL3, "BPMS:UNDH:2090:PSI")
	field(DOL4, "BPMS:UNDH:2090:PSI")
	field(DOL5, "BPMS:UNDH:2090:PSI")
	field(DOL6, "BPMS:UNDH:2090:PSI")
	field(DOL7, "BPMS:UNDH:2090:PSI")
	field(DOL8, "BPMS:UNDH:2090:PSI")
	field(DOL9, "BPMS:UNDH:2090:PSI")
	field(DOLA, "BPMS:UNDH:2090:PSI")
	field(LNK1, "BPMS:UNDH:2090:PSI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:PSI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:PSI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:PSI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:PSI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:PSI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:PSI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:PSI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:PSI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2090:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:PSI_SEL")
	field(OUTA, "BPMS:UNDH:2090:CALC.F CA")
	field(OUTB, "BPMS:UNDH:2090:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:PSI_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:PSI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:UPHAS")
	field(DOL2, "BPMS:UNDH:2090:UPHAS")
	field(DOL3, "BPMS:UNDH:2090:UPHAS")
	field(DOL4, "BPMS:UNDH:2090:UPHAS")
	field(DOL5, "BPMS:UNDH:2090:UPHAS")
	field(DOL6, "BPMS:UNDH:2090:UPHAS")
	field(DOL7, "BPMS:UNDH:2090:UPHAS")
	field(DOL8, "BPMS:UNDH:2090:UPHAS")
	field(DOL9, "BPMS:UNDH:2090:UPHAS")
	field(DOLA, "BPMS:UNDH:2090:UPHAS")
	field(LNK1, "BPMS:UNDH:2090:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:UPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:UPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2090:UPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:UPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2090:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2090:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:UPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:UPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:VPHAS")
	field(DOL2, "BPMS:UNDH:2090:VPHAS")
	field(DOL3, "BPMS:UNDH:2090:VPHAS")
	field(DOL4, "BPMS:UNDH:2090:VPHAS")
	field(DOL5, "BPMS:UNDH:2090:VPHAS")
	field(DOL6, "BPMS:UNDH:2090:VPHAS")
	field(DOL7, "BPMS:UNDH:2090:VPHAS")
	field(DOL8, "BPMS:UNDH:2090:VPHAS")
	field(DOL9, "BPMS:UNDH:2090:VPHAS")
	field(DOLA, "BPMS:UNDH:2090:VPHAS")
	field(LNK1, "BPMS:UNDH:2090:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:VPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:VPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2090:VPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:VPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2090:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2090:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:VPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:VPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:QSCL")
	field(DOL2, "BPMS:UNDH:2090:QSCL")
	field(DOL3, "BPMS:UNDH:2090:QSCL")
	field(DOL4, "BPMS:UNDH:2090:QSCL")
	field(DOL5, "BPMS:UNDH:2090:QSCL")
	field(DOL6, "BPMS:UNDH:2090:QSCL")
	field(DOL7, "BPMS:UNDH:2090:QSCL")
	field(DOL8, "BPMS:UNDH:2090:QSCL")
	field(DOL9, "BPMS:UNDH:2090:QSCL")
	field(DOLA, "BPMS:UNDH:2090:QSCL")
	field(LNK1, "BPMS:UNDH:2090:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:QSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:QSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2090:QSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:QSCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:TMIT.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:QSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:QSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:URSCL")
	field(DOL2, "BPMS:UNDH:2090:URSCL")
	field(DOL3, "BPMS:UNDH:2090:URSCL")
	field(DOL4, "BPMS:UNDH:2090:URSCL")
	field(DOL5, "BPMS:UNDH:2090:URSCL")
	field(DOL6, "BPMS:UNDH:2090:URSCL")
	field(DOL7, "BPMS:UNDH:2090:URSCL")
	field(DOL8, "BPMS:UNDH:2090:URSCL")
	field(DOL9, "BPMS:UNDH:2090:URSCL")
	field(DOLA, "BPMS:UNDH:2090:URSCL")
	field(LNK1, "BPMS:UNDH:2090:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:URSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:URSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:URSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:URSCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:URMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:URSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:URSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:VRSCL")
	field(DOL2, "BPMS:UNDH:2090:VRSCL")
	field(DOL3, "BPMS:UNDH:2090:VRSCL")
	field(DOL4, "BPMS:UNDH:2090:VRSCL")
	field(DOL5, "BPMS:UNDH:2090:VRSCL")
	field(DOL6, "BPMS:UNDH:2090:VRSCL")
	field(DOL7, "BPMS:UNDH:2090:VRSCL")
	field(DOL8, "BPMS:UNDH:2090:VRSCL")
	field(DOL9, "BPMS:UNDH:2090:VRSCL")
	field(DOLA, "BPMS:UNDH:2090:VRSCL")
	field(LNK1, "BPMS:UNDH:2090:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:VRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:VRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2090:VRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:VRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:VRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:VRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:VRSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2090:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2090:QRSCL")
	field(DOL2, "BPMS:UNDH:2090:QRSCL")
	field(DOL3, "BPMS:UNDH:2090:QRSCL")
	field(DOL4, "BPMS:UNDH:2090:QRSCL")
	field(DOL5, "BPMS:UNDH:2090:QRSCL")
	field(DOL6, "BPMS:UNDH:2090:QRSCL")
	field(DOL7, "BPMS:UNDH:2090:QRSCL")
	field(DOL8, "BPMS:UNDH:2090:QRSCL")
	field(DOL9, "BPMS:UNDH:2090:QRSCL")
	field(DOLA, "BPMS:UNDH:2090:QRSCL")
	field(LNK1, "BPMS:UNDH:2090:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2090:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2090:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2090:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2090:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2090:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2090:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2090:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2090:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2090:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2090:QRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2090:QRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2090:QRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2090:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2090:QRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2090:RRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2090:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2090:QRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2090:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2090:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UNDH:2090:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UNDH:2090:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "BPMS:UNDH:2290:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2290:URER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2290:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2290:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2290:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2290:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S6")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

##############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:UNDH:2290:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S0")
  field(EGU, "Nel")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:UNDH:2290:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UNDH:2290:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2290:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2290:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UNDH:2290:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UNDH:2290:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C3 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2290:PRENV")
}

record(waveform, "BPMS:UNDH:2290:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C3 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
}

# Filter frequency response
# (updated/scanned by driver)
record(waveform, "BPMS:UNDH:2290:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C3 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UNDH:2290:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C3 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "BPMS:UNDH:2290:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UNDH:2290:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2290:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UNDH:2290:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UNDH:2290:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "BPMS:UNDH:2290:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:UNDH:2290:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2290:CHK.SEVR MS NPP")
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UNDH:2290:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2290:FILT.B PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#field(VAL,  "0")
#field(UDF,  "0")
#field(STAT, "0")
#field(SEVR, "0")
#}
#record(ao,  "BPMS:UNDH:2290:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2290:FILT.C PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#}
# Filter Parameters. 
# 
# B: fc; reference cavity
# C: bw; reference cavity
#
# E: fc; U cavity
# F: bw; U cavity
# G: ts; U cavity
# H: fc; V cavity
# I: bw; V cavity
# J: ts; V cavity
# K: fo; sampling freq.
#
# NOTE: Do NOT create other records to write
#       the fc or bw parameters w/o providing
#       proper logic to update those records
#       when the driver changes bw/fc (auto-set
#       feature if either of them is zero)
record(sub, "BPMS:UNDH:2290:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "3")
#field(INPB, "BPMS:UNDH:2290:FC_REF")
#field(INPC, "BPMS:UNDH:2290:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "BPMS:UNDH:2290:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:TS_U_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2290:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2290:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UNDH:2290:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:TS_V_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  field(ASLO, ".001")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2290:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2290:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "BPMS:UNDH:2290:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "BPMS:UNDH:2290:FILT.B NPP")
#field(LNK1, "BPMS:UNDH:2290:FC_REF NPP")
#field(DOL2, "BPMS:UNDH:2290:FILT.C NPP")
#field(LNK2, "BPMS:UNDH:2290:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "BPMS:UNDH:2290:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2290:UPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2290:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2290:VPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2290:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C3S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2290:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "BPMS:UNDH:2290:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2290:UPHAS_OUT")
  field(OUT, "BPMS:UNDH:2290:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2290:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C3S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2290:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "BPMS:UNDH:2290:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2290:VPHAS_OUT")
  field(OUT, "BPMS:UNDH:2290:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2290:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2290:QSCL_SEQ")
}

record(ao, "BPMS:UNDH:2290:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:URSCL_SEQ")
}

record(ao, "BPMS:UNDH:2290:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:VRSCL_SEQ")
}

record(ao, "BPMS:UNDH:2290:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2290:QRSCL_SEQ")
}

record(sub, "BPMS:UNDH:2290:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "3")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "BPMS:UNDH:2290:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "BPMS:UNDH:2290:REFR MS CA")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(FLNK, "BPMS:UNDH:2290:URER_SLOW")
}

record(ai, "BPMS:UNDH:2290:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2290:URER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2290:UIMR_SLOW")
}

record(ai, "BPMS:UNDH:2290:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2290:UIMR MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2290:VRER_SLOW")
}

record(ai, "BPMS:UNDH:2290:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2290:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2290:VIMR_SLOW")
}

record(ai, "BPMS:UNDH:2290:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2290:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

######################################
# HEAD of main processing chain
######################################

record(ai, "BPMS:UNDH:2290:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2290:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2290:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S12")
  field(FLNK, "BPMS:UNDH:2290:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2290:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UNDH:2290:EFX.PROC")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "BPMS:UNDH:2290:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C3 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "BPMS:UNDH:2290:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S8")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2290:V")
}

record(ai, "BPMS:UNDH:2290:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2290:PINC")
}

record(ai, "BPMS:UNDH:2290:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S10")
  field(SCAN, "Passive")
}

record(longin, "BPMS:UNDH:2290:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C3S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "BPMS:UNDH:2290:RSTA_ALH")
}


record(calc, "BPMS:UNDH:2290:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "BPMS:UNDH:2290:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "BPMS:UNDH:2290:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2290:PHI_SEQ")
}

record(ao, "BPMS:UNDH:2290:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2290:PSI_SEQ")
}

#record(dfanout, "BPMS:UNDH:2290:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "BPMS:UNDH:2290:USCL PP MS")
#  field(OUTB, "BPMS:UNDH:2290:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "BPMS:UNDH:2290:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2290:UOFF_SEQ")
}

record(ao, "BPMS:UNDH:2290:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2290:VOFF_SEQ")
}

record(ao, "BPMS:UNDH:2290:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:USCL_SEQ")
}

record(ao, "BPMS:UNDH:2290:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:VSCL_SEQ")
}


record(mbbo, "BPMS:UNDH:2290:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C3 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:UNDH:2290:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:UNDH:2290:FBCK")
{
  field(DESC, "Feedback State")
  field(PINI, "YES")
# Off - this device can be used in feedback but all feedback loops 
# using it are off.
  field(ZRST, "Off")
# On - this device is being used by one or more feedback loops.
  field(ONST, "On")
# Unavailable - this device is not used by any feedback loop.
  field(TWST, "Unavailable")
  info(autosaveFields, "RVAL")
}

# Convenience record holding the MAD name
record(stringin, "BPMS:UNDH:2290:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBHX22")
  field(PINI, "YES")
}

record(stringin, "RFBHX22:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UNDH:2290")
  field(PINI, "YES")
}

record(ai, "BPMS:UNDH:2290:X_SLOW") {
#alias("BPMS:UNDH:2290:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2290:X MS")
  field(FLNK, "BPMS:UNDH:2290:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2290:Y_SLOW") {
#alias("BPMS:UNDH:2290:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2290:Y NPP MS")
  field(FLNK, "BPMS:UNDH:2290:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2290:TMIT_SLOW") {
#alias("BPMS:UNDH:2290:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UNDH:2290:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "BPMS:UNDH:2290:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UNDH:2290:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UNDH:2290:SIMC PP")
}

record(calcout, "BPMS:UNDH:2290:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "3")
#CALC & VAL unused; the real calculation is done
#        in device support. The reason this is a
#        calcout rather than sub is that we want
#        to use the OUT link...
  field(CALC, "A")
  field(INPA, "BPMS:UNDH:2290:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UNDH:2290:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UNDH:2290:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UNDH:2290:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:UNDH:2290:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2290:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2290:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UNDH:2290:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:UNDH:2290:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "BPMS:UNDH:2290:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2290:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "BPMS:UNDH:2290:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C3 S0")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32678")
  field(LOPR, "-32768")
# 16384 samples/channel * 4 channels
  field(NELM, "65536")
  field(PINI, "NO")
}

#Used by model/database folks to verify BPM

record(ao, "BPMS:UNDH:2290:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UNDH:2290:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x008")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2290:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x008")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(calc, "BPMS:UNDH:2290:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UNDH:2290:TMIT")
  field(INPB, "BPMS:UNDH:2290:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UNDH:2290:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UNDH:2290:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
}

# Proxy records for users to set X.AOFF, Y.AOFF
# Placed CAS on X and Y for MPS 
# Feb 2010 - CAS has since been removed, but we'll keep 
# these proxy records as they're already in use

record(ao, "BPMS:UNDH:2290:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UNDH:2290:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:UNDH:2290:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "BPMS:UNDH:2290:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2290:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "BPMS:UNDH:2290:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2290:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2290:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "BPMS:UNDH:2290:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2290:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2290:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "BPMS:UNDH:2290:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2290:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2290:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2290:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2290:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2290:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C3 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bi, "BPMS:UNDH:2290:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:UNDH:2290:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:UNDH:2290:SIMCSEQ") {
  field(DESC, "BPM Sim Ctl Seq")
  field(SELM, "Mask")
  field(SELN, "0")

  field(DO1,  "1")
  field(DO2,  "0")
  field(DO3,  "0")
  field(DO4,  "0") #Passive

#  field(DO5,  "7") # .5 second
  field(DO5,  "9") # .1 second
  field(DO6,  "2")
  field(DO7,  "1")
  field(DO8,  "10")
  field(DO9,  "0")

# LNK 1, 2, 8, 9 only relevant for PADs
# Default macro values are set for PADs; other
# architectures must pass in "" for lnk1 and lnk2
  field(LNK1, "")
  field(LNK2, "")
  field(LNK3, "BPMS:UNDH:2290:SIM.L     PP")
  field(LNK4, "BPMS:UNDH:2290:SIM.SCAN  PP")

  field(LNK5, "BPMS:UNDH:2290:SIM.SCAN  PP")
  field(LNK6, "BPMS:UNDH:2290:SIM.L     PP")
  field(LNK7, "BPMS:UNDH:2290:SIM.L     PP")
  field(LNK8, "")
  field(LNK9, "")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:UOFF")
	field(DOL2, "BPMS:UNDH:2290:UOFF")
	field(DOL3, "BPMS:UNDH:2290:UOFF")
	field(DOL4, "BPMS:UNDH:2290:UOFF")
	field(DOL5, "BPMS:UNDH:2290:UOFF")
	field(DOL6, "BPMS:UNDH:2290:UOFF")
	field(DOL7, "BPMS:UNDH:2290:UOFF")
	field(DOL8, "BPMS:UNDH:2290:UOFF")
	field(DOL9, "BPMS:UNDH:2290:UOFF")
	field(DOLA, "BPMS:UNDH:2290:UOFF")
	field(LNK1, "BPMS:UNDH:2290:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:UOFF_SEL")
	field(OUTA, "BPMS:UNDH:2290:U.AOFF CA")
	field(OUTB, "BPMS:UNDH:2290:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:UOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:VOFF")
	field(DOL2, "BPMS:UNDH:2290:VOFF")
	field(DOL3, "BPMS:UNDH:2290:VOFF")
	field(DOL4, "BPMS:UNDH:2290:VOFF")
	field(DOL5, "BPMS:UNDH:2290:VOFF")
	field(DOL6, "BPMS:UNDH:2290:VOFF")
	field(DOL7, "BPMS:UNDH:2290:VOFF")
	field(DOL8, "BPMS:UNDH:2290:VOFF")
	field(DOL9, "BPMS:UNDH:2290:VOFF")
	field(DOLA, "BPMS:UNDH:2290:VOFF")
	field(LNK1, "BPMS:UNDH:2290:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:VOFF_SEL")
	field(OUTA, "BPMS:UNDH:2290:V.AOFF CA")
	field(OUTB, "BPMS:UNDH:2290:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:VOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:USCL")
	field(DOL2, "BPMS:UNDH:2290:USCL")
	field(DOL3, "BPMS:UNDH:2290:USCL")
	field(DOL4, "BPMS:UNDH:2290:USCL")
	field(DOL5, "BPMS:UNDH:2290:USCL")
	field(DOL6, "BPMS:UNDH:2290:USCL")
	field(DOL7, "BPMS:UNDH:2290:USCL")
	field(DOL8, "BPMS:UNDH:2290:USCL")
	field(DOL9, "BPMS:UNDH:2290:USCL")
	field(DOLA, "BPMS:UNDH:2290:USCL")
	field(LNK1, "BPMS:UNDH:2290:USCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:USCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:USCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:USCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:USCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:USCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:USCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:USCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:USCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:USCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:U.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:USCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:VSCL")
	field(DOL2, "BPMS:UNDH:2290:VSCL")
	field(DOL3, "BPMS:UNDH:2290:VSCL")
	field(DOL4, "BPMS:UNDH:2290:VSCL")
	field(DOL5, "BPMS:UNDH:2290:VSCL")
	field(DOL6, "BPMS:UNDH:2290:VSCL")
	field(DOL7, "BPMS:UNDH:2290:VSCL")
	field(DOL8, "BPMS:UNDH:2290:VSCL")
	field(DOL9, "BPMS:UNDH:2290:VSCL")
	field(DOLA, "BPMS:UNDH:2290:VSCL")
	field(LNK1, "BPMS:UNDH:2290:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:VSCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:V.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:VSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:PHI")
	field(DOL2, "BPMS:UNDH:2290:PHI")
	field(DOL3, "BPMS:UNDH:2290:PHI")
	field(DOL4, "BPMS:UNDH:2290:PHI")
	field(DOL5, "BPMS:UNDH:2290:PHI")
	field(DOL6, "BPMS:UNDH:2290:PHI")
	field(DOL7, "BPMS:UNDH:2290:PHI")
	field(DOL8, "BPMS:UNDH:2290:PHI")
	field(DOL9, "BPMS:UNDH:2290:PHI")
	field(DOLA, "BPMS:UNDH:2290:PHI")
	field(LNK1, "BPMS:UNDH:2290:PHI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:PHI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:PHI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:PHI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:PHI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:PHI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:PHI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:PHI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:PHI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2290:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:PHI_SEL")
	field(OUTA, "BPMS:UNDH:2290:CALC.E CA")
	field(OUTB, "BPMS:UNDH:2290:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:PHI_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:PSI")
	field(DOL2, "BPMS:UNDH:2290:PSI")
	field(DOL3, "BPMS:UNDH:2290:PSI")
	field(DOL4, "BPMS:UNDH:2290:PSI")
	field(DOL5, "BPMS:UNDH:2290:PSI")
	field(DOL6, "BPMS:UNDH:2290:PSI")
	field(DOL7, "BPMS:UNDH:2290:PSI")
	field(DOL8, "BPMS:UNDH:2290:PSI")
	field(DOL9, "BPMS:UNDH:2290:PSI")
	field(DOLA, "BPMS:UNDH:2290:PSI")
	field(LNK1, "BPMS:UNDH:2290:PSI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:PSI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:PSI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:PSI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:PSI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:PSI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:PSI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:PSI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:PSI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2290:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:PSI_SEL")
	field(OUTA, "BPMS:UNDH:2290:CALC.F CA")
	field(OUTB, "BPMS:UNDH:2290:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:PSI_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:PSI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:UPHAS")
	field(DOL2, "BPMS:UNDH:2290:UPHAS")
	field(DOL3, "BPMS:UNDH:2290:UPHAS")
	field(DOL4, "BPMS:UNDH:2290:UPHAS")
	field(DOL5, "BPMS:UNDH:2290:UPHAS")
	field(DOL6, "BPMS:UNDH:2290:UPHAS")
	field(DOL7, "BPMS:UNDH:2290:UPHAS")
	field(DOL8, "BPMS:UNDH:2290:UPHAS")
	field(DOL9, "BPMS:UNDH:2290:UPHAS")
	field(DOLA, "BPMS:UNDH:2290:UPHAS")
	field(LNK1, "BPMS:UNDH:2290:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:UPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:UPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2290:UPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:UPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2290:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2290:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:UPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:UPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:VPHAS")
	field(DOL2, "BPMS:UNDH:2290:VPHAS")
	field(DOL3, "BPMS:UNDH:2290:VPHAS")
	field(DOL4, "BPMS:UNDH:2290:VPHAS")
	field(DOL5, "BPMS:UNDH:2290:VPHAS")
	field(DOL6, "BPMS:UNDH:2290:VPHAS")
	field(DOL7, "BPMS:UNDH:2290:VPHAS")
	field(DOL8, "BPMS:UNDH:2290:VPHAS")
	field(DOL9, "BPMS:UNDH:2290:VPHAS")
	field(DOLA, "BPMS:UNDH:2290:VPHAS")
	field(LNK1, "BPMS:UNDH:2290:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:VPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:VPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2290:VPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:VPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2290:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2290:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:VPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:VPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:QSCL")
	field(DOL2, "BPMS:UNDH:2290:QSCL")
	field(DOL3, "BPMS:UNDH:2290:QSCL")
	field(DOL4, "BPMS:UNDH:2290:QSCL")
	field(DOL5, "BPMS:UNDH:2290:QSCL")
	field(DOL6, "BPMS:UNDH:2290:QSCL")
	field(DOL7, "BPMS:UNDH:2290:QSCL")
	field(DOL8, "BPMS:UNDH:2290:QSCL")
	field(DOL9, "BPMS:UNDH:2290:QSCL")
	field(DOLA, "BPMS:UNDH:2290:QSCL")
	field(LNK1, "BPMS:UNDH:2290:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:QSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:QSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2290:QSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:QSCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:TMIT.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:QSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:QSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:URSCL")
	field(DOL2, "BPMS:UNDH:2290:URSCL")
	field(DOL3, "BPMS:UNDH:2290:URSCL")
	field(DOL4, "BPMS:UNDH:2290:URSCL")
	field(DOL5, "BPMS:UNDH:2290:URSCL")
	field(DOL6, "BPMS:UNDH:2290:URSCL")
	field(DOL7, "BPMS:UNDH:2290:URSCL")
	field(DOL8, "BPMS:UNDH:2290:URSCL")
	field(DOL9, "BPMS:UNDH:2290:URSCL")
	field(DOLA, "BPMS:UNDH:2290:URSCL")
	field(LNK1, "BPMS:UNDH:2290:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:URSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:URSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:URSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:URSCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:URMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:URSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:URSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:VRSCL")
	field(DOL2, "BPMS:UNDH:2290:VRSCL")
	field(DOL3, "BPMS:UNDH:2290:VRSCL")
	field(DOL4, "BPMS:UNDH:2290:VRSCL")
	field(DOL5, "BPMS:UNDH:2290:VRSCL")
	field(DOL6, "BPMS:UNDH:2290:VRSCL")
	field(DOL7, "BPMS:UNDH:2290:VRSCL")
	field(DOL8, "BPMS:UNDH:2290:VRSCL")
	field(DOL9, "BPMS:UNDH:2290:VRSCL")
	field(DOLA, "BPMS:UNDH:2290:VRSCL")
	field(LNK1, "BPMS:UNDH:2290:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:VRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:VRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2290:VRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:VRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:VRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:VRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:VRSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2290:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2290:QRSCL")
	field(DOL2, "BPMS:UNDH:2290:QRSCL")
	field(DOL3, "BPMS:UNDH:2290:QRSCL")
	field(DOL4, "BPMS:UNDH:2290:QRSCL")
	field(DOL5, "BPMS:UNDH:2290:QRSCL")
	field(DOL6, "BPMS:UNDH:2290:QRSCL")
	field(DOL7, "BPMS:UNDH:2290:QRSCL")
	field(DOL8, "BPMS:UNDH:2290:QRSCL")
	field(DOL9, "BPMS:UNDH:2290:QRSCL")
	field(DOLA, "BPMS:UNDH:2290:QRSCL")
	field(LNK1, "BPMS:UNDH:2290:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2290:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2290:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2290:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2290:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2290:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2290:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2290:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2290:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2290:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2290:QRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2290:QRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2290:QRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2290:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2290:QRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2290:RRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2290:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2290:QRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2290:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UNDH:2290:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UNDH:2290:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "BPMS:UNDH:2390:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2390:URER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2390:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2390:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2390:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UNDH:2390:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S6")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

##############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:UNDH:2390:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S0")
  field(EGU, "Nel")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:UNDH:2390:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UNDH:2390:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2390:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UNDH:2390:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UNDH:2390:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UNDH:2390:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C4 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UNDH:2390:PRENV")
}

record(waveform, "BPMS:UNDH:2390:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C4 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
}

# Filter frequency response
# (updated/scanned by driver)
record(waveform, "BPMS:UNDH:2390:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C4 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UNDH:2390:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C4 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "BPMS:UNDH:2390:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UNDH:2390:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2390:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UNDH:2390:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UNDH:2390:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "BPMS:UNDH:2390:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:UNDH:2390:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:UNDH:2390:CHK.SEVR MS NPP")
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UNDH:2390:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2390:FILT.B PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#field(VAL,  "0")
#field(UDF,  "0")
#field(STAT, "0")
#field(SEVR, "0")
#}
#record(ao,  "BPMS:UNDH:2390:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UNDH:2390:FILT.C PP")
#field(EGU,  "MHz")
#field(PREC, "1")
#field(DRVL, "0")
#field(DRVH, "60")
#field(PINI, "NO")
#}
# Filter Parameters. 
# 
# B: fc; reference cavity
# C: bw; reference cavity
#
# E: fc; U cavity
# F: bw; U cavity
# G: ts; U cavity
# H: fc; V cavity
# I: bw; V cavity
# J: ts; V cavity
# K: fo; sampling freq.
#
# NOTE: Do NOT create other records to write
#       the fc or bw parameters w/o providing
#       proper logic to update those records
#       when the driver changes bw/fc (auto-set
#       feature if either of them is zero)
record(sub, "BPMS:UNDH:2390:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "4")
#field(INPB, "BPMS:UNDH:2390:FC_REF")
#field(INPC, "BPMS:UNDH:2390:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "BPMS:UNDH:2390:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:TS_U_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2390:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2390:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UNDH:2390:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:TS_V_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  field(ASLO, ".001")
  info(autosaveFields, "VAL")
}

record(calcout, "BPMS:UNDH:2390:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UNDH:2390:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "BPMS:UNDH:2390:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "BPMS:UNDH:2390:FILT.B NPP")
#field(LNK1, "BPMS:UNDH:2390:FC_REF NPP")
#field(DOL2, "BPMS:UNDH:2390:FILT.C NPP")
#field(LNK2, "BPMS:UNDH:2390:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "BPMS:UNDH:2390:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2390:UPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2390:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2390:VPHAS_SEQ")
}

record(ao, "BPMS:UNDH:2390:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C4S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2390:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "BPMS:UNDH:2390:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2390:UPHAS_OUT")
  field(OUT, "BPMS:UNDH:2390:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2390:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C4S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "BPMS:UNDH:2390:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "BPMS:UNDH:2390:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "BPMS:UNDH:2390:VPHAS_OUT")
  field(OUT, "BPMS:UNDH:2390:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "BPMS:UNDH:2390:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2390:QSCL_SEQ")
}

record(ao, "BPMS:UNDH:2390:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:URSCL_SEQ")
}

record(ao, "BPMS:UNDH:2390:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:VRSCL_SEQ")
}

record(ao, "BPMS:UNDH:2390:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "BPMS:UNDH:2390:QRSCL_SEQ")
}

record(sub, "BPMS:UNDH:2390:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "4")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "BPMS:UNDH:2390:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "BPMS:UNDH:2390:REFR MS CA")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(FLNK, "BPMS:UNDH:2390:URER_SLOW")
}

record(ai, "BPMS:UNDH:2390:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2390:URER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2390:UIMR_SLOW")
}

record(ai, "BPMS:UNDH:2390:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "BPMS:UNDH:2390:UIMR MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2390:VRER_SLOW")
}

record(ai, "BPMS:UNDH:2390:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2390:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(FLNK, "BPMS:UNDH:2390:VIMR_SLOW")
}

record(ai, "BPMS:UNDH:2390:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "BPMS:UNDH:2390:VRER MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

######################################
# HEAD of main processing chain
######################################

record(ai, "BPMS:UNDH:2390:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:UNDH:2390:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2390:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S12")
  field(FLNK, "BPMS:UNDH:2390:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "BPMS:UNDH:2390:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UNDH:2390:EFX.PROC")
  field(ASG,  "EOICDESK")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "BPMS:UNDH:2390:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C4 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "BPMS:UNDH:2390:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S8")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2390:V")
}

record(ai, "BPMS:UNDH:2390:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "BPMS:UNDH:2390:PINC")
}

record(ai, "BPMS:UNDH:2390:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S10")
  field(SCAN, "Passive")
}

record(longin, "BPMS:UNDH:2390:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C4S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "BPMS:UNDH:2390:RSTA_ALH")
}


record(calc, "BPMS:UNDH:2390:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "BPMS:UNDH:2390:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "BPMS:UNDH:2390:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2390:PHI_SEQ")
}

record(ao, "BPMS:UNDH:2390:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:UNDH:2390:PSI_SEQ")
}

#record(dfanout, "BPMS:UNDH:2390:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "BPMS:UNDH:2390:USCL PP MS")
#  field(OUTB, "BPMS:UNDH:2390:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "BPMS:UNDH:2390:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2390:UOFF_SEQ")
}

record(ao, "BPMS:UNDH:2390:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:UNDH:2390:VOFF_SEQ")
}

record(ao, "BPMS:UNDH:2390:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:USCL_SEQ")
}

record(ao, "BPMS:UNDH:2390:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:VSCL_SEQ")
}


record(mbbo, "BPMS:UNDH:2390:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C4 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:UNDH:2390:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:UNDH:2390:FBCK")
{
  field(DESC, "Feedback State")
  field(PINI, "YES")
# Off - this device can be used in feedback but all feedback loops 
# using it are off.
  field(ZRST, "Off")
# On - this device is being used by one or more feedback loops.
  field(ONST, "On")
# Unavailable - this device is not used by any feedback loop.
  field(TWST, "Unavailable")
  info(autosaveFields, "RVAL")
}

# Convenience record holding the MAD name
record(stringin, "BPMS:UNDH:2390:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBHX23")
  field(PINI, "YES")
}

record(stringin, "RFBHX23:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UNDH:2390")
  field(PINI, "YES")
}

record(ai, "BPMS:UNDH:2390:X_SLOW") {
#alias("BPMS:UNDH:2390:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2390:X MS")
  field(FLNK, "BPMS:UNDH:2390:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2390:Y_SLOW") {
#alias("BPMS:UNDH:2390:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "BPMS:UNDH:2390:Y NPP MS")
  field(FLNK, "BPMS:UNDH:2390:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "BPMS:UNDH:2390:TMIT_SLOW") {
#alias("BPMS:UNDH:2390:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UNDH:2390:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "BPMS:UNDH:2390:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UNDH:2390:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UNDH:2390:SIMC PP")
}

record(calcout, "BPMS:UNDH:2390:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "4")
#CALC & VAL unused; the real calculation is done
#        in device support. The reason this is a
#        calcout rather than sub is that we want
#        to use the OUT link...
  field(CALC, "A")
  field(INPA, "BPMS:UNDH:2390:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UNDH:2390:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UNDH:2390:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UNDH:2390:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:UNDH:2390:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2390:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UNDH:2390:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UNDH:2390:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:UNDH:2390:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "BPMS:UNDH:2390:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UNDH:2390:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "BPMS:UNDH:2390:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C4 S0")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32678")
  field(LOPR, "-32768")
# 16384 samples/channel * 4 channels
  field(NELM, "65536")
  field(PINI, "NO")
}

#Used by model/database folks to verify BPM

record(ao, "BPMS:UNDH:2390:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UNDH:2390:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x010")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2390:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x010")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "EOICDESK")
  info(autosaveFields, "VAL")
}

record(calc, "BPMS:UNDH:2390:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UNDH:2390:TMIT")
  field(INPB, "BPMS:UNDH:2390:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UNDH:2390:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UNDH:2390:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
}

# Proxy records for users to set X.AOFF, Y.AOFF
# Placed CAS on X and Y for MPS 
# Feb 2010 - CAS has since been removed, but we'll keep 
# these proxy records as they're already in use

record(ao, "BPMS:UNDH:2390:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UNDH:2390:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:UNDH:2390:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "BPMS:UNDH:2390:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UNDH:2390:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "BPMS:UNDH:2390:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2390:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2390:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "BPMS:UNDH:2390:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "BPMS:UNDH:2390:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "BPMS:UNDH:2390:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "BPMS:UNDH:2390:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2390:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2390:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2390:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2390:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}
record(ao, "BPMS:UNDH:2390:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C4 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "EOICDESK")
  info(autosaveFields, "VAL")
}

record(bi, "BPMS:UNDH:2390:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:UNDH:2390:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:UNDH:2390:SIMCSEQ") {
  field(DESC, "BPM Sim Ctl Seq")
  field(SELM, "Mask")
  field(SELN, "0")

  field(DO1,  "1")
  field(DO2,  "0")
  field(DO3,  "0")
  field(DO4,  "0") #Passive

#  field(DO5,  "7") # .5 second
  field(DO5,  "9") # .1 second
  field(DO6,  "2")
  field(DO7,  "1")
  field(DO8,  "10")
  field(DO9,  "0")

# LNK 1, 2, 8, 9 only relevant for PADs
# Default macro values are set for PADs; other
# architectures must pass in "" for lnk1 and lnk2
  field(LNK1, "")
  field(LNK2, "")
  field(LNK3, "BPMS:UNDH:2390:SIM.L     PP")
  field(LNK4, "BPMS:UNDH:2390:SIM.SCAN  PP")

  field(LNK5, "BPMS:UNDH:2390:SIM.SCAN  PP")
  field(LNK6, "BPMS:UNDH:2390:SIM.L     PP")
  field(LNK7, "BPMS:UNDH:2390:SIM.L     PP")
  field(LNK8, "")
  field(LNK9, "")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:UOFF")
	field(DOL2, "BPMS:UNDH:2390:UOFF")
	field(DOL3, "BPMS:UNDH:2390:UOFF")
	field(DOL4, "BPMS:UNDH:2390:UOFF")
	field(DOL5, "BPMS:UNDH:2390:UOFF")
	field(DOL6, "BPMS:UNDH:2390:UOFF")
	field(DOL7, "BPMS:UNDH:2390:UOFF")
	field(DOL8, "BPMS:UNDH:2390:UOFF")
	field(DOL9, "BPMS:UNDH:2390:UOFF")
	field(DOLA, "BPMS:UNDH:2390:UOFF")
	field(LNK1, "BPMS:UNDH:2390:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:UOFF_SEL")
	field(OUTA, "BPMS:UNDH:2390:U.AOFF CA")
	field(OUTB, "BPMS:UNDH:2390:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:UOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:VOFF")
	field(DOL2, "BPMS:UNDH:2390:VOFF")
	field(DOL3, "BPMS:UNDH:2390:VOFF")
	field(DOL4, "BPMS:UNDH:2390:VOFF")
	field(DOL5, "BPMS:UNDH:2390:VOFF")
	field(DOL6, "BPMS:UNDH:2390:VOFF")
	field(DOL7, "BPMS:UNDH:2390:VOFF")
	field(DOL8, "BPMS:UNDH:2390:VOFF")
	field(DOL9, "BPMS:UNDH:2390:VOFF")
	field(DOLA, "BPMS:UNDH:2390:VOFF")
	field(LNK1, "BPMS:UNDH:2390:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:VOFF_SEL")
	field(OUTA, "BPMS:UNDH:2390:V.AOFF CA")
	field(OUTB, "BPMS:UNDH:2390:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:VOFF_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:USCL")
	field(DOL2, "BPMS:UNDH:2390:USCL")
	field(DOL3, "BPMS:UNDH:2390:USCL")
	field(DOL4, "BPMS:UNDH:2390:USCL")
	field(DOL5, "BPMS:UNDH:2390:USCL")
	field(DOL6, "BPMS:UNDH:2390:USCL")
	field(DOL7, "BPMS:UNDH:2390:USCL")
	field(DOL8, "BPMS:UNDH:2390:USCL")
	field(DOL9, "BPMS:UNDH:2390:USCL")
	field(DOLA, "BPMS:UNDH:2390:USCL")
	field(LNK1, "BPMS:UNDH:2390:USCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:USCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:USCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:USCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:USCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:USCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:USCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:USCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:USCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:USCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:U.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:USCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:VSCL")
	field(DOL2, "BPMS:UNDH:2390:VSCL")
	field(DOL3, "BPMS:UNDH:2390:VSCL")
	field(DOL4, "BPMS:UNDH:2390:VSCL")
	field(DOL5, "BPMS:UNDH:2390:VSCL")
	field(DOL6, "BPMS:UNDH:2390:VSCL")
	field(DOL7, "BPMS:UNDH:2390:VSCL")
	field(DOL8, "BPMS:UNDH:2390:VSCL")
	field(DOL9, "BPMS:UNDH:2390:VSCL")
	field(DOLA, "BPMS:UNDH:2390:VSCL")
	field(LNK1, "BPMS:UNDH:2390:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:VSCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:V.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:VSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:PHI")
	field(DOL2, "BPMS:UNDH:2390:PHI")
	field(DOL3, "BPMS:UNDH:2390:PHI")
	field(DOL4, "BPMS:UNDH:2390:PHI")
	field(DOL5, "BPMS:UNDH:2390:PHI")
	field(DOL6, "BPMS:UNDH:2390:PHI")
	field(DOL7, "BPMS:UNDH:2390:PHI")
	field(DOL8, "BPMS:UNDH:2390:PHI")
	field(DOL9, "BPMS:UNDH:2390:PHI")
	field(DOLA, "BPMS:UNDH:2390:PHI")
	field(LNK1, "BPMS:UNDH:2390:PHI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:PHI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:PHI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:PHI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:PHI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:PHI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:PHI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:PHI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:PHI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2390:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:PHI_SEL")
	field(OUTA, "BPMS:UNDH:2390:CALC.E CA")
	field(OUTB, "BPMS:UNDH:2390:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:PHI_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:PSI")
	field(DOL2, "BPMS:UNDH:2390:PSI")
	field(DOL3, "BPMS:UNDH:2390:PSI")
	field(DOL4, "BPMS:UNDH:2390:PSI")
	field(DOL5, "BPMS:UNDH:2390:PSI")
	field(DOL6, "BPMS:UNDH:2390:PSI")
	field(DOL7, "BPMS:UNDH:2390:PSI")
	field(DOL8, "BPMS:UNDH:2390:PSI")
	field(DOL9, "BPMS:UNDH:2390:PSI")
	field(DOLA, "BPMS:UNDH:2390:PSI")
	field(LNK1, "BPMS:UNDH:2390:PSI_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:PSI_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:PSI_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:PSI_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:PSI_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:PSI_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:PSI_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:PSI_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:PSI_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2390:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:PSI_SEL")
	field(OUTA, "BPMS:UNDH:2390:CALC.F CA")
	field(OUTB, "BPMS:UNDH:2390:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:PSI_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:PSI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:UPHAS")
	field(DOL2, "BPMS:UNDH:2390:UPHAS")
	field(DOL3, "BPMS:UNDH:2390:UPHAS")
	field(DOL4, "BPMS:UNDH:2390:UPHAS")
	field(DOL5, "BPMS:UNDH:2390:UPHAS")
	field(DOL6, "BPMS:UNDH:2390:UPHAS")
	field(DOL7, "BPMS:UNDH:2390:UPHAS")
	field(DOL8, "BPMS:UNDH:2390:UPHAS")
	field(DOL9, "BPMS:UNDH:2390:UPHAS")
	field(DOLA, "BPMS:UNDH:2390:UPHAS")
	field(LNK1, "BPMS:UNDH:2390:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:UPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:UPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2390:UPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:UPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2390:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2390:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:UPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:UPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:VPHAS")
	field(DOL2, "BPMS:UNDH:2390:VPHAS")
	field(DOL3, "BPMS:UNDH:2390:VPHAS")
	field(DOL4, "BPMS:UNDH:2390:VPHAS")
	field(DOL5, "BPMS:UNDH:2390:VPHAS")
	field(DOL6, "BPMS:UNDH:2390:VPHAS")
	field(DOL7, "BPMS:UNDH:2390:VPHAS")
	field(DOL8, "BPMS:UNDH:2390:VPHAS")
	field(DOL9, "BPMS:UNDH:2390:VPHAS")
	field(DOLA, "BPMS:UNDH:2390:VPHAS")
	field(LNK1, "BPMS:UNDH:2390:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:VPHAS_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:VPHAS_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1000")
	field(B,    "1000")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:UNDH:2390:VPHAS_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:VPHAS_SEL")
	field(OUTA, "BPMS:UNDH:2390:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UNDH:2390:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:VPHAS_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:VPHAS_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:QSCL")
	field(DOL2, "BPMS:UNDH:2390:QSCL")
	field(DOL3, "BPMS:UNDH:2390:QSCL")
	field(DOL4, "BPMS:UNDH:2390:QSCL")
	field(DOL5, "BPMS:UNDH:2390:QSCL")
	field(DOL6, "BPMS:UNDH:2390:QSCL")
	field(DOL7, "BPMS:UNDH:2390:QSCL")
	field(DOL8, "BPMS:UNDH:2390:QSCL")
	field(DOL9, "BPMS:UNDH:2390:QSCL")
	field(DOLA, "BPMS:UNDH:2390:QSCL")
	field(LNK1, "BPMS:UNDH:2390:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:QSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:QSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2390:QSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:QSCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:TMIT.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:QSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:QSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:URSCL")
	field(DOL2, "BPMS:UNDH:2390:URSCL")
	field(DOL3, "BPMS:UNDH:2390:URSCL")
	field(DOL4, "BPMS:UNDH:2390:URSCL")
	field(DOL5, "BPMS:UNDH:2390:URSCL")
	field(DOL6, "BPMS:UNDH:2390:URSCL")
	field(DOL7, "BPMS:UNDH:2390:URSCL")
	field(DOL8, "BPMS:UNDH:2390:URSCL")
	field(DOL9, "BPMS:UNDH:2390:URSCL")
	field(DOLA, "BPMS:UNDH:2390:URSCL")
	field(LNK1, "BPMS:UNDH:2390:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:URSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:URSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:URSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:URSCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:URMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:URSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:URSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:VRSCL")
	field(DOL2, "BPMS:UNDH:2390:VRSCL")
	field(DOL3, "BPMS:UNDH:2390:VRSCL")
	field(DOL4, "BPMS:UNDH:2390:VRSCL")
	field(DOL5, "BPMS:UNDH:2390:VRSCL")
	field(DOL6, "BPMS:UNDH:2390:VRSCL")
	field(DOL7, "BPMS:UNDH:2390:VRSCL")
	field(DOL8, "BPMS:UNDH:2390:VRSCL")
	field(DOL9, "BPMS:UNDH:2390:VRSCL")
	field(DOLA, "BPMS:UNDH:2390:VRSCL")
	field(LNK1, "BPMS:UNDH:2390:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:VRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:VRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:UNDH:2390:VRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:VRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:VRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:VRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:VRSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:UNDH:2390:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UNDH:2390:QRSCL")
	field(DOL2, "BPMS:UNDH:2390:QRSCL")
	field(DOL3, "BPMS:UNDH:2390:QRSCL")
	field(DOL4, "BPMS:UNDH:2390:QRSCL")
	field(DOL5, "BPMS:UNDH:2390:QRSCL")
	field(DOL6, "BPMS:UNDH:2390:QRSCL")
	field(DOL7, "BPMS:UNDH:2390:QRSCL")
	field(DOL8, "BPMS:UNDH:2390:QRSCL")
	field(DOL9, "BPMS:UNDH:2390:QRSCL")
	field(DOLA, "BPMS:UNDH:2390:QRSCL")
	field(LNK1, "BPMS:UNDH:2390:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UNDH:2390:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UNDH:2390:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UNDH:2390:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UNDH:2390:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UNDH:2390:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UNDH:2390:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UNDH:2390:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UNDH:2390:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UNDH:2390:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UNDH:2390:QRSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:UNDH:2390:QRSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "3")
	field(FLNK, "BPMS:UNDH:2390:QRSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:UNDH:2390:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UNDH:2390:QRSCL_SEL")
	field(OUTA, "BPMS:UNDH:2390:RRMS.ASLO CA")
	field(OUTB, "BPMS:UNDH:2390:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UNDH:2390:QRSCL_CTRL")
{
	field(INPA, "BPMS:UNDH:2390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UNDH:2390:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UNDH:2390:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UNDH:2390:RCVR_GAIN CP")
}
# per IOC database for stripline BPMs

#record(sub, "IOC:UNDH:BP02:FIDP") {
#	field(DESC, "BPM Fiducial Processing")
#	field(SNAM, "bpmEvrFidProcess")
#	#This tells us if there is beam during this cycle...
#	field(INPA, "IOC:UNDH:BP02:MODIFIER5.R")
#}

#record(mbbo, "IOC:UNDH:BP02:PATTERNSIM") {
#	field(DESC, "Pattern Simulation")
#	field(ZRST, "Off")
#	field(ONST, "Soft")
#	field(TWST, "Raw")
#	field(DOL,  "0")
#	field(PINI, "YES")
#}

record(sub, "IOC:UNDH:BP02:EVTM") {
	field(SNAM, "subEventTestTiming")
	field(SCAN, "Event")
	field(EVNT, "40")
}

record(longin, "IOC:UNDH:BP02:MPSFLT_X") {
  field(DESC, "Latched MPS Flt. X")
  field(DTYP, "BusAddress")
  field(INP,  "#C2S2@bpmMPS+0,m32,bpmMPS")
  field(SCAN, "I/O Intr")
  field(PINI, "YES")
}

record(longin, "IOC:UNDH:BP02:MPSFLT_Y") {
  field(DESC, "Latched MPS Flt. Y")
  field(DTYP, "BusAddress")
  field(INP,  "#C3S2@bpmMPS+0,m32,bpmMPS")
  field(SCAN, "I/O Intr")
  field(PINI, "YES")
}

record(longin, "IOC:UNDH:BP02:MPSFLT_T") {
  field(DESC, "Latched MPS Flt. TMIT")
  field(DTYP, "BusAddress")
  field(INP,  "#C4S2@bpmMPS+0,m32,bpmMPS")
  field(SCAN, "I/O Intr")
  field(PINI, "YES")
}

record(bi,    "BPMS:UNDH:790:SUM_10TO18") {
  field(DESC, "MPS Heartbeat state")
  field(DTYP, "BusAddress")
  field(INP,  "#C5S2@bpmMPS+0,m32,bpmMPS")
  field(SCAN, "1 second")
  field(ZNAM, "OK")
  field(ONAM, "FAULT")
  field(OSV,  "MAJOR")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UNDH:1990:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B7")
  field(SCAN, "1 second")
  field(ZNAM, "Locked")
  field(ONAM, "Not locked")
  field(ZSV, "NO_ALARM")
  field(OSV, "MINOR")
}

# Set gain of all three signals
record(bo, "BPMS:UNDH:1990:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UNDH:1990:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:1990:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B0")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UNDH:1990:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B1")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

# Set local oscillator mode:
# Lock or unlock wrt 119 MHz reference

record(bo, "BPMS:UNDH:1990:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B2")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UNDH:2090:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B6")
  field(SCAN, "1 second")
  field(ZNAM, "Locked")
  field(ONAM, "Not locked")
  field(ZSV, "NO_ALARM")
  field(OSV, "MINOR")
}

# Set gain of all three signals
record(bo, "BPMS:UNDH:2090:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UNDH:2090:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2090:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B3")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UNDH:2090:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B4")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

# Set local oscillator mode:
# Lock or unlock wrt 119 MHz reference

record(bo, "BPMS:UNDH:2090:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P0 B5")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UNDH:2290:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B4")
  field(SCAN, "1 second")
  field(ZNAM, "Locked")
  field(ONAM, "Not locked")
  field(ZSV, "NO_ALARM")
  field(OSV, "MINOR")
}

# Set gain of all three signals
record(bo, "BPMS:UNDH:2290:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UNDH:2290:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2290:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B1")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UNDH:2290:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B2")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

# Set local oscillator mode:
# Lock or unlock wrt 119 MHz reference

record(bo, "BPMS:UNDH:2290:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B3")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UNDH:2390:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B3")
  field(SCAN, "1 second")
  field(ZNAM, "Locked")
  field(ONAM, "Not locked")
  field(ZSV, "NO_ALARM")
  field(OSV, "MINOR")
}

# Set gain of all three signals
record(bo, "BPMS:UNDH:2390:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UNDH:2390:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UNDH:2390:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B4")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UNDH:2390:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B5")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

# Set local oscillator mode:
# Lock or unlock wrt 119 MHz reference

record(bo, "BPMS:UNDH:2390:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P1 B6")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}
