# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:LTU1:910: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:LTU1:910:PRENV")
}

record(waveform, "BPMS:LTU1:910: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:LTU1:910:HFILT") {
  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:LTU1:910:hFILT") {
  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:LTU1:910:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:910:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:910:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:910:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:910:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:LTU1:910:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:LTU1:910: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:LTU1:910:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:LTU1:910: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:LTU1:910:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "0")
#field(INPB, "BPMS:LTU1:910:FC_REF")
#field(INPC, "BPMS:LTU1:910: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:LTU1:910:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:910: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:LTU1:910:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:LTU1:910:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:LTU1:910:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:910: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:LTU1:910:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:LTU1:910:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

record(ao, "BPMS:LTU1:910: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:LTU1:910:UPHAS_FB")
}

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

record(ao, "BPMS:LTU1:910: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:LTU1:910:VPHAS_FB")
}

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S12")
  field(FLNK, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:V")
}

record(ai, "BPMS:LTU1:910: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:LTU1:910:PINC")
}

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

record(longin, "BPMS:LTU1:910: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:LTU1:910:RSTA_ALH")
}


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

record(calc, "BPMS:LTU1:910:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:LTU1:910:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:LTU1:910:PADTO")
}

record(bi, "BPMS:LTU1:910:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:LTU1:910:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:LTU1:910: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:LTU1:910:PHI_SEQ")
}

record(ao, "BPMS:LTU1:910: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:LTU1:910:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:910: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:LTU1:910:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:910: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:LTU1:910:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFB07")
  field(PINI, "YES")
}

record(stringin, "RFB07:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:LTU1:910")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:LTU1:910:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:LTU1:910: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:LTU1:910:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:LTU1:910:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:LTU1:910:SIMC PP")
}

record(calcout, "BPMS:LTU1:910: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:LTU1:910:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:LTU1:910:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:LTU1:910:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:910: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:LTU1:910:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:910: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:LTU1:910:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:910:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:LTU1:910:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:910: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:LTU1:910:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:910:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:LTU1:910: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:LTU1:910:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:LTU1:910:TMIT")
  field(INPB, "BPMS:LTU1:910:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:LTU1:910:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:LTU1:910: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:LTU1:910:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:LTU1:910:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:LTU1:910:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:910:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:910:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:910:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:910: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:LTU1:910:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:UOFF")
	field(DOL2, "BPMS:LTU1:910:UOFF")
	field(DOL3, "BPMS:LTU1:910:UOFF")
	field(DOL4, "BPMS:LTU1:910:UOFF")
	field(DOL5, "BPMS:LTU1:910:UOFF")
	field(DOL6, "BPMS:LTU1:910:UOFF")
	field(DOL7, "BPMS:LTU1:910:UOFF")
	field(DOL8, "BPMS:LTU1:910:UOFF")
	field(DOL9, "BPMS:LTU1:910:UOFF")
	field(DOLA, "BPMS:LTU1:910:UOFF")
	field(LNK1, "BPMS:LTU1:910:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:910:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:910:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:VOFF")
	field(DOL2, "BPMS:LTU1:910:VOFF")
	field(DOL3, "BPMS:LTU1:910:VOFF")
	field(DOL4, "BPMS:LTU1:910:VOFF")
	field(DOL5, "BPMS:LTU1:910:VOFF")
	field(DOL6, "BPMS:LTU1:910:VOFF")
	field(DOL7, "BPMS:LTU1:910:VOFF")
	field(DOL8, "BPMS:LTU1:910:VOFF")
	field(DOL9, "BPMS:LTU1:910:VOFF")
	field(DOLA, "BPMS:LTU1:910:VOFF")
	field(LNK1, "BPMS:LTU1:910:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:910:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:910:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:USCL")
	field(DOL2, "BPMS:LTU1:910:USCL")
	field(DOL3, "BPMS:LTU1:910:USCL")
	field(DOL4, "BPMS:LTU1:910:USCL")
	field(DOL5, "BPMS:LTU1:910:USCL")
	field(DOL6, "BPMS:LTU1:910:USCL")
	field(DOL7, "BPMS:LTU1:910:USCL")
	field(DOL8, "BPMS:LTU1:910:USCL")
	field(DOL9, "BPMS:LTU1:910:USCL")
	field(DOLA, "BPMS:LTU1:910:USCL")
	field(LNK1, "BPMS:LTU1:910:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:USCL_SEL")
	field(OUTA, "BPMS:LTU1:910:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:VSCL")
	field(DOL2, "BPMS:LTU1:910:VSCL")
	field(DOL3, "BPMS:LTU1:910:VSCL")
	field(DOL4, "BPMS:LTU1:910:VSCL")
	field(DOL5, "BPMS:LTU1:910:VSCL")
	field(DOL6, "BPMS:LTU1:910:VSCL")
	field(DOL7, "BPMS:LTU1:910:VSCL")
	field(DOL8, "BPMS:LTU1:910:VSCL")
	field(DOL9, "BPMS:LTU1:910:VSCL")
	field(DOLA, "BPMS:LTU1:910:VSCL")
	field(LNK1, "BPMS:LTU1:910:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:910:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:PHI")
	field(DOL2, "BPMS:LTU1:910:PHI")
	field(DOL3, "BPMS:LTU1:910:PHI")
	field(DOL4, "BPMS:LTU1:910:PHI")
	field(DOL5, "BPMS:LTU1:910:PHI")
	field(DOL6, "BPMS:LTU1:910:PHI")
	field(DOL7, "BPMS:LTU1:910:PHI")
	field(DOL8, "BPMS:LTU1:910:PHI")
	field(DOL9, "BPMS:LTU1:910:PHI")
	field(DOLA, "BPMS:LTU1:910:PHI")
	field(LNK1, "BPMS:LTU1:910:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:PHI_SEL")
	field(OUTA, "BPMS:LTU1:910:CALC.E CA")
	field(OUTB, "BPMS:LTU1:910:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:PSI")
	field(DOL2, "BPMS:LTU1:910:PSI")
	field(DOL3, "BPMS:LTU1:910:PSI")
	field(DOL4, "BPMS:LTU1:910:PSI")
	field(DOL5, "BPMS:LTU1:910:PSI")
	field(DOL6, "BPMS:LTU1:910:PSI")
	field(DOL7, "BPMS:LTU1:910:PSI")
	field(DOL8, "BPMS:LTU1:910:PSI")
	field(DOL9, "BPMS:LTU1:910:PSI")
	field(DOLA, "BPMS:LTU1:910:PSI")
	field(LNK1, "BPMS:LTU1:910:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:PSI_SEL")
	field(OUTA, "BPMS:LTU1:910:CALC.F CA")
	field(OUTB, "BPMS:LTU1:910:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:UPHAS")
	field(DOL2, "BPMS:LTU1:910:UPHAS")
	field(DOL3, "BPMS:LTU1:910:UPHAS")
	field(DOL4, "BPMS:LTU1:910:UPHAS")
	field(DOL5, "BPMS:LTU1:910:UPHAS")
	field(DOL6, "BPMS:LTU1:910:UPHAS")
	field(DOL7, "BPMS:LTU1:910:UPHAS")
	field(DOL8, "BPMS:LTU1:910:UPHAS")
	field(DOL9, "BPMS:LTU1:910:UPHAS")
	field(DOLA, "BPMS:LTU1:910:UPHAS")
	field(LNK1, "BPMS:LTU1:910:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:UPHAS_SEL")
	field(OUTA, "BPMS:LTU1:910:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:LTU1:910:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:UPHAS_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:VPHAS")
	field(DOL2, "BPMS:LTU1:910:VPHAS")
	field(DOL3, "BPMS:LTU1:910:VPHAS")
	field(DOL4, "BPMS:LTU1:910:VPHAS")
	field(DOL5, "BPMS:LTU1:910:VPHAS")
	field(DOL6, "BPMS:LTU1:910:VPHAS")
	field(DOL7, "BPMS:LTU1:910:VPHAS")
	field(DOL8, "BPMS:LTU1:910:VPHAS")
	field(DOL9, "BPMS:LTU1:910:VPHAS")
	field(DOLA, "BPMS:LTU1:910:VPHAS")
	field(LNK1, "BPMS:LTU1:910:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:VPHAS_SEL")
	field(OUTA, "BPMS:LTU1:910:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:LTU1:910:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:VPHAS_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:QSCL")
	field(DOL2, "BPMS:LTU1:910:QSCL")
	field(DOL3, "BPMS:LTU1:910:QSCL")
	field(DOL4, "BPMS:LTU1:910:QSCL")
	field(DOL5, "BPMS:LTU1:910:QSCL")
	field(DOL6, "BPMS:LTU1:910:QSCL")
	field(DOL7, "BPMS:LTU1:910:QSCL")
	field(DOL8, "BPMS:LTU1:910:QSCL")
	field(DOL9, "BPMS:LTU1:910:QSCL")
	field(DOLA, "BPMS:LTU1:910:QSCL")
	field(LNK1, "BPMS:LTU1:910:QSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:QSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:QSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:QSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:QSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:QSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:QSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:QSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:QSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:QSCL_SEL")
	field(OUTA, "BPMS:LTU1:910:TMIT.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:QSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:URSCL")
	field(DOL2, "BPMS:LTU1:910:URSCL")
	field(DOL3, "BPMS:LTU1:910:URSCL")
	field(DOL4, "BPMS:LTU1:910:URSCL")
	field(DOL5, "BPMS:LTU1:910:URSCL")
	field(DOL6, "BPMS:LTU1:910:URSCL")
	field(DOL7, "BPMS:LTU1:910:URSCL")
	field(DOL8, "BPMS:LTU1:910:URSCL")
	field(DOL9, "BPMS:LTU1:910:URSCL")
	field(DOLA, "BPMS:LTU1:910:URSCL")
	field(LNK1, "BPMS:LTU1:910:URSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:URSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:URSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:URSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:URSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:URSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:URSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:URSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:URSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:URSCL_SEL")
	field(OUTA, "BPMS:LTU1:910:URMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:URSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:VRSCL")
	field(DOL2, "BPMS:LTU1:910:VRSCL")
	field(DOL3, "BPMS:LTU1:910:VRSCL")
	field(DOL4, "BPMS:LTU1:910:VRSCL")
	field(DOL5, "BPMS:LTU1:910:VRSCL")
	field(DOL6, "BPMS:LTU1:910:VRSCL")
	field(DOL7, "BPMS:LTU1:910:VRSCL")
	field(DOL8, "BPMS:LTU1:910:VRSCL")
	field(DOL9, "BPMS:LTU1:910:VRSCL")
	field(DOLA, "BPMS:LTU1:910:VRSCL")
	field(LNK1, "BPMS:LTU1:910:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:VRSCL_SEL")
	field(OUTA, "BPMS:LTU1:910:VRMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:VRSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910: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:LTU1:910:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:910:QRSCL")
	field(DOL2, "BPMS:LTU1:910:QRSCL")
	field(DOL3, "BPMS:LTU1:910:QRSCL")
	field(DOL4, "BPMS:LTU1:910:QRSCL")
	field(DOL5, "BPMS:LTU1:910:QRSCL")
	field(DOL6, "BPMS:LTU1:910:QRSCL")
	field(DOL7, "BPMS:LTU1:910:QRSCL")
	field(DOL8, "BPMS:LTU1:910:QRSCL")
	field(DOL9, "BPMS:LTU1:910:QRSCL")
	field(DOLA, "BPMS:LTU1:910:QRSCL")
	field(LNK1, "BPMS:LTU1:910:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:910:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:910:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:910:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:910:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:910:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:910:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:910:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:910:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:910:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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:LTU1:910:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:910:QRSCL_SEL")
	field(OUTA, "BPMS:LTU1:910:RRMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:910:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:910:QRSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:910:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:910:QRSCL_SEL.L PP")
}
record(longout,"BPMS:LTU1:910:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:LTU1:910: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:LTU1:960: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:LTU1:960:PRENV")
}

record(waveform, "BPMS:LTU1:960: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:LTU1:960:HFILT") {
  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:LTU1:960:hFILT") {
  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:LTU1:960:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:960:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:960:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:960:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:960:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:LTU1:960:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:LTU1:960: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:LTU1:960:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:LTU1:960: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:LTU1:960:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "1")
#field(INPB, "BPMS:LTU1:960:FC_REF")
#field(INPC, "BPMS:LTU1:960: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:LTU1:960:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:960: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:LTU1:960:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:LTU1:960:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:LTU1:960:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:960: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:LTU1:960:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:LTU1:960:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

record(ao, "BPMS:LTU1:960: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:LTU1:960:UPHAS_FB")
}

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

record(ao, "BPMS:LTU1:960: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:LTU1:960:VPHAS_FB")
}

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S12")
  field(FLNK, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:V")
}

record(ai, "BPMS:LTU1:960: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:LTU1:960:PINC")
}

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

record(longin, "BPMS:LTU1:960: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:LTU1:960:RSTA_ALH")
}


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

record(calc, "BPMS:LTU1:960:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:LTU1:960:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:LTU1:960:PADTO")
}

record(bi, "BPMS:LTU1:960:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:LTU1:960:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:LTU1:960: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:LTU1:960:PHI_SEQ")
}

record(ao, "BPMS:LTU1:960: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:LTU1:960:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:960: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:LTU1:960:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:960: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:LTU1:960:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFB08")
  field(PINI, "YES")
}

record(stringin, "RFB08:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:LTU1:960")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:LTU1:960:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:LTU1:960: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:LTU1:960:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:LTU1:960:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:LTU1:960:SIMC PP")
}

record(calcout, "BPMS:LTU1:960: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:LTU1:960:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:LTU1:960:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:LTU1:960:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:960: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:LTU1:960:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:960: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:LTU1:960:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:960:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:LTU1:960:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:960: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:LTU1:960:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:960:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:LTU1:960: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:LTU1:960:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:LTU1:960:TMIT")
  field(INPB, "BPMS:LTU1:960:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:LTU1:960:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:LTU1:960: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:LTU1:960:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:LTU1:960:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:LTU1:960:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:960:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:960:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:960:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:960: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:LTU1:960:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:UOFF")
	field(DOL2, "BPMS:LTU1:960:UOFF")
	field(DOL3, "BPMS:LTU1:960:UOFF")
	field(DOL4, "BPMS:LTU1:960:UOFF")
	field(DOL5, "BPMS:LTU1:960:UOFF")
	field(DOL6, "BPMS:LTU1:960:UOFF")
	field(DOL7, "BPMS:LTU1:960:UOFF")
	field(DOL8, "BPMS:LTU1:960:UOFF")
	field(DOL9, "BPMS:LTU1:960:UOFF")
	field(DOLA, "BPMS:LTU1:960:UOFF")
	field(LNK1, "BPMS:LTU1:960:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:960:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:960:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:VOFF")
	field(DOL2, "BPMS:LTU1:960:VOFF")
	field(DOL3, "BPMS:LTU1:960:VOFF")
	field(DOL4, "BPMS:LTU1:960:VOFF")
	field(DOL5, "BPMS:LTU1:960:VOFF")
	field(DOL6, "BPMS:LTU1:960:VOFF")
	field(DOL7, "BPMS:LTU1:960:VOFF")
	field(DOL8, "BPMS:LTU1:960:VOFF")
	field(DOL9, "BPMS:LTU1:960:VOFF")
	field(DOLA, "BPMS:LTU1:960:VOFF")
	field(LNK1, "BPMS:LTU1:960:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:960:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:960:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:USCL")
	field(DOL2, "BPMS:LTU1:960:USCL")
	field(DOL3, "BPMS:LTU1:960:USCL")
	field(DOL4, "BPMS:LTU1:960:USCL")
	field(DOL5, "BPMS:LTU1:960:USCL")
	field(DOL6, "BPMS:LTU1:960:USCL")
	field(DOL7, "BPMS:LTU1:960:USCL")
	field(DOL8, "BPMS:LTU1:960:USCL")
	field(DOL9, "BPMS:LTU1:960:USCL")
	field(DOLA, "BPMS:LTU1:960:USCL")
	field(LNK1, "BPMS:LTU1:960:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:USCL_SEL")
	field(OUTA, "BPMS:LTU1:960:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:VSCL")
	field(DOL2, "BPMS:LTU1:960:VSCL")
	field(DOL3, "BPMS:LTU1:960:VSCL")
	field(DOL4, "BPMS:LTU1:960:VSCL")
	field(DOL5, "BPMS:LTU1:960:VSCL")
	field(DOL6, "BPMS:LTU1:960:VSCL")
	field(DOL7, "BPMS:LTU1:960:VSCL")
	field(DOL8, "BPMS:LTU1:960:VSCL")
	field(DOL9, "BPMS:LTU1:960:VSCL")
	field(DOLA, "BPMS:LTU1:960:VSCL")
	field(LNK1, "BPMS:LTU1:960:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:960:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:PHI")
	field(DOL2, "BPMS:LTU1:960:PHI")
	field(DOL3, "BPMS:LTU1:960:PHI")
	field(DOL4, "BPMS:LTU1:960:PHI")
	field(DOL5, "BPMS:LTU1:960:PHI")
	field(DOL6, "BPMS:LTU1:960:PHI")
	field(DOL7, "BPMS:LTU1:960:PHI")
	field(DOL8, "BPMS:LTU1:960:PHI")
	field(DOL9, "BPMS:LTU1:960:PHI")
	field(DOLA, "BPMS:LTU1:960:PHI")
	field(LNK1, "BPMS:LTU1:960:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:PHI_SEL")
	field(OUTA, "BPMS:LTU1:960:CALC.E CA")
	field(OUTB, "BPMS:LTU1:960:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:PSI")
	field(DOL2, "BPMS:LTU1:960:PSI")
	field(DOL3, "BPMS:LTU1:960:PSI")
	field(DOL4, "BPMS:LTU1:960:PSI")
	field(DOL5, "BPMS:LTU1:960:PSI")
	field(DOL6, "BPMS:LTU1:960:PSI")
	field(DOL7, "BPMS:LTU1:960:PSI")
	field(DOL8, "BPMS:LTU1:960:PSI")
	field(DOL9, "BPMS:LTU1:960:PSI")
	field(DOLA, "BPMS:LTU1:960:PSI")
	field(LNK1, "BPMS:LTU1:960:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:PSI_SEL")
	field(OUTA, "BPMS:LTU1:960:CALC.F CA")
	field(OUTB, "BPMS:LTU1:960:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:UPHAS")
	field(DOL2, "BPMS:LTU1:960:UPHAS")
	field(DOL3, "BPMS:LTU1:960:UPHAS")
	field(DOL4, "BPMS:LTU1:960:UPHAS")
	field(DOL5, "BPMS:LTU1:960:UPHAS")
	field(DOL6, "BPMS:LTU1:960:UPHAS")
	field(DOL7, "BPMS:LTU1:960:UPHAS")
	field(DOL8, "BPMS:LTU1:960:UPHAS")
	field(DOL9, "BPMS:LTU1:960:UPHAS")
	field(DOLA, "BPMS:LTU1:960:UPHAS")
	field(LNK1, "BPMS:LTU1:960:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:UPHAS_SEL")
	field(OUTA, "BPMS:LTU1:960:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:LTU1:960:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:UPHAS_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:VPHAS")
	field(DOL2, "BPMS:LTU1:960:VPHAS")
	field(DOL3, "BPMS:LTU1:960:VPHAS")
	field(DOL4, "BPMS:LTU1:960:VPHAS")
	field(DOL5, "BPMS:LTU1:960:VPHAS")
	field(DOL6, "BPMS:LTU1:960:VPHAS")
	field(DOL7, "BPMS:LTU1:960:VPHAS")
	field(DOL8, "BPMS:LTU1:960:VPHAS")
	field(DOL9, "BPMS:LTU1:960:VPHAS")
	field(DOLA, "BPMS:LTU1:960:VPHAS")
	field(LNK1, "BPMS:LTU1:960:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:VPHAS_SEL")
	field(OUTA, "BPMS:LTU1:960:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:LTU1:960:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:VPHAS_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:QSCL")
	field(DOL2, "BPMS:LTU1:960:QSCL")
	field(DOL3, "BPMS:LTU1:960:QSCL")
	field(DOL4, "BPMS:LTU1:960:QSCL")
	field(DOL5, "BPMS:LTU1:960:QSCL")
	field(DOL6, "BPMS:LTU1:960:QSCL")
	field(DOL7, "BPMS:LTU1:960:QSCL")
	field(DOL8, "BPMS:LTU1:960:QSCL")
	field(DOL9, "BPMS:LTU1:960:QSCL")
	field(DOLA, "BPMS:LTU1:960:QSCL")
	field(LNK1, "BPMS:LTU1:960:QSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:QSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:QSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:QSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:QSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:QSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:QSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:QSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:QSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:QSCL_SEL")
	field(OUTA, "BPMS:LTU1:960:TMIT.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:QSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:URSCL")
	field(DOL2, "BPMS:LTU1:960:URSCL")
	field(DOL3, "BPMS:LTU1:960:URSCL")
	field(DOL4, "BPMS:LTU1:960:URSCL")
	field(DOL5, "BPMS:LTU1:960:URSCL")
	field(DOL6, "BPMS:LTU1:960:URSCL")
	field(DOL7, "BPMS:LTU1:960:URSCL")
	field(DOL8, "BPMS:LTU1:960:URSCL")
	field(DOL9, "BPMS:LTU1:960:URSCL")
	field(DOLA, "BPMS:LTU1:960:URSCL")
	field(LNK1, "BPMS:LTU1:960:URSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:URSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:URSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:URSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:URSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:URSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:URSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:URSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:URSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:URSCL_SEL")
	field(OUTA, "BPMS:LTU1:960:URMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:URSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:VRSCL")
	field(DOL2, "BPMS:LTU1:960:VRSCL")
	field(DOL3, "BPMS:LTU1:960:VRSCL")
	field(DOL4, "BPMS:LTU1:960:VRSCL")
	field(DOL5, "BPMS:LTU1:960:VRSCL")
	field(DOL6, "BPMS:LTU1:960:VRSCL")
	field(DOL7, "BPMS:LTU1:960:VRSCL")
	field(DOL8, "BPMS:LTU1:960:VRSCL")
	field(DOL9, "BPMS:LTU1:960:VRSCL")
	field(DOLA, "BPMS:LTU1:960:VRSCL")
	field(LNK1, "BPMS:LTU1:960:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:VRSCL_SEL")
	field(OUTA, "BPMS:LTU1:960:VRMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:VRSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960: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:LTU1:960:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:960:QRSCL")
	field(DOL2, "BPMS:LTU1:960:QRSCL")
	field(DOL3, "BPMS:LTU1:960:QRSCL")
	field(DOL4, "BPMS:LTU1:960:QRSCL")
	field(DOL5, "BPMS:LTU1:960:QRSCL")
	field(DOL6, "BPMS:LTU1:960:QRSCL")
	field(DOL7, "BPMS:LTU1:960:QRSCL")
	field(DOL8, "BPMS:LTU1:960:QRSCL")
	field(DOL9, "BPMS:LTU1:960:QRSCL")
	field(DOLA, "BPMS:LTU1:960:QRSCL")
	field(LNK1, "BPMS:LTU1:960:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:960:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:960:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:960:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:960:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:960:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:960:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:960:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:960:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:960:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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:LTU1:960:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:960:QRSCL_SEL")
	field(OUTA, "BPMS:LTU1:960:RRMS.ASLO CA")
	field(OUTB, "BPMS:LTU1:960:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:960:QRSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:960:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:960:QRSCL_SEL.L PP")
}
record(longout,"BPMS:LTU1:960:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:LTU1:960: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:UND1:100:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 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:UND1:100: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:UND1:100:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UND1:100:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

record(ai, "BPMS:UND1:100:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 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:UND1:100:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 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:UND1:100:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

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

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

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

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

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

record(waveform, "BPMS:UND1:100:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C2 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:UND1:100:HFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C2 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UND1:100:hFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C2 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

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

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:100:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:100: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:UND1:100:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:100: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:UND1:100:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "2")
#field(INPB, "BPMS:UND1:100:FC_REF")
#field(INPC, "BPMS:UND1:100: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:UND1:100:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:100: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:UND1:100:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:100:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:100:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:100: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:UND1:100:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:100:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:100:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 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:UND1:100: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:UND1:100:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S12")
  field(FLNK, "BPMS:UND1:100: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:UND1:100:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UND1:100: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:UND1:100:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C2 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:UND1:100:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 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:UND1:100:V")
}

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

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

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


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

record(calc, "BPMS:UND1:100:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:100:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:100:PADTO")
}

record(bi, "BPMS:UND1:100:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:100:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:100: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:UND1:100:PHI_SEQ")
}

record(ao, "BPMS:UND1:100: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:UND1:100:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:100: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:UND1:100:UOFF_SEQ")
}

record(ao, "BPMS:UND1:100: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:UND1:100:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:100:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C2 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:UND1:100: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:UND1:100: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:UND1:100:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU00")
  field(PINI, "YES")
}

record(stringin, "RFBU00:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:100")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:100:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:100: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:UND1:100:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:100:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:100:SIMC PP")
}

record(calcout, "BPMS:UND1:100:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "2")
#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:UND1:100:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:100:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:100:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:100: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:UND1:100:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:100: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:UND1:100:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:100:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:100:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:100: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:UND1:100:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:100:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:100:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C2 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:UND1:100:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:100:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x004")
  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:UND1:100:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x004")
  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:UND1:100:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:100:TMIT")
  field(INPB, "BPMS:UND1:100:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:100:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:100: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:UND1:100:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:100:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:100:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

record(bi, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:SIM.L     PP")
  field(LNK4, "BPMS:UND1:100:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:100:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:100:SIM.L     PP")
  field(LNK7, "BPMS:UND1:100: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:UND1:100:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:UOFF")
	field(DOL2, "BPMS:UND1:100:UOFF")
	field(DOL3, "BPMS:UND1:100:UOFF")
	field(DOL4, "BPMS:UND1:100:UOFF")
	field(DOL5, "BPMS:UND1:100:UOFF")
	field(DOL6, "BPMS:UND1:100:UOFF")
	field(DOL7, "BPMS:UND1:100:UOFF")
	field(DOL8, "BPMS:UND1:100:UOFF")
	field(DOL9, "BPMS:UND1:100:UOFF")
	field(DOLA, "BPMS:UND1:100:UOFF")
	field(LNK1, "BPMS:UND1:100:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:UOFF_SEL")
	field(OUTA, "BPMS:UND1:100:U.AOFF CA")
	field(OUTB, "BPMS:UND1:100:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:VOFF")
	field(DOL2, "BPMS:UND1:100:VOFF")
	field(DOL3, "BPMS:UND1:100:VOFF")
	field(DOL4, "BPMS:UND1:100:VOFF")
	field(DOL5, "BPMS:UND1:100:VOFF")
	field(DOL6, "BPMS:UND1:100:VOFF")
	field(DOL7, "BPMS:UND1:100:VOFF")
	field(DOL8, "BPMS:UND1:100:VOFF")
	field(DOL9, "BPMS:UND1:100:VOFF")
	field(DOLA, "BPMS:UND1:100:VOFF")
	field(LNK1, "BPMS:UND1:100:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:VOFF_SEL")
	field(OUTA, "BPMS:UND1:100:V.AOFF CA")
	field(OUTB, "BPMS:UND1:100:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:USCL")
	field(DOL2, "BPMS:UND1:100:USCL")
	field(DOL3, "BPMS:UND1:100:USCL")
	field(DOL4, "BPMS:UND1:100:USCL")
	field(DOL5, "BPMS:UND1:100:USCL")
	field(DOL6, "BPMS:UND1:100:USCL")
	field(DOL7, "BPMS:UND1:100:USCL")
	field(DOL8, "BPMS:UND1:100:USCL")
	field(DOL9, "BPMS:UND1:100:USCL")
	field(DOLA, "BPMS:UND1:100:USCL")
	field(LNK1, "BPMS:UND1:100:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:USCL_SEL")
	field(OUTA, "BPMS:UND1:100:U.ASLO CA")
	field(OUTB, "BPMS:UND1:100:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:VSCL")
	field(DOL2, "BPMS:UND1:100:VSCL")
	field(DOL3, "BPMS:UND1:100:VSCL")
	field(DOL4, "BPMS:UND1:100:VSCL")
	field(DOL5, "BPMS:UND1:100:VSCL")
	field(DOL6, "BPMS:UND1:100:VSCL")
	field(DOL7, "BPMS:UND1:100:VSCL")
	field(DOL8, "BPMS:UND1:100:VSCL")
	field(DOL9, "BPMS:UND1:100:VSCL")
	field(DOLA, "BPMS:UND1:100:VSCL")
	field(LNK1, "BPMS:UND1:100:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:VSCL_SEL")
	field(OUTA, "BPMS:UND1:100:V.ASLO CA")
	field(OUTB, "BPMS:UND1:100:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:PHI")
	field(DOL2, "BPMS:UND1:100:PHI")
	field(DOL3, "BPMS:UND1:100:PHI")
	field(DOL4, "BPMS:UND1:100:PHI")
	field(DOL5, "BPMS:UND1:100:PHI")
	field(DOL6, "BPMS:UND1:100:PHI")
	field(DOL7, "BPMS:UND1:100:PHI")
	field(DOL8, "BPMS:UND1:100:PHI")
	field(DOL9, "BPMS:UND1:100:PHI")
	field(DOLA, "BPMS:UND1:100:PHI")
	field(LNK1, "BPMS:UND1:100:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:PHI_SEL")
	field(OUTA, "BPMS:UND1:100:CALC.E CA")
	field(OUTB, "BPMS:UND1:100:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:PSI")
	field(DOL2, "BPMS:UND1:100:PSI")
	field(DOL3, "BPMS:UND1:100:PSI")
	field(DOL4, "BPMS:UND1:100:PSI")
	field(DOL5, "BPMS:UND1:100:PSI")
	field(DOL6, "BPMS:UND1:100:PSI")
	field(DOL7, "BPMS:UND1:100:PSI")
	field(DOL8, "BPMS:UND1:100:PSI")
	field(DOL9, "BPMS:UND1:100:PSI")
	field(DOLA, "BPMS:UND1:100:PSI")
	field(LNK1, "BPMS:UND1:100:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:PSI_SEL")
	field(OUTA, "BPMS:UND1:100:CALC.F CA")
	field(OUTB, "BPMS:UND1:100:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:UPHAS")
	field(DOL2, "BPMS:UND1:100:UPHAS")
	field(DOL3, "BPMS:UND1:100:UPHAS")
	field(DOL4, "BPMS:UND1:100:UPHAS")
	field(DOL5, "BPMS:UND1:100:UPHAS")
	field(DOL6, "BPMS:UND1:100:UPHAS")
	field(DOL7, "BPMS:UND1:100:UPHAS")
	field(DOL8, "BPMS:UND1:100:UPHAS")
	field(DOL9, "BPMS:UND1:100:UPHAS")
	field(DOLA, "BPMS:UND1:100:UPHAS")
	field(LNK1, "BPMS:UND1:100:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:100:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:100:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:VPHAS")
	field(DOL2, "BPMS:UND1:100:VPHAS")
	field(DOL3, "BPMS:UND1:100:VPHAS")
	field(DOL4, "BPMS:UND1:100:VPHAS")
	field(DOL5, "BPMS:UND1:100:VPHAS")
	field(DOL6, "BPMS:UND1:100:VPHAS")
	field(DOL7, "BPMS:UND1:100:VPHAS")
	field(DOL8, "BPMS:UND1:100:VPHAS")
	field(DOL9, "BPMS:UND1:100:VPHAS")
	field(DOLA, "BPMS:UND1:100:VPHAS")
	field(LNK1, "BPMS:UND1:100:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:100:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:100:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:QSCL")
	field(DOL2, "BPMS:UND1:100:QSCL")
	field(DOL3, "BPMS:UND1:100:QSCL")
	field(DOL4, "BPMS:UND1:100:QSCL")
	field(DOL5, "BPMS:UND1:100:QSCL")
	field(DOL6, "BPMS:UND1:100:QSCL")
	field(DOL7, "BPMS:UND1:100:QSCL")
	field(DOL8, "BPMS:UND1:100:QSCL")
	field(DOL9, "BPMS:UND1:100:QSCL")
	field(DOLA, "BPMS:UND1:100:QSCL")
	field(LNK1, "BPMS:UND1:100:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:QSCL_SEL")
	field(OUTA, "BPMS:UND1:100:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:100:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:URSCL")
	field(DOL2, "BPMS:UND1:100:URSCL")
	field(DOL3, "BPMS:UND1:100:URSCL")
	field(DOL4, "BPMS:UND1:100:URSCL")
	field(DOL5, "BPMS:UND1:100:URSCL")
	field(DOL6, "BPMS:UND1:100:URSCL")
	field(DOL7, "BPMS:UND1:100:URSCL")
	field(DOL8, "BPMS:UND1:100:URSCL")
	field(DOL9, "BPMS:UND1:100:URSCL")
	field(DOLA, "BPMS:UND1:100:URSCL")
	field(LNK1, "BPMS:UND1:100:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:URSCL_SEL")
	field(OUTA, "BPMS:UND1:100:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:100:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:VRSCL")
	field(DOL2, "BPMS:UND1:100:VRSCL")
	field(DOL3, "BPMS:UND1:100:VRSCL")
	field(DOL4, "BPMS:UND1:100:VRSCL")
	field(DOL5, "BPMS:UND1:100:VRSCL")
	field(DOL6, "BPMS:UND1:100:VRSCL")
	field(DOL7, "BPMS:UND1:100:VRSCL")
	field(DOL8, "BPMS:UND1:100:VRSCL")
	field(DOL9, "BPMS:UND1:100:VRSCL")
	field(DOLA, "BPMS:UND1:100:VRSCL")
	field(LNK1, "BPMS:UND1:100:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:100:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:100:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100: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:UND1:100:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:100:QRSCL")
	field(DOL2, "BPMS:UND1:100:QRSCL")
	field(DOL3, "BPMS:UND1:100:QRSCL")
	field(DOL4, "BPMS:UND1:100:QRSCL")
	field(DOL5, "BPMS:UND1:100:QRSCL")
	field(DOL6, "BPMS:UND1:100:QRSCL")
	field(DOL7, "BPMS:UND1:100:QRSCL")
	field(DOL8, "BPMS:UND1:100:QRSCL")
	field(DOL9, "BPMS:UND1:100:QRSCL")
	field(DOLA, "BPMS:UND1:100:QRSCL")
	field(LNK1, "BPMS:UND1:100:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:100:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:100:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:100:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:100:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:100:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:100:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:100:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:100:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:100:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:100: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:UND1:100: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:UND1:100: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:UND1:100:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:100:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:100:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:100:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:100:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:100:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:100:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:100:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:100: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:190: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:UND1:190:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:190: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:UND1:190:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:190: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:UND1:190: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:UND1:190:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UND1:190: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:UND1:190:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UND1:190: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:UND1:190:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UND1:190: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:UND1:190:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UND1:190: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:UND1:190:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UND1:190: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:UND1:190:PRENV")
}

record(waveform, "BPMS:UND1:190: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:UND1:190:HFILT") {
  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:UND1:190:hFILT") {
  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:UND1:190:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UND1:190:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UND1:190:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UND1:190:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UND1:190:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:190:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:190: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:UND1:190:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:190: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:UND1:190:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "3")
#field(INPB, "BPMS:UND1:190:FC_REF")
#field(INPC, "BPMS:UND1:190: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:UND1:190:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:190: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:UND1:190:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:190:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:190:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:190: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:UND1:190:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:190:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

record(ao, "BPMS:UND1:190: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:UND1:190:UPHAS_FB")
}

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

record(ao, "BPMS:UND1:190: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:UND1:190:VPHAS_FB")
}

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:190: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:UND1:190: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:UND1:190:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S12")
  field(FLNK, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:V")
}

record(ai, "BPMS:UND1:190: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:UND1:190:PINC")
}

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

record(longin, "BPMS:UND1:190: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:UND1:190:RSTA_ALH")
}


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

record(calc, "BPMS:UND1:190:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:190:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:190:PADTO")
}

record(bi, "BPMS:UND1:190:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:190:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:190: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:UND1:190:PHI_SEQ")
}

record(ao, "BPMS:UND1:190: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:UND1:190:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:190: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:UND1:190:UOFF_SEQ")
}

record(ao, "BPMS:UND1:190: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:UND1:190:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU01")
  field(PINI, "YES")
}

record(stringin, "RFBU01:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:190")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:190:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:190: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:UND1:190:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:190:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:190:SIMC PP")
}

record(calcout, "BPMS:UND1:190: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:UND1:190:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:190:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:190:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:190: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:UND1:190:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:190: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:UND1:190:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:190:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:190:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:190: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:UND1:190:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:190:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:190: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:UND1:190:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:190: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:UND1:190: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:UND1:190:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:190:TMIT")
  field(INPB, "BPMS:UND1:190:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:190:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:190: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:UND1:190:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:190:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:190:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:SIM.L     PP")
  field(LNK4, "BPMS:UND1:190:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:190:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:190:SIM.L     PP")
  field(LNK7, "BPMS:UND1:190: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:UND1:190:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:UOFF")
	field(DOL2, "BPMS:UND1:190:UOFF")
	field(DOL3, "BPMS:UND1:190:UOFF")
	field(DOL4, "BPMS:UND1:190:UOFF")
	field(DOL5, "BPMS:UND1:190:UOFF")
	field(DOL6, "BPMS:UND1:190:UOFF")
	field(DOL7, "BPMS:UND1:190:UOFF")
	field(DOL8, "BPMS:UND1:190:UOFF")
	field(DOL9, "BPMS:UND1:190:UOFF")
	field(DOLA, "BPMS:UND1:190:UOFF")
	field(LNK1, "BPMS:UND1:190:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:UOFF_SEL")
	field(OUTA, "BPMS:UND1:190:U.AOFF CA")
	field(OUTB, "BPMS:UND1:190:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:VOFF")
	field(DOL2, "BPMS:UND1:190:VOFF")
	field(DOL3, "BPMS:UND1:190:VOFF")
	field(DOL4, "BPMS:UND1:190:VOFF")
	field(DOL5, "BPMS:UND1:190:VOFF")
	field(DOL6, "BPMS:UND1:190:VOFF")
	field(DOL7, "BPMS:UND1:190:VOFF")
	field(DOL8, "BPMS:UND1:190:VOFF")
	field(DOL9, "BPMS:UND1:190:VOFF")
	field(DOLA, "BPMS:UND1:190:VOFF")
	field(LNK1, "BPMS:UND1:190:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:VOFF_SEL")
	field(OUTA, "BPMS:UND1:190:V.AOFF CA")
	field(OUTB, "BPMS:UND1:190:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:USCL")
	field(DOL2, "BPMS:UND1:190:USCL")
	field(DOL3, "BPMS:UND1:190:USCL")
	field(DOL4, "BPMS:UND1:190:USCL")
	field(DOL5, "BPMS:UND1:190:USCL")
	field(DOL6, "BPMS:UND1:190:USCL")
	field(DOL7, "BPMS:UND1:190:USCL")
	field(DOL8, "BPMS:UND1:190:USCL")
	field(DOL9, "BPMS:UND1:190:USCL")
	field(DOLA, "BPMS:UND1:190:USCL")
	field(LNK1, "BPMS:UND1:190:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:USCL_SEL")
	field(OUTA, "BPMS:UND1:190:U.ASLO CA")
	field(OUTB, "BPMS:UND1:190:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:VSCL")
	field(DOL2, "BPMS:UND1:190:VSCL")
	field(DOL3, "BPMS:UND1:190:VSCL")
	field(DOL4, "BPMS:UND1:190:VSCL")
	field(DOL5, "BPMS:UND1:190:VSCL")
	field(DOL6, "BPMS:UND1:190:VSCL")
	field(DOL7, "BPMS:UND1:190:VSCL")
	field(DOL8, "BPMS:UND1:190:VSCL")
	field(DOL9, "BPMS:UND1:190:VSCL")
	field(DOLA, "BPMS:UND1:190:VSCL")
	field(LNK1, "BPMS:UND1:190:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:VSCL_SEL")
	field(OUTA, "BPMS:UND1:190:V.ASLO CA")
	field(OUTB, "BPMS:UND1:190:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:PHI")
	field(DOL2, "BPMS:UND1:190:PHI")
	field(DOL3, "BPMS:UND1:190:PHI")
	field(DOL4, "BPMS:UND1:190:PHI")
	field(DOL5, "BPMS:UND1:190:PHI")
	field(DOL6, "BPMS:UND1:190:PHI")
	field(DOL7, "BPMS:UND1:190:PHI")
	field(DOL8, "BPMS:UND1:190:PHI")
	field(DOL9, "BPMS:UND1:190:PHI")
	field(DOLA, "BPMS:UND1:190:PHI")
	field(LNK1, "BPMS:UND1:190:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:PHI_SEL")
	field(OUTA, "BPMS:UND1:190:CALC.E CA")
	field(OUTB, "BPMS:UND1:190:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:PSI")
	field(DOL2, "BPMS:UND1:190:PSI")
	field(DOL3, "BPMS:UND1:190:PSI")
	field(DOL4, "BPMS:UND1:190:PSI")
	field(DOL5, "BPMS:UND1:190:PSI")
	field(DOL6, "BPMS:UND1:190:PSI")
	field(DOL7, "BPMS:UND1:190:PSI")
	field(DOL8, "BPMS:UND1:190:PSI")
	field(DOL9, "BPMS:UND1:190:PSI")
	field(DOLA, "BPMS:UND1:190:PSI")
	field(LNK1, "BPMS:UND1:190:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:PSI_SEL")
	field(OUTA, "BPMS:UND1:190:CALC.F CA")
	field(OUTB, "BPMS:UND1:190:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:UPHAS")
	field(DOL2, "BPMS:UND1:190:UPHAS")
	field(DOL3, "BPMS:UND1:190:UPHAS")
	field(DOL4, "BPMS:UND1:190:UPHAS")
	field(DOL5, "BPMS:UND1:190:UPHAS")
	field(DOL6, "BPMS:UND1:190:UPHAS")
	field(DOL7, "BPMS:UND1:190:UPHAS")
	field(DOL8, "BPMS:UND1:190:UPHAS")
	field(DOL9, "BPMS:UND1:190:UPHAS")
	field(DOLA, "BPMS:UND1:190:UPHAS")
	field(LNK1, "BPMS:UND1:190:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:190:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:190:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:VPHAS")
	field(DOL2, "BPMS:UND1:190:VPHAS")
	field(DOL3, "BPMS:UND1:190:VPHAS")
	field(DOL4, "BPMS:UND1:190:VPHAS")
	field(DOL5, "BPMS:UND1:190:VPHAS")
	field(DOL6, "BPMS:UND1:190:VPHAS")
	field(DOL7, "BPMS:UND1:190:VPHAS")
	field(DOL8, "BPMS:UND1:190:VPHAS")
	field(DOL9, "BPMS:UND1:190:VPHAS")
	field(DOLA, "BPMS:UND1:190:VPHAS")
	field(LNK1, "BPMS:UND1:190:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:190:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:190:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:QSCL")
	field(DOL2, "BPMS:UND1:190:QSCL")
	field(DOL3, "BPMS:UND1:190:QSCL")
	field(DOL4, "BPMS:UND1:190:QSCL")
	field(DOL5, "BPMS:UND1:190:QSCL")
	field(DOL6, "BPMS:UND1:190:QSCL")
	field(DOL7, "BPMS:UND1:190:QSCL")
	field(DOL8, "BPMS:UND1:190:QSCL")
	field(DOL9, "BPMS:UND1:190:QSCL")
	field(DOLA, "BPMS:UND1:190:QSCL")
	field(LNK1, "BPMS:UND1:190:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:QSCL_SEL")
	field(OUTA, "BPMS:UND1:190:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:190:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:URSCL")
	field(DOL2, "BPMS:UND1:190:URSCL")
	field(DOL3, "BPMS:UND1:190:URSCL")
	field(DOL4, "BPMS:UND1:190:URSCL")
	field(DOL5, "BPMS:UND1:190:URSCL")
	field(DOL6, "BPMS:UND1:190:URSCL")
	field(DOL7, "BPMS:UND1:190:URSCL")
	field(DOL8, "BPMS:UND1:190:URSCL")
	field(DOL9, "BPMS:UND1:190:URSCL")
	field(DOLA, "BPMS:UND1:190:URSCL")
	field(LNK1, "BPMS:UND1:190:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:URSCL_SEL")
	field(OUTA, "BPMS:UND1:190:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:190:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:VRSCL")
	field(DOL2, "BPMS:UND1:190:VRSCL")
	field(DOL3, "BPMS:UND1:190:VRSCL")
	field(DOL4, "BPMS:UND1:190:VRSCL")
	field(DOL5, "BPMS:UND1:190:VRSCL")
	field(DOL6, "BPMS:UND1:190:VRSCL")
	field(DOL7, "BPMS:UND1:190:VRSCL")
	field(DOL8, "BPMS:UND1:190:VRSCL")
	field(DOL9, "BPMS:UND1:190:VRSCL")
	field(DOLA, "BPMS:UND1:190:VRSCL")
	field(LNK1, "BPMS:UND1:190:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:190:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:190:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190: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:UND1:190:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:190:QRSCL")
	field(DOL2, "BPMS:UND1:190:QRSCL")
	field(DOL3, "BPMS:UND1:190:QRSCL")
	field(DOL4, "BPMS:UND1:190:QRSCL")
	field(DOL5, "BPMS:UND1:190:QRSCL")
	field(DOL6, "BPMS:UND1:190:QRSCL")
	field(DOL7, "BPMS:UND1:190:QRSCL")
	field(DOL8, "BPMS:UND1:190:QRSCL")
	field(DOL9, "BPMS:UND1:190:QRSCL")
	field(DOLA, "BPMS:UND1:190:QRSCL")
	field(LNK1, "BPMS:UND1:190:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:190:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:190:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:190:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:190:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:190:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:190:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:190:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:190:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:190:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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:UND1:190:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:190:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:190:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:190:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:190:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:190:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:190:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:190:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:190: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:290: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:UND1:290:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:290: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:UND1:290:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "BPMS:UND1:290: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:UND1:290: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:UND1:290:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "BPMS:UND1:290: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:UND1:290:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UND1:290: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:UND1:290:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "BPMS:UND1:290: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:UND1:290:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "BPMS:UND1:290: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:UND1:290:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "BPMS:UND1:290: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:UND1:290:PRENV")
}

record(waveform, "BPMS:UND1:290: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:UND1:290:HFILT") {
  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:UND1:290:hFILT") {
  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:UND1:290:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:UND1:290:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:UND1:290:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:UND1:290:Y.SEVR    MS NPP")
  field(INPD, "BPMS:UND1:290:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:290:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:290: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:UND1:290:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:290: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:UND1:290:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "4")
#field(INPB, "BPMS:UND1:290:FC_REF")
#field(INPC, "BPMS:UND1:290: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:UND1:290:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:290: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:UND1:290:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:290:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:290:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:290: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:UND1:290:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:290:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

record(ao, "BPMS:UND1:290: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:UND1:290:UPHAS_FB")
}

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

record(ao, "BPMS:UND1:290: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:UND1:290:VPHAS_FB")
}

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:290: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:UND1:290: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:UND1:290:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S12")
  field(FLNK, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:V")
}

record(ai, "BPMS:UND1:290: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:UND1:290:PINC")
}

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

record(longin, "BPMS:UND1:290: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:UND1:290:RSTA_ALH")
}


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

record(calc, "BPMS:UND1:290:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:290:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:290:PADTO")
}

record(bi, "BPMS:UND1:290:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:290:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:290: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:UND1:290:PHI_SEQ")
}

record(ao, "BPMS:UND1:290: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:UND1:290:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:290: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:UND1:290:UOFF_SEQ")
}

record(ao, "BPMS:UND1:290: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:UND1:290:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU02")
  field(PINI, "YES")
}

record(stringin, "RFBU02:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:290")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:290:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:290: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:UND1:290:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:290:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:290:SIMC PP")
}

record(calcout, "BPMS:UND1:290: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:UND1:290:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:290:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:290:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:290: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:UND1:290:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:290: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:UND1:290:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:290:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:290:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:290: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:UND1:290:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:290:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:290: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:UND1:290:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:290: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:UND1:290: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:UND1:290:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:290:TMIT")
  field(INPB, "BPMS:UND1:290:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:290:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:290: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:UND1:290:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:290:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:290:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:SIM.L     PP")
  field(LNK4, "BPMS:UND1:290:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:290:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:290:SIM.L     PP")
  field(LNK7, "BPMS:UND1:290: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:UND1:290:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:UOFF")
	field(DOL2, "BPMS:UND1:290:UOFF")
	field(DOL3, "BPMS:UND1:290:UOFF")
	field(DOL4, "BPMS:UND1:290:UOFF")
	field(DOL5, "BPMS:UND1:290:UOFF")
	field(DOL6, "BPMS:UND1:290:UOFF")
	field(DOL7, "BPMS:UND1:290:UOFF")
	field(DOL8, "BPMS:UND1:290:UOFF")
	field(DOL9, "BPMS:UND1:290:UOFF")
	field(DOLA, "BPMS:UND1:290:UOFF")
	field(LNK1, "BPMS:UND1:290:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:UOFF_SEL")
	field(OUTA, "BPMS:UND1:290:U.AOFF CA")
	field(OUTB, "BPMS:UND1:290:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:VOFF")
	field(DOL2, "BPMS:UND1:290:VOFF")
	field(DOL3, "BPMS:UND1:290:VOFF")
	field(DOL4, "BPMS:UND1:290:VOFF")
	field(DOL5, "BPMS:UND1:290:VOFF")
	field(DOL6, "BPMS:UND1:290:VOFF")
	field(DOL7, "BPMS:UND1:290:VOFF")
	field(DOL8, "BPMS:UND1:290:VOFF")
	field(DOL9, "BPMS:UND1:290:VOFF")
	field(DOLA, "BPMS:UND1:290:VOFF")
	field(LNK1, "BPMS:UND1:290:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:VOFF_SEL")
	field(OUTA, "BPMS:UND1:290:V.AOFF CA")
	field(OUTB, "BPMS:UND1:290:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:USCL")
	field(DOL2, "BPMS:UND1:290:USCL")
	field(DOL3, "BPMS:UND1:290:USCL")
	field(DOL4, "BPMS:UND1:290:USCL")
	field(DOL5, "BPMS:UND1:290:USCL")
	field(DOL6, "BPMS:UND1:290:USCL")
	field(DOL7, "BPMS:UND1:290:USCL")
	field(DOL8, "BPMS:UND1:290:USCL")
	field(DOL9, "BPMS:UND1:290:USCL")
	field(DOLA, "BPMS:UND1:290:USCL")
	field(LNK1, "BPMS:UND1:290:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:USCL_SEL")
	field(OUTA, "BPMS:UND1:290:U.ASLO CA")
	field(OUTB, "BPMS:UND1:290:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:VSCL")
	field(DOL2, "BPMS:UND1:290:VSCL")
	field(DOL3, "BPMS:UND1:290:VSCL")
	field(DOL4, "BPMS:UND1:290:VSCL")
	field(DOL5, "BPMS:UND1:290:VSCL")
	field(DOL6, "BPMS:UND1:290:VSCL")
	field(DOL7, "BPMS:UND1:290:VSCL")
	field(DOL8, "BPMS:UND1:290:VSCL")
	field(DOL9, "BPMS:UND1:290:VSCL")
	field(DOLA, "BPMS:UND1:290:VSCL")
	field(LNK1, "BPMS:UND1:290:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:VSCL_SEL")
	field(OUTA, "BPMS:UND1:290:V.ASLO CA")
	field(OUTB, "BPMS:UND1:290:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:PHI")
	field(DOL2, "BPMS:UND1:290:PHI")
	field(DOL3, "BPMS:UND1:290:PHI")
	field(DOL4, "BPMS:UND1:290:PHI")
	field(DOL5, "BPMS:UND1:290:PHI")
	field(DOL6, "BPMS:UND1:290:PHI")
	field(DOL7, "BPMS:UND1:290:PHI")
	field(DOL8, "BPMS:UND1:290:PHI")
	field(DOL9, "BPMS:UND1:290:PHI")
	field(DOLA, "BPMS:UND1:290:PHI")
	field(LNK1, "BPMS:UND1:290:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:PHI_SEL")
	field(OUTA, "BPMS:UND1:290:CALC.E CA")
	field(OUTB, "BPMS:UND1:290:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:PSI")
	field(DOL2, "BPMS:UND1:290:PSI")
	field(DOL3, "BPMS:UND1:290:PSI")
	field(DOL4, "BPMS:UND1:290:PSI")
	field(DOL5, "BPMS:UND1:290:PSI")
	field(DOL6, "BPMS:UND1:290:PSI")
	field(DOL7, "BPMS:UND1:290:PSI")
	field(DOL8, "BPMS:UND1:290:PSI")
	field(DOL9, "BPMS:UND1:290:PSI")
	field(DOLA, "BPMS:UND1:290:PSI")
	field(LNK1, "BPMS:UND1:290:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:PSI_SEL")
	field(OUTA, "BPMS:UND1:290:CALC.F CA")
	field(OUTB, "BPMS:UND1:290:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:UPHAS")
	field(DOL2, "BPMS:UND1:290:UPHAS")
	field(DOL3, "BPMS:UND1:290:UPHAS")
	field(DOL4, "BPMS:UND1:290:UPHAS")
	field(DOL5, "BPMS:UND1:290:UPHAS")
	field(DOL6, "BPMS:UND1:290:UPHAS")
	field(DOL7, "BPMS:UND1:290:UPHAS")
	field(DOL8, "BPMS:UND1:290:UPHAS")
	field(DOL9, "BPMS:UND1:290:UPHAS")
	field(DOLA, "BPMS:UND1:290:UPHAS")
	field(LNK1, "BPMS:UND1:290:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:290:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:290:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:VPHAS")
	field(DOL2, "BPMS:UND1:290:VPHAS")
	field(DOL3, "BPMS:UND1:290:VPHAS")
	field(DOL4, "BPMS:UND1:290:VPHAS")
	field(DOL5, "BPMS:UND1:290:VPHAS")
	field(DOL6, "BPMS:UND1:290:VPHAS")
	field(DOL7, "BPMS:UND1:290:VPHAS")
	field(DOL8, "BPMS:UND1:290:VPHAS")
	field(DOL9, "BPMS:UND1:290:VPHAS")
	field(DOLA, "BPMS:UND1:290:VPHAS")
	field(LNK1, "BPMS:UND1:290:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:290:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:290:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:QSCL")
	field(DOL2, "BPMS:UND1:290:QSCL")
	field(DOL3, "BPMS:UND1:290:QSCL")
	field(DOL4, "BPMS:UND1:290:QSCL")
	field(DOL5, "BPMS:UND1:290:QSCL")
	field(DOL6, "BPMS:UND1:290:QSCL")
	field(DOL7, "BPMS:UND1:290:QSCL")
	field(DOL8, "BPMS:UND1:290:QSCL")
	field(DOL9, "BPMS:UND1:290:QSCL")
	field(DOLA, "BPMS:UND1:290:QSCL")
	field(LNK1, "BPMS:UND1:290:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:QSCL_SEL")
	field(OUTA, "BPMS:UND1:290:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:290:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:URSCL")
	field(DOL2, "BPMS:UND1:290:URSCL")
	field(DOL3, "BPMS:UND1:290:URSCL")
	field(DOL4, "BPMS:UND1:290:URSCL")
	field(DOL5, "BPMS:UND1:290:URSCL")
	field(DOL6, "BPMS:UND1:290:URSCL")
	field(DOL7, "BPMS:UND1:290:URSCL")
	field(DOL8, "BPMS:UND1:290:URSCL")
	field(DOL9, "BPMS:UND1:290:URSCL")
	field(DOLA, "BPMS:UND1:290:URSCL")
	field(LNK1, "BPMS:UND1:290:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:URSCL_SEL")
	field(OUTA, "BPMS:UND1:290:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:290:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:VRSCL")
	field(DOL2, "BPMS:UND1:290:VRSCL")
	field(DOL3, "BPMS:UND1:290:VRSCL")
	field(DOL4, "BPMS:UND1:290:VRSCL")
	field(DOL5, "BPMS:UND1:290:VRSCL")
	field(DOL6, "BPMS:UND1:290:VRSCL")
	field(DOL7, "BPMS:UND1:290:VRSCL")
	field(DOL8, "BPMS:UND1:290:VRSCL")
	field(DOL9, "BPMS:UND1:290:VRSCL")
	field(DOLA, "BPMS:UND1:290:VRSCL")
	field(LNK1, "BPMS:UND1:290:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:290:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:290:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290: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:UND1:290:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:290:QRSCL")
	field(DOL2, "BPMS:UND1:290:QRSCL")
	field(DOL3, "BPMS:UND1:290:QRSCL")
	field(DOL4, "BPMS:UND1:290:QRSCL")
	field(DOL5, "BPMS:UND1:290:QRSCL")
	field(DOL6, "BPMS:UND1:290:QRSCL")
	field(DOL7, "BPMS:UND1:290:QRSCL")
	field(DOL8, "BPMS:UND1:290:QRSCL")
	field(DOL9, "BPMS:UND1:290:QRSCL")
	field(DOLA, "BPMS:UND1:290:QRSCL")
	field(LNK1, "BPMS:UND1:290:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:290:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:290:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:290:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:290:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:290:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:290:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:290:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:290:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:290:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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:UND1:290:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:290:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:290:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:290:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:290:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:290:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:290:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:290:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:290: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:UND1:390:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 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:UND1:390: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:UND1:390:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UND1:390:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

record(ai, "BPMS:UND1:390:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 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:UND1:390:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 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:UND1:390:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

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

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

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

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

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

record(waveform, "BPMS:UND1:390:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C5 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:UND1:390:HFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C5 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UND1:390:hFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C5 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

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

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:390:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:390: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:UND1:390:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:390: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:UND1:390:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "5")
#field(INPB, "BPMS:UND1:390:FC_REF")
#field(INPC, "BPMS:UND1:390: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:UND1:390:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:390: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:UND1:390:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:390:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:390:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:390: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:UND1:390:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:390:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:390:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 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:UND1:390: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:UND1:390:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S12")
  field(FLNK, "BPMS:UND1:390: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:UND1:390:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UND1:390: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:UND1:390:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C5 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:UND1:390:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 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:UND1:390:V")
}

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

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

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


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

record(calc, "BPMS:UND1:390:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:390:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:390:PADTO")
}

record(bi, "BPMS:UND1:390:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:390:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:390: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:UND1:390:PHI_SEQ")
}

record(ao, "BPMS:UND1:390: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:UND1:390:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:390: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:UND1:390:UOFF_SEQ")
}

record(ao, "BPMS:UND1:390: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:UND1:390:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:390:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C5 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:UND1:390: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:UND1:390: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:UND1:390:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU03")
  field(PINI, "YES")
}

record(stringin, "RFBU03:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:390")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:390:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:390: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:UND1:390:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:390:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:390:SIMC PP")
}

record(calcout, "BPMS:UND1:390:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "5")
#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:UND1:390:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:390:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:390:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:390: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:UND1:390:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:390: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:UND1:390:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:390:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:390:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:390: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:UND1:390:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:390:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:390:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C5 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:UND1:390:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:390:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x020")
  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:UND1:390:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x020")
  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:UND1:390:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:390:TMIT")
  field(INPB, "BPMS:UND1:390:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:390:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:390: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:UND1:390:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:390:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:390:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

record(bi, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:SIM.L     PP")
  field(LNK4, "BPMS:UND1:390:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:390:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:390:SIM.L     PP")
  field(LNK7, "BPMS:UND1:390: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:UND1:390:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:UOFF")
	field(DOL2, "BPMS:UND1:390:UOFF")
	field(DOL3, "BPMS:UND1:390:UOFF")
	field(DOL4, "BPMS:UND1:390:UOFF")
	field(DOL5, "BPMS:UND1:390:UOFF")
	field(DOL6, "BPMS:UND1:390:UOFF")
	field(DOL7, "BPMS:UND1:390:UOFF")
	field(DOL8, "BPMS:UND1:390:UOFF")
	field(DOL9, "BPMS:UND1:390:UOFF")
	field(DOLA, "BPMS:UND1:390:UOFF")
	field(LNK1, "BPMS:UND1:390:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:UOFF_SEL")
	field(OUTA, "BPMS:UND1:390:U.AOFF CA")
	field(OUTB, "BPMS:UND1:390:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:VOFF")
	field(DOL2, "BPMS:UND1:390:VOFF")
	field(DOL3, "BPMS:UND1:390:VOFF")
	field(DOL4, "BPMS:UND1:390:VOFF")
	field(DOL5, "BPMS:UND1:390:VOFF")
	field(DOL6, "BPMS:UND1:390:VOFF")
	field(DOL7, "BPMS:UND1:390:VOFF")
	field(DOL8, "BPMS:UND1:390:VOFF")
	field(DOL9, "BPMS:UND1:390:VOFF")
	field(DOLA, "BPMS:UND1:390:VOFF")
	field(LNK1, "BPMS:UND1:390:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:VOFF_SEL")
	field(OUTA, "BPMS:UND1:390:V.AOFF CA")
	field(OUTB, "BPMS:UND1:390:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:USCL")
	field(DOL2, "BPMS:UND1:390:USCL")
	field(DOL3, "BPMS:UND1:390:USCL")
	field(DOL4, "BPMS:UND1:390:USCL")
	field(DOL5, "BPMS:UND1:390:USCL")
	field(DOL6, "BPMS:UND1:390:USCL")
	field(DOL7, "BPMS:UND1:390:USCL")
	field(DOL8, "BPMS:UND1:390:USCL")
	field(DOL9, "BPMS:UND1:390:USCL")
	field(DOLA, "BPMS:UND1:390:USCL")
	field(LNK1, "BPMS:UND1:390:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:USCL_SEL")
	field(OUTA, "BPMS:UND1:390:U.ASLO CA")
	field(OUTB, "BPMS:UND1:390:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:VSCL")
	field(DOL2, "BPMS:UND1:390:VSCL")
	field(DOL3, "BPMS:UND1:390:VSCL")
	field(DOL4, "BPMS:UND1:390:VSCL")
	field(DOL5, "BPMS:UND1:390:VSCL")
	field(DOL6, "BPMS:UND1:390:VSCL")
	field(DOL7, "BPMS:UND1:390:VSCL")
	field(DOL8, "BPMS:UND1:390:VSCL")
	field(DOL9, "BPMS:UND1:390:VSCL")
	field(DOLA, "BPMS:UND1:390:VSCL")
	field(LNK1, "BPMS:UND1:390:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:VSCL_SEL")
	field(OUTA, "BPMS:UND1:390:V.ASLO CA")
	field(OUTB, "BPMS:UND1:390:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:PHI")
	field(DOL2, "BPMS:UND1:390:PHI")
	field(DOL3, "BPMS:UND1:390:PHI")
	field(DOL4, "BPMS:UND1:390:PHI")
	field(DOL5, "BPMS:UND1:390:PHI")
	field(DOL6, "BPMS:UND1:390:PHI")
	field(DOL7, "BPMS:UND1:390:PHI")
	field(DOL8, "BPMS:UND1:390:PHI")
	field(DOL9, "BPMS:UND1:390:PHI")
	field(DOLA, "BPMS:UND1:390:PHI")
	field(LNK1, "BPMS:UND1:390:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:PHI_SEL")
	field(OUTA, "BPMS:UND1:390:CALC.E CA")
	field(OUTB, "BPMS:UND1:390:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:PSI")
	field(DOL2, "BPMS:UND1:390:PSI")
	field(DOL3, "BPMS:UND1:390:PSI")
	field(DOL4, "BPMS:UND1:390:PSI")
	field(DOL5, "BPMS:UND1:390:PSI")
	field(DOL6, "BPMS:UND1:390:PSI")
	field(DOL7, "BPMS:UND1:390:PSI")
	field(DOL8, "BPMS:UND1:390:PSI")
	field(DOL9, "BPMS:UND1:390:PSI")
	field(DOLA, "BPMS:UND1:390:PSI")
	field(LNK1, "BPMS:UND1:390:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:PSI_SEL")
	field(OUTA, "BPMS:UND1:390:CALC.F CA")
	field(OUTB, "BPMS:UND1:390:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:UPHAS")
	field(DOL2, "BPMS:UND1:390:UPHAS")
	field(DOL3, "BPMS:UND1:390:UPHAS")
	field(DOL4, "BPMS:UND1:390:UPHAS")
	field(DOL5, "BPMS:UND1:390:UPHAS")
	field(DOL6, "BPMS:UND1:390:UPHAS")
	field(DOL7, "BPMS:UND1:390:UPHAS")
	field(DOL8, "BPMS:UND1:390:UPHAS")
	field(DOL9, "BPMS:UND1:390:UPHAS")
	field(DOLA, "BPMS:UND1:390:UPHAS")
	field(LNK1, "BPMS:UND1:390:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:390:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:390:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:VPHAS")
	field(DOL2, "BPMS:UND1:390:VPHAS")
	field(DOL3, "BPMS:UND1:390:VPHAS")
	field(DOL4, "BPMS:UND1:390:VPHAS")
	field(DOL5, "BPMS:UND1:390:VPHAS")
	field(DOL6, "BPMS:UND1:390:VPHAS")
	field(DOL7, "BPMS:UND1:390:VPHAS")
	field(DOL8, "BPMS:UND1:390:VPHAS")
	field(DOL9, "BPMS:UND1:390:VPHAS")
	field(DOLA, "BPMS:UND1:390:VPHAS")
	field(LNK1, "BPMS:UND1:390:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:390:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:390:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:QSCL")
	field(DOL2, "BPMS:UND1:390:QSCL")
	field(DOL3, "BPMS:UND1:390:QSCL")
	field(DOL4, "BPMS:UND1:390:QSCL")
	field(DOL5, "BPMS:UND1:390:QSCL")
	field(DOL6, "BPMS:UND1:390:QSCL")
	field(DOL7, "BPMS:UND1:390:QSCL")
	field(DOL8, "BPMS:UND1:390:QSCL")
	field(DOL9, "BPMS:UND1:390:QSCL")
	field(DOLA, "BPMS:UND1:390:QSCL")
	field(LNK1, "BPMS:UND1:390:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:QSCL_SEL")
	field(OUTA, "BPMS:UND1:390:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:390:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:URSCL")
	field(DOL2, "BPMS:UND1:390:URSCL")
	field(DOL3, "BPMS:UND1:390:URSCL")
	field(DOL4, "BPMS:UND1:390:URSCL")
	field(DOL5, "BPMS:UND1:390:URSCL")
	field(DOL6, "BPMS:UND1:390:URSCL")
	field(DOL7, "BPMS:UND1:390:URSCL")
	field(DOL8, "BPMS:UND1:390:URSCL")
	field(DOL9, "BPMS:UND1:390:URSCL")
	field(DOLA, "BPMS:UND1:390:URSCL")
	field(LNK1, "BPMS:UND1:390:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:URSCL_SEL")
	field(OUTA, "BPMS:UND1:390:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:390:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:VRSCL")
	field(DOL2, "BPMS:UND1:390:VRSCL")
	field(DOL3, "BPMS:UND1:390:VRSCL")
	field(DOL4, "BPMS:UND1:390:VRSCL")
	field(DOL5, "BPMS:UND1:390:VRSCL")
	field(DOL6, "BPMS:UND1:390:VRSCL")
	field(DOL7, "BPMS:UND1:390:VRSCL")
	field(DOL8, "BPMS:UND1:390:VRSCL")
	field(DOL9, "BPMS:UND1:390:VRSCL")
	field(DOLA, "BPMS:UND1:390:VRSCL")
	field(LNK1, "BPMS:UND1:390:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:390:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:390:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390: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:UND1:390:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:390:QRSCL")
	field(DOL2, "BPMS:UND1:390:QRSCL")
	field(DOL3, "BPMS:UND1:390:QRSCL")
	field(DOL4, "BPMS:UND1:390:QRSCL")
	field(DOL5, "BPMS:UND1:390:QRSCL")
	field(DOL6, "BPMS:UND1:390:QRSCL")
	field(DOL7, "BPMS:UND1:390:QRSCL")
	field(DOL8, "BPMS:UND1:390:QRSCL")
	field(DOL9, "BPMS:UND1:390:QRSCL")
	field(DOLA, "BPMS:UND1:390:QRSCL")
	field(LNK1, "BPMS:UND1:390:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:390:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:390:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:390:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:390:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:390:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:390:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:390:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:390:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:390:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:390: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:UND1:390: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:UND1:390: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:UND1:390:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:390:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:390:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:390:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:390:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:390:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:390:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:390:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:390: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:UND1:490:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 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:UND1:490: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:UND1:490:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UND1:490:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

record(ai, "BPMS:UND1:490:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 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:UND1:490:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 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:UND1:490:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

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

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

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

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

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

record(waveform, "BPMS:UND1:490:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C6 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:UND1:490:HFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C6 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UND1:490:hFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C6 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

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

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:490:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:490: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:UND1:490:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:490: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:UND1:490:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "6")
#field(INPB, "BPMS:UND1:490:FC_REF")
#field(INPC, "BPMS:UND1:490: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:UND1:490:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:490: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:UND1:490:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:490:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:490:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:490: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:UND1:490:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:490:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:490:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 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:UND1:490: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:UND1:490:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 S12")
  field(FLNK, "BPMS:UND1:490: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:UND1:490:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UND1:490: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:UND1:490:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C6 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:UND1:490:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 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:UND1:490:V")
}

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

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

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


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

record(calc, "BPMS:UND1:490:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:490:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:490:PADTO")
}

record(bi, "BPMS:UND1:490:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:490:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:490: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:UND1:490:PHI_SEQ")
}

record(ao, "BPMS:UND1:490: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:UND1:490:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:490: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:UND1:490:UOFF_SEQ")
}

record(ao, "BPMS:UND1:490: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:UND1:490:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:490:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C6 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:UND1:490: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:UND1:490: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:UND1:490:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU04")
  field(PINI, "YES")
}

record(stringin, "RFBU04:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:490")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:490:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:490: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:UND1:490:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:490:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:490:SIMC PP")
}

record(calcout, "BPMS:UND1:490:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "6")
#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:UND1:490:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:490:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:490:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:490: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:UND1:490:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:490: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:UND1:490:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:490:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:490:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:490: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:UND1:490:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:490:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:490:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C6 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:UND1:490:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:490:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x040")
  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:UND1:490:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x040")
  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:UND1:490:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:490:TMIT")
  field(INPB, "BPMS:UND1:490:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:490:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:490: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:UND1:490:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:490:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:490:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

record(bi, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:SIM.L     PP")
  field(LNK4, "BPMS:UND1:490:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:490:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:490:SIM.L     PP")
  field(LNK7, "BPMS:UND1:490: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:UND1:490:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:UOFF")
	field(DOL2, "BPMS:UND1:490:UOFF")
	field(DOL3, "BPMS:UND1:490:UOFF")
	field(DOL4, "BPMS:UND1:490:UOFF")
	field(DOL5, "BPMS:UND1:490:UOFF")
	field(DOL6, "BPMS:UND1:490:UOFF")
	field(DOL7, "BPMS:UND1:490:UOFF")
	field(DOL8, "BPMS:UND1:490:UOFF")
	field(DOL9, "BPMS:UND1:490:UOFF")
	field(DOLA, "BPMS:UND1:490:UOFF")
	field(LNK1, "BPMS:UND1:490:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:UOFF_SEL")
	field(OUTA, "BPMS:UND1:490:U.AOFF CA")
	field(OUTB, "BPMS:UND1:490:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:VOFF")
	field(DOL2, "BPMS:UND1:490:VOFF")
	field(DOL3, "BPMS:UND1:490:VOFF")
	field(DOL4, "BPMS:UND1:490:VOFF")
	field(DOL5, "BPMS:UND1:490:VOFF")
	field(DOL6, "BPMS:UND1:490:VOFF")
	field(DOL7, "BPMS:UND1:490:VOFF")
	field(DOL8, "BPMS:UND1:490:VOFF")
	field(DOL9, "BPMS:UND1:490:VOFF")
	field(DOLA, "BPMS:UND1:490:VOFF")
	field(LNK1, "BPMS:UND1:490:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:VOFF_SEL")
	field(OUTA, "BPMS:UND1:490:V.AOFF CA")
	field(OUTB, "BPMS:UND1:490:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:USCL")
	field(DOL2, "BPMS:UND1:490:USCL")
	field(DOL3, "BPMS:UND1:490:USCL")
	field(DOL4, "BPMS:UND1:490:USCL")
	field(DOL5, "BPMS:UND1:490:USCL")
	field(DOL6, "BPMS:UND1:490:USCL")
	field(DOL7, "BPMS:UND1:490:USCL")
	field(DOL8, "BPMS:UND1:490:USCL")
	field(DOL9, "BPMS:UND1:490:USCL")
	field(DOLA, "BPMS:UND1:490:USCL")
	field(LNK1, "BPMS:UND1:490:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:USCL_SEL")
	field(OUTA, "BPMS:UND1:490:U.ASLO CA")
	field(OUTB, "BPMS:UND1:490:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:VSCL")
	field(DOL2, "BPMS:UND1:490:VSCL")
	field(DOL3, "BPMS:UND1:490:VSCL")
	field(DOL4, "BPMS:UND1:490:VSCL")
	field(DOL5, "BPMS:UND1:490:VSCL")
	field(DOL6, "BPMS:UND1:490:VSCL")
	field(DOL7, "BPMS:UND1:490:VSCL")
	field(DOL8, "BPMS:UND1:490:VSCL")
	field(DOL9, "BPMS:UND1:490:VSCL")
	field(DOLA, "BPMS:UND1:490:VSCL")
	field(LNK1, "BPMS:UND1:490:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:VSCL_SEL")
	field(OUTA, "BPMS:UND1:490:V.ASLO CA")
	field(OUTB, "BPMS:UND1:490:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:PHI")
	field(DOL2, "BPMS:UND1:490:PHI")
	field(DOL3, "BPMS:UND1:490:PHI")
	field(DOL4, "BPMS:UND1:490:PHI")
	field(DOL5, "BPMS:UND1:490:PHI")
	field(DOL6, "BPMS:UND1:490:PHI")
	field(DOL7, "BPMS:UND1:490:PHI")
	field(DOL8, "BPMS:UND1:490:PHI")
	field(DOL9, "BPMS:UND1:490:PHI")
	field(DOLA, "BPMS:UND1:490:PHI")
	field(LNK1, "BPMS:UND1:490:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:PHI_SEL")
	field(OUTA, "BPMS:UND1:490:CALC.E CA")
	field(OUTB, "BPMS:UND1:490:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:PSI")
	field(DOL2, "BPMS:UND1:490:PSI")
	field(DOL3, "BPMS:UND1:490:PSI")
	field(DOL4, "BPMS:UND1:490:PSI")
	field(DOL5, "BPMS:UND1:490:PSI")
	field(DOL6, "BPMS:UND1:490:PSI")
	field(DOL7, "BPMS:UND1:490:PSI")
	field(DOL8, "BPMS:UND1:490:PSI")
	field(DOL9, "BPMS:UND1:490:PSI")
	field(DOLA, "BPMS:UND1:490:PSI")
	field(LNK1, "BPMS:UND1:490:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:PSI_SEL")
	field(OUTA, "BPMS:UND1:490:CALC.F CA")
	field(OUTB, "BPMS:UND1:490:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:UPHAS")
	field(DOL2, "BPMS:UND1:490:UPHAS")
	field(DOL3, "BPMS:UND1:490:UPHAS")
	field(DOL4, "BPMS:UND1:490:UPHAS")
	field(DOL5, "BPMS:UND1:490:UPHAS")
	field(DOL6, "BPMS:UND1:490:UPHAS")
	field(DOL7, "BPMS:UND1:490:UPHAS")
	field(DOL8, "BPMS:UND1:490:UPHAS")
	field(DOL9, "BPMS:UND1:490:UPHAS")
	field(DOLA, "BPMS:UND1:490:UPHAS")
	field(LNK1, "BPMS:UND1:490:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:490:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:490:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:VPHAS")
	field(DOL2, "BPMS:UND1:490:VPHAS")
	field(DOL3, "BPMS:UND1:490:VPHAS")
	field(DOL4, "BPMS:UND1:490:VPHAS")
	field(DOL5, "BPMS:UND1:490:VPHAS")
	field(DOL6, "BPMS:UND1:490:VPHAS")
	field(DOL7, "BPMS:UND1:490:VPHAS")
	field(DOL8, "BPMS:UND1:490:VPHAS")
	field(DOL9, "BPMS:UND1:490:VPHAS")
	field(DOLA, "BPMS:UND1:490:VPHAS")
	field(LNK1, "BPMS:UND1:490:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:490:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:490:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:QSCL")
	field(DOL2, "BPMS:UND1:490:QSCL")
	field(DOL3, "BPMS:UND1:490:QSCL")
	field(DOL4, "BPMS:UND1:490:QSCL")
	field(DOL5, "BPMS:UND1:490:QSCL")
	field(DOL6, "BPMS:UND1:490:QSCL")
	field(DOL7, "BPMS:UND1:490:QSCL")
	field(DOL8, "BPMS:UND1:490:QSCL")
	field(DOL9, "BPMS:UND1:490:QSCL")
	field(DOLA, "BPMS:UND1:490:QSCL")
	field(LNK1, "BPMS:UND1:490:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:QSCL_SEL")
	field(OUTA, "BPMS:UND1:490:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:490:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:URSCL")
	field(DOL2, "BPMS:UND1:490:URSCL")
	field(DOL3, "BPMS:UND1:490:URSCL")
	field(DOL4, "BPMS:UND1:490:URSCL")
	field(DOL5, "BPMS:UND1:490:URSCL")
	field(DOL6, "BPMS:UND1:490:URSCL")
	field(DOL7, "BPMS:UND1:490:URSCL")
	field(DOL8, "BPMS:UND1:490:URSCL")
	field(DOL9, "BPMS:UND1:490:URSCL")
	field(DOLA, "BPMS:UND1:490:URSCL")
	field(LNK1, "BPMS:UND1:490:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:URSCL_SEL")
	field(OUTA, "BPMS:UND1:490:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:490:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:VRSCL")
	field(DOL2, "BPMS:UND1:490:VRSCL")
	field(DOL3, "BPMS:UND1:490:VRSCL")
	field(DOL4, "BPMS:UND1:490:VRSCL")
	field(DOL5, "BPMS:UND1:490:VRSCL")
	field(DOL6, "BPMS:UND1:490:VRSCL")
	field(DOL7, "BPMS:UND1:490:VRSCL")
	field(DOL8, "BPMS:UND1:490:VRSCL")
	field(DOL9, "BPMS:UND1:490:VRSCL")
	field(DOLA, "BPMS:UND1:490:VRSCL")
	field(LNK1, "BPMS:UND1:490:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:490:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:490:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490: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:UND1:490:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:490:QRSCL")
	field(DOL2, "BPMS:UND1:490:QRSCL")
	field(DOL3, "BPMS:UND1:490:QRSCL")
	field(DOL4, "BPMS:UND1:490:QRSCL")
	field(DOL5, "BPMS:UND1:490:QRSCL")
	field(DOL6, "BPMS:UND1:490:QRSCL")
	field(DOL7, "BPMS:UND1:490:QRSCL")
	field(DOL8, "BPMS:UND1:490:QRSCL")
	field(DOL9, "BPMS:UND1:490:QRSCL")
	field(DOLA, "BPMS:UND1:490:QRSCL")
	field(LNK1, "BPMS:UND1:490:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:490:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:490:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:490:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:490:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:490:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:490:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:490:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:490:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:490:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:490: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:UND1:490: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:UND1:490: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:UND1:490:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:490:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:490:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:490:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:490:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:490:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:490:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:490:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:490: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:UND1:590:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 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:UND1:590: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:UND1:590:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UND1:590:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

record(ai, "BPMS:UND1:590:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 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:UND1:590:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 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:UND1:590:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

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

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

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

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

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

record(waveform, "BPMS:UND1:590:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C7 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:UND1:590:HFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C7 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UND1:590:hFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C7 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

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

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:590:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:590: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:UND1:590:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:590: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:UND1:590:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "7")
#field(INPB, "BPMS:UND1:590:FC_REF")
#field(INPC, "BPMS:UND1:590: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:UND1:590:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:590: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:UND1:590:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:590:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:590:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:590: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:UND1:590:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:590:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:590:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 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:UND1:590: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:UND1:590:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 S12")
  field(FLNK, "BPMS:UND1:590: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:UND1:590:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UND1:590: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:UND1:590:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C7 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:UND1:590:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 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:UND1:590:V")
}

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

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

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


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

record(calc, "BPMS:UND1:590:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:590:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:590:PADTO")
}

record(bi, "BPMS:UND1:590:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:590:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:590: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:UND1:590:PHI_SEQ")
}

record(ao, "BPMS:UND1:590: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:UND1:590:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:590: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:UND1:590:UOFF_SEQ")
}

record(ao, "BPMS:UND1:590: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:UND1:590:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:590:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C7 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:UND1:590: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:UND1:590: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:UND1:590:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU05")
  field(PINI, "YES")
}

record(stringin, "RFBU05:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:590")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:590:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:590: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:UND1:590:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:590:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:590:SIMC PP")
}

record(calcout, "BPMS:UND1:590:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "7")
#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:UND1:590:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:590:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:590:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:590: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:UND1:590:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:590: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:UND1:590:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:590:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:590:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:590: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:UND1:590:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:590:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:590:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C7 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:UND1:590:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:590:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x080")
  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:UND1:590:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x080")
  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:UND1:590:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:590:TMIT")
  field(INPB, "BPMS:UND1:590:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:590:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:590: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:UND1:590:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:590:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:590:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

record(bi, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:SIM.L     PP")
  field(LNK4, "BPMS:UND1:590:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:590:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:590:SIM.L     PP")
  field(LNK7, "BPMS:UND1:590: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:UND1:590:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:UOFF")
	field(DOL2, "BPMS:UND1:590:UOFF")
	field(DOL3, "BPMS:UND1:590:UOFF")
	field(DOL4, "BPMS:UND1:590:UOFF")
	field(DOL5, "BPMS:UND1:590:UOFF")
	field(DOL6, "BPMS:UND1:590:UOFF")
	field(DOL7, "BPMS:UND1:590:UOFF")
	field(DOL8, "BPMS:UND1:590:UOFF")
	field(DOL9, "BPMS:UND1:590:UOFF")
	field(DOLA, "BPMS:UND1:590:UOFF")
	field(LNK1, "BPMS:UND1:590:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:UOFF_SEL")
	field(OUTA, "BPMS:UND1:590:U.AOFF CA")
	field(OUTB, "BPMS:UND1:590:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:VOFF")
	field(DOL2, "BPMS:UND1:590:VOFF")
	field(DOL3, "BPMS:UND1:590:VOFF")
	field(DOL4, "BPMS:UND1:590:VOFF")
	field(DOL5, "BPMS:UND1:590:VOFF")
	field(DOL6, "BPMS:UND1:590:VOFF")
	field(DOL7, "BPMS:UND1:590:VOFF")
	field(DOL8, "BPMS:UND1:590:VOFF")
	field(DOL9, "BPMS:UND1:590:VOFF")
	field(DOLA, "BPMS:UND1:590:VOFF")
	field(LNK1, "BPMS:UND1:590:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:VOFF_SEL")
	field(OUTA, "BPMS:UND1:590:V.AOFF CA")
	field(OUTB, "BPMS:UND1:590:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:USCL")
	field(DOL2, "BPMS:UND1:590:USCL")
	field(DOL3, "BPMS:UND1:590:USCL")
	field(DOL4, "BPMS:UND1:590:USCL")
	field(DOL5, "BPMS:UND1:590:USCL")
	field(DOL6, "BPMS:UND1:590:USCL")
	field(DOL7, "BPMS:UND1:590:USCL")
	field(DOL8, "BPMS:UND1:590:USCL")
	field(DOL9, "BPMS:UND1:590:USCL")
	field(DOLA, "BPMS:UND1:590:USCL")
	field(LNK1, "BPMS:UND1:590:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:USCL_SEL")
	field(OUTA, "BPMS:UND1:590:U.ASLO CA")
	field(OUTB, "BPMS:UND1:590:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:VSCL")
	field(DOL2, "BPMS:UND1:590:VSCL")
	field(DOL3, "BPMS:UND1:590:VSCL")
	field(DOL4, "BPMS:UND1:590:VSCL")
	field(DOL5, "BPMS:UND1:590:VSCL")
	field(DOL6, "BPMS:UND1:590:VSCL")
	field(DOL7, "BPMS:UND1:590:VSCL")
	field(DOL8, "BPMS:UND1:590:VSCL")
	field(DOL9, "BPMS:UND1:590:VSCL")
	field(DOLA, "BPMS:UND1:590:VSCL")
	field(LNK1, "BPMS:UND1:590:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:VSCL_SEL")
	field(OUTA, "BPMS:UND1:590:V.ASLO CA")
	field(OUTB, "BPMS:UND1:590:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:PHI")
	field(DOL2, "BPMS:UND1:590:PHI")
	field(DOL3, "BPMS:UND1:590:PHI")
	field(DOL4, "BPMS:UND1:590:PHI")
	field(DOL5, "BPMS:UND1:590:PHI")
	field(DOL6, "BPMS:UND1:590:PHI")
	field(DOL7, "BPMS:UND1:590:PHI")
	field(DOL8, "BPMS:UND1:590:PHI")
	field(DOL9, "BPMS:UND1:590:PHI")
	field(DOLA, "BPMS:UND1:590:PHI")
	field(LNK1, "BPMS:UND1:590:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:PHI_SEL")
	field(OUTA, "BPMS:UND1:590:CALC.E CA")
	field(OUTB, "BPMS:UND1:590:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:PSI")
	field(DOL2, "BPMS:UND1:590:PSI")
	field(DOL3, "BPMS:UND1:590:PSI")
	field(DOL4, "BPMS:UND1:590:PSI")
	field(DOL5, "BPMS:UND1:590:PSI")
	field(DOL6, "BPMS:UND1:590:PSI")
	field(DOL7, "BPMS:UND1:590:PSI")
	field(DOL8, "BPMS:UND1:590:PSI")
	field(DOL9, "BPMS:UND1:590:PSI")
	field(DOLA, "BPMS:UND1:590:PSI")
	field(LNK1, "BPMS:UND1:590:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:PSI_SEL")
	field(OUTA, "BPMS:UND1:590:CALC.F CA")
	field(OUTB, "BPMS:UND1:590:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:UPHAS")
	field(DOL2, "BPMS:UND1:590:UPHAS")
	field(DOL3, "BPMS:UND1:590:UPHAS")
	field(DOL4, "BPMS:UND1:590:UPHAS")
	field(DOL5, "BPMS:UND1:590:UPHAS")
	field(DOL6, "BPMS:UND1:590:UPHAS")
	field(DOL7, "BPMS:UND1:590:UPHAS")
	field(DOL8, "BPMS:UND1:590:UPHAS")
	field(DOL9, "BPMS:UND1:590:UPHAS")
	field(DOLA, "BPMS:UND1:590:UPHAS")
	field(LNK1, "BPMS:UND1:590:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:590:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:590:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:VPHAS")
	field(DOL2, "BPMS:UND1:590:VPHAS")
	field(DOL3, "BPMS:UND1:590:VPHAS")
	field(DOL4, "BPMS:UND1:590:VPHAS")
	field(DOL5, "BPMS:UND1:590:VPHAS")
	field(DOL6, "BPMS:UND1:590:VPHAS")
	field(DOL7, "BPMS:UND1:590:VPHAS")
	field(DOL8, "BPMS:UND1:590:VPHAS")
	field(DOL9, "BPMS:UND1:590:VPHAS")
	field(DOLA, "BPMS:UND1:590:VPHAS")
	field(LNK1, "BPMS:UND1:590:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:590:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:590:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:QSCL")
	field(DOL2, "BPMS:UND1:590:QSCL")
	field(DOL3, "BPMS:UND1:590:QSCL")
	field(DOL4, "BPMS:UND1:590:QSCL")
	field(DOL5, "BPMS:UND1:590:QSCL")
	field(DOL6, "BPMS:UND1:590:QSCL")
	field(DOL7, "BPMS:UND1:590:QSCL")
	field(DOL8, "BPMS:UND1:590:QSCL")
	field(DOL9, "BPMS:UND1:590:QSCL")
	field(DOLA, "BPMS:UND1:590:QSCL")
	field(LNK1, "BPMS:UND1:590:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:QSCL_SEL")
	field(OUTA, "BPMS:UND1:590:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:590:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:URSCL")
	field(DOL2, "BPMS:UND1:590:URSCL")
	field(DOL3, "BPMS:UND1:590:URSCL")
	field(DOL4, "BPMS:UND1:590:URSCL")
	field(DOL5, "BPMS:UND1:590:URSCL")
	field(DOL6, "BPMS:UND1:590:URSCL")
	field(DOL7, "BPMS:UND1:590:URSCL")
	field(DOL8, "BPMS:UND1:590:URSCL")
	field(DOL9, "BPMS:UND1:590:URSCL")
	field(DOLA, "BPMS:UND1:590:URSCL")
	field(LNK1, "BPMS:UND1:590:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:URSCL_SEL")
	field(OUTA, "BPMS:UND1:590:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:590:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:VRSCL")
	field(DOL2, "BPMS:UND1:590:VRSCL")
	field(DOL3, "BPMS:UND1:590:VRSCL")
	field(DOL4, "BPMS:UND1:590:VRSCL")
	field(DOL5, "BPMS:UND1:590:VRSCL")
	field(DOL6, "BPMS:UND1:590:VRSCL")
	field(DOL7, "BPMS:UND1:590:VRSCL")
	field(DOL8, "BPMS:UND1:590:VRSCL")
	field(DOL9, "BPMS:UND1:590:VRSCL")
	field(DOLA, "BPMS:UND1:590:VRSCL")
	field(LNK1, "BPMS:UND1:590:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:590:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:590:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590: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:UND1:590:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:590:QRSCL")
	field(DOL2, "BPMS:UND1:590:QRSCL")
	field(DOL3, "BPMS:UND1:590:QRSCL")
	field(DOL4, "BPMS:UND1:590:QRSCL")
	field(DOL5, "BPMS:UND1:590:QRSCL")
	field(DOL6, "BPMS:UND1:590:QRSCL")
	field(DOL7, "BPMS:UND1:590:QRSCL")
	field(DOL8, "BPMS:UND1:590:QRSCL")
	field(DOL9, "BPMS:UND1:590:QRSCL")
	field(DOLA, "BPMS:UND1:590:QRSCL")
	field(LNK1, "BPMS:UND1:590:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:590:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:590:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:590:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:590:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:590:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:590:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:590:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:590:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:590:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:590: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:UND1:590: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:UND1:590: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:UND1:590:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:590:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:590:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:590:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:590:QRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:590:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:590:QRSCL_SEL.L PP")
}
record(longout,"BPMS:UND1:590:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "BPMS:UND1:590: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:UND1:690:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 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:UND1:690: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:UND1:690:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "BPMS:UND1:690:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

record(ai, "BPMS:UND1:690:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 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:UND1:690:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 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:UND1:690:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

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

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

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

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

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

record(waveform, "BPMS:UND1:690:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C8 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:UND1:690:HFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C8 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:UND1:690:hFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C8 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

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

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

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "BPMS:UND1:690:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:690: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:UND1:690:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "BPMS:UND1:690: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:UND1:690:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "8")
#field(INPB, "BPMS:UND1:690:FC_REF")
#field(INPC, "BPMS:UND1:690: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:UND1:690:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:690: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:UND1:690:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "BPMS:UND1:690:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "BPMS:UND1:690:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:690: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:UND1:690:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "BPMS:UND1:690:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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


#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:UND1:690:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 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:UND1:690: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:UND1:690:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 S12")
  field(FLNK, "BPMS:UND1:690: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:UND1:690:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:UND1:690: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:UND1:690:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C8 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:UND1:690:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 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:UND1:690:V")
}

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

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

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


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

record(calc, "BPMS:UND1:690:PADTOC") {
  field(CALC, "(A&B)?1:0")
  field(INPA, "BPMS:UND1:690:RSTA")
  field(INPB, "0x100")
  field(FLNK, "BPMS:UND1:690:PADTO")
}

record(bi, "BPMS:UND1:690:PADTO") {
  field(DESC, "PAD connection timeout")
  field(INP,  "BPMS:UND1:690:PADTOC")
  field(ZNAM, "OK")
  field(ONAM, "TIMEOUT")
}

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

record(ao, "BPMS:UND1:690: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:UND1:690:PHI_SEQ")
}

record(ao, "BPMS:UND1:690: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:UND1:690:PSI_SEQ")
}

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

record(ao, "BPMS:UND1:690: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:UND1:690:UOFF_SEQ")
}

record(ao, "BPMS:UND1:690: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:UND1:690:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:UND1:690:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C8 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:UND1:690: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:UND1:690: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:UND1:690:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "RFBU06")
  field(PINI, "YES")
}

record(stringin, "RFBU06:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "BPMS:UND1:690")
  field(PINI, "YES")
}

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

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

record(ai, "BPMS:UND1:690:TMIT_SLOW") {
  field(DESC, "TMIT snapshot for display")
  field(INP, "BPMS:UND1:690: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:UND1:690:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "BPMS:UND1:690:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "BPMS:UND1:690:SIMC PP")
}

record(calcout, "BPMS:UND1:690:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "8")
#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:UND1:690:USCL")
  field(INPL, "0")
}

# Switch simulation record BPMS:UND1:690:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "BPMS:UND1:690:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:UND1:690: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:UND1:690:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:690: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:UND1:690:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:690:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "BPMS:UND1:690:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:UND1:690: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:UND1:690:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:UND1:690:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

record(aao, "BPMS:UND1:690:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C8 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:UND1:690:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "BPMS:UND1:690:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x100")
  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:UND1:690:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x100")
  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:UND1:690:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "BPMS:UND1:690:TMIT")
  field(INPB, "BPMS:UND1:690:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "EOICDESK")
}

record(bi, "BPMS:UND1:690:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "BPMS:UND1:690: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:UND1:690:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "BPMS:UND1:690:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "BPMS:UND1:690:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

record(bi, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:SIM.L     PP")
  field(LNK4, "BPMS:UND1:690:SIM.SCAN  PP")

  field(LNK5, "BPMS:UND1:690:SIM.SCAN  PP")
  field(LNK6, "BPMS:UND1:690:SIM.L     PP")
  field(LNK7, "BPMS:UND1:690: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:UND1:690:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:UOFF")
	field(DOL2, "BPMS:UND1:690:UOFF")
	field(DOL3, "BPMS:UND1:690:UOFF")
	field(DOL4, "BPMS:UND1:690:UOFF")
	field(DOL5, "BPMS:UND1:690:UOFF")
	field(DOL6, "BPMS:UND1:690:UOFF")
	field(DOL7, "BPMS:UND1:690:UOFF")
	field(DOL8, "BPMS:UND1:690:UOFF")
	field(DOL9, "BPMS:UND1:690:UOFF")
	field(DOLA, "BPMS:UND1:690:UOFF")
	field(LNK1, "BPMS:UND1:690:UOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:UOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:UOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:UOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:UOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:UOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:UOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:UOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:UOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:UOFF_SEL")
	field(OUTA, "BPMS:UND1:690:U.AOFF CA")
	field(OUTB, "BPMS:UND1:690:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:UOFF_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:VOFF")
	field(DOL2, "BPMS:UND1:690:VOFF")
	field(DOL3, "BPMS:UND1:690:VOFF")
	field(DOL4, "BPMS:UND1:690:VOFF")
	field(DOL5, "BPMS:UND1:690:VOFF")
	field(DOL6, "BPMS:UND1:690:VOFF")
	field(DOL7, "BPMS:UND1:690:VOFF")
	field(DOL8, "BPMS:UND1:690:VOFF")
	field(DOL9, "BPMS:UND1:690:VOFF")
	field(DOLA, "BPMS:UND1:690:VOFF")
	field(LNK1, "BPMS:UND1:690:VOFF_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:VOFF_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:VOFF_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:VOFF_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:VOFF_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:VOFF_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:VOFF_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:VOFF_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:VOFF_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:VOFF_SEL")
	field(OUTA, "BPMS:UND1:690:V.AOFF CA")
	field(OUTB, "BPMS:UND1:690:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:VOFF_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:USCL")
	field(DOL2, "BPMS:UND1:690:USCL")
	field(DOL3, "BPMS:UND1:690:USCL")
	field(DOL4, "BPMS:UND1:690:USCL")
	field(DOL5, "BPMS:UND1:690:USCL")
	field(DOL6, "BPMS:UND1:690:USCL")
	field(DOL7, "BPMS:UND1:690:USCL")
	field(DOL8, "BPMS:UND1:690:USCL")
	field(DOL9, "BPMS:UND1:690:USCL")
	field(DOLA, "BPMS:UND1:690:USCL")
	field(LNK1, "BPMS:UND1:690:USCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:USCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:USCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:USCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:USCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:USCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:USCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:USCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:USCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:USCL_SEL")
	field(OUTA, "BPMS:UND1:690:U.ASLO CA")
	field(OUTB, "BPMS:UND1:690:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:USCL_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:VSCL")
	field(DOL2, "BPMS:UND1:690:VSCL")
	field(DOL3, "BPMS:UND1:690:VSCL")
	field(DOL4, "BPMS:UND1:690:VSCL")
	field(DOL5, "BPMS:UND1:690:VSCL")
	field(DOL6, "BPMS:UND1:690:VSCL")
	field(DOL7, "BPMS:UND1:690:VSCL")
	field(DOL8, "BPMS:UND1:690:VSCL")
	field(DOL9, "BPMS:UND1:690:VSCL")
	field(DOLA, "BPMS:UND1:690:VSCL")
	field(LNK1, "BPMS:UND1:690:VSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:VSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:VSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:VSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:VSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:VSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:VSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:VSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:VSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:VSCL_SEL")
	field(OUTA, "BPMS:UND1:690:V.ASLO CA")
	field(OUTB, "BPMS:UND1:690:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:VSCL_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:PHI")
	field(DOL2, "BPMS:UND1:690:PHI")
	field(DOL3, "BPMS:UND1:690:PHI")
	field(DOL4, "BPMS:UND1:690:PHI")
	field(DOL5, "BPMS:UND1:690:PHI")
	field(DOL6, "BPMS:UND1:690:PHI")
	field(DOL7, "BPMS:UND1:690:PHI")
	field(DOL8, "BPMS:UND1:690:PHI")
	field(DOL9, "BPMS:UND1:690:PHI")
	field(DOLA, "BPMS:UND1:690:PHI")
	field(LNK1, "BPMS:UND1:690:PHI_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:PHI_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:PHI_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:PHI_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:PHI_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:PHI_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:PHI_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:PHI_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:PHI_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:PHI_SEL")
	field(OUTA, "BPMS:UND1:690:CALC.E CA")
	field(OUTB, "BPMS:UND1:690:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:PHI_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:PSI")
	field(DOL2, "BPMS:UND1:690:PSI")
	field(DOL3, "BPMS:UND1:690:PSI")
	field(DOL4, "BPMS:UND1:690:PSI")
	field(DOL5, "BPMS:UND1:690:PSI")
	field(DOL6, "BPMS:UND1:690:PSI")
	field(DOL7, "BPMS:UND1:690:PSI")
	field(DOL8, "BPMS:UND1:690:PSI")
	field(DOL9, "BPMS:UND1:690:PSI")
	field(DOLA, "BPMS:UND1:690:PSI")
	field(LNK1, "BPMS:UND1:690:PSI_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:PSI_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:PSI_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:PSI_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:PSI_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:PSI_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:PSI_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:PSI_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:PSI_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:PSI_SEL")
	field(OUTA, "BPMS:UND1:690:CALC.F CA")
	field(OUTB, "BPMS:UND1:690:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:PSI_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:UPHAS")
	field(DOL2, "BPMS:UND1:690:UPHAS")
	field(DOL3, "BPMS:UND1:690:UPHAS")
	field(DOL4, "BPMS:UND1:690:UPHAS")
	field(DOL5, "BPMS:UND1:690:UPHAS")
	field(DOL6, "BPMS:UND1:690:UPHAS")
	field(DOL7, "BPMS:UND1:690:UPHAS")
	field(DOL8, "BPMS:UND1:690:UPHAS")
	field(DOL9, "BPMS:UND1:690:UPHAS")
	field(DOLA, "BPMS:UND1:690:UPHAS")
	field(LNK1, "BPMS:UND1:690:UPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:UPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:UPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:UPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:UPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:UPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:UPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:UPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:UPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:UPHAS_SEL")
	field(OUTA, "BPMS:UND1:690:UPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:690:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:UPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:VPHAS")
	field(DOL2, "BPMS:UND1:690:VPHAS")
	field(DOL3, "BPMS:UND1:690:VPHAS")
	field(DOL4, "BPMS:UND1:690:VPHAS")
	field(DOL5, "BPMS:UND1:690:VPHAS")
	field(DOL6, "BPMS:UND1:690:VPHAS")
	field(DOL7, "BPMS:UND1:690:VPHAS")
	field(DOL8, "BPMS:UND1:690:VPHAS")
	field(DOL9, "BPMS:UND1:690:VPHAS")
	field(DOLA, "BPMS:UND1:690:VPHAS")
	field(LNK1, "BPMS:UND1:690:VPHAS_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:VPHAS_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:VPHAS_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:VPHAS_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:VPHAS_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:VPHAS_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:VPHAS_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:VPHAS_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:VPHAS_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:VPHAS_SEL")
	field(OUTA, "BPMS:UND1:690:VPHAS_OUT PP NMS")
	field(OUTB, "BPMS:UND1:690:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:VPHAS_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:QSCL")
	field(DOL2, "BPMS:UND1:690:QSCL")
	field(DOL3, "BPMS:UND1:690:QSCL")
	field(DOL4, "BPMS:UND1:690:QSCL")
	field(DOL5, "BPMS:UND1:690:QSCL")
	field(DOL6, "BPMS:UND1:690:QSCL")
	field(DOL7, "BPMS:UND1:690:QSCL")
	field(DOL8, "BPMS:UND1:690:QSCL")
	field(DOL9, "BPMS:UND1:690:QSCL")
	field(DOLA, "BPMS:UND1:690:QSCL")
	field(LNK1, "BPMS:UND1:690:QSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:QSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:QSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:QSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:QSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:QSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:QSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:QSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:QSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:QSCL_SEL")
	field(OUTA, "BPMS:UND1:690:TMIT.ASLO CA")
	field(OUTB, "BPMS:UND1:690:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:QSCL_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:URSCL")
	field(DOL2, "BPMS:UND1:690:URSCL")
	field(DOL3, "BPMS:UND1:690:URSCL")
	field(DOL4, "BPMS:UND1:690:URSCL")
	field(DOL5, "BPMS:UND1:690:URSCL")
	field(DOL6, "BPMS:UND1:690:URSCL")
	field(DOL7, "BPMS:UND1:690:URSCL")
	field(DOL8, "BPMS:UND1:690:URSCL")
	field(DOL9, "BPMS:UND1:690:URSCL")
	field(DOLA, "BPMS:UND1:690:URSCL")
	field(LNK1, "BPMS:UND1:690:URSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:URSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:URSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:URSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:URSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:URSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:URSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:URSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:URSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:URSCL_SEL")
	field(OUTA, "BPMS:UND1:690:URMS.ASLO CA")
	field(OUTB, "BPMS:UND1:690:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:URSCL_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:VRSCL")
	field(DOL2, "BPMS:UND1:690:VRSCL")
	field(DOL3, "BPMS:UND1:690:VRSCL")
	field(DOL4, "BPMS:UND1:690:VRSCL")
	field(DOL5, "BPMS:UND1:690:VRSCL")
	field(DOL6, "BPMS:UND1:690:VRSCL")
	field(DOL7, "BPMS:UND1:690:VRSCL")
	field(DOL8, "BPMS:UND1:690:VRSCL")
	field(DOL9, "BPMS:UND1:690:VRSCL")
	field(DOLA, "BPMS:UND1:690:VRSCL")
	field(LNK1, "BPMS:UND1:690:VRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:VRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:VRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:VRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:VRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:VRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:VRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:VRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:VRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:VRSCL_SEL")
	field(OUTA, "BPMS:UND1:690:VRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:690:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:UND1:690:VRSCL_CTRL")
{
	field(INPA, "BPMS:UND1:690:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:UND1:690: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:UND1:690:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:UND1:690:QRSCL")
	field(DOL2, "BPMS:UND1:690:QRSCL")
	field(DOL3, "BPMS:UND1:690:QRSCL")
	field(DOL4, "BPMS:UND1:690:QRSCL")
	field(DOL5, "BPMS:UND1:690:QRSCL")
	field(DOL6, "BPMS:UND1:690:QRSCL")
	field(DOL7, "BPMS:UND1:690:QRSCL")
	field(DOL8, "BPMS:UND1:690:QRSCL")
	field(DOL9, "BPMS:UND1:690:QRSCL")
	field(DOLA, "BPMS:UND1:690:QRSCL")
	field(LNK1, "BPMS:UND1:690:QRSCL_SEL.A PP")
	field(LNK2, "BPMS:UND1:690:QRSCL_SEL.B PP")
	field(LNK3, "BPMS:UND1:690:QRSCL_SEL.C PP")
	field(LNK4, "BPMS:UND1:690:QRSCL_SEL.D PP")
	field(LNK5, "BPMS:UND1:690:QRSCL_SEL.E PP")
	field(LNK6, "BPMS:UND1:690:QRSCL_SEL.F PP")
	field(LNK7, "BPMS:UND1:690:QRSCL_SEL.G PP")
	field(LNK8, "BPMS:UND1:690:QRSCL_SEL.H PP")
	field(LNK9, "BPMS:UND1:690:QRSCL_SEL.I PP")
	field(LNKA, "BPMS:UND1:690:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:UND1:690: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:UND1:690: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:UND1:690: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:UND1:690:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:UND1:690:QRSCL_SEL")
	field(OUTA, "BPMS:UND1:690:RRMS.ASLO CA")
	field(OUTB, "BPMS:UND1:690:QRSCL PP")
}

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

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

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

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

record(longin, "IOC:UND1:BP01: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:UND1:BP01: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:UND1:BP01: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:LTU1:910:SUM_1TO9") {
  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:LTU1:910: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:LTU1:910:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:LTU1:910:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:LTU1:910: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:LTU1:910: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:LTU1:910: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")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:LTU1:960: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:LTU1:960:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:LTU1:960:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:LTU1:960: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:LTU1:960: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:LTU1:960: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")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:100:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B5")
  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:UND1:100:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:100:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

# Set self-test mode

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

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

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

record(bi, "BPMS:UND1:190: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:UND1:190:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:190:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UND1:190: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:UND1:190: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:UND1:190: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")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:290: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:UND1:290:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:290:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UND1:290: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:UND1:290: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:UND1:290: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")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:390:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B2")
  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:UND1:390:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:390:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

# Set self-test mode

record(bo, "BPMS:UND1:390:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B0")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

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

record(bo, "BPMS:UND1:390:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B1")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:490:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B1")
  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:UND1:490:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:490:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UND1:490:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B2")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UND1:490:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B3")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

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

record(bo, "BPMS:UND1:490:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B4")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:590:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P0 B0")
  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:UND1:590:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:590:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(bo, "BPMS:UND1:590:RCVR_GAIN_OUT") {
  field(DESC, "Signal gain")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B5")
  field(ZNAM, "High")
  field(ONAM, "Low")
}

# Set self-test mode

record(bo, "BPMS:UND1:590:RCVR_SELFTST") {
  field(DESC, "Inject 11 Ghz signal")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B6")
  field(ZNAM, "Off")
  field(ONAM, "On")
  field(PINI, "YES")
}

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

record(bo, "BPMS:UND1:590:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P2 B7")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
}
# Local oscillator status:
# Indicates if oscillator is locked to 119 Mhz reference

record(bi, "BPMS:UND1:690:RCVR_LO_STA") {
  field(DESC, "Local oscillator status")
  field(DTYP, "ACROMAG-IP470")
  field(INP, "@cavBpmDigI_MPS P1 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:UND1:690:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "BPMS:UND1:690:RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

# Set self-test mode

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

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

record(bo, "BPMS:UND1:690:RCVR_LO_CTL") {
  field(DESC, "Set local oscillator mode")
  field(DTYP, "ACROMAG-IP445")
  field(OUT, "@cavBpmDigO P3 B2")
  field(ZNAM, "Lock")
  field(ONAM, "Unlock")
  field(PINI, "YES")
}
