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

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

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

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

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

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

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

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

record(waveform, "$(DEV):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, "$(DEV):PRENV")
}

record(waveform, "$(DEV):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")
  field(FLNK, "$(DEV):ENVU")
}

record(subArray, "$(DEV):ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "$(DEV):PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "$(DEV):ENVV")
}

record(subArray, "$(DEV):ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "$(DEV):PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



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

record(subArray, "$(DEV):REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "$(DEV):RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

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

record(subArray, "$(DEV):SFFTR") {
  field(DESC, "Raw FFT Ref")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "$(DEV):SFFT CP MSI")
  field(MALM, "192")
  field(NELM, "64")
  field(INDX, "0")
  field(TSEL, "$(DEV):SFFT.TIME")
  field(FLNK, "$(DEV):SFFTU")
}

record(subArray, "$(DEV):SFFTU") {
  field(DESC, "Raw FFT U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "$(DEV):SFFT CA MSI")
  field(MALM, "192")
  field(NELM, "64")
  field(INDX, "64")
  field(TSEL, "$(DEV):SFFT.TIME")
  field(FLNK, "$(DEV):SFFTV")
}

record(subArray, "$(DEV):SFFTV") {
  field(DESC, "Raw FFT V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "$(DEV):SFFT CA MSI")
  field(MALM, "192")
  field(NELM, "64")
  field(INDX, "128")
  field(TSEL, "$(DEV):SFFT.TIME")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
# Set dispsuffix macro to "F" to use FW values
record(sel, "$(DEV):STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "$(DEV):RSTA.SEVR MS NPP")
  field(INPB, "$(DEV):TMIT_SLOW.SEVR MS NPP")
  field(INPC, "$(DEV):Y_SLOW.SEVR    MS NPP")
  field(INPD, "$(DEV):X_SLOW.SEVR    MS NPP")
# for optional additional alarm input:
  field(INPE, "$(DEV):CPSTAT_ALH MS")
  field(SCAN, "1 second")
}

record(calc, "$(DEV):STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "$(DEV):RSTA_ALH.SEVR MS NPP")
  field(INPB, "$(DEV):CHK.SEVR MS NPP")
  field(INPC, "$(DEV):RCVR_SUM.SEVR MS")
# for optional additional alarm inputs:
  field(INPD, "$(DEV):CPSTAT_ALH MS")
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "$(DEV):FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "$(DEV):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,  "$(DEV):BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "$(DEV):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, "$(DEV):FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "1")
#field(INPB, "$(DEV):FC_REF")
#field(INPC, "$(DEV):BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
# Digitizer sampling frequency
# Set default to LCLS digi value
  field(K, "351")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

# Cause software to calculate new
# bandwidth and center-frequency
# values for U, V, Ref
# CA links so that FILT.* PVs
# update for CA clients without
# additional process of FILT
record(seq, "$(DEV):AUTOFILTR") {
  field(SELM, "All")
  field(DOL1, "0")
  field(LNK1, "$(DEV):FILT.B CA")
  field(DLY2, "1")
  field(DOL2, "0")
  field(LNK2, "$(DEV):FILT.C CA")
}
record(seq, "$(DEV):AUTOFILTU") {
  field(SELM, "All")
  field(DOL1, "0")
  field(LNK1, "$(DEV):FILT.E CA")
  field(DLY2, "1")
  field(DOL2, "0")
  field(LNK2, "$(DEV):FILT.F CA")
}
record(seq, "$(DEV):AUTOFILTV") {
  field(SELM, "All")
  field(DOL1, "0")
  field(LNK1, "$(DEV):FILT.H CA")
  field(DLY2, "1")
  field(DOL2, "0")
  field(LNK2, "$(DEV):FILT.I CA")
}
record(seq, "$(DEV):AUTOFILT") {
  field(SELM, "All")
  field(LNK1, "$(DEV):AUTOFILTR PP")
  field(DLY2, "1")
  field(LNK2, "$(DEV):AUTOFILTU PP")
  field(DLY3, "1")
  field(LNK3, "$(DEV):AUTOFILTV PP")
}

# Cause software to calculate new
# U and V detector phases
record(seq, "$(DEV):AUTOPHAS") {
  field(SELM, "All")
  field(DOL1, "400")
  field(LNK1, "$(DEV):UPHAS CA")
  field(DLY2, "1")
  field(DOL2, "400")
  field(LNK2, "$(DEV):VPHAS CA")
}

record(ao, "$(DEV):TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "$(DEV):TS_R_ADJ.A PP")
  field(EGU, "ns")
  field(PREC, "1")
  field(DRVL, "-1000")
  field(DRVH, "1000")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(calcout, "$(DEV):TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "$(DEV):FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "$(DEV):TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "$(DEV):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, "$(DEV):TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "$(DEV):FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

record(ao, "$(DEV):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, "$(DEV):UPHAS_FB")
}

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

record(ao, "$(DEV):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, "$(DEV):VPHAS_FB")
}

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
# Slowly updating records for displays
# May point to SW or FW values, depending
# on architecture
record(ai, "$(DEV):REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "$(DEV):REFR MS CA")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(FLNK, "$(DEV):URER_SLOW")
}

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

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

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

record(ai, "$(DEV):VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "$(DEV):VIMR MS CA")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

# Previously resided in rcvrDigIO.db
# Moved here now that multiple flavors
# of receiver control exist.
# Also, want this PV to live in master IOC
# because critical BPM parameters are slaved
# to it.
record(bo, "$(DEV):RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "$(DEV):RCVR_GAIN_OUT PP")
  field(ZNAM, "High")
  field(ONAM, "Low")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "$(DEV):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, "$(DEV):Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "$(ASG)")
  field(TSE,  "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(sub, "$(DEV):XLIMS") {
  field(DESC, "Monitor X Alarm Limits for BsaCore")
  field(INAM, "drvBpmCopyAlarmLimitsIni")
  field(SNAM, "drvBpmCopyAlarmLimits")
  field(INPA, "$(DEV):X.LOLO CPP")
  field(INPB, "$(DEV):X.LOW  CPP")
  field(INPC, "$(DEV):X.HIGH CPP")
  field(INPD, "$(DEV):X.HIHI CPP")
  field(INPE, "$(DEV):X.HYST CPP")
  field(INPF, "$(DEV):X.LLSV CPP")
  field(INPG, "$(DEV):X.LSV  CPP")
  field(INPH, "$(DEV):X.HSV  CPP")
  field(INPI, "$(DEV):X.HHSV CPP")
  field(INPJ, "1")
  field(INPK, "3")
}

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

record(sub, "$(DEV):YLIMS") {
  field(DESC, "Monitor Y Alarm Limits for BsaCore")
  field(INAM, "drvBpmCopyAlarmLimitsIni")
  field(SNAM, "drvBpmCopyAlarmLimits")
  field(INPA, "$(DEV):Y.LOLO CPP")
  field(INPB, "$(DEV):Y.LOW  CPP")
  field(INPC, "$(DEV):Y.HIGH CPP")
  field(INPD, "$(DEV):Y.HIHI CPP")
  field(INPE, "$(DEV):Y.HYST CPP")
  field(INPF, "$(DEV):Y.LLSV CPP")
  field(INPG, "$(DEV):Y.LSV  CPP")
  field(INPH, "$(DEV):Y.HSV  CPP")
  field(INPI, "$(DEV):Y.HHSV CPP")
  field(INPJ, "1")
  field(INPK, "4")
}


record(ai, "$(DEV):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
# $(DEV):EFX.PROC for legacy, record-based BSA
  field(FLNK, "")
  field(ASG,  "$(ASG)")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}

record(sub, "$(DEV):TMITLIMS") {
  field(DESC, "Monitor TMIT Alarm Limits for BsaCore")
  field(INAM, "drvBpmCopyAlarmLimitsIni")
  field(SNAM, "drvBpmCopyAlarmLimits")
  field(INPA, "$(DEV):TMIT.LOLO CPP")
  field(INPB, "$(DEV):TMIT.LOW  CPP")
  field(INPC, "$(DEV):TMIT.HIGH CPP")
  field(INPD, "$(DEV):TMIT.HIHI CPP")
  field(INPE, "$(DEV):TMIT.HYST CPP")
  field(INPF, "$(DEV):TMIT.LLSV CPP")
  field(INPG, "$(DEV):TMIT.LSV  CPP")
  field(INPH, "$(DEV):TMIT.HSV  CPP")
  field(INPI, "$(DEV):TMIT.HHSV CPP")
  field(INPJ, "1")
  field(INPK, "5")
}

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

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "$(DEV):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")
  field(TSE,  "-2")
}

record(ai, "$(DEV):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, "$(DEV):V")
}

record(ai, "$(DEV):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, "$(DEV):PINC")
}

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

record(longin, "$(DEV):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, "$(DEV):RSTA_ALH")
}


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

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

record(ao, "$(DEV):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, "$(DEV):PHI_SEQ")
}

record(ao, "$(DEV):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, "$(DEV):PSI_SEQ")
}

record(ao, "$(DEV):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, "$(DEV):UOFF_SEQ")
}

record(ao, "$(DEV):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, "$(DEV):VOFF_SEQ")
}

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

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


record(mbbo, "$(DEV):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, "$(DEV):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, "$(DEV):FBCK")
{
  field(DESC, "Feedback State")
  field(PINI, "YES")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
# 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, "VAL")
}

# Convenience record holding the MAD name
record(stringin, "$(DEV):MADN") {
  field(DESC, "MAD Name")
  field(VAL, "$(MAD)")
  field(PINI, "YES")
}

record(stringin, "$(MAD):NAME") {
  field(DESC, "BPM Name")
  field(VAL, "$(DEV)")
  field(PINI, "YES")
}

record(ai, "$(DEV):X_SLOW") {
#alias("$(DEV):X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "$(DEV):X MSS CA")
  field(TSEL, "$(DEV):X.TIME MSS CA")
  field(FLNK, "$(DEV):Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "$(DEV):Y_SLOW") {
#alias("$(DEV):Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "$(DEV):Y MSS CA")
  field(TSEL, "$(DEV):Y.TIME CA")
  field(FLNK, "$(DEV):TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "$(DEV):TMIT_SLOW") {
#alias("$(DEV):TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "$(DEV):TMIT MSS CA")
  field(TSEL, "$(DEV):TMIT.TIME CA")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

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

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

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

# Switch simulation record $(DEV):SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

# 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, "$(DEV):XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "$(DEV):X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "$(DEV):XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


# Records to set MPS thresholds
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}
record(ao, "$(DEV):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, "$(ASG)")
  info(autosaveFields, "VAL")
}

record(bi, "$(DEV):FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN)")
  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, "$(DEV):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, "$(DEV):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, "$(DEV):SIM.L     PP")
  field(LNK4, "$(DEV):SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

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

#=======================================
# FW status bits, current and latched
# FWSTATRESET resets all
#=======================================
record(longout, "$(DEV):FWSTATRESETRAW") {
  field(DESC, "Reset latched stat bits")
  field(DTYP, "bpmAlgParm")
  field(OMSL, "supervisory")
  field(OUT,  "#C1S0@StatusClear")
}

record(seq, "$(DEV):FWSTATRESET") {
  field(DESC, "Reset latched stat bits")
  field(SELM, "All")
  field(DOL1, "1")
  field(LNK1, "$(DEV):FWSTATRESETRAW PP")
  field(DLY2, "1.0")
  field(DOL2, "0")
  field(LNK2, "$(DEV):FWSTATRESETRAW PP")
}

record(longin, "$(DEV):FWSTATRESETRBV") {
  field(DESC, "Reset latched stat bits")
  field(SCAN, "1 second")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusClear")
}

record(longin, "$(DEV):FWSTAT") {
  field(DESC, "All status bits")
  field(DTYP, "bpmAlgParm")
  field(SCAN, "1 second")
  field(INP,  "#C1S0@StatusRaw")
  field(FLNK, "$(DEV):FWSTATLTCH")
}
record(longin, "$(DEV):FWSTATLTCH") {
  field(DESC, "All status bits (latched)")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusRawLatched")
  field(FLNK, "$(DEV):FWSTAT_UINV")
}
record(longin, "$(DEV):FWSTAT_UINV") {
  field(DESC, "U invalid samples")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusInputUInvalid")
  field(FLNK, "$(DEV):FWSTAT_VINV")
}
record(longin, "$(DEV):FWSTAT_VINV") {
  field(DESC, "V invalid samples")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusInputVInvalid")
  field(FLNK, "$(DEV):FWSTAT_RINV")
}
record(longin, "$(DEV):FWSTAT_RINV") {
  field(DESC, "R Invalid samples")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusInputRInvalid")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLU")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLU") {
  field(DESC, "U-DFT overflow (summary)")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDFTOvflU")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLV")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLV") {
  field(DESC, "V-DFT overflow (summary)")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDFTOvflV")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLR")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLR") {
  field(DESC, "R-DFT overflow (summary)")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDFTOvflR")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLREU")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLREU") {
  field(DESC, "U-DFT division Re(U) overflow")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDivOvflReU")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLIMU")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLIMU") {
  field(DESC, "U-DFT division Im(U) overflow")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDivOvflImU")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLREV") 
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLREV") {
  field(DESC, "V-DFT division Re(V) overflow")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDivOvflReV")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLIMV")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLIMV") {
  field(DESC, "V-DFT division Im(V) overflow")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDivOvflImV")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFL")
}
# Individual overflow bits of all DFT channels 
# (R5,V5,U5,R4,V4,U4,...R0,V0,U0)
record(longin, "$(DEV):FWSTAT_DFTOVFL") {
  field(DESC, "Ovfl bits for all DFT channels")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusDFTOvfl")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(FLNK, "$(DEV):FWSTAT_VINVLTCH")
}
record(longin, "$(DEV):FWSTAT_VINVLTCH") {
  field(DESC, "V Invalid samples")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedInputVInvalid")
  field(FLNK, "$(DEV):FWSTAT_UINVLTCH")
}
record(longin, "$(DEV):FWSTAT_UINVLTCH") {
  field(DESC, "U Invalid samples")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedInputUInvalid")
  field(FLNK, "$(DEV):FWSTAT_RINVLTCH")
}
record(longin, "$(DEV):FWSTAT_RINVLTCH") {
  field(DESC, "R Invalid samples latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedInputRInvalid")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLULTCH")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLULTCH") {
  field(DESC, "U-DFT overflow (summary)")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDFTOvflU")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLVLTCH")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLVLTCH") {
  field(DESC, "V-DFT overflow (summary) latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDFTOvflV")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLRLTCH")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLRLTCH") {
  field(DESC, "R-DFT overflow (summary) latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDFTOvflR")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLREULTCH")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLREULTCH") {
  field(DESC, "U-DFT division Re(U) overflow latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDivOvflReU")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLIMULTCH") 
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLIMULTCH") {
  field(DESC, "U-DFT division Im(U) overflow latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDivOvflImU")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLREVLTCH")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLREVLTCH") {
  field(DESC, "V-DFT division Re(V) overflow latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDivOvflReV")
  field(FLNK, "$(DEV):FWSTAT_DFTDIVOVFLIMVLTCH")
}
record(longin, "$(DEV):FWSTAT_DFTDIVOVFLIMVLTCH") {
  field(DESC, "V-DFT division Im(V) overflow latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDivOvflImV")
  field(FLNK, "$(DEV):FWSTAT_DFTOVFLLTCH")
}
record(longin, "$(DEV):FWSTAT_DFTOVFLLTCH") {
  field(DESC, "Ovfl bits for all DFT channels latched")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@StatusLatchedDFTOvfl")
}

record(calc, "$(DEV):ADCSTAT_ALH") {
  field(DESC, "For display alarms")
  field(SCAN, "1 second")
  field(INPA, "$(DEV):MUXSTAT.SEVR MS")
  field(INPB, "$(DEV):RSTAF.SEVR MS")
  field(INPC, "$(DEV):FWSTAT_ALH1.SEVR MS")
  field(INPD, "$(DEV):ADCVALID.SEVR MS")
  field(ASG,  "NOWRITE")
}
#=======================================
# Firmware configuration info
#=======================================

record(mbbi, "$(DEV):FWTYPE") {
  field(DESC, "FW mode")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@FirmwareConfiguration")
  field(ZRST, "Stripline")
  field(ZRVL, "0")
  field(ONST, "Cavity")
  field(ONVL, "1")
  field(PINI, "YES")
  field(ASG,  "NOWRITE")
  field(FLNK, "$(DEV):FWTYPESTAT")
}

record(calc, "$(DEV):FWTYPESTAT") {
  field(DESC, "FW mode alarm")
  field(CALC, "(A=B)?1:0")
  field(INPA, "$(DEV):FWTYPE MSI")
# 0 for stripline, 1 for cavity
  field(INPB, "1")
  field(LOLO, "0")
  field(LLSV, "MAJOR")
  field(HIHI, "2")
  field(HHSV, "MAJOR")
}

#=======================================
# NOTE that MUX settings changed with
# 2020 firmware. This software is not
# compatible with older firmware versions.
# See ChangeLog for more details.
#
# Diagnostic control/readback of channel
# multiplexer settings. Correct values
# should be set by defaults yaml file.
# For stripline:
#   GRN 3
#   BLU 2
#   YLO 1
#   RED 0
# For cavity:
#   GRN 1
#   BLU 0
#   YLO 2
#   RED 3
#=======================================

record(calc, "$(DEV):MUXSET1") {
  field(DESC, "Set mux alarms based on BPM type")
  field(CALC, "A+1")
# 0 for stripline, 1 for cavity
  field(INPA, "1")
  field(PINI, "YES")
  field(FLNK, "$(DEV):MUXSET2")
  field(ASG,  "NOWRITE")
}

record(seq, "$(DEV):MUXSET2") {
  field(DESC, "Set mux alarms based on BPM type")
  field(SELM, "Specified")
  field(SELL, "$(DEV):MUXSET1")
  field(LNK1, "$(DEV):MUXSETS1 PP")
  field(LNK2, "$(DEV):MUXSETC1 PP")
  field(ASG,  "NOWRITE")
}

record(seq, "$(DEV):MUXSETS1") {
  field(DESC, "Set mux alarms for stripline")
  field(SELM, "All")
  field(DOL1, "-1")
  field(LNK1, "$(DEV):MUXREDRB.LOLO")
  field(DOL2, "1")
  field(LNK2, "$(DEV):MUXREDRB.HIHI")
  field(DOL3, "1")
  field(LNK3, "$(DEV):MUXBLURB.LOLO")
  field(DOL4, "3")
  field(LNK4, "$(DEV):MUXBLURB.HIHI")
  field(DOL5, "2")
  field(LNK5, "$(DEV):MUXGRNRB.LOLO")
  field(DOL6, "4")
  field(LNK6, "$(DEV):MUXGRNRB.HIHI")
  field(DOL7, "0")
  field(LNK7, "$(DEV):MUXYLORB.LOLO")
  field(DOL8, "2")
  field(LNK8, "$(DEV):MUXYLORB.HIHI")
  field(FLNK, "$(DEV):MUXSETS2")
  field(ASG,  "NOWRITE")
}

record(seq, "$(DEV):MUXSETS2") {
  field(DESC, "Set mux for stripline")
  field(SELM, "All")
  field(DOL1, "0")
  field(LNK1, "$(DEV):MUXRED PP")
  field(DOL2, "2")
  field(LNK2, "$(DEV):MUXBLU PP")
  field(DOL3, "3")
  field(LNK3, "$(DEV):MUXGRN PP")
  field(DOL4, "1")
  field(LNK4, "$(DEV):MUXYLO PP")
  field(ASG,  "NOWRITE")
}

record(seq, "$(DEV):MUXSETC1") {
  field(DESC, "Set mux alarms for cavity")
  field(SELM, "All")
  field(DOL1, "2")
  field(LNK1, "$(DEV):MUXREDRB.LOLO")
  field(DOL2, "4")
  field(LNK2, "$(DEV):MUXREDRB.HIHI PP")
  field(DOL3, "-1")
  field(LNK3, "$(DEV):MUXBLURB.LOLO")
  field(DOL4, "1")
  field(LNK4, "$(DEV):MUXBLURB.HIHI PP")
  field(DOL5, "0")
  field(LNK5, "$(DEV):MUXGRNRB.LOLO")
  field(DOL6, "2")
  field(LNK6, "$(DEV):MUXGRNRB.HIHI PP")
  field(DOL7, "1")
  field(LNK7, "$(DEV):MUXYLORB.LOLO")
  field(DOL8, "3")
  field(LNK8, "$(DEV):MUXYLORB.HIHI PP")
  field(FLNK, "$(DEV):MUXSETC2")
  field(ASG,  "NOWRITE")
}

record(seq, "$(DEV):MUXSETC2") {
  field(DESC, "Set mux for cavity")
  field(SELM, "All")
  field(DOL1, "3")
  field(LNK1, "$(DEV):MUXRED PP")
  field(DOL2, "0")
  field(LNK2, "$(DEV):MUXBLU PP")
  field(DOL3, "1")
  field(LNK3, "$(DEV):MUXGRN PP")
  field(DOL4, "2")
  field(LNK4, "$(DEV):MUXYLO PP")
  field(ASG,  "NOWRITE")
}

record(longout, "$(DEV):MUXGRN") {
  field(DTYP, "bpmAlgParm")
  field(OMSL, "supervisory")
  field(OUT,  "#C1S0@MuxGRN")
  field(ASG,  "NOWRITE")
}
record(longout, "$(DEV):MUXBLU") {
  field(DTYP, "bpmAlgParm")
  field(OMSL, "supervisory")
  field(OUT,  "#C1S0@MuxBLU")
  field(ASG,  "NOWRITE")
}
record(longout, "$(DEV):MUXYLO") {
  field(DTYP, "bpmAlgParm")
  field(OMSL, "supervisory")
  field(OUT,  "#C1S0@MuxYLO")
  field(ASG,  "NOWRITE")
}
record(longout, "$(DEV):MUXRED") {
  field(DTYP, "bpmAlgParm")
  field(OMSL, "supervisory")
  field(OUT,  "#C1S0@MuxRED")
  field(ASG,  "NOWRITE")
}
record(longin, "$(DEV):MUXGRNRB") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@MuxGRN")
  field(SCAN, "10 second")
  field(LLSV, "MAJOR")
  field(HHSV, "MAJOR")
  field(ASG,  "NOWRITE")
}
record(longin, "$(DEV):MUXBLURB") {
  field(SCAN, "10 second")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@MuxBLU")
  field(ASG,  "NOWRITE")
  field(LLSV, "MAJOR")
  field(HHSV, "MAJOR")
}
record(longin, "$(DEV):MUXYLORB") {
  field(SCAN, "10 second")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@MuxYLO")
  field(ASG,  "NOWRITE")
  field(LLSV, "MAJOR")
  field(HHSV, "MAJOR")
}
record(longin, "$(DEV):MUXREDRB") {
  field(SCAN, "10 second")
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@MuxRED")
  field(ASG,  "NOWRITE")
  field(LLSV, "MAJOR")
  field(HHSV, "MAJOR")
}

record(calc, "$(DEV):MUXSTAT") {
  field(DESC, "Channel mux selection alarm")
  field(CALC, "(A+B+C+D)=0?1:0")
  field(INPA, "$(DEV):MUXGRNRB.SEVR CPP MS")
  field(INPB, "$(DEV):MUXBLURB.SEVR CPP MS")
  field(INPC, "$(DEV):MUXYLORB.SEVR CPP MS")
  field(INPD, "$(DEV):MUXREDRB.SEVR CPP MS")
  field(PINI, "YES")
}

record(ai, "$(DEV):RSTAF") {
  field(DESC, "Status word from FW")
  field(SCAN, "I/O Intr")
  field(DTYP, "bpmSig")
  field(INP,  "#C1S3")
  field(LINR, "LINEAR")
  field(PINI, "YES")
  field(ASG,  "NOWRITE")
  field(FLNK, "$(DEV):RSTAF_ALH")
}

record(calc, "$(DEV):RSTAF_ALH") {
  field(DESC, "For display alarms")
  field(CALC, "A&B?0:1")
  field(INPA, "$(DEV):RSTAF MSI")
  field(INPB, "0x100")
  field(LOLO, "0")
  field(LLSV, "MAJOR")
  field(HIHI, "2")
}

# First-level Common Platform alarm summary
# Used on displays and included in
# higher-level CPSTAT_ALH below, which
# in turn is included in BPM alarm
# summary records STA and STA_ALH
# in vmeBpmApp/Db/common/bpm*.db.part 
record(calc, "$(DEV):CPSTAT") {
  field(DESC, "For display alarms")
  field(SCAN, "1 second")
  field(INPA, "$(DEV):MUXSTAT.SEVR MS")
  field(INPB, "$(DEV):RSTAF_ALH.SEVR MS")
  field(INPC, "$(DEV):FWTYPE.SEVR MS")
  field(INPD, "$(DEV):FWVERSSTAT.SEVR MS")
  field(FLNK, "$(DEV):CPSTAT_ALH")
}

record(calc, "$(DEV):CPSTAT_ALH") {
  field(DESC, "For display alarms")
  field(CALC, "A")
  field(INPA, "$(DEV):CPSTAT.SEVR MS")
  field(INPB, "$(DEV):FWSTAT_ALH.SEVR MS")
}

# Set by bpmDigiAlg*Common.template,
# if those databases are loaded. 
# Otherwise, always 0 and NO_ALARM
record(longin, "$(DEV):FWSTAT_ALH") {
  field(DESC, "For display alarms")
  field(VAL,  "0")
  field(PINI, "YES")
}

# Indicates whether firmware algorithm
# is in use and whether it or
# software is primary. Used in visibility
# rules on displays and to determine which
# PVs feed into alarms
record(mbbi, "$(DEV):ALG") {
  field(DESC, "FW alg info")
  field(ZRVL, "0")
  field(ZRST, "SW only")
  field(ONVL, "1")
  field(ONST, "SW primary")
  field(TWVL, "2")
  field(TWST, "FW primary")
  field(VAL,  "0")
  field(PINI, "YES")
}

# 0xF = 15 is valid state
record(longin, "$(DEV):ADCVALID") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AdcValid")
  field(SCAN, "10 second")
  field(HIHI, "16")
  field(HHSV, "MAJOR")
  field(LOLO, "14")
  field(LLSV, "MAJOR")
}
record(longin, "$(DEV):ADCVALIDCNT0") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AdcValidCnt[0]")
  field(SCAN, "10 second")
}
record(longin, "$(DEV):ADCVALIDCNT1") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AdcValidCnt[1]")
  field(SCAN, "10 second")
}
record(longin, "$(DEV):ADCVALIDCNT2") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AdcValidCnt[2]")
  field(SCAN, "10 second")
}
record(longin, "$(DEV):ADCVALIDCNT3") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AdcValidCnt[3]")
  field(SCAN, "10 second")
}
record(longin, "$(DEV):CLKFREQ") {
  field(DTYP, "bpmAlgParm")
  field(INP,  "#C1S0@AmcClkFreq")
  field(SCAN, "10 second")
}
