# per IOC database for stripline BPMs

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

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

record(sub, "VIOC:HU19: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU17:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S12")
  field(FLNK, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H17:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU17")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU17:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU18:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S12")
  field(FLNK, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H18:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU18")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU18:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU19:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S12")
  field(FLNK, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H19:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU19")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU19:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU20:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S12")
  field(FLNK, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H20:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU20")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU20:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU21:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S12")
  field(FLNK, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H21:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU21")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU21:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU22:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S12")
  field(FLNK, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H22:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU22")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU22:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU23:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C6 S12")
  field(FLNK, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H23:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU23")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU23:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU24:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C7 S12")
  field(FLNK, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H24:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU24")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU24:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU25:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C8 S12")
  field(FLNK, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H25:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU25")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU25:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU26:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C9 S12")
  field(FLNK, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H26:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU26")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU26:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(sub, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27:URER_SLOW")
}

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

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

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

record(ai, "HU1:CBPM:HU27:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C10 S12")
  field(FLNK, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27:V")
}

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

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

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


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

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

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

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

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

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

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

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

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


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

record(stringin, "CBPM_H27:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU27")
  field(PINI, "YES")
}

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

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

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

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

# Switch simulation record HU1:CBPM:HU27:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

record(ai, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PRENV")
}

record(waveform, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:ENVU")
}

record(subArray, "HU1:CBPM:HU28:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU28:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU28:ENVV")
}

record(subArray, "HU1:CBPM:HU28:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU28:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU28:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU28:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU28:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU28:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU28:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU28:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU28:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU28:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU28:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "11")
#field(INPB, "HU1:CBPM:HU28:FC_REF")
#field(INPC, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU28:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU28:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU28:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU28:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU28:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU28:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU28:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU28:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU28:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU28:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU28:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU28:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU28:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU28:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU28:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU28:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU28:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU28:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU28:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU28:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU28:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU28:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU28:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU28:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU28:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU28:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:URER_SLOW")
}

record(ai, "HU1:CBPM:HU28:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU28:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU28:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU28:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S12")
  field(FLNK, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:V")
}

record(ai, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PINC")
}

record(ai, "HU1:CBPM:HU28:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C11 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU28:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU28:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU28:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU28:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU28:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU28:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU28:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H28")
  field(PINI, "YES")
}

record(stringin, "CBPM_H28:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU28")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU28:X_SLOW") {
#alias("HU1:CBPM:HU28:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU28:X MS")
  field(FLNK, "HU1:CBPM:HU28:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU28:Y_SLOW") {
#alias("HU1:CBPM:HU28:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU28:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU28:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU28:TMIT_SLOW") {
#alias("HU1:CBPM:HU28:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU28:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU28:SIMC PP")
}

record(calcout, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU28:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU28:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU28:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU28:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU28:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU28:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU28:TMIT")
  field(INPB, "HU1:CBPM:HU28:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU28:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU28:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU28:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU28:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU28:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU28:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU28:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU28:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU28:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU28:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU28:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU28:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU28:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU28:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:UOFF")
	field(DOL2, "HU1:CBPM:HU28:UOFF")
	field(DOL3, "HU1:CBPM:HU28:UOFF")
	field(DOL4, "HU1:CBPM:HU28:UOFF")
	field(DOL5, "HU1:CBPM:HU28:UOFF")
	field(DOL6, "HU1:CBPM:HU28:UOFF")
	field(DOL7, "HU1:CBPM:HU28:UOFF")
	field(DOL8, "HU1:CBPM:HU28:UOFF")
	field(DOL9, "HU1:CBPM:HU28:UOFF")
	field(DOLA, "HU1:CBPM:HU28:UOFF")
	field(LNK1, "HU1:CBPM:HU28:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU28:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU28:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:VOFF")
	field(DOL2, "HU1:CBPM:HU28:VOFF")
	field(DOL3, "HU1:CBPM:HU28:VOFF")
	field(DOL4, "HU1:CBPM:HU28:VOFF")
	field(DOL5, "HU1:CBPM:HU28:VOFF")
	field(DOL6, "HU1:CBPM:HU28:VOFF")
	field(DOL7, "HU1:CBPM:HU28:VOFF")
	field(DOL8, "HU1:CBPM:HU28:VOFF")
	field(DOL9, "HU1:CBPM:HU28:VOFF")
	field(DOLA, "HU1:CBPM:HU28:VOFF")
	field(LNK1, "HU1:CBPM:HU28:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU28:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU28:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:USCL")
	field(DOL2, "HU1:CBPM:HU28:USCL")
	field(DOL3, "HU1:CBPM:HU28:USCL")
	field(DOL4, "HU1:CBPM:HU28:USCL")
	field(DOL5, "HU1:CBPM:HU28:USCL")
	field(DOL6, "HU1:CBPM:HU28:USCL")
	field(DOL7, "HU1:CBPM:HU28:USCL")
	field(DOL8, "HU1:CBPM:HU28:USCL")
	field(DOL9, "HU1:CBPM:HU28:USCL")
	field(DOLA, "HU1:CBPM:HU28:USCL")
	field(LNK1, "HU1:CBPM:HU28:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:VSCL")
	field(DOL2, "HU1:CBPM:HU28:VSCL")
	field(DOL3, "HU1:CBPM:HU28:VSCL")
	field(DOL4, "HU1:CBPM:HU28:VSCL")
	field(DOL5, "HU1:CBPM:HU28:VSCL")
	field(DOL6, "HU1:CBPM:HU28:VSCL")
	field(DOL7, "HU1:CBPM:HU28:VSCL")
	field(DOL8, "HU1:CBPM:HU28:VSCL")
	field(DOL9, "HU1:CBPM:HU28:VSCL")
	field(DOLA, "HU1:CBPM:HU28:VSCL")
	field(LNK1, "HU1:CBPM:HU28:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:PHI")
	field(DOL2, "HU1:CBPM:HU28:PHI")
	field(DOL3, "HU1:CBPM:HU28:PHI")
	field(DOL4, "HU1:CBPM:HU28:PHI")
	field(DOL5, "HU1:CBPM:HU28:PHI")
	field(DOL6, "HU1:CBPM:HU28:PHI")
	field(DOL7, "HU1:CBPM:HU28:PHI")
	field(DOL8, "HU1:CBPM:HU28:PHI")
	field(DOL9, "HU1:CBPM:HU28:PHI")
	field(DOLA, "HU1:CBPM:HU28:PHI")
	field(LNK1, "HU1:CBPM:HU28:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU28:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU28:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:PSI")
	field(DOL2, "HU1:CBPM:HU28:PSI")
	field(DOL3, "HU1:CBPM:HU28:PSI")
	field(DOL4, "HU1:CBPM:HU28:PSI")
	field(DOL5, "HU1:CBPM:HU28:PSI")
	field(DOL6, "HU1:CBPM:HU28:PSI")
	field(DOL7, "HU1:CBPM:HU28:PSI")
	field(DOL8, "HU1:CBPM:HU28:PSI")
	field(DOL9, "HU1:CBPM:HU28:PSI")
	field(DOLA, "HU1:CBPM:HU28:PSI")
	field(LNK1, "HU1:CBPM:HU28:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU28:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU28:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:UPHAS")
	field(DOL2, "HU1:CBPM:HU28:UPHAS")
	field(DOL3, "HU1:CBPM:HU28:UPHAS")
	field(DOL4, "HU1:CBPM:HU28:UPHAS")
	field(DOL5, "HU1:CBPM:HU28:UPHAS")
	field(DOL6, "HU1:CBPM:HU28:UPHAS")
	field(DOL7, "HU1:CBPM:HU28:UPHAS")
	field(DOL8, "HU1:CBPM:HU28:UPHAS")
	field(DOL9, "HU1:CBPM:HU28:UPHAS")
	field(DOLA, "HU1:CBPM:HU28:UPHAS")
	field(LNK1, "HU1:CBPM:HU28:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU28:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU28:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:VPHAS")
	field(DOL2, "HU1:CBPM:HU28:VPHAS")
	field(DOL3, "HU1:CBPM:HU28:VPHAS")
	field(DOL4, "HU1:CBPM:HU28:VPHAS")
	field(DOL5, "HU1:CBPM:HU28:VPHAS")
	field(DOL6, "HU1:CBPM:HU28:VPHAS")
	field(DOL7, "HU1:CBPM:HU28:VPHAS")
	field(DOL8, "HU1:CBPM:HU28:VPHAS")
	field(DOL9, "HU1:CBPM:HU28:VPHAS")
	field(DOLA, "HU1:CBPM:HU28:VPHAS")
	field(LNK1, "HU1:CBPM:HU28:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU28:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU28:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:QSCL")
	field(DOL2, "HU1:CBPM:HU28:QSCL")
	field(DOL3, "HU1:CBPM:HU28:QSCL")
	field(DOL4, "HU1:CBPM:HU28:QSCL")
	field(DOL5, "HU1:CBPM:HU28:QSCL")
	field(DOL6, "HU1:CBPM:HU28:QSCL")
	field(DOL7, "HU1:CBPM:HU28:QSCL")
	field(DOL8, "HU1:CBPM:HU28:QSCL")
	field(DOL9, "HU1:CBPM:HU28:QSCL")
	field(DOLA, "HU1:CBPM:HU28:QSCL")
	field(LNK1, "HU1:CBPM:HU28:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:URSCL")
	field(DOL2, "HU1:CBPM:HU28:URSCL")
	field(DOL3, "HU1:CBPM:HU28:URSCL")
	field(DOL4, "HU1:CBPM:HU28:URSCL")
	field(DOL5, "HU1:CBPM:HU28:URSCL")
	field(DOL6, "HU1:CBPM:HU28:URSCL")
	field(DOL7, "HU1:CBPM:HU28:URSCL")
	field(DOL8, "HU1:CBPM:HU28:URSCL")
	field(DOL9, "HU1:CBPM:HU28:URSCL")
	field(DOLA, "HU1:CBPM:HU28:URSCL")
	field(LNK1, "HU1:CBPM:HU28:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:VRSCL")
	field(DOL2, "HU1:CBPM:HU28:VRSCL")
	field(DOL3, "HU1:CBPM:HU28:VRSCL")
	field(DOL4, "HU1:CBPM:HU28:VRSCL")
	field(DOL5, "HU1:CBPM:HU28:VRSCL")
	field(DOL6, "HU1:CBPM:HU28:VRSCL")
	field(DOL7, "HU1:CBPM:HU28:VRSCL")
	field(DOL8, "HU1:CBPM:HU28:VRSCL")
	field(DOL9, "HU1:CBPM:HU28:VRSCL")
	field(DOLA, "HU1:CBPM:HU28:VRSCL")
	field(LNK1, "HU1:CBPM:HU28:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28: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, "HU1:CBPM:HU28:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU28:QRSCL")
	field(DOL2, "HU1:CBPM:HU28:QRSCL")
	field(DOL3, "HU1:CBPM:HU28:QRSCL")
	field(DOL4, "HU1:CBPM:HU28:QRSCL")
	field(DOL5, "HU1:CBPM:HU28:QRSCL")
	field(DOL6, "HU1:CBPM:HU28:QRSCL")
	field(DOL7, "HU1:CBPM:HU28:QRSCL")
	field(DOL8, "HU1:CBPM:HU28:QRSCL")
	field(DOL9, "HU1:CBPM:HU28:QRSCL")
	field(DOLA, "HU1:CBPM:HU28:QRSCL")
	field(LNK1, "HU1:CBPM:HU28:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU28:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU28:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU28:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU28:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU28:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU28:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU28:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU28:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU28:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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,  "HU1:CBPM:HU28:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU28:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU28:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU28:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU28:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU28:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU28:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU28:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU28: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PRENV")
}

record(waveform, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:ENVU")
}

record(subArray, "HU1:CBPM:HU29:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU29:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU29:ENVV")
}

record(subArray, "HU1:CBPM:HU29:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU29:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU29:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU29:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU29:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU29:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU29:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU29:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU29:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU29:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU29:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "12")
#field(INPB, "HU1:CBPM:HU29:FC_REF")
#field(INPC, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU29:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU29:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU29:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU29:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU29:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU29:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU29:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU29:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU29:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU29:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU29:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU29:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU29:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU29:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU29:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU29:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU29:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU29:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU29:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU29:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU29:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU29:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU29:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU29:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU29:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU29:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:URER_SLOW")
}

record(ai, "HU1:CBPM:HU29:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU29:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU29:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU29:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S12")
  field(FLNK, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:V")
}

record(ai, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PINC")
}

record(ai, "HU1:CBPM:HU29:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU29:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU29:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU29:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU29:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU29:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU29:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU29:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H29")
  field(PINI, "YES")
}

record(stringin, "CBPM_H29:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU29")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU29:X_SLOW") {
#alias("HU1:CBPM:HU29:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU29:X MS")
  field(FLNK, "HU1:CBPM:HU29:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU29:Y_SLOW") {
#alias("HU1:CBPM:HU29:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU29:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU29:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU29:TMIT_SLOW") {
#alias("HU1:CBPM:HU29:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU29:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU29:SIMC PP")
}

record(calcout, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU29:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU29:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU29:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU29:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU29:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU29:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU29:TMIT")
  field(INPB, "HU1:CBPM:HU29:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU29:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU29:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU29:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU29:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU29:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU29:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU29:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU29:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU29:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU29:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU29:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU29:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU29:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU29:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:UOFF")
	field(DOL2, "HU1:CBPM:HU29:UOFF")
	field(DOL3, "HU1:CBPM:HU29:UOFF")
	field(DOL4, "HU1:CBPM:HU29:UOFF")
	field(DOL5, "HU1:CBPM:HU29:UOFF")
	field(DOL6, "HU1:CBPM:HU29:UOFF")
	field(DOL7, "HU1:CBPM:HU29:UOFF")
	field(DOL8, "HU1:CBPM:HU29:UOFF")
	field(DOL9, "HU1:CBPM:HU29:UOFF")
	field(DOLA, "HU1:CBPM:HU29:UOFF")
	field(LNK1, "HU1:CBPM:HU29:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU29:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU29:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:VOFF")
	field(DOL2, "HU1:CBPM:HU29:VOFF")
	field(DOL3, "HU1:CBPM:HU29:VOFF")
	field(DOL4, "HU1:CBPM:HU29:VOFF")
	field(DOL5, "HU1:CBPM:HU29:VOFF")
	field(DOL6, "HU1:CBPM:HU29:VOFF")
	field(DOL7, "HU1:CBPM:HU29:VOFF")
	field(DOL8, "HU1:CBPM:HU29:VOFF")
	field(DOL9, "HU1:CBPM:HU29:VOFF")
	field(DOLA, "HU1:CBPM:HU29:VOFF")
	field(LNK1, "HU1:CBPM:HU29:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU29:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU29:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:USCL")
	field(DOL2, "HU1:CBPM:HU29:USCL")
	field(DOL3, "HU1:CBPM:HU29:USCL")
	field(DOL4, "HU1:CBPM:HU29:USCL")
	field(DOL5, "HU1:CBPM:HU29:USCL")
	field(DOL6, "HU1:CBPM:HU29:USCL")
	field(DOL7, "HU1:CBPM:HU29:USCL")
	field(DOL8, "HU1:CBPM:HU29:USCL")
	field(DOL9, "HU1:CBPM:HU29:USCL")
	field(DOLA, "HU1:CBPM:HU29:USCL")
	field(LNK1, "HU1:CBPM:HU29:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:VSCL")
	field(DOL2, "HU1:CBPM:HU29:VSCL")
	field(DOL3, "HU1:CBPM:HU29:VSCL")
	field(DOL4, "HU1:CBPM:HU29:VSCL")
	field(DOL5, "HU1:CBPM:HU29:VSCL")
	field(DOL6, "HU1:CBPM:HU29:VSCL")
	field(DOL7, "HU1:CBPM:HU29:VSCL")
	field(DOL8, "HU1:CBPM:HU29:VSCL")
	field(DOL9, "HU1:CBPM:HU29:VSCL")
	field(DOLA, "HU1:CBPM:HU29:VSCL")
	field(LNK1, "HU1:CBPM:HU29:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:PHI")
	field(DOL2, "HU1:CBPM:HU29:PHI")
	field(DOL3, "HU1:CBPM:HU29:PHI")
	field(DOL4, "HU1:CBPM:HU29:PHI")
	field(DOL5, "HU1:CBPM:HU29:PHI")
	field(DOL6, "HU1:CBPM:HU29:PHI")
	field(DOL7, "HU1:CBPM:HU29:PHI")
	field(DOL8, "HU1:CBPM:HU29:PHI")
	field(DOL9, "HU1:CBPM:HU29:PHI")
	field(DOLA, "HU1:CBPM:HU29:PHI")
	field(LNK1, "HU1:CBPM:HU29:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU29:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU29:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:PSI")
	field(DOL2, "HU1:CBPM:HU29:PSI")
	field(DOL3, "HU1:CBPM:HU29:PSI")
	field(DOL4, "HU1:CBPM:HU29:PSI")
	field(DOL5, "HU1:CBPM:HU29:PSI")
	field(DOL6, "HU1:CBPM:HU29:PSI")
	field(DOL7, "HU1:CBPM:HU29:PSI")
	field(DOL8, "HU1:CBPM:HU29:PSI")
	field(DOL9, "HU1:CBPM:HU29:PSI")
	field(DOLA, "HU1:CBPM:HU29:PSI")
	field(LNK1, "HU1:CBPM:HU29:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU29:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU29:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:UPHAS")
	field(DOL2, "HU1:CBPM:HU29:UPHAS")
	field(DOL3, "HU1:CBPM:HU29:UPHAS")
	field(DOL4, "HU1:CBPM:HU29:UPHAS")
	field(DOL5, "HU1:CBPM:HU29:UPHAS")
	field(DOL6, "HU1:CBPM:HU29:UPHAS")
	field(DOL7, "HU1:CBPM:HU29:UPHAS")
	field(DOL8, "HU1:CBPM:HU29:UPHAS")
	field(DOL9, "HU1:CBPM:HU29:UPHAS")
	field(DOLA, "HU1:CBPM:HU29:UPHAS")
	field(LNK1, "HU1:CBPM:HU29:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU29:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU29:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:VPHAS")
	field(DOL2, "HU1:CBPM:HU29:VPHAS")
	field(DOL3, "HU1:CBPM:HU29:VPHAS")
	field(DOL4, "HU1:CBPM:HU29:VPHAS")
	field(DOL5, "HU1:CBPM:HU29:VPHAS")
	field(DOL6, "HU1:CBPM:HU29:VPHAS")
	field(DOL7, "HU1:CBPM:HU29:VPHAS")
	field(DOL8, "HU1:CBPM:HU29:VPHAS")
	field(DOL9, "HU1:CBPM:HU29:VPHAS")
	field(DOLA, "HU1:CBPM:HU29:VPHAS")
	field(LNK1, "HU1:CBPM:HU29:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU29:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU29:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:QSCL")
	field(DOL2, "HU1:CBPM:HU29:QSCL")
	field(DOL3, "HU1:CBPM:HU29:QSCL")
	field(DOL4, "HU1:CBPM:HU29:QSCL")
	field(DOL5, "HU1:CBPM:HU29:QSCL")
	field(DOL6, "HU1:CBPM:HU29:QSCL")
	field(DOL7, "HU1:CBPM:HU29:QSCL")
	field(DOL8, "HU1:CBPM:HU29:QSCL")
	field(DOL9, "HU1:CBPM:HU29:QSCL")
	field(DOLA, "HU1:CBPM:HU29:QSCL")
	field(LNK1, "HU1:CBPM:HU29:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:URSCL")
	field(DOL2, "HU1:CBPM:HU29:URSCL")
	field(DOL3, "HU1:CBPM:HU29:URSCL")
	field(DOL4, "HU1:CBPM:HU29:URSCL")
	field(DOL5, "HU1:CBPM:HU29:URSCL")
	field(DOL6, "HU1:CBPM:HU29:URSCL")
	field(DOL7, "HU1:CBPM:HU29:URSCL")
	field(DOL8, "HU1:CBPM:HU29:URSCL")
	field(DOL9, "HU1:CBPM:HU29:URSCL")
	field(DOLA, "HU1:CBPM:HU29:URSCL")
	field(LNK1, "HU1:CBPM:HU29:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:VRSCL")
	field(DOL2, "HU1:CBPM:HU29:VRSCL")
	field(DOL3, "HU1:CBPM:HU29:VRSCL")
	field(DOL4, "HU1:CBPM:HU29:VRSCL")
	field(DOL5, "HU1:CBPM:HU29:VRSCL")
	field(DOL6, "HU1:CBPM:HU29:VRSCL")
	field(DOL7, "HU1:CBPM:HU29:VRSCL")
	field(DOL8, "HU1:CBPM:HU29:VRSCL")
	field(DOL9, "HU1:CBPM:HU29:VRSCL")
	field(DOLA, "HU1:CBPM:HU29:VRSCL")
	field(LNK1, "HU1:CBPM:HU29:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29: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, "HU1:CBPM:HU29:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU29:QRSCL")
	field(DOL2, "HU1:CBPM:HU29:QRSCL")
	field(DOL3, "HU1:CBPM:HU29:QRSCL")
	field(DOL4, "HU1:CBPM:HU29:QRSCL")
	field(DOL5, "HU1:CBPM:HU29:QRSCL")
	field(DOL6, "HU1:CBPM:HU29:QRSCL")
	field(DOL7, "HU1:CBPM:HU29:QRSCL")
	field(DOL8, "HU1:CBPM:HU29:QRSCL")
	field(DOL9, "HU1:CBPM:HU29:QRSCL")
	field(DOLA, "HU1:CBPM:HU29:QRSCL")
	field(LNK1, "HU1:CBPM:HU29:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU29:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU29:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU29:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU29:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU29:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU29:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU29:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU29:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU29:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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,  "HU1:CBPM:HU29:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU29:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU29:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU29:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU29:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU29:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU29:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU29:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU29: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PRENV")
}

record(waveform, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:ENVU")
}

record(subArray, "HU1:CBPM:HU30:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU30:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU30:ENVV")
}

record(subArray, "HU1:CBPM:HU30:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU30:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU30:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU30:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU30:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU30:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU30:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU30:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU30:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU30:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU30:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "13")
#field(INPB, "HU1:CBPM:HU30:FC_REF")
#field(INPC, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU30:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU30:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU30:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU30:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU30:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU30:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU30:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU30:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU30:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU30:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU30:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU30:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU30:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU30:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU30:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU30:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU30:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU30:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU30:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU30:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU30:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU30:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU30:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU30:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU30:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU30:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:URER_SLOW")
}

record(ai, "HU1:CBPM:HU30:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU30:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU30:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU30:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S12")
  field(FLNK, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:V")
}

record(ai, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PINC")
}

record(ai, "HU1:CBPM:HU30:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU30:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU30:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU30:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU30:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU30:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU30:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU30:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H30")
  field(PINI, "YES")
}

record(stringin, "CBPM_H30:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU30")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU30:X_SLOW") {
#alias("HU1:CBPM:HU30:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU30:X MS")
  field(FLNK, "HU1:CBPM:HU30:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU30:Y_SLOW") {
#alias("HU1:CBPM:HU30:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU30:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU30:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU30:TMIT_SLOW") {
#alias("HU1:CBPM:HU30:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU30:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU30:SIMC PP")
}

record(calcout, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU30:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU30:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU30:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU30:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU30:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU30:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU30:TMIT")
  field(INPB, "HU1:CBPM:HU30:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU30:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU30:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU30:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU30:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU30:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU30:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU30:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU30:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU30:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU30:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU30:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU30:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU30:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU30:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:UOFF")
	field(DOL2, "HU1:CBPM:HU30:UOFF")
	field(DOL3, "HU1:CBPM:HU30:UOFF")
	field(DOL4, "HU1:CBPM:HU30:UOFF")
	field(DOL5, "HU1:CBPM:HU30:UOFF")
	field(DOL6, "HU1:CBPM:HU30:UOFF")
	field(DOL7, "HU1:CBPM:HU30:UOFF")
	field(DOL8, "HU1:CBPM:HU30:UOFF")
	field(DOL9, "HU1:CBPM:HU30:UOFF")
	field(DOLA, "HU1:CBPM:HU30:UOFF")
	field(LNK1, "HU1:CBPM:HU30:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU30:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU30:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:VOFF")
	field(DOL2, "HU1:CBPM:HU30:VOFF")
	field(DOL3, "HU1:CBPM:HU30:VOFF")
	field(DOL4, "HU1:CBPM:HU30:VOFF")
	field(DOL5, "HU1:CBPM:HU30:VOFF")
	field(DOL6, "HU1:CBPM:HU30:VOFF")
	field(DOL7, "HU1:CBPM:HU30:VOFF")
	field(DOL8, "HU1:CBPM:HU30:VOFF")
	field(DOL9, "HU1:CBPM:HU30:VOFF")
	field(DOLA, "HU1:CBPM:HU30:VOFF")
	field(LNK1, "HU1:CBPM:HU30:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU30:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU30:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:USCL")
	field(DOL2, "HU1:CBPM:HU30:USCL")
	field(DOL3, "HU1:CBPM:HU30:USCL")
	field(DOL4, "HU1:CBPM:HU30:USCL")
	field(DOL5, "HU1:CBPM:HU30:USCL")
	field(DOL6, "HU1:CBPM:HU30:USCL")
	field(DOL7, "HU1:CBPM:HU30:USCL")
	field(DOL8, "HU1:CBPM:HU30:USCL")
	field(DOL9, "HU1:CBPM:HU30:USCL")
	field(DOLA, "HU1:CBPM:HU30:USCL")
	field(LNK1, "HU1:CBPM:HU30:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:VSCL")
	field(DOL2, "HU1:CBPM:HU30:VSCL")
	field(DOL3, "HU1:CBPM:HU30:VSCL")
	field(DOL4, "HU1:CBPM:HU30:VSCL")
	field(DOL5, "HU1:CBPM:HU30:VSCL")
	field(DOL6, "HU1:CBPM:HU30:VSCL")
	field(DOL7, "HU1:CBPM:HU30:VSCL")
	field(DOL8, "HU1:CBPM:HU30:VSCL")
	field(DOL9, "HU1:CBPM:HU30:VSCL")
	field(DOLA, "HU1:CBPM:HU30:VSCL")
	field(LNK1, "HU1:CBPM:HU30:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:PHI")
	field(DOL2, "HU1:CBPM:HU30:PHI")
	field(DOL3, "HU1:CBPM:HU30:PHI")
	field(DOL4, "HU1:CBPM:HU30:PHI")
	field(DOL5, "HU1:CBPM:HU30:PHI")
	field(DOL6, "HU1:CBPM:HU30:PHI")
	field(DOL7, "HU1:CBPM:HU30:PHI")
	field(DOL8, "HU1:CBPM:HU30:PHI")
	field(DOL9, "HU1:CBPM:HU30:PHI")
	field(DOLA, "HU1:CBPM:HU30:PHI")
	field(LNK1, "HU1:CBPM:HU30:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU30:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU30:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:PSI")
	field(DOL2, "HU1:CBPM:HU30:PSI")
	field(DOL3, "HU1:CBPM:HU30:PSI")
	field(DOL4, "HU1:CBPM:HU30:PSI")
	field(DOL5, "HU1:CBPM:HU30:PSI")
	field(DOL6, "HU1:CBPM:HU30:PSI")
	field(DOL7, "HU1:CBPM:HU30:PSI")
	field(DOL8, "HU1:CBPM:HU30:PSI")
	field(DOL9, "HU1:CBPM:HU30:PSI")
	field(DOLA, "HU1:CBPM:HU30:PSI")
	field(LNK1, "HU1:CBPM:HU30:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU30:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU30:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:UPHAS")
	field(DOL2, "HU1:CBPM:HU30:UPHAS")
	field(DOL3, "HU1:CBPM:HU30:UPHAS")
	field(DOL4, "HU1:CBPM:HU30:UPHAS")
	field(DOL5, "HU1:CBPM:HU30:UPHAS")
	field(DOL6, "HU1:CBPM:HU30:UPHAS")
	field(DOL7, "HU1:CBPM:HU30:UPHAS")
	field(DOL8, "HU1:CBPM:HU30:UPHAS")
	field(DOL9, "HU1:CBPM:HU30:UPHAS")
	field(DOLA, "HU1:CBPM:HU30:UPHAS")
	field(LNK1, "HU1:CBPM:HU30:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU30:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU30:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:VPHAS")
	field(DOL2, "HU1:CBPM:HU30:VPHAS")
	field(DOL3, "HU1:CBPM:HU30:VPHAS")
	field(DOL4, "HU1:CBPM:HU30:VPHAS")
	field(DOL5, "HU1:CBPM:HU30:VPHAS")
	field(DOL6, "HU1:CBPM:HU30:VPHAS")
	field(DOL7, "HU1:CBPM:HU30:VPHAS")
	field(DOL8, "HU1:CBPM:HU30:VPHAS")
	field(DOL9, "HU1:CBPM:HU30:VPHAS")
	field(DOLA, "HU1:CBPM:HU30:VPHAS")
	field(LNK1, "HU1:CBPM:HU30:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU30:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU30:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:QSCL")
	field(DOL2, "HU1:CBPM:HU30:QSCL")
	field(DOL3, "HU1:CBPM:HU30:QSCL")
	field(DOL4, "HU1:CBPM:HU30:QSCL")
	field(DOL5, "HU1:CBPM:HU30:QSCL")
	field(DOL6, "HU1:CBPM:HU30:QSCL")
	field(DOL7, "HU1:CBPM:HU30:QSCL")
	field(DOL8, "HU1:CBPM:HU30:QSCL")
	field(DOL9, "HU1:CBPM:HU30:QSCL")
	field(DOLA, "HU1:CBPM:HU30:QSCL")
	field(LNK1, "HU1:CBPM:HU30:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:URSCL")
	field(DOL2, "HU1:CBPM:HU30:URSCL")
	field(DOL3, "HU1:CBPM:HU30:URSCL")
	field(DOL4, "HU1:CBPM:HU30:URSCL")
	field(DOL5, "HU1:CBPM:HU30:URSCL")
	field(DOL6, "HU1:CBPM:HU30:URSCL")
	field(DOL7, "HU1:CBPM:HU30:URSCL")
	field(DOL8, "HU1:CBPM:HU30:URSCL")
	field(DOL9, "HU1:CBPM:HU30:URSCL")
	field(DOLA, "HU1:CBPM:HU30:URSCL")
	field(LNK1, "HU1:CBPM:HU30:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:VRSCL")
	field(DOL2, "HU1:CBPM:HU30:VRSCL")
	field(DOL3, "HU1:CBPM:HU30:VRSCL")
	field(DOL4, "HU1:CBPM:HU30:VRSCL")
	field(DOL5, "HU1:CBPM:HU30:VRSCL")
	field(DOL6, "HU1:CBPM:HU30:VRSCL")
	field(DOL7, "HU1:CBPM:HU30:VRSCL")
	field(DOL8, "HU1:CBPM:HU30:VRSCL")
	field(DOL9, "HU1:CBPM:HU30:VRSCL")
	field(DOLA, "HU1:CBPM:HU30:VRSCL")
	field(LNK1, "HU1:CBPM:HU30:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30: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, "HU1:CBPM:HU30:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU30:QRSCL")
	field(DOL2, "HU1:CBPM:HU30:QRSCL")
	field(DOL3, "HU1:CBPM:HU30:QRSCL")
	field(DOL4, "HU1:CBPM:HU30:QRSCL")
	field(DOL5, "HU1:CBPM:HU30:QRSCL")
	field(DOL6, "HU1:CBPM:HU30:QRSCL")
	field(DOL7, "HU1:CBPM:HU30:QRSCL")
	field(DOL8, "HU1:CBPM:HU30:QRSCL")
	field(DOL9, "HU1:CBPM:HU30:QRSCL")
	field(DOLA, "HU1:CBPM:HU30:QRSCL")
	field(LNK1, "HU1:CBPM:HU30:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU30:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU30:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU30:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU30:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU30:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU30:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU30:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU30:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU30:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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,  "HU1:CBPM:HU30:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU30:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU30:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU30:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU30:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU30:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU30:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU30:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU30: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PRENV")
}

record(waveform, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:ENVU")
}

record(subArray, "HU1:CBPM:HU31:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU31:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU31:ENVV")
}

record(subArray, "HU1:CBPM:HU31:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU31:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU31:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU31:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU31:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU31:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU31:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU31:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU31:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU31:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU31:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "14")
#field(INPB, "HU1:CBPM:HU31:FC_REF")
#field(INPC, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU31:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU31:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU31:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU31:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU31:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU31:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU31:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU31:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU31:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU31:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU31:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU31:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU31:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU31:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU31:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU31:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU31:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU31:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU31:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU31:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU31:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU31:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU31:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU31:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU31:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU31:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:URER_SLOW")
}

record(ai, "HU1:CBPM:HU31:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU31:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU31:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU31:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S12")
  field(FLNK, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:V")
}

record(ai, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PINC")
}

record(ai, "HU1:CBPM:HU31:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU31:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU31:RSTA")
  field(INPB, "0x30F")
  field(HIHI, "1")
  field(LOLO, "-1")
  field(HHSV, "MAJOR")
  field(LLSV, "MAJOR")
  field(SCAN, "Passive")
}

######################################
# Input/Parameteres
######################################

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU31:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU31:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU31:VSCL PP MS")
#  field(VAL, "12")
#  field(EGU, "mm")
#  field(PREC, "4")
#  field(LOPR, "5")
#  field(HOPR, "15")
#  field(PINI, "YES")
#}

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU31:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU31:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H31")
  field(PINI, "YES")
}

record(stringin, "CBPM_H31:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU31")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU31:X_SLOW") {
#alias("HU1:CBPM:HU31:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU31:X MS")
  field(FLNK, "HU1:CBPM:HU31:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU31:Y_SLOW") {
#alias("HU1:CBPM:HU31:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU31:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU31:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU31:TMIT_SLOW") {
#alias("HU1:CBPM:HU31:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU31:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU31:SIMC PP")
}

record(calcout, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU31:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU31:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU31:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31:SIM.C PP")
  field(VAL, "0.")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ao, "HU1:CBPM:HU31:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU31:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU31:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU31:TMIT")
  field(INPB, "HU1:CBPM:HU31:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU31:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU31:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU31:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU31:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU31:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU31:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU31:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU31:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU31:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU31:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU31:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU31:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU31:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU31:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:UOFF")
	field(DOL2, "HU1:CBPM:HU31:UOFF")
	field(DOL3, "HU1:CBPM:HU31:UOFF")
	field(DOL4, "HU1:CBPM:HU31:UOFF")
	field(DOL5, "HU1:CBPM:HU31:UOFF")
	field(DOL6, "HU1:CBPM:HU31:UOFF")
	field(DOL7, "HU1:CBPM:HU31:UOFF")
	field(DOL8, "HU1:CBPM:HU31:UOFF")
	field(DOL9, "HU1:CBPM:HU31:UOFF")
	field(DOLA, "HU1:CBPM:HU31:UOFF")
	field(LNK1, "HU1:CBPM:HU31:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU31:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU31:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:VOFF")
	field(DOL2, "HU1:CBPM:HU31:VOFF")
	field(DOL3, "HU1:CBPM:HU31:VOFF")
	field(DOL4, "HU1:CBPM:HU31:VOFF")
	field(DOL5, "HU1:CBPM:HU31:VOFF")
	field(DOL6, "HU1:CBPM:HU31:VOFF")
	field(DOL7, "HU1:CBPM:HU31:VOFF")
	field(DOL8, "HU1:CBPM:HU31:VOFF")
	field(DOL9, "HU1:CBPM:HU31:VOFF")
	field(DOLA, "HU1:CBPM:HU31:VOFF")
	field(LNK1, "HU1:CBPM:HU31:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU31:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU31:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:USCL")
	field(DOL2, "HU1:CBPM:HU31:USCL")
	field(DOL3, "HU1:CBPM:HU31:USCL")
	field(DOL4, "HU1:CBPM:HU31:USCL")
	field(DOL5, "HU1:CBPM:HU31:USCL")
	field(DOL6, "HU1:CBPM:HU31:USCL")
	field(DOL7, "HU1:CBPM:HU31:USCL")
	field(DOL8, "HU1:CBPM:HU31:USCL")
	field(DOL9, "HU1:CBPM:HU31:USCL")
	field(DOLA, "HU1:CBPM:HU31:USCL")
	field(LNK1, "HU1:CBPM:HU31:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:VSCL")
	field(DOL2, "HU1:CBPM:HU31:VSCL")
	field(DOL3, "HU1:CBPM:HU31:VSCL")
	field(DOL4, "HU1:CBPM:HU31:VSCL")
	field(DOL5, "HU1:CBPM:HU31:VSCL")
	field(DOL6, "HU1:CBPM:HU31:VSCL")
	field(DOL7, "HU1:CBPM:HU31:VSCL")
	field(DOL8, "HU1:CBPM:HU31:VSCL")
	field(DOL9, "HU1:CBPM:HU31:VSCL")
	field(DOLA, "HU1:CBPM:HU31:VSCL")
	field(LNK1, "HU1:CBPM:HU31:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:PHI")
	field(DOL2, "HU1:CBPM:HU31:PHI")
	field(DOL3, "HU1:CBPM:HU31:PHI")
	field(DOL4, "HU1:CBPM:HU31:PHI")
	field(DOL5, "HU1:CBPM:HU31:PHI")
	field(DOL6, "HU1:CBPM:HU31:PHI")
	field(DOL7, "HU1:CBPM:HU31:PHI")
	field(DOL8, "HU1:CBPM:HU31:PHI")
	field(DOL9, "HU1:CBPM:HU31:PHI")
	field(DOLA, "HU1:CBPM:HU31:PHI")
	field(LNK1, "HU1:CBPM:HU31:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU31:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU31:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:PSI")
	field(DOL2, "HU1:CBPM:HU31:PSI")
	field(DOL3, "HU1:CBPM:HU31:PSI")
	field(DOL4, "HU1:CBPM:HU31:PSI")
	field(DOL5, "HU1:CBPM:HU31:PSI")
	field(DOL6, "HU1:CBPM:HU31:PSI")
	field(DOL7, "HU1:CBPM:HU31:PSI")
	field(DOL8, "HU1:CBPM:HU31:PSI")
	field(DOL9, "HU1:CBPM:HU31:PSI")
	field(DOLA, "HU1:CBPM:HU31:PSI")
	field(LNK1, "HU1:CBPM:HU31:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU31:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU31:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:UPHAS")
	field(DOL2, "HU1:CBPM:HU31:UPHAS")
	field(DOL3, "HU1:CBPM:HU31:UPHAS")
	field(DOL4, "HU1:CBPM:HU31:UPHAS")
	field(DOL5, "HU1:CBPM:HU31:UPHAS")
	field(DOL6, "HU1:CBPM:HU31:UPHAS")
	field(DOL7, "HU1:CBPM:HU31:UPHAS")
	field(DOL8, "HU1:CBPM:HU31:UPHAS")
	field(DOL9, "HU1:CBPM:HU31:UPHAS")
	field(DOLA, "HU1:CBPM:HU31:UPHAS")
	field(LNK1, "HU1:CBPM:HU31:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU31:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU31:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:VPHAS")
	field(DOL2, "HU1:CBPM:HU31:VPHAS")
	field(DOL3, "HU1:CBPM:HU31:VPHAS")
	field(DOL4, "HU1:CBPM:HU31:VPHAS")
	field(DOL5, "HU1:CBPM:HU31:VPHAS")
	field(DOL6, "HU1:CBPM:HU31:VPHAS")
	field(DOL7, "HU1:CBPM:HU31:VPHAS")
	field(DOL8, "HU1:CBPM:HU31:VPHAS")
	field(DOL9, "HU1:CBPM:HU31:VPHAS")
	field(DOLA, "HU1:CBPM:HU31:VPHAS")
	field(LNK1, "HU1:CBPM:HU31:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU31:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU31:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:QSCL")
	field(DOL2, "HU1:CBPM:HU31:QSCL")
	field(DOL3, "HU1:CBPM:HU31:QSCL")
	field(DOL4, "HU1:CBPM:HU31:QSCL")
	field(DOL5, "HU1:CBPM:HU31:QSCL")
	field(DOL6, "HU1:CBPM:HU31:QSCL")
	field(DOL7, "HU1:CBPM:HU31:QSCL")
	field(DOL8, "HU1:CBPM:HU31:QSCL")
	field(DOL9, "HU1:CBPM:HU31:QSCL")
	field(DOLA, "HU1:CBPM:HU31:QSCL")
	field(LNK1, "HU1:CBPM:HU31:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:URSCL")
	field(DOL2, "HU1:CBPM:HU31:URSCL")
	field(DOL3, "HU1:CBPM:HU31:URSCL")
	field(DOL4, "HU1:CBPM:HU31:URSCL")
	field(DOL5, "HU1:CBPM:HU31:URSCL")
	field(DOL6, "HU1:CBPM:HU31:URSCL")
	field(DOL7, "HU1:CBPM:HU31:URSCL")
	field(DOL8, "HU1:CBPM:HU31:URSCL")
	field(DOL9, "HU1:CBPM:HU31:URSCL")
	field(DOLA, "HU1:CBPM:HU31:URSCL")
	field(LNK1, "HU1:CBPM:HU31:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:VRSCL")
	field(DOL2, "HU1:CBPM:HU31:VRSCL")
	field(DOL3, "HU1:CBPM:HU31:VRSCL")
	field(DOL4, "HU1:CBPM:HU31:VRSCL")
	field(DOL5, "HU1:CBPM:HU31:VRSCL")
	field(DOL6, "HU1:CBPM:HU31:VRSCL")
	field(DOL7, "HU1:CBPM:HU31:VRSCL")
	field(DOL8, "HU1:CBPM:HU31:VRSCL")
	field(DOL9, "HU1:CBPM:HU31:VRSCL")
	field(DOLA, "HU1:CBPM:HU31:VRSCL")
	field(LNK1, "HU1:CBPM:HU31:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU31:QRSCL")
	field(DOL2, "HU1:CBPM:HU31:QRSCL")
	field(DOL3, "HU1:CBPM:HU31:QRSCL")
	field(DOL4, "HU1:CBPM:HU31:QRSCL")
	field(DOL5, "HU1:CBPM:HU31:QRSCL")
	field(DOL6, "HU1:CBPM:HU31:QRSCL")
	field(DOL7, "HU1:CBPM:HU31:QRSCL")
	field(DOL8, "HU1:CBPM:HU31:QRSCL")
	field(DOL9, "HU1:CBPM:HU31:QRSCL")
	field(DOLA, "HU1:CBPM:HU31:QRSCL")
	field(LNK1, "HU1:CBPM:HU31:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU31:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU31:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU31:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU31:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU31:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU31:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU31:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU31:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU31:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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,  "HU1:CBPM:HU31:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU31:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU31:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU31:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU31:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU31:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU31:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU31:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU31:RCVR_GAIN CP")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU17: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU18: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU19: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU20: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU21: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU22: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU23: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU24: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU25: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU26: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU27: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU28: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU29: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU30: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31: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, "HU1:CBPM:HU31:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4FC(8)")
	field(PINI, "YES")
}
