# per IOC database for stripline BPMs

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

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

record(sub, "VIOC:SU6:BPM:EVTM") {
	field(SNAM, "subEventTestTiming")
	field(SCAN, "Event")
	field(EVNT, "40")
}

# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU01:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C0 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU01:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU01:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU01:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU01:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU01:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU01:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU01:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:URER_SLOW")
}

record(ai, "SU1:CBPM:SU01:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU01:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU01:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU01:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU01:VRER 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, "SU1:CBPM:SU01:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU01:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU01:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C0 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S1")
  field(PINI, "YES")
}

record(stringin, "CBPM_S1:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU01")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU01:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU01:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU01:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU01:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU01:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU01:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU01:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01: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, "SU1:CBPM:SU01:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU01:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU01:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU01:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU01:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU01:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU01:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

record(waveform, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:PRENV")
}

record(waveform, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:ENVU")
}

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

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



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU02:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

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

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

record(calc, "SU1:CBPM:SU02:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU02:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU02:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU02:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU02:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:UPHAS_FB")
}

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

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:VPHAS_FB")
}

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU02:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:URER_SLOW")
}

record(ai, "SU1:CBPM:SU02:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU02:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU02:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU02:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU02:VRER 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, "SU1:CBPM:SU02:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

record(ai, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:V")
}

record(ai, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:PINC")
}

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

record(longin, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:RSTA_ALH")
}


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

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

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S2")
  field(PINI, "YES")
}

record(stringin, "CBPM_S2:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU02")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU02:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

record(bi, "SU1:CBPM:SU02:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU02:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU02:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU02:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU02:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02: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, "SU1:CBPM:SU02:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU02:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU02:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU02:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU02:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU02:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU02:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU03:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C2 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU03:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU03:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU03:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU03:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU03:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU03:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU03:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:URER_SLOW")
}

record(ai, "SU1:CBPM:SU03:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU03:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU03:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU03:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU03:VRER 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, "SU1:CBPM:SU03:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU03:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU03:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C2 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S3")
  field(PINI, "YES")
}

record(stringin, "CBPM_S3:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU03")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU03:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU03:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU03:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU03:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU03:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU03:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU03:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03: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, "SU1:CBPM:SU03:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU03:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU03:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU03:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU03:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU03:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU03:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU04:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C3 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU04:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU04:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU04:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU04:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU04:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU04:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU04:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:URER_SLOW")
}

record(ai, "SU1:CBPM:SU04:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU04:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU04:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU04:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU04:VRER 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, "SU1:CBPM:SU04:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU04:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU04:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C3 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S4")
  field(PINI, "YES")
}

record(stringin, "CBPM_S4:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU04")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU04:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU04:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU04:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU04:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU04:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU04:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU04:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04: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, "SU1:CBPM:SU04:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU04:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU04:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU04:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU04:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU04:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU04:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU05:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C4 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU05:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU05:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU05:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU05:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU05:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU05:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU05:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:URER_SLOW")
}

record(ai, "SU1:CBPM:SU05:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU05:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU05:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU05:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU05:VRER 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, "SU1:CBPM:SU05:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU05:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU05:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C4 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S5")
  field(PINI, "YES")
}

record(stringin, "CBPM_S5:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU05")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU05:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU05:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU05:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU05:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU05:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU05:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU05:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05: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, "SU1:CBPM:SU05:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU05:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU05:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU05:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU05:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU05:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU05:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU06:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C5 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU06:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU06:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU06:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU06:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU06:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU06:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU06:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:URER_SLOW")
}

record(ai, "SU1:CBPM:SU06:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU06:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU06:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU06:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU06:VRER 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, "SU1:CBPM:SU06:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU06:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU06:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C5 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S6")
  field(PINI, "YES")
}

record(stringin, "CBPM_S6:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU06")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU06:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU06:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU06:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU06:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU06:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU06:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU06:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06: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, "SU1:CBPM:SU06:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU06:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU06:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU06:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU06:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU06:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU06:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU07:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C6 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU07:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU07:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU07:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU07:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU07:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU07:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU07:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:URER_SLOW")
}

record(ai, "SU1:CBPM:SU07:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU07:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU07:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU07:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU07:VRER 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, "SU1:CBPM:SU07:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU07:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU07:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C6 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S7")
  field(PINI, "YES")
}

record(stringin, "CBPM_S7:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU07")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU07:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU07:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU07:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU07:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU07:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU07:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU07:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07: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, "SU1:CBPM:SU07:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU07:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU07:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU07:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU07:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU07:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU07:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU08:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C7 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU08:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU08:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU08:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU08:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU08:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU08:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU08:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:URER_SLOW")
}

record(ai, "SU1:CBPM:SU08:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU08:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU08:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU08:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU08:VRER 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, "SU1:CBPM:SU08:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU08:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU08:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C7 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S8")
  field(PINI, "YES")
}

record(stringin, "CBPM_S8:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU08")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU08:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU08:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU08:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU08:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU08:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU08:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU08:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08: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, "SU1:CBPM:SU08:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU08:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU08:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU08:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU08:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU08:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU08:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU09:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C8 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU09:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU09:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU09:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU09:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU09:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU09:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU09:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:URER_SLOW")
}

record(ai, "SU1:CBPM:SU09:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU09:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU09:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU09:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU09:VRER 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, "SU1:CBPM:SU09:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "SU1:CBPM:SU09:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

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

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

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

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


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

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

record(ao, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU09:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C8 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S9")
  field(PINI, "YES")
}

record(stringin, "CBPM_S9:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU09")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU09:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

#Used by model/database folks to verify BPM

record(ao, "SU1:CBPM:SU09:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

record(bi, "SU1:CBPM:SU09:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU09:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU09:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU09:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU09:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09: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, "SU1:CBPM:SU09:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU09:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU09:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU09:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU09:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU09:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU09:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU10:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C9 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, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C9 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU10:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU10:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU10:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU10:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU10:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU10:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "SU1:CBPM:SU10:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "9")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU10:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:URER_SLOW")
}

record(ai, "SU1:CBPM:SU10:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU10:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU10:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU10:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU10:VRER 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, "SU1:CBPM:SU10:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C9 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, "SU1:CBPM:SU10:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

record(ai, "SU1:CBPM:SU10:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C9 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, "SU1:CBPM:SU10:V")
}

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

record(ai, "SU1:CBPM:SU10:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C9 S10")
  field(SCAN, "Passive")
}

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


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

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

record(ao, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU10:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C9 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, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S10")
  field(PINI, "YES")
}

record(stringin, "CBPM_S10:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU10")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU10:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

record(bi, "SU1:CBPM:SU10:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU10:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU10:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU10:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU10:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10: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, "SU1:CBPM:SU10:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU10:SIM.SCAN  PP")

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

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

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

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

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

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

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

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

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

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU10:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU10:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU10:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU10:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU10:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU11:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C10 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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C10 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU11:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

record(calc, "SU1:CBPM:SU11:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU11:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU11:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

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

record(ao, "SU1:CBPM:SU11:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU11:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "SU1:CBPM:SU11:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "10")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU11:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:URER_SLOW")
}

record(ai, "SU1:CBPM:SU11:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU11:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU11:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU11:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU11:VRER 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, "SU1:CBPM:SU11:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C10 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, "SU1:CBPM:SU11:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

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

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


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

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

record(ai, "SU1:CBPM:SU11:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C10 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, "SU1:CBPM:SU11:V")
}

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

record(ai, "SU1:CBPM:SU11:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C10 S10")
  field(SCAN, "Passive")
}

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


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

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

record(ao, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:PSI_SEQ")
}

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

record(ao, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VOFF_SEQ")
}

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

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


record(mbbo, "SU1:CBPM:SU11:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C10 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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S11")
  field(PINI, "YES")
}

record(stringin, "CBPM_S11:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU11")
  field(PINI, "YES")
}

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

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

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

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

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

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

# Switch simulation record SU1:CBPM:SU11:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

record(bi, "SU1:CBPM:SU11:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU11:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU11:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU11:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU11:XOFF")
  info(autosaveFields, "VAL")
}

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

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

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

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


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

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

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU11:SIM.SCAN  PP")

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

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

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

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:VSCL")
	field(DOL2, "SU1:CBPM:SU11:VSCL")
	field(DOL3, "SU1:CBPM:SU11:VSCL")
	field(DOL4, "SU1:CBPM:SU11:VSCL")
	field(DOL5, "SU1:CBPM:SU11:VSCL")
	field(DOL6, "SU1:CBPM:SU11:VSCL")
	field(DOL7, "SU1:CBPM:SU11:VSCL")
	field(DOL8, "SU1:CBPM:SU11:VSCL")
	field(DOL9, "SU1:CBPM:SU11:VSCL")
	field(DOLA, "SU1:CBPM:SU11:VSCL")
	field(LNK1, "SU1:CBPM:SU11:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU11:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU11:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:PHI")
	field(DOL2, "SU1:CBPM:SU11:PHI")
	field(DOL3, "SU1:CBPM:SU11:PHI")
	field(DOL4, "SU1:CBPM:SU11:PHI")
	field(DOL5, "SU1:CBPM:SU11:PHI")
	field(DOL6, "SU1:CBPM:SU11:PHI")
	field(DOL7, "SU1:CBPM:SU11:PHI")
	field(DOL8, "SU1:CBPM:SU11:PHI")
	field(DOL9, "SU1:CBPM:SU11:PHI")
	field(DOLA, "SU1:CBPM:SU11:PHI")
	field(LNK1, "SU1:CBPM:SU11:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU11:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU11:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:PSI")
	field(DOL2, "SU1:CBPM:SU11:PSI")
	field(DOL3, "SU1:CBPM:SU11:PSI")
	field(DOL4, "SU1:CBPM:SU11:PSI")
	field(DOL5, "SU1:CBPM:SU11:PSI")
	field(DOL6, "SU1:CBPM:SU11:PSI")
	field(DOL7, "SU1:CBPM:SU11:PSI")
	field(DOL8, "SU1:CBPM:SU11:PSI")
	field(DOL9, "SU1:CBPM:SU11:PSI")
	field(DOLA, "SU1:CBPM:SU11:PSI")
	field(LNK1, "SU1:CBPM:SU11:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU11:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU11:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:UPHAS")
	field(DOL2, "SU1:CBPM:SU11:UPHAS")
	field(DOL3, "SU1:CBPM:SU11:UPHAS")
	field(DOL4, "SU1:CBPM:SU11:UPHAS")
	field(DOL5, "SU1:CBPM:SU11:UPHAS")
	field(DOL6, "SU1:CBPM:SU11:UPHAS")
	field(DOL7, "SU1:CBPM:SU11:UPHAS")
	field(DOL8, "SU1:CBPM:SU11:UPHAS")
	field(DOL9, "SU1:CBPM:SU11:UPHAS")
	field(DOLA, "SU1:CBPM:SU11:UPHAS")
	field(LNK1, "SU1:CBPM:SU11:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU11:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU11:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:VPHAS")
	field(DOL2, "SU1:CBPM:SU11:VPHAS")
	field(DOL3, "SU1:CBPM:SU11:VPHAS")
	field(DOL4, "SU1:CBPM:SU11:VPHAS")
	field(DOL5, "SU1:CBPM:SU11:VPHAS")
	field(DOL6, "SU1:CBPM:SU11:VPHAS")
	field(DOL7, "SU1:CBPM:SU11:VPHAS")
	field(DOL8, "SU1:CBPM:SU11:VPHAS")
	field(DOL9, "SU1:CBPM:SU11:VPHAS")
	field(DOLA, "SU1:CBPM:SU11:VPHAS")
	field(LNK1, "SU1:CBPM:SU11:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU11:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU11:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:QSCL")
	field(DOL2, "SU1:CBPM:SU11:QSCL")
	field(DOL3, "SU1:CBPM:SU11:QSCL")
	field(DOL4, "SU1:CBPM:SU11:QSCL")
	field(DOL5, "SU1:CBPM:SU11:QSCL")
	field(DOL6, "SU1:CBPM:SU11:QSCL")
	field(DOL7, "SU1:CBPM:SU11:QSCL")
	field(DOL8, "SU1:CBPM:SU11:QSCL")
	field(DOL9, "SU1:CBPM:SU11:QSCL")
	field(DOLA, "SU1:CBPM:SU11:QSCL")
	field(LNK1, "SU1:CBPM:SU11:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU11:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU11:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:URSCL")
	field(DOL2, "SU1:CBPM:SU11:URSCL")
	field(DOL3, "SU1:CBPM:SU11:URSCL")
	field(DOL4, "SU1:CBPM:SU11:URSCL")
	field(DOL5, "SU1:CBPM:SU11:URSCL")
	field(DOL6, "SU1:CBPM:SU11:URSCL")
	field(DOL7, "SU1:CBPM:SU11:URSCL")
	field(DOL8, "SU1:CBPM:SU11:URSCL")
	field(DOL9, "SU1:CBPM:SU11:URSCL")
	field(DOLA, "SU1:CBPM:SU11:URSCL")
	field(LNK1, "SU1:CBPM:SU11:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU11:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU11:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:VRSCL")
	field(DOL2, "SU1:CBPM:SU11:VRSCL")
	field(DOL3, "SU1:CBPM:SU11:VRSCL")
	field(DOL4, "SU1:CBPM:SU11:VRSCL")
	field(DOL5, "SU1:CBPM:SU11:VRSCL")
	field(DOL6, "SU1:CBPM:SU11:VRSCL")
	field(DOL7, "SU1:CBPM:SU11:VRSCL")
	field(DOL8, "SU1:CBPM:SU11:VRSCL")
	field(DOL9, "SU1:CBPM:SU11:VRSCL")
	field(DOLA, "SU1:CBPM:SU11:VRSCL")
	field(LNK1, "SU1:CBPM:SU11:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU11:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU11:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11: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, "SU1:CBPM:SU11:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU11:QRSCL")
	field(DOL2, "SU1:CBPM:SU11:QRSCL")
	field(DOL3, "SU1:CBPM:SU11:QRSCL")
	field(DOL4, "SU1:CBPM:SU11:QRSCL")
	field(DOL5, "SU1:CBPM:SU11:QRSCL")
	field(DOL6, "SU1:CBPM:SU11:QRSCL")
	field(DOL7, "SU1:CBPM:SU11:QRSCL")
	field(DOL8, "SU1:CBPM:SU11:QRSCL")
	field(DOL9, "SU1:CBPM:SU11:QRSCL")
	field(DOLA, "SU1:CBPM:SU11:QRSCL")
	field(LNK1, "SU1:CBPM:SU11:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU11:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU11:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU11:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU11:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU11:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU11:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU11:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU11:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU11:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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, "SU1:CBPM:SU11: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,  "SU1:CBPM:SU11:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU11:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU11:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU11:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU11:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU11:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU11:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU11:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU11:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU12:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU12:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU12:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU12:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 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, "SU1:CBPM:SU12:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 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, "SU1:CBPM:SU12:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU12:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU12:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU12:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU12:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C11 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU12:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C11 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:PRENV")
}

record(waveform, "SU1:CBPM:SU12:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C11 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU12:ENVU")
}

record(subArray, "SU1:CBPM:SU12:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU12:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU12:ENVV")
}

record(subArray, "SU1:CBPM:SU12:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU12:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU12:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C11 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU12:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU12:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU12:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C11 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU12:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU12:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU12:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU12:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU12:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU12:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU12:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU12:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU12:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "11")
#field(INPB, "SU1:CBPM:SU12:FC_REF")
#field(INPC, "SU1:CBPM:SU12:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU12:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU12:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU12:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU12:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU12:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU12:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU12:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU12:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU12:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU12:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU12:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU12:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU12:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU12:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU12:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU12:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C11S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU12:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU12:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU12:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU12:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU12:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C11S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU12:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU12:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU12:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU12:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU12:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU12:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU12:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU12:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU12:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU12:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU12:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "11")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU12:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:URER_SLOW")
}

record(ai, "SU1:CBPM:SU12:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU12:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU12:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU12:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU12:VRER 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, "SU1:CBPM:SU12:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 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, "SU1:CBPM:SU12:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU12:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S12")
  field(FLNK, "SU1:CBPM:SU12:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU12:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU12:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU12:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C11 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU12:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 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, "SU1:CBPM:SU12:V")
}

record(ai, "SU1:CBPM:SU12:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU12:PINC")
}

record(ai, "SU1:CBPM:SU12:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU12:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C11S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU12:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU12:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU12:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU12:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU12:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU12:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU12:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU12:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU12:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C11 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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S12")
  field(PINI, "YES")
}

record(stringin, "CBPM_S12:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU12")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU12:X_SLOW") {
#alias("SU1:CBPM:SU12:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU12:X MS")
  field(FLNK, "SU1:CBPM:SU12:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU12:Y_SLOW") {
#alias("SU1:CBPM:SU12:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU12:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU12:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU12:TMIT_SLOW") {
#alias("SU1:CBPM:SU12:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU12:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU12:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU12:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU12:SIMC PP")
}

record(calcout, "SU1:CBPM:SU12:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "11")
#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, "SU1:CBPM:SU12:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU12:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU12:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU12:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU12:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU12:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU12:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU12:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C11 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, "SU1:CBPM:SU12:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU12:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x800")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU12:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x800")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU12:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU12:TMIT")
  field(INPB, "SU1:CBPM:SU12:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU12:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU12:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU12:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU12:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU12:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU12:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU12:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU12:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU12:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU12:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU12:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU12:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU12:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU12:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU12:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU12:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU12:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU12:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU12:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C11 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU12:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU12:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU12:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU12:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:UOFF")
	field(DOL2, "SU1:CBPM:SU12:UOFF")
	field(DOL3, "SU1:CBPM:SU12:UOFF")
	field(DOL4, "SU1:CBPM:SU12:UOFF")
	field(DOL5, "SU1:CBPM:SU12:UOFF")
	field(DOL6, "SU1:CBPM:SU12:UOFF")
	field(DOL7, "SU1:CBPM:SU12:UOFF")
	field(DOL8, "SU1:CBPM:SU12:UOFF")
	field(DOL9, "SU1:CBPM:SU12:UOFF")
	field(DOLA, "SU1:CBPM:SU12:UOFF")
	field(LNK1, "SU1:CBPM:SU12:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU12:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU12:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:VOFF")
	field(DOL2, "SU1:CBPM:SU12:VOFF")
	field(DOL3, "SU1:CBPM:SU12:VOFF")
	field(DOL4, "SU1:CBPM:SU12:VOFF")
	field(DOL5, "SU1:CBPM:SU12:VOFF")
	field(DOL6, "SU1:CBPM:SU12:VOFF")
	field(DOL7, "SU1:CBPM:SU12:VOFF")
	field(DOL8, "SU1:CBPM:SU12:VOFF")
	field(DOL9, "SU1:CBPM:SU12:VOFF")
	field(DOLA, "SU1:CBPM:SU12:VOFF")
	field(LNK1, "SU1:CBPM:SU12:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU12:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU12:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:USCL")
	field(DOL2, "SU1:CBPM:SU12:USCL")
	field(DOL3, "SU1:CBPM:SU12:USCL")
	field(DOL4, "SU1:CBPM:SU12:USCL")
	field(DOL5, "SU1:CBPM:SU12:USCL")
	field(DOL6, "SU1:CBPM:SU12:USCL")
	field(DOL7, "SU1:CBPM:SU12:USCL")
	field(DOL8, "SU1:CBPM:SU12:USCL")
	field(DOL9, "SU1:CBPM:SU12:USCL")
	field(DOLA, "SU1:CBPM:SU12:USCL")
	field(LNK1, "SU1:CBPM:SU12:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:VSCL")
	field(DOL2, "SU1:CBPM:SU12:VSCL")
	field(DOL3, "SU1:CBPM:SU12:VSCL")
	field(DOL4, "SU1:CBPM:SU12:VSCL")
	field(DOL5, "SU1:CBPM:SU12:VSCL")
	field(DOL6, "SU1:CBPM:SU12:VSCL")
	field(DOL7, "SU1:CBPM:SU12:VSCL")
	field(DOL8, "SU1:CBPM:SU12:VSCL")
	field(DOL9, "SU1:CBPM:SU12:VSCL")
	field(DOLA, "SU1:CBPM:SU12:VSCL")
	field(LNK1, "SU1:CBPM:SU12:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:PHI")
	field(DOL2, "SU1:CBPM:SU12:PHI")
	field(DOL3, "SU1:CBPM:SU12:PHI")
	field(DOL4, "SU1:CBPM:SU12:PHI")
	field(DOL5, "SU1:CBPM:SU12:PHI")
	field(DOL6, "SU1:CBPM:SU12:PHI")
	field(DOL7, "SU1:CBPM:SU12:PHI")
	field(DOL8, "SU1:CBPM:SU12:PHI")
	field(DOL9, "SU1:CBPM:SU12:PHI")
	field(DOLA, "SU1:CBPM:SU12:PHI")
	field(LNK1, "SU1:CBPM:SU12:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU12:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU12:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:PSI")
	field(DOL2, "SU1:CBPM:SU12:PSI")
	field(DOL3, "SU1:CBPM:SU12:PSI")
	field(DOL4, "SU1:CBPM:SU12:PSI")
	field(DOL5, "SU1:CBPM:SU12:PSI")
	field(DOL6, "SU1:CBPM:SU12:PSI")
	field(DOL7, "SU1:CBPM:SU12:PSI")
	field(DOL8, "SU1:CBPM:SU12:PSI")
	field(DOL9, "SU1:CBPM:SU12:PSI")
	field(DOLA, "SU1:CBPM:SU12:PSI")
	field(LNK1, "SU1:CBPM:SU12:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU12:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU12:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:UPHAS")
	field(DOL2, "SU1:CBPM:SU12:UPHAS")
	field(DOL3, "SU1:CBPM:SU12:UPHAS")
	field(DOL4, "SU1:CBPM:SU12:UPHAS")
	field(DOL5, "SU1:CBPM:SU12:UPHAS")
	field(DOL6, "SU1:CBPM:SU12:UPHAS")
	field(DOL7, "SU1:CBPM:SU12:UPHAS")
	field(DOL8, "SU1:CBPM:SU12:UPHAS")
	field(DOL9, "SU1:CBPM:SU12:UPHAS")
	field(DOLA, "SU1:CBPM:SU12:UPHAS")
	field(LNK1, "SU1:CBPM:SU12:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU12:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU12:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:VPHAS")
	field(DOL2, "SU1:CBPM:SU12:VPHAS")
	field(DOL3, "SU1:CBPM:SU12:VPHAS")
	field(DOL4, "SU1:CBPM:SU12:VPHAS")
	field(DOL5, "SU1:CBPM:SU12:VPHAS")
	field(DOL6, "SU1:CBPM:SU12:VPHAS")
	field(DOL7, "SU1:CBPM:SU12:VPHAS")
	field(DOL8, "SU1:CBPM:SU12:VPHAS")
	field(DOL9, "SU1:CBPM:SU12:VPHAS")
	field(DOLA, "SU1:CBPM:SU12:VPHAS")
	field(LNK1, "SU1:CBPM:SU12:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU12:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU12:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:QSCL")
	field(DOL2, "SU1:CBPM:SU12:QSCL")
	field(DOL3, "SU1:CBPM:SU12:QSCL")
	field(DOL4, "SU1:CBPM:SU12:QSCL")
	field(DOL5, "SU1:CBPM:SU12:QSCL")
	field(DOL6, "SU1:CBPM:SU12:QSCL")
	field(DOL7, "SU1:CBPM:SU12:QSCL")
	field(DOL8, "SU1:CBPM:SU12:QSCL")
	field(DOL9, "SU1:CBPM:SU12:QSCL")
	field(DOLA, "SU1:CBPM:SU12:QSCL")
	field(LNK1, "SU1:CBPM:SU12:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:URSCL")
	field(DOL2, "SU1:CBPM:SU12:URSCL")
	field(DOL3, "SU1:CBPM:SU12:URSCL")
	field(DOL4, "SU1:CBPM:SU12:URSCL")
	field(DOL5, "SU1:CBPM:SU12:URSCL")
	field(DOL6, "SU1:CBPM:SU12:URSCL")
	field(DOL7, "SU1:CBPM:SU12:URSCL")
	field(DOL8, "SU1:CBPM:SU12:URSCL")
	field(DOL9, "SU1:CBPM:SU12:URSCL")
	field(DOLA, "SU1:CBPM:SU12:URSCL")
	field(LNK1, "SU1:CBPM:SU12:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:VRSCL")
	field(DOL2, "SU1:CBPM:SU12:VRSCL")
	field(DOL3, "SU1:CBPM:SU12:VRSCL")
	field(DOL4, "SU1:CBPM:SU12:VRSCL")
	field(DOL5, "SU1:CBPM:SU12:VRSCL")
	field(DOL6, "SU1:CBPM:SU12:VRSCL")
	field(DOL7, "SU1:CBPM:SU12:VRSCL")
	field(DOL8, "SU1:CBPM:SU12:VRSCL")
	field(DOL9, "SU1:CBPM:SU12:VRSCL")
	field(DOLA, "SU1:CBPM:SU12:VRSCL")
	field(LNK1, "SU1:CBPM:SU12:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12: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, "SU1:CBPM:SU12:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU12:QRSCL")
	field(DOL2, "SU1:CBPM:SU12:QRSCL")
	field(DOL3, "SU1:CBPM:SU12:QRSCL")
	field(DOL4, "SU1:CBPM:SU12:QRSCL")
	field(DOL5, "SU1:CBPM:SU12:QRSCL")
	field(DOL6, "SU1:CBPM:SU12:QRSCL")
	field(DOL7, "SU1:CBPM:SU12:QRSCL")
	field(DOL8, "SU1:CBPM:SU12:QRSCL")
	field(DOL9, "SU1:CBPM:SU12:QRSCL")
	field(DOLA, "SU1:CBPM:SU12:QRSCL")
	field(LNK1, "SU1:CBPM:SU12:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU12:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU12:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU12:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU12:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU12:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU12:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU12:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU12:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU12:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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, "SU1:CBPM:SU12: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,  "SU1:CBPM:SU12:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU12:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU12:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU12:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU12:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU12:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU12:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU12:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU13:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU13:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU13:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU13:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 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, "SU1:CBPM:SU13:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 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, "SU1:CBPM:SU13:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU13:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU13:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU13:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU13:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C12 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU13:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C12 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:PRENV")
}

record(waveform, "SU1:CBPM:SU13:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C12 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU13:ENVU")
}

record(subArray, "SU1:CBPM:SU13:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU13:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU13:ENVV")
}

record(subArray, "SU1:CBPM:SU13:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU13:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU13:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C12 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU13:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU13:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU13:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C12 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU13:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU13:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU13:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU13:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU13:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU13:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU13:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU13:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU13:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "12")
#field(INPB, "SU1:CBPM:SU13:FC_REF")
#field(INPC, "SU1:CBPM:SU13:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU13:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU13:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU13:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU13:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU13:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU13:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU13:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU13:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU13:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU13:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU13:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU13:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU13:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU13:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU13:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU13:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C12S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU13:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU13:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU13:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU13:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU13:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C12S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU13:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU13:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU13:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU13:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU13:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU13:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU13:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU13:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU13:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU13:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU13:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "12")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU13:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:URER_SLOW")
}

record(ai, "SU1:CBPM:SU13:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU13:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU13:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU13:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU13:VRER 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, "SU1:CBPM:SU13:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 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, "SU1:CBPM:SU13:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU13:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S12")
  field(FLNK, "SU1:CBPM:SU13:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU13:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU13:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU13:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C12 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU13:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 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, "SU1:CBPM:SU13:V")
}

record(ai, "SU1:CBPM:SU13:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU13:PINC")
}

record(ai, "SU1:CBPM:SU13:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU13:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C12S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU13:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU13:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU13:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU13:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU13:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU13:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU13:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU13:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU13:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C12 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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S13")
  field(PINI, "YES")
}

record(stringin, "CBPM_S13:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU13")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU13:X_SLOW") {
#alias("SU1:CBPM:SU13:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU13:X MS")
  field(FLNK, "SU1:CBPM:SU13:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU13:Y_SLOW") {
#alias("SU1:CBPM:SU13:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU13:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU13:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU13:TMIT_SLOW") {
#alias("SU1:CBPM:SU13:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU13:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU13:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU13:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU13:SIMC PP")
}

record(calcout, "SU1:CBPM:SU13:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "12")
#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, "SU1:CBPM:SU13:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU13:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU13:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU13:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU13:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU13:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU13:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU13:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C12 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, "SU1:CBPM:SU13:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU13:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x1000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU13:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x1000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU13:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU13:TMIT")
  field(INPB, "SU1:CBPM:SU13:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU13:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU13:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU13:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU13:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU13:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU13:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU13:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU13:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU13:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU13:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU13:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU13:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU13:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU13:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU13:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU13:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU13:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU13:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU13:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C12 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU13:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU13:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU13:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU13:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:UOFF")
	field(DOL2, "SU1:CBPM:SU13:UOFF")
	field(DOL3, "SU1:CBPM:SU13:UOFF")
	field(DOL4, "SU1:CBPM:SU13:UOFF")
	field(DOL5, "SU1:CBPM:SU13:UOFF")
	field(DOL6, "SU1:CBPM:SU13:UOFF")
	field(DOL7, "SU1:CBPM:SU13:UOFF")
	field(DOL8, "SU1:CBPM:SU13:UOFF")
	field(DOL9, "SU1:CBPM:SU13:UOFF")
	field(DOLA, "SU1:CBPM:SU13:UOFF")
	field(LNK1, "SU1:CBPM:SU13:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU13:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU13:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:VOFF")
	field(DOL2, "SU1:CBPM:SU13:VOFF")
	field(DOL3, "SU1:CBPM:SU13:VOFF")
	field(DOL4, "SU1:CBPM:SU13:VOFF")
	field(DOL5, "SU1:CBPM:SU13:VOFF")
	field(DOL6, "SU1:CBPM:SU13:VOFF")
	field(DOL7, "SU1:CBPM:SU13:VOFF")
	field(DOL8, "SU1:CBPM:SU13:VOFF")
	field(DOL9, "SU1:CBPM:SU13:VOFF")
	field(DOLA, "SU1:CBPM:SU13:VOFF")
	field(LNK1, "SU1:CBPM:SU13:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU13:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU13:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:USCL")
	field(DOL2, "SU1:CBPM:SU13:USCL")
	field(DOL3, "SU1:CBPM:SU13:USCL")
	field(DOL4, "SU1:CBPM:SU13:USCL")
	field(DOL5, "SU1:CBPM:SU13:USCL")
	field(DOL6, "SU1:CBPM:SU13:USCL")
	field(DOL7, "SU1:CBPM:SU13:USCL")
	field(DOL8, "SU1:CBPM:SU13:USCL")
	field(DOL9, "SU1:CBPM:SU13:USCL")
	field(DOLA, "SU1:CBPM:SU13:USCL")
	field(LNK1, "SU1:CBPM:SU13:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:VSCL")
	field(DOL2, "SU1:CBPM:SU13:VSCL")
	field(DOL3, "SU1:CBPM:SU13:VSCL")
	field(DOL4, "SU1:CBPM:SU13:VSCL")
	field(DOL5, "SU1:CBPM:SU13:VSCL")
	field(DOL6, "SU1:CBPM:SU13:VSCL")
	field(DOL7, "SU1:CBPM:SU13:VSCL")
	field(DOL8, "SU1:CBPM:SU13:VSCL")
	field(DOL9, "SU1:CBPM:SU13:VSCL")
	field(DOLA, "SU1:CBPM:SU13:VSCL")
	field(LNK1, "SU1:CBPM:SU13:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:PHI")
	field(DOL2, "SU1:CBPM:SU13:PHI")
	field(DOL3, "SU1:CBPM:SU13:PHI")
	field(DOL4, "SU1:CBPM:SU13:PHI")
	field(DOL5, "SU1:CBPM:SU13:PHI")
	field(DOL6, "SU1:CBPM:SU13:PHI")
	field(DOL7, "SU1:CBPM:SU13:PHI")
	field(DOL8, "SU1:CBPM:SU13:PHI")
	field(DOL9, "SU1:CBPM:SU13:PHI")
	field(DOLA, "SU1:CBPM:SU13:PHI")
	field(LNK1, "SU1:CBPM:SU13:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU13:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU13:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:PSI")
	field(DOL2, "SU1:CBPM:SU13:PSI")
	field(DOL3, "SU1:CBPM:SU13:PSI")
	field(DOL4, "SU1:CBPM:SU13:PSI")
	field(DOL5, "SU1:CBPM:SU13:PSI")
	field(DOL6, "SU1:CBPM:SU13:PSI")
	field(DOL7, "SU1:CBPM:SU13:PSI")
	field(DOL8, "SU1:CBPM:SU13:PSI")
	field(DOL9, "SU1:CBPM:SU13:PSI")
	field(DOLA, "SU1:CBPM:SU13:PSI")
	field(LNK1, "SU1:CBPM:SU13:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU13:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU13:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:UPHAS")
	field(DOL2, "SU1:CBPM:SU13:UPHAS")
	field(DOL3, "SU1:CBPM:SU13:UPHAS")
	field(DOL4, "SU1:CBPM:SU13:UPHAS")
	field(DOL5, "SU1:CBPM:SU13:UPHAS")
	field(DOL6, "SU1:CBPM:SU13:UPHAS")
	field(DOL7, "SU1:CBPM:SU13:UPHAS")
	field(DOL8, "SU1:CBPM:SU13:UPHAS")
	field(DOL9, "SU1:CBPM:SU13:UPHAS")
	field(DOLA, "SU1:CBPM:SU13:UPHAS")
	field(LNK1, "SU1:CBPM:SU13:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU13:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU13:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:VPHAS")
	field(DOL2, "SU1:CBPM:SU13:VPHAS")
	field(DOL3, "SU1:CBPM:SU13:VPHAS")
	field(DOL4, "SU1:CBPM:SU13:VPHAS")
	field(DOL5, "SU1:CBPM:SU13:VPHAS")
	field(DOL6, "SU1:CBPM:SU13:VPHAS")
	field(DOL7, "SU1:CBPM:SU13:VPHAS")
	field(DOL8, "SU1:CBPM:SU13:VPHAS")
	field(DOL9, "SU1:CBPM:SU13:VPHAS")
	field(DOLA, "SU1:CBPM:SU13:VPHAS")
	field(LNK1, "SU1:CBPM:SU13:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU13:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU13:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:QSCL")
	field(DOL2, "SU1:CBPM:SU13:QSCL")
	field(DOL3, "SU1:CBPM:SU13:QSCL")
	field(DOL4, "SU1:CBPM:SU13:QSCL")
	field(DOL5, "SU1:CBPM:SU13:QSCL")
	field(DOL6, "SU1:CBPM:SU13:QSCL")
	field(DOL7, "SU1:CBPM:SU13:QSCL")
	field(DOL8, "SU1:CBPM:SU13:QSCL")
	field(DOL9, "SU1:CBPM:SU13:QSCL")
	field(DOLA, "SU1:CBPM:SU13:QSCL")
	field(LNK1, "SU1:CBPM:SU13:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:URSCL")
	field(DOL2, "SU1:CBPM:SU13:URSCL")
	field(DOL3, "SU1:CBPM:SU13:URSCL")
	field(DOL4, "SU1:CBPM:SU13:URSCL")
	field(DOL5, "SU1:CBPM:SU13:URSCL")
	field(DOL6, "SU1:CBPM:SU13:URSCL")
	field(DOL7, "SU1:CBPM:SU13:URSCL")
	field(DOL8, "SU1:CBPM:SU13:URSCL")
	field(DOL9, "SU1:CBPM:SU13:URSCL")
	field(DOLA, "SU1:CBPM:SU13:URSCL")
	field(LNK1, "SU1:CBPM:SU13:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:VRSCL")
	field(DOL2, "SU1:CBPM:SU13:VRSCL")
	field(DOL3, "SU1:CBPM:SU13:VRSCL")
	field(DOL4, "SU1:CBPM:SU13:VRSCL")
	field(DOL5, "SU1:CBPM:SU13:VRSCL")
	field(DOL6, "SU1:CBPM:SU13:VRSCL")
	field(DOL7, "SU1:CBPM:SU13:VRSCL")
	field(DOL8, "SU1:CBPM:SU13:VRSCL")
	field(DOL9, "SU1:CBPM:SU13:VRSCL")
	field(DOLA, "SU1:CBPM:SU13:VRSCL")
	field(LNK1, "SU1:CBPM:SU13:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13: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, "SU1:CBPM:SU13:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU13:QRSCL")
	field(DOL2, "SU1:CBPM:SU13:QRSCL")
	field(DOL3, "SU1:CBPM:SU13:QRSCL")
	field(DOL4, "SU1:CBPM:SU13:QRSCL")
	field(DOL5, "SU1:CBPM:SU13:QRSCL")
	field(DOL6, "SU1:CBPM:SU13:QRSCL")
	field(DOL7, "SU1:CBPM:SU13:QRSCL")
	field(DOL8, "SU1:CBPM:SU13:QRSCL")
	field(DOL9, "SU1:CBPM:SU13:QRSCL")
	field(DOLA, "SU1:CBPM:SU13:QRSCL")
	field(LNK1, "SU1:CBPM:SU13:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU13:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU13:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU13:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU13:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU13:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU13:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU13:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU13:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU13:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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, "SU1:CBPM:SU13: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,  "SU1:CBPM:SU13:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU13:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU13:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU13:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU13:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU13:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU13:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU13:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU14:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU14:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU14:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU14:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 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, "SU1:CBPM:SU14:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 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, "SU1:CBPM:SU14:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU14:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU14:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU14:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU14:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C13 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU14:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C13 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:PRENV")
}

record(waveform, "SU1:CBPM:SU14:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C13 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU14:ENVU")
}

record(subArray, "SU1:CBPM:SU14:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU14:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU14:ENVV")
}

record(subArray, "SU1:CBPM:SU14:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU14:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU14:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C13 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU14:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU14:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU14:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C13 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU14:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU14:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU14:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU14:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU14:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU14:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU14:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU14:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU14:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "13")
#field(INPB, "SU1:CBPM:SU14:FC_REF")
#field(INPC, "SU1:CBPM:SU14:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU14:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU14:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU14:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU14:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU14:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU14:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU14:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU14:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU14:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU14:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU14:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU14:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU14:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU14:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU14:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU14:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C13S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU14:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU14:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU14:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU14:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU14:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C13S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU14:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU14:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU14:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU14:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU14:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU14:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU14:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU14:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU14:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU14:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU14:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "13")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU14:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:URER_SLOW")
}

record(ai, "SU1:CBPM:SU14:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU14:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU14:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU14:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU14:VRER 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, "SU1:CBPM:SU14:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 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, "SU1:CBPM:SU14:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU14:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S12")
  field(FLNK, "SU1:CBPM:SU14:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU14:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU14:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU14:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C13 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU14:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 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, "SU1:CBPM:SU14:V")
}

record(ai, "SU1:CBPM:SU14:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU14:PINC")
}

record(ai, "SU1:CBPM:SU14:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU14:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C13S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU14:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU14:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU14:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU14:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU14:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU14:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU14:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU14:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU14:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C13 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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S14")
  field(PINI, "YES")
}

record(stringin, "CBPM_S14:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU14")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU14:X_SLOW") {
#alias("SU1:CBPM:SU14:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU14:X MS")
  field(FLNK, "SU1:CBPM:SU14:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU14:Y_SLOW") {
#alias("SU1:CBPM:SU14:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU14:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU14:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU14:TMIT_SLOW") {
#alias("SU1:CBPM:SU14:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU14:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU14:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU14:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU14:SIMC PP")
}

record(calcout, "SU1:CBPM:SU14:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "13")
#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, "SU1:CBPM:SU14:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU14:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU14:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU14:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU14:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU14:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU14:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU14:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C13 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, "SU1:CBPM:SU14:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU14:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x2000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU14:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x2000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU14:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU14:TMIT")
  field(INPB, "SU1:CBPM:SU14:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU14:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU14:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU14:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU14:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU14:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU14:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU14:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU14:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU14:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU14:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU14:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU14:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU14:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU14:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU14:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU14:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU14:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU14:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU14:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C13 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU14:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU14:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU14:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU14:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:UOFF")
	field(DOL2, "SU1:CBPM:SU14:UOFF")
	field(DOL3, "SU1:CBPM:SU14:UOFF")
	field(DOL4, "SU1:CBPM:SU14:UOFF")
	field(DOL5, "SU1:CBPM:SU14:UOFF")
	field(DOL6, "SU1:CBPM:SU14:UOFF")
	field(DOL7, "SU1:CBPM:SU14:UOFF")
	field(DOL8, "SU1:CBPM:SU14:UOFF")
	field(DOL9, "SU1:CBPM:SU14:UOFF")
	field(DOLA, "SU1:CBPM:SU14:UOFF")
	field(LNK1, "SU1:CBPM:SU14:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU14:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU14:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:VOFF")
	field(DOL2, "SU1:CBPM:SU14:VOFF")
	field(DOL3, "SU1:CBPM:SU14:VOFF")
	field(DOL4, "SU1:CBPM:SU14:VOFF")
	field(DOL5, "SU1:CBPM:SU14:VOFF")
	field(DOL6, "SU1:CBPM:SU14:VOFF")
	field(DOL7, "SU1:CBPM:SU14:VOFF")
	field(DOL8, "SU1:CBPM:SU14:VOFF")
	field(DOL9, "SU1:CBPM:SU14:VOFF")
	field(DOLA, "SU1:CBPM:SU14:VOFF")
	field(LNK1, "SU1:CBPM:SU14:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU14:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU14:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:USCL")
	field(DOL2, "SU1:CBPM:SU14:USCL")
	field(DOL3, "SU1:CBPM:SU14:USCL")
	field(DOL4, "SU1:CBPM:SU14:USCL")
	field(DOL5, "SU1:CBPM:SU14:USCL")
	field(DOL6, "SU1:CBPM:SU14:USCL")
	field(DOL7, "SU1:CBPM:SU14:USCL")
	field(DOL8, "SU1:CBPM:SU14:USCL")
	field(DOL9, "SU1:CBPM:SU14:USCL")
	field(DOLA, "SU1:CBPM:SU14:USCL")
	field(LNK1, "SU1:CBPM:SU14:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:VSCL")
	field(DOL2, "SU1:CBPM:SU14:VSCL")
	field(DOL3, "SU1:CBPM:SU14:VSCL")
	field(DOL4, "SU1:CBPM:SU14:VSCL")
	field(DOL5, "SU1:CBPM:SU14:VSCL")
	field(DOL6, "SU1:CBPM:SU14:VSCL")
	field(DOL7, "SU1:CBPM:SU14:VSCL")
	field(DOL8, "SU1:CBPM:SU14:VSCL")
	field(DOL9, "SU1:CBPM:SU14:VSCL")
	field(DOLA, "SU1:CBPM:SU14:VSCL")
	field(LNK1, "SU1:CBPM:SU14:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:PHI")
	field(DOL2, "SU1:CBPM:SU14:PHI")
	field(DOL3, "SU1:CBPM:SU14:PHI")
	field(DOL4, "SU1:CBPM:SU14:PHI")
	field(DOL5, "SU1:CBPM:SU14:PHI")
	field(DOL6, "SU1:CBPM:SU14:PHI")
	field(DOL7, "SU1:CBPM:SU14:PHI")
	field(DOL8, "SU1:CBPM:SU14:PHI")
	field(DOL9, "SU1:CBPM:SU14:PHI")
	field(DOLA, "SU1:CBPM:SU14:PHI")
	field(LNK1, "SU1:CBPM:SU14:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU14:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU14:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:PSI")
	field(DOL2, "SU1:CBPM:SU14:PSI")
	field(DOL3, "SU1:CBPM:SU14:PSI")
	field(DOL4, "SU1:CBPM:SU14:PSI")
	field(DOL5, "SU1:CBPM:SU14:PSI")
	field(DOL6, "SU1:CBPM:SU14:PSI")
	field(DOL7, "SU1:CBPM:SU14:PSI")
	field(DOL8, "SU1:CBPM:SU14:PSI")
	field(DOL9, "SU1:CBPM:SU14:PSI")
	field(DOLA, "SU1:CBPM:SU14:PSI")
	field(LNK1, "SU1:CBPM:SU14:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU14:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU14:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:UPHAS")
	field(DOL2, "SU1:CBPM:SU14:UPHAS")
	field(DOL3, "SU1:CBPM:SU14:UPHAS")
	field(DOL4, "SU1:CBPM:SU14:UPHAS")
	field(DOL5, "SU1:CBPM:SU14:UPHAS")
	field(DOL6, "SU1:CBPM:SU14:UPHAS")
	field(DOL7, "SU1:CBPM:SU14:UPHAS")
	field(DOL8, "SU1:CBPM:SU14:UPHAS")
	field(DOL9, "SU1:CBPM:SU14:UPHAS")
	field(DOLA, "SU1:CBPM:SU14:UPHAS")
	field(LNK1, "SU1:CBPM:SU14:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU14:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU14:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:VPHAS")
	field(DOL2, "SU1:CBPM:SU14:VPHAS")
	field(DOL3, "SU1:CBPM:SU14:VPHAS")
	field(DOL4, "SU1:CBPM:SU14:VPHAS")
	field(DOL5, "SU1:CBPM:SU14:VPHAS")
	field(DOL6, "SU1:CBPM:SU14:VPHAS")
	field(DOL7, "SU1:CBPM:SU14:VPHAS")
	field(DOL8, "SU1:CBPM:SU14:VPHAS")
	field(DOL9, "SU1:CBPM:SU14:VPHAS")
	field(DOLA, "SU1:CBPM:SU14:VPHAS")
	field(LNK1, "SU1:CBPM:SU14:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU14:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU14:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:QSCL")
	field(DOL2, "SU1:CBPM:SU14:QSCL")
	field(DOL3, "SU1:CBPM:SU14:QSCL")
	field(DOL4, "SU1:CBPM:SU14:QSCL")
	field(DOL5, "SU1:CBPM:SU14:QSCL")
	field(DOL6, "SU1:CBPM:SU14:QSCL")
	field(DOL7, "SU1:CBPM:SU14:QSCL")
	field(DOL8, "SU1:CBPM:SU14:QSCL")
	field(DOL9, "SU1:CBPM:SU14:QSCL")
	field(DOLA, "SU1:CBPM:SU14:QSCL")
	field(LNK1, "SU1:CBPM:SU14:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:URSCL")
	field(DOL2, "SU1:CBPM:SU14:URSCL")
	field(DOL3, "SU1:CBPM:SU14:URSCL")
	field(DOL4, "SU1:CBPM:SU14:URSCL")
	field(DOL5, "SU1:CBPM:SU14:URSCL")
	field(DOL6, "SU1:CBPM:SU14:URSCL")
	field(DOL7, "SU1:CBPM:SU14:URSCL")
	field(DOL8, "SU1:CBPM:SU14:URSCL")
	field(DOL9, "SU1:CBPM:SU14:URSCL")
	field(DOLA, "SU1:CBPM:SU14:URSCL")
	field(LNK1, "SU1:CBPM:SU14:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:VRSCL")
	field(DOL2, "SU1:CBPM:SU14:VRSCL")
	field(DOL3, "SU1:CBPM:SU14:VRSCL")
	field(DOL4, "SU1:CBPM:SU14:VRSCL")
	field(DOL5, "SU1:CBPM:SU14:VRSCL")
	field(DOL6, "SU1:CBPM:SU14:VRSCL")
	field(DOL7, "SU1:CBPM:SU14:VRSCL")
	field(DOL8, "SU1:CBPM:SU14:VRSCL")
	field(DOL9, "SU1:CBPM:SU14:VRSCL")
	field(DOLA, "SU1:CBPM:SU14:VRSCL")
	field(LNK1, "SU1:CBPM:SU14:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14: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, "SU1:CBPM:SU14:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU14:QRSCL")
	field(DOL2, "SU1:CBPM:SU14:QRSCL")
	field(DOL3, "SU1:CBPM:SU14:QRSCL")
	field(DOL4, "SU1:CBPM:SU14:QRSCL")
	field(DOL5, "SU1:CBPM:SU14:QRSCL")
	field(DOL6, "SU1:CBPM:SU14:QRSCL")
	field(DOL7, "SU1:CBPM:SU14:QRSCL")
	field(DOL8, "SU1:CBPM:SU14:QRSCL")
	field(DOL9, "SU1:CBPM:SU14:QRSCL")
	field(DOLA, "SU1:CBPM:SU14:QRSCL")
	field(LNK1, "SU1:CBPM:SU14:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU14:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU14:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU14:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU14:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU14:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU14:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU14:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU14:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU14:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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, "SU1:CBPM:SU14: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,  "SU1:CBPM:SU14:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU14:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU14:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU14:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU14:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU14:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU14:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU14:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU15:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU15:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU15:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU15:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 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, "SU1:CBPM:SU15:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 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, "SU1:CBPM:SU15:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU15:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU15:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU15:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU15:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C14 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU15:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C14 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:PRENV")
}

record(waveform, "SU1:CBPM:SU15:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C14 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU15:ENVU")
}

record(subArray, "SU1:CBPM:SU15:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU15:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU15:ENVV")
}

record(subArray, "SU1:CBPM:SU15:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU15:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU15:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C14 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU15:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU15:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU15:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C14 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU15:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU15:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU15:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU15:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU15:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU15:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU15:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU15:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU15:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "14")
#field(INPB, "SU1:CBPM:SU15:FC_REF")
#field(INPC, "SU1:CBPM:SU15:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU15:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU15:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU15:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU15:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU15:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU15:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU15:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU15:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU15:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU15:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU15:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU15:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU15:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU15:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU15:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU15:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C14S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU15:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU15:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU15:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU15:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU15:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C14S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU15:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU15:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU15:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU15:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU15:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU15:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU15:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU15:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU15:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU15:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU15:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "14")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU15:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:URER_SLOW")
}

record(ai, "SU1:CBPM:SU15:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU15:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU15:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU15:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU15:VRER 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, "SU1:CBPM:SU15:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 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, "SU1:CBPM:SU15:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU15:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S12")
  field(FLNK, "SU1:CBPM:SU15:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU15:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU15:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU15:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C14 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU15:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 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, "SU1:CBPM:SU15:V")
}

record(ai, "SU1:CBPM:SU15:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU15:PINC")
}

record(ai, "SU1:CBPM:SU15:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU15:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C14S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU15:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU15:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU15:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU15:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU15:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU15:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU15:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU15:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU15:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C14 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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S15")
  field(PINI, "YES")
}

record(stringin, "CBPM_S15:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU15")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU15:X_SLOW") {
#alias("SU1:CBPM:SU15:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU15:X MS")
  field(FLNK, "SU1:CBPM:SU15:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU15:Y_SLOW") {
#alias("SU1:CBPM:SU15:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU15:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU15:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU15:TMIT_SLOW") {
#alias("SU1:CBPM:SU15:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU15:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU15:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU15:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU15:SIMC PP")
}

record(calcout, "SU1:CBPM:SU15:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "14")
#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, "SU1:CBPM:SU15:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU15:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU15:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU15:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU15:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU15:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU15:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU15:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C14 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, "SU1:CBPM:SU15:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU15:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x4000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU15:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x4000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU15:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU15:TMIT")
  field(INPB, "SU1:CBPM:SU15:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU15:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU15:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU15:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU15:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU15:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU15:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU15:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU15:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU15:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU15:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU15:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU15:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU15:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU15:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU15:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU15:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU15:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU15:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU15:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C14 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU15:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU15:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU15:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU15:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:UOFF")
	field(DOL2, "SU1:CBPM:SU15:UOFF")
	field(DOL3, "SU1:CBPM:SU15:UOFF")
	field(DOL4, "SU1:CBPM:SU15:UOFF")
	field(DOL5, "SU1:CBPM:SU15:UOFF")
	field(DOL6, "SU1:CBPM:SU15:UOFF")
	field(DOL7, "SU1:CBPM:SU15:UOFF")
	field(DOL8, "SU1:CBPM:SU15:UOFF")
	field(DOL9, "SU1:CBPM:SU15:UOFF")
	field(DOLA, "SU1:CBPM:SU15:UOFF")
	field(LNK1, "SU1:CBPM:SU15:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU15:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU15:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:VOFF")
	field(DOL2, "SU1:CBPM:SU15:VOFF")
	field(DOL3, "SU1:CBPM:SU15:VOFF")
	field(DOL4, "SU1:CBPM:SU15:VOFF")
	field(DOL5, "SU1:CBPM:SU15:VOFF")
	field(DOL6, "SU1:CBPM:SU15:VOFF")
	field(DOL7, "SU1:CBPM:SU15:VOFF")
	field(DOL8, "SU1:CBPM:SU15:VOFF")
	field(DOL9, "SU1:CBPM:SU15:VOFF")
	field(DOLA, "SU1:CBPM:SU15:VOFF")
	field(LNK1, "SU1:CBPM:SU15:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU15:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU15:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:USCL")
	field(DOL2, "SU1:CBPM:SU15:USCL")
	field(DOL3, "SU1:CBPM:SU15:USCL")
	field(DOL4, "SU1:CBPM:SU15:USCL")
	field(DOL5, "SU1:CBPM:SU15:USCL")
	field(DOL6, "SU1:CBPM:SU15:USCL")
	field(DOL7, "SU1:CBPM:SU15:USCL")
	field(DOL8, "SU1:CBPM:SU15:USCL")
	field(DOL9, "SU1:CBPM:SU15:USCL")
	field(DOLA, "SU1:CBPM:SU15:USCL")
	field(LNK1, "SU1:CBPM:SU15:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:VSCL")
	field(DOL2, "SU1:CBPM:SU15:VSCL")
	field(DOL3, "SU1:CBPM:SU15:VSCL")
	field(DOL4, "SU1:CBPM:SU15:VSCL")
	field(DOL5, "SU1:CBPM:SU15:VSCL")
	field(DOL6, "SU1:CBPM:SU15:VSCL")
	field(DOL7, "SU1:CBPM:SU15:VSCL")
	field(DOL8, "SU1:CBPM:SU15:VSCL")
	field(DOL9, "SU1:CBPM:SU15:VSCL")
	field(DOLA, "SU1:CBPM:SU15:VSCL")
	field(LNK1, "SU1:CBPM:SU15:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:PHI")
	field(DOL2, "SU1:CBPM:SU15:PHI")
	field(DOL3, "SU1:CBPM:SU15:PHI")
	field(DOL4, "SU1:CBPM:SU15:PHI")
	field(DOL5, "SU1:CBPM:SU15:PHI")
	field(DOL6, "SU1:CBPM:SU15:PHI")
	field(DOL7, "SU1:CBPM:SU15:PHI")
	field(DOL8, "SU1:CBPM:SU15:PHI")
	field(DOL9, "SU1:CBPM:SU15:PHI")
	field(DOLA, "SU1:CBPM:SU15:PHI")
	field(LNK1, "SU1:CBPM:SU15:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU15:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU15:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:PSI")
	field(DOL2, "SU1:CBPM:SU15:PSI")
	field(DOL3, "SU1:CBPM:SU15:PSI")
	field(DOL4, "SU1:CBPM:SU15:PSI")
	field(DOL5, "SU1:CBPM:SU15:PSI")
	field(DOL6, "SU1:CBPM:SU15:PSI")
	field(DOL7, "SU1:CBPM:SU15:PSI")
	field(DOL8, "SU1:CBPM:SU15:PSI")
	field(DOL9, "SU1:CBPM:SU15:PSI")
	field(DOLA, "SU1:CBPM:SU15:PSI")
	field(LNK1, "SU1:CBPM:SU15:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU15:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU15:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:UPHAS")
	field(DOL2, "SU1:CBPM:SU15:UPHAS")
	field(DOL3, "SU1:CBPM:SU15:UPHAS")
	field(DOL4, "SU1:CBPM:SU15:UPHAS")
	field(DOL5, "SU1:CBPM:SU15:UPHAS")
	field(DOL6, "SU1:CBPM:SU15:UPHAS")
	field(DOL7, "SU1:CBPM:SU15:UPHAS")
	field(DOL8, "SU1:CBPM:SU15:UPHAS")
	field(DOL9, "SU1:CBPM:SU15:UPHAS")
	field(DOLA, "SU1:CBPM:SU15:UPHAS")
	field(LNK1, "SU1:CBPM:SU15:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU15:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU15:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:VPHAS")
	field(DOL2, "SU1:CBPM:SU15:VPHAS")
	field(DOL3, "SU1:CBPM:SU15:VPHAS")
	field(DOL4, "SU1:CBPM:SU15:VPHAS")
	field(DOL5, "SU1:CBPM:SU15:VPHAS")
	field(DOL6, "SU1:CBPM:SU15:VPHAS")
	field(DOL7, "SU1:CBPM:SU15:VPHAS")
	field(DOL8, "SU1:CBPM:SU15:VPHAS")
	field(DOL9, "SU1:CBPM:SU15:VPHAS")
	field(DOLA, "SU1:CBPM:SU15:VPHAS")
	field(LNK1, "SU1:CBPM:SU15:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU15:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU15:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:QSCL")
	field(DOL2, "SU1:CBPM:SU15:QSCL")
	field(DOL3, "SU1:CBPM:SU15:QSCL")
	field(DOL4, "SU1:CBPM:SU15:QSCL")
	field(DOL5, "SU1:CBPM:SU15:QSCL")
	field(DOL6, "SU1:CBPM:SU15:QSCL")
	field(DOL7, "SU1:CBPM:SU15:QSCL")
	field(DOL8, "SU1:CBPM:SU15:QSCL")
	field(DOL9, "SU1:CBPM:SU15:QSCL")
	field(DOLA, "SU1:CBPM:SU15:QSCL")
	field(LNK1, "SU1:CBPM:SU15:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:URSCL")
	field(DOL2, "SU1:CBPM:SU15:URSCL")
	field(DOL3, "SU1:CBPM:SU15:URSCL")
	field(DOL4, "SU1:CBPM:SU15:URSCL")
	field(DOL5, "SU1:CBPM:SU15:URSCL")
	field(DOL6, "SU1:CBPM:SU15:URSCL")
	field(DOL7, "SU1:CBPM:SU15:URSCL")
	field(DOL8, "SU1:CBPM:SU15:URSCL")
	field(DOL9, "SU1:CBPM:SU15:URSCL")
	field(DOLA, "SU1:CBPM:SU15:URSCL")
	field(LNK1, "SU1:CBPM:SU15:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:VRSCL")
	field(DOL2, "SU1:CBPM:SU15:VRSCL")
	field(DOL3, "SU1:CBPM:SU15:VRSCL")
	field(DOL4, "SU1:CBPM:SU15:VRSCL")
	field(DOL5, "SU1:CBPM:SU15:VRSCL")
	field(DOL6, "SU1:CBPM:SU15:VRSCL")
	field(DOL7, "SU1:CBPM:SU15:VRSCL")
	field(DOL8, "SU1:CBPM:SU15:VRSCL")
	field(DOL9, "SU1:CBPM:SU15:VRSCL")
	field(DOLA, "SU1:CBPM:SU15:VRSCL")
	field(LNK1, "SU1:CBPM:SU15:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15: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, "SU1:CBPM:SU15:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU15:QRSCL")
	field(DOL2, "SU1:CBPM:SU15:QRSCL")
	field(DOL3, "SU1:CBPM:SU15:QRSCL")
	field(DOL4, "SU1:CBPM:SU15:QRSCL")
	field(DOL5, "SU1:CBPM:SU15:QRSCL")
	field(DOL6, "SU1:CBPM:SU15:QRSCL")
	field(DOL7, "SU1:CBPM:SU15:QRSCL")
	field(DOL8, "SU1:CBPM:SU15:QRSCL")
	field(DOL9, "SU1:CBPM:SU15:QRSCL")
	field(DOLA, "SU1:CBPM:SU15:QRSCL")
	field(LNK1, "SU1:CBPM:SU15:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU15:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU15:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU15:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU15:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU15:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU15:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU15:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU15:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU15:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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, "SU1:CBPM:SU15: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,  "SU1:CBPM:SU15:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU15:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU15:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU15:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU15:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU15:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU15:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU15:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU16:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU16:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU16:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU16:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 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, "SU1:CBPM:SU16:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 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, "SU1:CBPM:SU16:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU16:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU16:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU16:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU16:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU16:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C15 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:PRENV")
}

record(waveform, "SU1:CBPM:SU16:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C15 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU16:ENVU")
}

record(subArray, "SU1:CBPM:SU16:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU16:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU16:ENVV")
}

record(subArray, "SU1:CBPM:SU16:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU16:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU16:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C15 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU16:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU16:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU16:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C15 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU16:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU16:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU16:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU16:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU16:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU16:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU16:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU16:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU16:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "15")
#field(INPB, "SU1:CBPM:SU16:FC_REF")
#field(INPC, "SU1:CBPM:SU16:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU16:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU16:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU16:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU16:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU16:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU16:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU16:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU16:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU16:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU16:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU16:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU16:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU16:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU16:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU16:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU16:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C15S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU16:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU16:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU16:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU16:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU16:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C15S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU16:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU16:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU16:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU16:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU16:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU16:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU16:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU16:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU16:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU16:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU16:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "15")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU16:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:URER_SLOW")
}

record(ai, "SU1:CBPM:SU16:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU16:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU16:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU16:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU16:VRER 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, "SU1:CBPM:SU16:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 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, "SU1:CBPM:SU16:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU16:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S12")
  field(FLNK, "SU1:CBPM:SU16:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU16:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU16:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU16:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C15 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU16:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 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, "SU1:CBPM:SU16:V")
}

record(ai, "SU1:CBPM:SU16:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU16:PINC")
}

record(ai, "SU1:CBPM:SU16:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU16:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C15S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU16:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU16:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU16:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU16:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU16:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU16:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU16:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU16:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU16:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C15 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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S16")
  field(PINI, "YES")
}

record(stringin, "CBPM_S16:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU16")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU16:X_SLOW") {
#alias("SU1:CBPM:SU16:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU16:X MS")
  field(FLNK, "SU1:CBPM:SU16:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU16:Y_SLOW") {
#alias("SU1:CBPM:SU16:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU16:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU16:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU16:TMIT_SLOW") {
#alias("SU1:CBPM:SU16:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU16:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU16:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU16:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU16:SIMC PP")
}

record(calcout, "SU1:CBPM:SU16:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "15")
#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, "SU1:CBPM:SU16:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU16:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU16:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU16:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU16:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU16:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU16:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU16:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C15 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, "SU1:CBPM:SU16:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU16:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x8000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU16:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x8000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU16:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU16:TMIT")
  field(INPB, "SU1:CBPM:SU16:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU16:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU16:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU16:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU16:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU16:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU16:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU16:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU16:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU16:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU16:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU16:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU16:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU16:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU16:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU16:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU16:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU16:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU16:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU16:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU16:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU16:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU16:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU16:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:UOFF")
	field(DOL2, "SU1:CBPM:SU16:UOFF")
	field(DOL3, "SU1:CBPM:SU16:UOFF")
	field(DOL4, "SU1:CBPM:SU16:UOFF")
	field(DOL5, "SU1:CBPM:SU16:UOFF")
	field(DOL6, "SU1:CBPM:SU16:UOFF")
	field(DOL7, "SU1:CBPM:SU16:UOFF")
	field(DOL8, "SU1:CBPM:SU16:UOFF")
	field(DOL9, "SU1:CBPM:SU16:UOFF")
	field(DOLA, "SU1:CBPM:SU16:UOFF")
	field(LNK1, "SU1:CBPM:SU16:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU16:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU16:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:VOFF")
	field(DOL2, "SU1:CBPM:SU16:VOFF")
	field(DOL3, "SU1:CBPM:SU16:VOFF")
	field(DOL4, "SU1:CBPM:SU16:VOFF")
	field(DOL5, "SU1:CBPM:SU16:VOFF")
	field(DOL6, "SU1:CBPM:SU16:VOFF")
	field(DOL7, "SU1:CBPM:SU16:VOFF")
	field(DOL8, "SU1:CBPM:SU16:VOFF")
	field(DOL9, "SU1:CBPM:SU16:VOFF")
	field(DOLA, "SU1:CBPM:SU16:VOFF")
	field(LNK1, "SU1:CBPM:SU16:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU16:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU16:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:USCL")
	field(DOL2, "SU1:CBPM:SU16:USCL")
	field(DOL3, "SU1:CBPM:SU16:USCL")
	field(DOL4, "SU1:CBPM:SU16:USCL")
	field(DOL5, "SU1:CBPM:SU16:USCL")
	field(DOL6, "SU1:CBPM:SU16:USCL")
	field(DOL7, "SU1:CBPM:SU16:USCL")
	field(DOL8, "SU1:CBPM:SU16:USCL")
	field(DOL9, "SU1:CBPM:SU16:USCL")
	field(DOLA, "SU1:CBPM:SU16:USCL")
	field(LNK1, "SU1:CBPM:SU16:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:VSCL")
	field(DOL2, "SU1:CBPM:SU16:VSCL")
	field(DOL3, "SU1:CBPM:SU16:VSCL")
	field(DOL4, "SU1:CBPM:SU16:VSCL")
	field(DOL5, "SU1:CBPM:SU16:VSCL")
	field(DOL6, "SU1:CBPM:SU16:VSCL")
	field(DOL7, "SU1:CBPM:SU16:VSCL")
	field(DOL8, "SU1:CBPM:SU16:VSCL")
	field(DOL9, "SU1:CBPM:SU16:VSCL")
	field(DOLA, "SU1:CBPM:SU16:VSCL")
	field(LNK1, "SU1:CBPM:SU16:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:PHI")
	field(DOL2, "SU1:CBPM:SU16:PHI")
	field(DOL3, "SU1:CBPM:SU16:PHI")
	field(DOL4, "SU1:CBPM:SU16:PHI")
	field(DOL5, "SU1:CBPM:SU16:PHI")
	field(DOL6, "SU1:CBPM:SU16:PHI")
	field(DOL7, "SU1:CBPM:SU16:PHI")
	field(DOL8, "SU1:CBPM:SU16:PHI")
	field(DOL9, "SU1:CBPM:SU16:PHI")
	field(DOLA, "SU1:CBPM:SU16:PHI")
	field(LNK1, "SU1:CBPM:SU16:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU16:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU16:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:PSI")
	field(DOL2, "SU1:CBPM:SU16:PSI")
	field(DOL3, "SU1:CBPM:SU16:PSI")
	field(DOL4, "SU1:CBPM:SU16:PSI")
	field(DOL5, "SU1:CBPM:SU16:PSI")
	field(DOL6, "SU1:CBPM:SU16:PSI")
	field(DOL7, "SU1:CBPM:SU16:PSI")
	field(DOL8, "SU1:CBPM:SU16:PSI")
	field(DOL9, "SU1:CBPM:SU16:PSI")
	field(DOLA, "SU1:CBPM:SU16:PSI")
	field(LNK1, "SU1:CBPM:SU16:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU16:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU16:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:UPHAS")
	field(DOL2, "SU1:CBPM:SU16:UPHAS")
	field(DOL3, "SU1:CBPM:SU16:UPHAS")
	field(DOL4, "SU1:CBPM:SU16:UPHAS")
	field(DOL5, "SU1:CBPM:SU16:UPHAS")
	field(DOL6, "SU1:CBPM:SU16:UPHAS")
	field(DOL7, "SU1:CBPM:SU16:UPHAS")
	field(DOL8, "SU1:CBPM:SU16:UPHAS")
	field(DOL9, "SU1:CBPM:SU16:UPHAS")
	field(DOLA, "SU1:CBPM:SU16:UPHAS")
	field(LNK1, "SU1:CBPM:SU16:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU16:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU16:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:VPHAS")
	field(DOL2, "SU1:CBPM:SU16:VPHAS")
	field(DOL3, "SU1:CBPM:SU16:VPHAS")
	field(DOL4, "SU1:CBPM:SU16:VPHAS")
	field(DOL5, "SU1:CBPM:SU16:VPHAS")
	field(DOL6, "SU1:CBPM:SU16:VPHAS")
	field(DOL7, "SU1:CBPM:SU16:VPHAS")
	field(DOL8, "SU1:CBPM:SU16:VPHAS")
	field(DOL9, "SU1:CBPM:SU16:VPHAS")
	field(DOLA, "SU1:CBPM:SU16:VPHAS")
	field(LNK1, "SU1:CBPM:SU16:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU16:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU16:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:QSCL")
	field(DOL2, "SU1:CBPM:SU16:QSCL")
	field(DOL3, "SU1:CBPM:SU16:QSCL")
	field(DOL4, "SU1:CBPM:SU16:QSCL")
	field(DOL5, "SU1:CBPM:SU16:QSCL")
	field(DOL6, "SU1:CBPM:SU16:QSCL")
	field(DOL7, "SU1:CBPM:SU16:QSCL")
	field(DOL8, "SU1:CBPM:SU16:QSCL")
	field(DOL9, "SU1:CBPM:SU16:QSCL")
	field(DOLA, "SU1:CBPM:SU16:QSCL")
	field(LNK1, "SU1:CBPM:SU16:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:URSCL")
	field(DOL2, "SU1:CBPM:SU16:URSCL")
	field(DOL3, "SU1:CBPM:SU16:URSCL")
	field(DOL4, "SU1:CBPM:SU16:URSCL")
	field(DOL5, "SU1:CBPM:SU16:URSCL")
	field(DOL6, "SU1:CBPM:SU16:URSCL")
	field(DOL7, "SU1:CBPM:SU16:URSCL")
	field(DOL8, "SU1:CBPM:SU16:URSCL")
	field(DOL9, "SU1:CBPM:SU16:URSCL")
	field(DOLA, "SU1:CBPM:SU16:URSCL")
	field(LNK1, "SU1:CBPM:SU16:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:VRSCL")
	field(DOL2, "SU1:CBPM:SU16:VRSCL")
	field(DOL3, "SU1:CBPM:SU16:VRSCL")
	field(DOL4, "SU1:CBPM:SU16:VRSCL")
	field(DOL5, "SU1:CBPM:SU16:VRSCL")
	field(DOL6, "SU1:CBPM:SU16:VRSCL")
	field(DOL7, "SU1:CBPM:SU16:VRSCL")
	field(DOL8, "SU1:CBPM:SU16:VRSCL")
	field(DOL9, "SU1:CBPM:SU16:VRSCL")
	field(DOLA, "SU1:CBPM:SU16:VRSCL")
	field(LNK1, "SU1:CBPM:SU16:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16: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, "SU1:CBPM:SU16:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU16:QRSCL")
	field(DOL2, "SU1:CBPM:SU16:QRSCL")
	field(DOL3, "SU1:CBPM:SU16:QRSCL")
	field(DOL4, "SU1:CBPM:SU16:QRSCL")
	field(DOL5, "SU1:CBPM:SU16:QRSCL")
	field(DOL6, "SU1:CBPM:SU16:QRSCL")
	field(DOL7, "SU1:CBPM:SU16:QRSCL")
	field(DOL8, "SU1:CBPM:SU16:QRSCL")
	field(DOL9, "SU1:CBPM:SU16:QRSCL")
	field(DOLA, "SU1:CBPM:SU16:QRSCL")
	field(LNK1, "SU1:CBPM:SU16:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU16:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU16:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU16:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU16:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU16:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU16:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU16:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU16:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU16:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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, "SU1:CBPM:SU16: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,  "SU1:CBPM:SU16:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU16:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU16:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU16:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU16:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU16:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU16:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU16:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU17:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU17:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU17:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU17:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 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, "SU1:CBPM:SU17:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 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, "SU1:CBPM:SU17:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU17:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU17:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU17:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU17:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C16 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU17:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C16 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:PRENV")
}

record(waveform, "SU1:CBPM:SU17:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C16 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU17:ENVU")
}

record(subArray, "SU1:CBPM:SU17:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU17:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU17:ENVV")
}

record(subArray, "SU1:CBPM:SU17:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU17:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU17:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C16 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU17:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU17:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU17:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C16 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU17:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU17:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU17:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU17:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU17:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU17:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU17:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU17:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU17:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "16")
#field(INPB, "SU1:CBPM:SU17:FC_REF")
#field(INPC, "SU1:CBPM:SU17:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU17:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU17:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU17:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU17:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU17:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU17:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU17:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU17:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU17:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU17:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU17:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU17:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU17:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU17:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU17:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU17:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C16S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU17:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU17:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU17:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU17:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU17:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C16S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU17:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU17:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU17:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU17:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU17:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU17:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU17:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU17:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU17:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU17:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU17:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "16")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU17:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:URER_SLOW")
}

record(ai, "SU1:CBPM:SU17:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU17:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU17:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU17:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU17:VRER 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, "SU1:CBPM:SU17:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 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, "SU1:CBPM:SU17:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU17:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 S12")
  field(FLNK, "SU1:CBPM:SU17:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU17:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU17:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU17:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C16 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU17:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 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, "SU1:CBPM:SU17:V")
}

record(ai, "SU1:CBPM:SU17:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU17:PINC")
}

record(ai, "SU1:CBPM:SU17:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C16 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU17:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C16S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU17:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU17:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU17:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU17:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU17:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU17:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU17:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU17:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU17:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C16 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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S17")
  field(PINI, "YES")
}

record(stringin, "CBPM_S17:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU17")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU17:X_SLOW") {
#alias("SU1:CBPM:SU17:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU17:X MS")
  field(FLNK, "SU1:CBPM:SU17:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU17:Y_SLOW") {
#alias("SU1:CBPM:SU17:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU17:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU17:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU17:TMIT_SLOW") {
#alias("SU1:CBPM:SU17:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU17:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU17:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU17:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU17:SIMC PP")
}

record(calcout, "SU1:CBPM:SU17:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "16")
#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, "SU1:CBPM:SU17:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU17:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU17:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU17:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU17:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU17:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU17:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU17:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C16 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, "SU1:CBPM:SU17:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU17:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x10000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU17:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x10000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU17:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU17:TMIT")
  field(INPB, "SU1:CBPM:SU17:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU17:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU17:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU17:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU17:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU17:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU17:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU17:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU17:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU17:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU17:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU17:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU17:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU17:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU17:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU17:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU17:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU17:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU17:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU17:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C16 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU17:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU17:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU17:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU17:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:UOFF")
	field(DOL2, "SU1:CBPM:SU17:UOFF")
	field(DOL3, "SU1:CBPM:SU17:UOFF")
	field(DOL4, "SU1:CBPM:SU17:UOFF")
	field(DOL5, "SU1:CBPM:SU17:UOFF")
	field(DOL6, "SU1:CBPM:SU17:UOFF")
	field(DOL7, "SU1:CBPM:SU17:UOFF")
	field(DOL8, "SU1:CBPM:SU17:UOFF")
	field(DOL9, "SU1:CBPM:SU17:UOFF")
	field(DOLA, "SU1:CBPM:SU17:UOFF")
	field(LNK1, "SU1:CBPM:SU17:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU17:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU17:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:VOFF")
	field(DOL2, "SU1:CBPM:SU17:VOFF")
	field(DOL3, "SU1:CBPM:SU17:VOFF")
	field(DOL4, "SU1:CBPM:SU17:VOFF")
	field(DOL5, "SU1:CBPM:SU17:VOFF")
	field(DOL6, "SU1:CBPM:SU17:VOFF")
	field(DOL7, "SU1:CBPM:SU17:VOFF")
	field(DOL8, "SU1:CBPM:SU17:VOFF")
	field(DOL9, "SU1:CBPM:SU17:VOFF")
	field(DOLA, "SU1:CBPM:SU17:VOFF")
	field(LNK1, "SU1:CBPM:SU17:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU17:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU17:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:USCL")
	field(DOL2, "SU1:CBPM:SU17:USCL")
	field(DOL3, "SU1:CBPM:SU17:USCL")
	field(DOL4, "SU1:CBPM:SU17:USCL")
	field(DOL5, "SU1:CBPM:SU17:USCL")
	field(DOL6, "SU1:CBPM:SU17:USCL")
	field(DOL7, "SU1:CBPM:SU17:USCL")
	field(DOL8, "SU1:CBPM:SU17:USCL")
	field(DOL9, "SU1:CBPM:SU17:USCL")
	field(DOLA, "SU1:CBPM:SU17:USCL")
	field(LNK1, "SU1:CBPM:SU17:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:VSCL")
	field(DOL2, "SU1:CBPM:SU17:VSCL")
	field(DOL3, "SU1:CBPM:SU17:VSCL")
	field(DOL4, "SU1:CBPM:SU17:VSCL")
	field(DOL5, "SU1:CBPM:SU17:VSCL")
	field(DOL6, "SU1:CBPM:SU17:VSCL")
	field(DOL7, "SU1:CBPM:SU17:VSCL")
	field(DOL8, "SU1:CBPM:SU17:VSCL")
	field(DOL9, "SU1:CBPM:SU17:VSCL")
	field(DOLA, "SU1:CBPM:SU17:VSCL")
	field(LNK1, "SU1:CBPM:SU17:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:PHI")
	field(DOL2, "SU1:CBPM:SU17:PHI")
	field(DOL3, "SU1:CBPM:SU17:PHI")
	field(DOL4, "SU1:CBPM:SU17:PHI")
	field(DOL5, "SU1:CBPM:SU17:PHI")
	field(DOL6, "SU1:CBPM:SU17:PHI")
	field(DOL7, "SU1:CBPM:SU17:PHI")
	field(DOL8, "SU1:CBPM:SU17:PHI")
	field(DOL9, "SU1:CBPM:SU17:PHI")
	field(DOLA, "SU1:CBPM:SU17:PHI")
	field(LNK1, "SU1:CBPM:SU17:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU17:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU17:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:PSI")
	field(DOL2, "SU1:CBPM:SU17:PSI")
	field(DOL3, "SU1:CBPM:SU17:PSI")
	field(DOL4, "SU1:CBPM:SU17:PSI")
	field(DOL5, "SU1:CBPM:SU17:PSI")
	field(DOL6, "SU1:CBPM:SU17:PSI")
	field(DOL7, "SU1:CBPM:SU17:PSI")
	field(DOL8, "SU1:CBPM:SU17:PSI")
	field(DOL9, "SU1:CBPM:SU17:PSI")
	field(DOLA, "SU1:CBPM:SU17:PSI")
	field(LNK1, "SU1:CBPM:SU17:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU17:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU17:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:UPHAS")
	field(DOL2, "SU1:CBPM:SU17:UPHAS")
	field(DOL3, "SU1:CBPM:SU17:UPHAS")
	field(DOL4, "SU1:CBPM:SU17:UPHAS")
	field(DOL5, "SU1:CBPM:SU17:UPHAS")
	field(DOL6, "SU1:CBPM:SU17:UPHAS")
	field(DOL7, "SU1:CBPM:SU17:UPHAS")
	field(DOL8, "SU1:CBPM:SU17:UPHAS")
	field(DOL9, "SU1:CBPM:SU17:UPHAS")
	field(DOLA, "SU1:CBPM:SU17:UPHAS")
	field(LNK1, "SU1:CBPM:SU17:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU17:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU17:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:VPHAS")
	field(DOL2, "SU1:CBPM:SU17:VPHAS")
	field(DOL3, "SU1:CBPM:SU17:VPHAS")
	field(DOL4, "SU1:CBPM:SU17:VPHAS")
	field(DOL5, "SU1:CBPM:SU17:VPHAS")
	field(DOL6, "SU1:CBPM:SU17:VPHAS")
	field(DOL7, "SU1:CBPM:SU17:VPHAS")
	field(DOL8, "SU1:CBPM:SU17:VPHAS")
	field(DOL9, "SU1:CBPM:SU17:VPHAS")
	field(DOLA, "SU1:CBPM:SU17:VPHAS")
	field(LNK1, "SU1:CBPM:SU17:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU17:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU17:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:QSCL")
	field(DOL2, "SU1:CBPM:SU17:QSCL")
	field(DOL3, "SU1:CBPM:SU17:QSCL")
	field(DOL4, "SU1:CBPM:SU17:QSCL")
	field(DOL5, "SU1:CBPM:SU17:QSCL")
	field(DOL6, "SU1:CBPM:SU17:QSCL")
	field(DOL7, "SU1:CBPM:SU17:QSCL")
	field(DOL8, "SU1:CBPM:SU17:QSCL")
	field(DOL9, "SU1:CBPM:SU17:QSCL")
	field(DOLA, "SU1:CBPM:SU17:QSCL")
	field(LNK1, "SU1:CBPM:SU17:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:URSCL")
	field(DOL2, "SU1:CBPM:SU17:URSCL")
	field(DOL3, "SU1:CBPM:SU17:URSCL")
	field(DOL4, "SU1:CBPM:SU17:URSCL")
	field(DOL5, "SU1:CBPM:SU17:URSCL")
	field(DOL6, "SU1:CBPM:SU17:URSCL")
	field(DOL7, "SU1:CBPM:SU17:URSCL")
	field(DOL8, "SU1:CBPM:SU17:URSCL")
	field(DOL9, "SU1:CBPM:SU17:URSCL")
	field(DOLA, "SU1:CBPM:SU17:URSCL")
	field(LNK1, "SU1:CBPM:SU17:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:VRSCL")
	field(DOL2, "SU1:CBPM:SU17:VRSCL")
	field(DOL3, "SU1:CBPM:SU17:VRSCL")
	field(DOL4, "SU1:CBPM:SU17:VRSCL")
	field(DOL5, "SU1:CBPM:SU17:VRSCL")
	field(DOL6, "SU1:CBPM:SU17:VRSCL")
	field(DOL7, "SU1:CBPM:SU17:VRSCL")
	field(DOL8, "SU1:CBPM:SU17:VRSCL")
	field(DOL9, "SU1:CBPM:SU17:VRSCL")
	field(DOLA, "SU1:CBPM:SU17:VRSCL")
	field(LNK1, "SU1:CBPM:SU17:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17: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, "SU1:CBPM:SU17:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU17:QRSCL")
	field(DOL2, "SU1:CBPM:SU17:QRSCL")
	field(DOL3, "SU1:CBPM:SU17:QRSCL")
	field(DOL4, "SU1:CBPM:SU17:QRSCL")
	field(DOL5, "SU1:CBPM:SU17:QRSCL")
	field(DOL6, "SU1:CBPM:SU17:QRSCL")
	field(DOL7, "SU1:CBPM:SU17:QRSCL")
	field(DOL8, "SU1:CBPM:SU17:QRSCL")
	field(DOL9, "SU1:CBPM:SU17:QRSCL")
	field(DOLA, "SU1:CBPM:SU17:QRSCL")
	field(LNK1, "SU1:CBPM:SU17:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU17:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU17:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU17:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU17:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU17:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU17:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU17:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU17:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU17:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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, "SU1:CBPM:SU17: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,  "SU1:CBPM:SU17:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU17:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU17:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU17:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU17:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU17:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU17:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU17:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU17:RCVR_GAIN CP")
}
# per BPM database for cavity BPMs
#
#
#
##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################
record(ai, "SU1:CBPM:SU18:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU18:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU18:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "SU1:CBPM:SU18:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 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, "SU1:CBPM:SU18:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 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, "SU1:CBPM:SU18:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "SU1:CBPM:SU18:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU18:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "SU1:CBPM:SU18:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "SU1:CBPM:SU18:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C17 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "SU1:CBPM:SU18:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C17 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:PRENV")
}

record(waveform, "SU1:CBPM:SU18:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C17 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "SU1:CBPM:SU18:ENVU")
}

record(subArray, "SU1:CBPM:SU18:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU18:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "SU1:CBPM:SU18:ENVV")
}

record(subArray, "SU1:CBPM:SU18:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "SU1:CBPM:SU18:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "SU1:CBPM:SU18:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C17 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "SU1:CBPM:SU18:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "SU1:CBPM:SU18:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "SU1:CBPM:SU18:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C17 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "SU1:CBPM:SU18:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "SU1:CBPM:SU18:RSTA.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU18:TMIT.SEVR MS NPP")
  field(INPC, "SU1:CBPM:SU18:Y.SEVR    MS NPP")
  field(INPD, "SU1:CBPM:SU18:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "SU1:CBPM:SU18:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "SU1:CBPM:SU18:RSTA_ALH.SEVR MS NPP")
  field(INPB, "SU1:CBPM:SU18:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "SU1:CBPM:SU18:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "17")
#field(INPB, "SU1:CBPM:SU18:FC_REF")
#field(INPC, "SU1:CBPM:SU18:BW_REF")
  field(D, "0")
#field(E,    "30")
#field(F,    "12")
#field(G,    "0")
#field(H,    "30")
  field(I, "1")
  field(J, "0")
  field(K, "125")
  field(PREC, "1")
  field(EGU, "MHz")
  field(PINI, "YES")
  info(autosaveFields, "B C E F H I")
}

record(ao, "SU1:CBPM:SU18:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU18:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU18:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU18:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "SU1:CBPM:SU18:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "SU1:CBPM:SU18:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "SU1:CBPM:SU18:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "SU1:CBPM:SU18:FILT.B NPP")
#field(LNK1, "SU1:CBPM:SU18:FC_REF NPP")
#field(DOL2, "SU1:CBPM:SU18:FILT.C NPP")
#field(LNK2, "SU1:CBPM:SU18:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "SU1:CBPM:SU18:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU18:UPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU18:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU18:VPHAS_SEQ")
}

record(ao, "SU1:CBPM:SU18:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C17S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU18:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "SU1:CBPM:SU18:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU18:UPHAS_OUT")
  field(OUT, "SU1:CBPM:SU18:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU18:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C17S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "SU1:CBPM:SU18:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "SU1:CBPM:SU18:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "SU1:CBPM:SU18:VPHAS_OUT")
  field(OUT, "SU1:CBPM:SU18:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "SU1:CBPM:SU18:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU18:QSCL_SEQ")
}

record(ao, "SU1:CBPM:SU18:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:URSCL_SEQ")
}

record(ao, "SU1:CBPM:SU18:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:VRSCL_SEQ")
}

record(ao, "SU1:CBPM:SU18:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "SU1:CBPM:SU18:QRSCL_SEQ")
}

record(sub, "SU1:CBPM:SU18:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "17")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "SU1:CBPM:SU18:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:URER_SLOW")
}

record(ai, "SU1:CBPM:SU18:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:UIMR_SLOW")
}

record(ai, "SU1:CBPM:SU18:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VRER_SLOW")
}

record(ai, "SU1:CBPM:SU18:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VIMR_SLOW")
}

record(ai, "SU1:CBPM:SU18:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "SU1:CBPM:SU18:VRER 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, "SU1:CBPM:SU18:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 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, "SU1:CBPM:SU18:Y")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU18:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 S12")
  field(FLNK, "SU1:CBPM:SU18:TMIT")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "ASLO LOLO LOW HIGH HIHI HHSV LLSV")
}

record(ai, "SU1:CBPM:SU18:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "SU1:CBPM:SU18:EFX.PROC")
  field(ASG,  "")
  field(TSE, "-2")
  info(autosaveFields, "LOLO LOW HIGH HIHI HHSV LLSV ")
}


######################################
# HEAD of diagnostics processing chain
######################################

# leave RWAV in it's own lockset; don't FLNK
# to 'U' & friends
record(waveform, "SU1:CBPM:SU18:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C17 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "SU1:CBPM:SU18:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 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, "SU1:CBPM:SU18:V")
}

record(ai, "SU1:CBPM:SU18:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "SU1:CBPM:SU18:PINC")
}

record(ai, "SU1:CBPM:SU18:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C17 S10")
  field(SCAN, "Passive")
}

record(longin, "SU1:CBPM:SU18:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C17S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "SU1:CBPM:SU18:RSTA_ALH")
}


record(calc, "SU1:CBPM:SU18:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "SU1:CBPM:SU18:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:PHI_SEQ")
}

record(ao, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:PSI_SEQ")
}

#record(dfanout, "SU1:CBPM:SU18:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "SU1:CBPM:SU18:USCL PP MS")
#  field(OUTB, "SU1:CBPM:SU18:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:UOFF_SEQ")
}

record(ao, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VOFF_SEQ")
}

record(ao, "SU1:CBPM:SU18:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:USCL_SEQ")
}

record(ao, "SU1:CBPM:SU18:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:VSCL_SEQ")
}


record(mbbo, "SU1:CBPM:SU18:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C17 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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_S18")
  field(PINI, "YES")
}

record(stringin, "CBPM_S18:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "SU1:CBPM:SU18")
  field(PINI, "YES")
}

record(ai, "SU1:CBPM:SU18:X_SLOW") {
#alias("SU1:CBPM:SU18:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU18:X MS")
  field(FLNK, "SU1:CBPM:SU18:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU18:Y_SLOW") {
#alias("SU1:CBPM:SU18:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "SU1:CBPM:SU18:Y NPP MS")
  field(FLNK, "SU1:CBPM:SU18:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "SU1:CBPM:SU18:TMIT_SLOW") {
#alias("SU1:CBPM:SU18:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "SU1:CBPM:SU18:TMIT NPP MS")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

######################################
# Simulation Parameters + Control
######################################

# switch off simulation when going off-line
record(calcout, "SU1:CBPM:SU18:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "SU1:CBPM:SU18:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "SU1:CBPM:SU18:SIMC PP")
}

record(calcout, "SU1:CBPM:SU18:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "17")
#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, "SU1:CBPM:SU18:USCL")
  field(INPL, "0")
}

# Switch simulation record SU1:CBPM:SU18:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "SU1:CBPM:SU18:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU18:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "SU1:CBPM:SU18:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "SU1:CBPM:SU18:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "SU1:CBPM:SU18:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "SU1:CBPM:SU18:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C17 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, "SU1:CBPM:SU18:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "SU1:CBPM:SU18:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x20000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "SU1:CBPM:SU18:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x20000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "SU1:CBPM:SU18:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "SU1:CBPM:SU18:TMIT")
  field(INPB, "SU1:CBPM:SU18:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "SU1:CBPM:SU18:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "SU1:CBPM:SU18:MPSIGNRCALC PP")
  field(ZSV, "NO_ALARM")
  field(OSV, "MAJOR")
  field(ZNAM, "Not ignored")
  field(ONAM, "Ignored")
  field(PINI, "YES")
  field(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, "SU1:CBPM:SU18:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "SU1:CBPM:SU18:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "SU1:CBPM:SU18:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "SU1:CBPM:SU18:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "SU1:CBPM:SU18:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "SU1:CBPM:SU18:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU18:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU18:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "SU1:CBPM:SU18:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "SU1:CBPM:SU18:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "SU1:CBPM:SU18:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "SU1:CBPM:SU18:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU18:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU18:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU18:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU18:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "SU1:CBPM:SU18:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C17 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "SU1:CBPM:SU18:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:SIM.L     PP")
  field(LNK4, "SU1:CBPM:SU18:SIM.SCAN  PP")

  field(LNK5, "SU1:CBPM:SU18:SIM.SCAN  PP")
  field(LNK6, "SU1:CBPM:SU18:SIM.L     PP")
  field(LNK7, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:UOFF")
	field(DOL2, "SU1:CBPM:SU18:UOFF")
	field(DOL3, "SU1:CBPM:SU18:UOFF")
	field(DOL4, "SU1:CBPM:SU18:UOFF")
	field(DOL5, "SU1:CBPM:SU18:UOFF")
	field(DOL6, "SU1:CBPM:SU18:UOFF")
	field(DOL7, "SU1:CBPM:SU18:UOFF")
	field(DOL8, "SU1:CBPM:SU18:UOFF")
	field(DOL9, "SU1:CBPM:SU18:UOFF")
	field(DOLA, "SU1:CBPM:SU18:UOFF")
	field(LNK1, "SU1:CBPM:SU18:UOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:UOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:UOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:UOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:UOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:UOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:UOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:UOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:UOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:UOFF_SEL")
	field(OUTA, "SU1:CBPM:SU18:U.AOFF CA")
	field(OUTB, "SU1:CBPM:SU18:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:UOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:VOFF")
	field(DOL2, "SU1:CBPM:SU18:VOFF")
	field(DOL3, "SU1:CBPM:SU18:VOFF")
	field(DOL4, "SU1:CBPM:SU18:VOFF")
	field(DOL5, "SU1:CBPM:SU18:VOFF")
	field(DOL6, "SU1:CBPM:SU18:VOFF")
	field(DOL7, "SU1:CBPM:SU18:VOFF")
	field(DOL8, "SU1:CBPM:SU18:VOFF")
	field(DOL9, "SU1:CBPM:SU18:VOFF")
	field(DOLA, "SU1:CBPM:SU18:VOFF")
	field(LNK1, "SU1:CBPM:SU18:VOFF_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:VOFF_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:VOFF_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:VOFF_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:VOFF_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:VOFF_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:VOFF_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:VOFF_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:VOFF_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:VOFF_SEL")
	field(OUTA, "SU1:CBPM:SU18:V.AOFF CA")
	field(OUTB, "SU1:CBPM:SU18:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:VOFF_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:USCL")
	field(DOL2, "SU1:CBPM:SU18:USCL")
	field(DOL3, "SU1:CBPM:SU18:USCL")
	field(DOL4, "SU1:CBPM:SU18:USCL")
	field(DOL5, "SU1:CBPM:SU18:USCL")
	field(DOL6, "SU1:CBPM:SU18:USCL")
	field(DOL7, "SU1:CBPM:SU18:USCL")
	field(DOL8, "SU1:CBPM:SU18:USCL")
	field(DOL9, "SU1:CBPM:SU18:USCL")
	field(DOLA, "SU1:CBPM:SU18:USCL")
	field(LNK1, "SU1:CBPM:SU18:USCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:USCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:USCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:USCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:USCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:USCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:USCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:USCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:USCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:USCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:U.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:USCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:VSCL")
	field(DOL2, "SU1:CBPM:SU18:VSCL")
	field(DOL3, "SU1:CBPM:SU18:VSCL")
	field(DOL4, "SU1:CBPM:SU18:VSCL")
	field(DOL5, "SU1:CBPM:SU18:VSCL")
	field(DOL6, "SU1:CBPM:SU18:VSCL")
	field(DOL7, "SU1:CBPM:SU18:VSCL")
	field(DOL8, "SU1:CBPM:SU18:VSCL")
	field(DOL9, "SU1:CBPM:SU18:VSCL")
	field(DOLA, "SU1:CBPM:SU18:VSCL")
	field(LNK1, "SU1:CBPM:SU18:VSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:VSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:VSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:VSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:VSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:VSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:VSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:VSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:VSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:VSCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:V.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:VSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:PHI")
	field(DOL2, "SU1:CBPM:SU18:PHI")
	field(DOL3, "SU1:CBPM:SU18:PHI")
	field(DOL4, "SU1:CBPM:SU18:PHI")
	field(DOL5, "SU1:CBPM:SU18:PHI")
	field(DOL6, "SU1:CBPM:SU18:PHI")
	field(DOL7, "SU1:CBPM:SU18:PHI")
	field(DOL8, "SU1:CBPM:SU18:PHI")
	field(DOL9, "SU1:CBPM:SU18:PHI")
	field(DOLA, "SU1:CBPM:SU18:PHI")
	field(LNK1, "SU1:CBPM:SU18:PHI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:PHI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:PHI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:PHI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:PHI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:PHI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:PHI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:PHI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:PHI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:PHI_SEL")
	field(OUTA, "SU1:CBPM:SU18:CALC.E CA")
	field(OUTB, "SU1:CBPM:SU18:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:PHI_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:PSI")
	field(DOL2, "SU1:CBPM:SU18:PSI")
	field(DOL3, "SU1:CBPM:SU18:PSI")
	field(DOL4, "SU1:CBPM:SU18:PSI")
	field(DOL5, "SU1:CBPM:SU18:PSI")
	field(DOL6, "SU1:CBPM:SU18:PSI")
	field(DOL7, "SU1:CBPM:SU18:PSI")
	field(DOL8, "SU1:CBPM:SU18:PSI")
	field(DOL9, "SU1:CBPM:SU18:PSI")
	field(DOLA, "SU1:CBPM:SU18:PSI")
	field(LNK1, "SU1:CBPM:SU18:PSI_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:PSI_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:PSI_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:PSI_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:PSI_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:PSI_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:PSI_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:PSI_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:PSI_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:PSI_SEL")
	field(OUTA, "SU1:CBPM:SU18:CALC.F CA")
	field(OUTB, "SU1:CBPM:SU18:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:PSI_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:UPHAS")
	field(DOL2, "SU1:CBPM:SU18:UPHAS")
	field(DOL3, "SU1:CBPM:SU18:UPHAS")
	field(DOL4, "SU1:CBPM:SU18:UPHAS")
	field(DOL5, "SU1:CBPM:SU18:UPHAS")
	field(DOL6, "SU1:CBPM:SU18:UPHAS")
	field(DOL7, "SU1:CBPM:SU18:UPHAS")
	field(DOL8, "SU1:CBPM:SU18:UPHAS")
	field(DOL9, "SU1:CBPM:SU18:UPHAS")
	field(DOLA, "SU1:CBPM:SU18:UPHAS")
	field(LNK1, "SU1:CBPM:SU18:UPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:UPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:UPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:UPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:UPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:UPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:UPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:UPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:UPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:UPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU18:UPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU18:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:UPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:VPHAS")
	field(DOL2, "SU1:CBPM:SU18:VPHAS")
	field(DOL3, "SU1:CBPM:SU18:VPHAS")
	field(DOL4, "SU1:CBPM:SU18:VPHAS")
	field(DOL5, "SU1:CBPM:SU18:VPHAS")
	field(DOL6, "SU1:CBPM:SU18:VPHAS")
	field(DOL7, "SU1:CBPM:SU18:VPHAS")
	field(DOL8, "SU1:CBPM:SU18:VPHAS")
	field(DOL9, "SU1:CBPM:SU18:VPHAS")
	field(DOLA, "SU1:CBPM:SU18:VPHAS")
	field(LNK1, "SU1:CBPM:SU18:VPHAS_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:VPHAS_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:VPHAS_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:VPHAS_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:VPHAS_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:VPHAS_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:VPHAS_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:VPHAS_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:VPHAS_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:VPHAS_SEL")
	field(OUTA, "SU1:CBPM:SU18:VPHAS_OUT PP NMS")
	field(OUTB, "SU1:CBPM:SU18:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:VPHAS_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:QSCL")
	field(DOL2, "SU1:CBPM:SU18:QSCL")
	field(DOL3, "SU1:CBPM:SU18:QSCL")
	field(DOL4, "SU1:CBPM:SU18:QSCL")
	field(DOL5, "SU1:CBPM:SU18:QSCL")
	field(DOL6, "SU1:CBPM:SU18:QSCL")
	field(DOL7, "SU1:CBPM:SU18:QSCL")
	field(DOL8, "SU1:CBPM:SU18:QSCL")
	field(DOL9, "SU1:CBPM:SU18:QSCL")
	field(DOLA, "SU1:CBPM:SU18:QSCL")
	field(LNK1, "SU1:CBPM:SU18:QSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:QSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:QSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:QSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:QSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:QSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:QSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:QSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:QSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:QSCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:TMIT.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:QSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:URSCL")
	field(DOL2, "SU1:CBPM:SU18:URSCL")
	field(DOL3, "SU1:CBPM:SU18:URSCL")
	field(DOL4, "SU1:CBPM:SU18:URSCL")
	field(DOL5, "SU1:CBPM:SU18:URSCL")
	field(DOL6, "SU1:CBPM:SU18:URSCL")
	field(DOL7, "SU1:CBPM:SU18:URSCL")
	field(DOL8, "SU1:CBPM:SU18:URSCL")
	field(DOL9, "SU1:CBPM:SU18:URSCL")
	field(DOLA, "SU1:CBPM:SU18:URSCL")
	field(LNK1, "SU1:CBPM:SU18:URSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:URSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:URSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:URSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:URSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:URSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:URSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:URSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:URSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:URSCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:URMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:URSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:VRSCL")
	field(DOL2, "SU1:CBPM:SU18:VRSCL")
	field(DOL3, "SU1:CBPM:SU18:VRSCL")
	field(DOL4, "SU1:CBPM:SU18:VRSCL")
	field(DOL5, "SU1:CBPM:SU18:VRSCL")
	field(DOL6, "SU1:CBPM:SU18:VRSCL")
	field(DOL7, "SU1:CBPM:SU18:VRSCL")
	field(DOL8, "SU1:CBPM:SU18:VRSCL")
	field(DOL9, "SU1:CBPM:SU18:VRSCL")
	field(DOLA, "SU1:CBPM:SU18:VRSCL")
	field(LNK1, "SU1:CBPM:SU18:VRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:VRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:VRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:VRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:VRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:VRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:VRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:VRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:VRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:VRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:VRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:VRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18: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, "SU1:CBPM:SU18:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "SU1:CBPM:SU18:QRSCL")
	field(DOL2, "SU1:CBPM:SU18:QRSCL")
	field(DOL3, "SU1:CBPM:SU18:QRSCL")
	field(DOL4, "SU1:CBPM:SU18:QRSCL")
	field(DOL5, "SU1:CBPM:SU18:QRSCL")
	field(DOL6, "SU1:CBPM:SU18:QRSCL")
	field(DOL7, "SU1:CBPM:SU18:QRSCL")
	field(DOL8, "SU1:CBPM:SU18:QRSCL")
	field(DOL9, "SU1:CBPM:SU18:QRSCL")
	field(DOLA, "SU1:CBPM:SU18:QRSCL")
	field(LNK1, "SU1:CBPM:SU18:QRSCL_SEL.A PP")
	field(LNK2, "SU1:CBPM:SU18:QRSCL_SEL.B PP")
	field(LNK3, "SU1:CBPM:SU18:QRSCL_SEL.C PP")
	field(LNK4, "SU1:CBPM:SU18:QRSCL_SEL.D PP")
	field(LNK5, "SU1:CBPM:SU18:QRSCL_SEL.E PP")
	field(LNK6, "SU1:CBPM:SU18:QRSCL_SEL.F PP")
	field(LNK7, "SU1:CBPM:SU18:QRSCL_SEL.G PP")
	field(LNK8, "SU1:CBPM:SU18:QRSCL_SEL.H PP")
	field(LNK9, "SU1:CBPM:SU18:QRSCL_SEL.I PP")
	field(LNKA, "SU1:CBPM:SU18:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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, "SU1:CBPM:SU18: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,  "SU1:CBPM:SU18:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "SU1:CBPM:SU18:QRSCL_SEL")
	field(OUTA, "SU1:CBPM:SU18:RRMS.ASLO CA")
	field(OUTB, "SU1:CBPM:SU18:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "SU1:CBPM:SU18:QRSCL_CTRL")
{
	field(INPA, "SU1:CBPM:SU18:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "SU1:CBPM:SU18:QRSCL_SEL.L PP")
}
record(longout,"SU1:CBPM:SU18:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "SU1:CBPM:SU18:RCVR_GAIN CP")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU01:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C0S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU01:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C0S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU01:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C0S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU01:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C0S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU02:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C1S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU02:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C1S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU02:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C1S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU02:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C1S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU03:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C2S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU03:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C2S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU03:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C2S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU03:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C2S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU04:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C3S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU04:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C3S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU04:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C3S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU04:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C3S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU05:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C4S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU05:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C4S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU05:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C4S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU05:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C4S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU06:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C5S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU06:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C5S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU06:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C5S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU06:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C5S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU07:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C6S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU07:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C6S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU07:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C6S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU07:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C6S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU08:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C7S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU08:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C7S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU08:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C7S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU08:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C7S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU09:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C8S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU09:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C8S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU09:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C8S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU09:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C8S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU10:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C9S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU10:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C9S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU10:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C9S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU10:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C9S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU11:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C10S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU11:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C10S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU11:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C10S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU11:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C10S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU12:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C11S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU12:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C11S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU12:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C11S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU12:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C11S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU13:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C12S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU13:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C12S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU13:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C12S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU13:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C12S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU14:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C13S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU14:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C13S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU14:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C13S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU14:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C13S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU15:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU15:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU15:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU15:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU16:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU16:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU16:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU16:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU17:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C16S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU17:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C16S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU17:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C16S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU17:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C16S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "SU1:CBPM:SU18:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C17S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "SU1:CBPM:SU18:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C17S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "SU1:CBPM:SU18:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C17S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "SU1:CBPM:SU18:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C17S0@0x4FC(8)")
	field(PINI, "YES")
}
