# per IOC database for stripline BPMs

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU01:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU01: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:HU01: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:HU01:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU01:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU01:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU01: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:HU01: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:HU01:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU01:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU01: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:HU01:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU01: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:HU01:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU01: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:HU01:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU01: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:HU01:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU01:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU02:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU02: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:HU02: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:HU02:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU02:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU02:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU02: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:HU02: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:HU02:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU02:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU02: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:HU02:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU02: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:HU02:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU02: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:HU02:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU02: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:HU02:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU02:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU03:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU03: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:HU03: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:HU03:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU03:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU03:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU03: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:HU03: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:HU03:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU03:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU03: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:HU03:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU03: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:HU03:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU03: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:HU03:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU03: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:HU03:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU03:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU04:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU04: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:HU04: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:HU04:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU04:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU04:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU04: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:HU04: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:HU04:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU04:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU04: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:HU04:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU04: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:HU04:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU04: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:HU04:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU04: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:HU04:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU04:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU05:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU05: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:HU05: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:HU05:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU05:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU05:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU05: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:HU05: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:HU05:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU05:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU05: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:HU05:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU05: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:HU05:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU05: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:HU05:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU05: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:HU05:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU05:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU06:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU06: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:HU06: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:HU06:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU06:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU06:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU06: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:HU06: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:HU06:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU06:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU06: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:HU06:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU06: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:HU06:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU06: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:HU06:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU06: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:HU06:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU06:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU07:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU07: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:HU07: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:HU07:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU07:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU07:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU07: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:HU07: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:HU07:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU07:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU07: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:HU07:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU07: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:HU07:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU07: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:HU07:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU07: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:HU07:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU07:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU08:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU08: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:HU08: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:HU08:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU08:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU08:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU08: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:HU08: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:HU08:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU08:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU08: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:HU08:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU08: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:HU08:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU08: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:HU08:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU08: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:HU08:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU08:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU09:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU09: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:HU09: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:HU09:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU09:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU09:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU09: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:HU09: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:HU09:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU09:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU09: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:HU09:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU09: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:HU09:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU09: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:HU09:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU09: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:HU09:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU09:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU10:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU10: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:HU10: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:HU10:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU10:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU10:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU10: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:HU10: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:HU10:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU10:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU10: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:HU10:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU10: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:HU10:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU10: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:HU10:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU10: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:HU10:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU10:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU11:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU11: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:HU11: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:HU11:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU11:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU11:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU11: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:HU11: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:HU11:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU11:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU11: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:HU11:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU11: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:HU11:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU11: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:HU11:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU11: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:HU11:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU11:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


record(calc, "HU1:CBPM:HU12:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU12: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:HU12: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:HU12:PHI_SEQ")
}

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

#record(dfanout, "HU1:CBPM:HU12:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU12:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU12: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:HU12: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:HU12:UOFF_SEQ")
}

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

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

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


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

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

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

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

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

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

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

record(mbbo, "HU1:CBPM:HU12:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU12: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:HU12:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU12: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:HU12:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU12: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:HU12:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU12: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:HU12:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU12:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

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

record(bi, "HU1:CBPM:HU12:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU12: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:HU12:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU12:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU12:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU12:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU12:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU12:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU12:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU12:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU12:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU12:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU12:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU12:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12: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:HU12: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:HU12: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:HU12: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:HU12: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:HU12: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:HU12:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU12:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU12:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU12:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU12: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:HU12:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:UOFF")
	field(DOL2, "HU1:CBPM:HU12:UOFF")
	field(DOL3, "HU1:CBPM:HU12:UOFF")
	field(DOL4, "HU1:CBPM:HU12:UOFF")
	field(DOL5, "HU1:CBPM:HU12:UOFF")
	field(DOL6, "HU1:CBPM:HU12:UOFF")
	field(DOL7, "HU1:CBPM:HU12:UOFF")
	field(DOL8, "HU1:CBPM:HU12:UOFF")
	field(DOL9, "HU1:CBPM:HU12:UOFF")
	field(DOLA, "HU1:CBPM:HU12:UOFF")
	field(LNK1, "HU1:CBPM:HU12:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU12:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU12:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:VOFF")
	field(DOL2, "HU1:CBPM:HU12:VOFF")
	field(DOL3, "HU1:CBPM:HU12:VOFF")
	field(DOL4, "HU1:CBPM:HU12:VOFF")
	field(DOL5, "HU1:CBPM:HU12:VOFF")
	field(DOL6, "HU1:CBPM:HU12:VOFF")
	field(DOL7, "HU1:CBPM:HU12:VOFF")
	field(DOL8, "HU1:CBPM:HU12:VOFF")
	field(DOL9, "HU1:CBPM:HU12:VOFF")
	field(DOLA, "HU1:CBPM:HU12:VOFF")
	field(LNK1, "HU1:CBPM:HU12:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU12:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU12:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:USCL")
	field(DOL2, "HU1:CBPM:HU12:USCL")
	field(DOL3, "HU1:CBPM:HU12:USCL")
	field(DOL4, "HU1:CBPM:HU12:USCL")
	field(DOL5, "HU1:CBPM:HU12:USCL")
	field(DOL6, "HU1:CBPM:HU12:USCL")
	field(DOL7, "HU1:CBPM:HU12:USCL")
	field(DOL8, "HU1:CBPM:HU12:USCL")
	field(DOL9, "HU1:CBPM:HU12:USCL")
	field(DOLA, "HU1:CBPM:HU12:USCL")
	field(LNK1, "HU1:CBPM:HU12:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:VSCL")
	field(DOL2, "HU1:CBPM:HU12:VSCL")
	field(DOL3, "HU1:CBPM:HU12:VSCL")
	field(DOL4, "HU1:CBPM:HU12:VSCL")
	field(DOL5, "HU1:CBPM:HU12:VSCL")
	field(DOL6, "HU1:CBPM:HU12:VSCL")
	field(DOL7, "HU1:CBPM:HU12:VSCL")
	field(DOL8, "HU1:CBPM:HU12:VSCL")
	field(DOL9, "HU1:CBPM:HU12:VSCL")
	field(DOLA, "HU1:CBPM:HU12:VSCL")
	field(LNK1, "HU1:CBPM:HU12:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:PHI")
	field(DOL2, "HU1:CBPM:HU12:PHI")
	field(DOL3, "HU1:CBPM:HU12:PHI")
	field(DOL4, "HU1:CBPM:HU12:PHI")
	field(DOL5, "HU1:CBPM:HU12:PHI")
	field(DOL6, "HU1:CBPM:HU12:PHI")
	field(DOL7, "HU1:CBPM:HU12:PHI")
	field(DOL8, "HU1:CBPM:HU12:PHI")
	field(DOL9, "HU1:CBPM:HU12:PHI")
	field(DOLA, "HU1:CBPM:HU12:PHI")
	field(LNK1, "HU1:CBPM:HU12:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU12:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU12:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:PSI")
	field(DOL2, "HU1:CBPM:HU12:PSI")
	field(DOL3, "HU1:CBPM:HU12:PSI")
	field(DOL4, "HU1:CBPM:HU12:PSI")
	field(DOL5, "HU1:CBPM:HU12:PSI")
	field(DOL6, "HU1:CBPM:HU12:PSI")
	field(DOL7, "HU1:CBPM:HU12:PSI")
	field(DOL8, "HU1:CBPM:HU12:PSI")
	field(DOL9, "HU1:CBPM:HU12:PSI")
	field(DOLA, "HU1:CBPM:HU12:PSI")
	field(LNK1, "HU1:CBPM:HU12:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU12:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU12:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:UPHAS")
	field(DOL2, "HU1:CBPM:HU12:UPHAS")
	field(DOL3, "HU1:CBPM:HU12:UPHAS")
	field(DOL4, "HU1:CBPM:HU12:UPHAS")
	field(DOL5, "HU1:CBPM:HU12:UPHAS")
	field(DOL6, "HU1:CBPM:HU12:UPHAS")
	field(DOL7, "HU1:CBPM:HU12:UPHAS")
	field(DOL8, "HU1:CBPM:HU12:UPHAS")
	field(DOL9, "HU1:CBPM:HU12:UPHAS")
	field(DOLA, "HU1:CBPM:HU12:UPHAS")
	field(LNK1, "HU1:CBPM:HU12:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU12:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU12:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:VPHAS")
	field(DOL2, "HU1:CBPM:HU12:VPHAS")
	field(DOL3, "HU1:CBPM:HU12:VPHAS")
	field(DOL4, "HU1:CBPM:HU12:VPHAS")
	field(DOL5, "HU1:CBPM:HU12:VPHAS")
	field(DOL6, "HU1:CBPM:HU12:VPHAS")
	field(DOL7, "HU1:CBPM:HU12:VPHAS")
	field(DOL8, "HU1:CBPM:HU12:VPHAS")
	field(DOL9, "HU1:CBPM:HU12:VPHAS")
	field(DOLA, "HU1:CBPM:HU12:VPHAS")
	field(LNK1, "HU1:CBPM:HU12:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU12:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU12:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:QSCL")
	field(DOL2, "HU1:CBPM:HU12:QSCL")
	field(DOL3, "HU1:CBPM:HU12:QSCL")
	field(DOL4, "HU1:CBPM:HU12:QSCL")
	field(DOL5, "HU1:CBPM:HU12:QSCL")
	field(DOL6, "HU1:CBPM:HU12:QSCL")
	field(DOL7, "HU1:CBPM:HU12:QSCL")
	field(DOL8, "HU1:CBPM:HU12:QSCL")
	field(DOL9, "HU1:CBPM:HU12:QSCL")
	field(DOLA, "HU1:CBPM:HU12:QSCL")
	field(LNK1, "HU1:CBPM:HU12:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:URSCL")
	field(DOL2, "HU1:CBPM:HU12:URSCL")
	field(DOL3, "HU1:CBPM:HU12:URSCL")
	field(DOL4, "HU1:CBPM:HU12:URSCL")
	field(DOL5, "HU1:CBPM:HU12:URSCL")
	field(DOL6, "HU1:CBPM:HU12:URSCL")
	field(DOL7, "HU1:CBPM:HU12:URSCL")
	field(DOL8, "HU1:CBPM:HU12:URSCL")
	field(DOL9, "HU1:CBPM:HU12:URSCL")
	field(DOLA, "HU1:CBPM:HU12:URSCL")
	field(LNK1, "HU1:CBPM:HU12:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:VRSCL")
	field(DOL2, "HU1:CBPM:HU12:VRSCL")
	field(DOL3, "HU1:CBPM:HU12:VRSCL")
	field(DOL4, "HU1:CBPM:HU12:VRSCL")
	field(DOL5, "HU1:CBPM:HU12:VRSCL")
	field(DOL6, "HU1:CBPM:HU12:VRSCL")
	field(DOL7, "HU1:CBPM:HU12:VRSCL")
	field(DOL8, "HU1:CBPM:HU12:VRSCL")
	field(DOL9, "HU1:CBPM:HU12:VRSCL")
	field(DOLA, "HU1:CBPM:HU12:VRSCL")
	field(LNK1, "HU1:CBPM:HU12:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12: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:HU12:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU12:QRSCL")
	field(DOL2, "HU1:CBPM:HU12:QRSCL")
	field(DOL3, "HU1:CBPM:HU12:QRSCL")
	field(DOL4, "HU1:CBPM:HU12:QRSCL")
	field(DOL5, "HU1:CBPM:HU12:QRSCL")
	field(DOL6, "HU1:CBPM:HU12:QRSCL")
	field(DOL7, "HU1:CBPM:HU12:QRSCL")
	field(DOL8, "HU1:CBPM:HU12:QRSCL")
	field(DOL9, "HU1:CBPM:HU12:QRSCL")
	field(DOLA, "HU1:CBPM:HU12:QRSCL")
	field(LNK1, "HU1:CBPM:HU12:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU12:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU12:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU12:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU12:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU12:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU12:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU12:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU12:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU12:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU12: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:HU12: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:HU12: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:HU12:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU12:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU12:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU12:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU12:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU12:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU12:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU12:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU12: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:HU13: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:HU13: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:HU13: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:HU13:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU13: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:HU13:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU13: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:HU13:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU13: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:HU13: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:HU13:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU13: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:HU13:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU13: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:HU13:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU13: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:HU13:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU13: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:HU13:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU13: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:HU13:PRENV")
}

record(waveform, "HU1:CBPM:HU13: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:HU13:ENVU")
}

record(subArray, "HU1:CBPM:HU13:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU13:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU13:ENVV")
}

record(subArray, "HU1:CBPM:HU13:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU13:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU13: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:HU13:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU13:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU13: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:HU13:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU13:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU13:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU13:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU13:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU13:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU13:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU13:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU13:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU13: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:HU13:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU13: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:HU13:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "12")
#field(INPB, "HU1:CBPM:HU13:FC_REF")
#field(INPC, "HU1:CBPM:HU13: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:HU13:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU13:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU13:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU13:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU13:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU13:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU13:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU13:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU13:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU13:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU13:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU13:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU13:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU13:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU13:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU13: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:HU13:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU13:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU13:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU13:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU13: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:HU13:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU13:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU13:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU13:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU13:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU13:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU13:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU13:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU13:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU13:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU13: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:HU13:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU13: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:HU13:URER_SLOW")
}

record(ai, "HU1:CBPM:HU13:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU13: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:HU13:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU13:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU13: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:HU13:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU13:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU13: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:HU13:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU13:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU13: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:HU13:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S12")
  field(FLNK, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13:V")
}

record(ai, "HU1:CBPM:HU13: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:HU13:PINC")
}

record(ai, "HU1:CBPM:HU13:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C12 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU13: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:HU13:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU13:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU13: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:HU13: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:HU13:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU13: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:HU13:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU13:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU13:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU13: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:HU13: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:HU13:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU13: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:HU13:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU13:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU13:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H13")
  field(PINI, "YES")
}

record(stringin, "CBPM_H13:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU13")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU13:X_SLOW") {
#alias("HU1:CBPM:HU13:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU13:X MS")
  field(FLNK, "HU1:CBPM:HU13:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU13:Y_SLOW") {
#alias("HU1:CBPM:HU13:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU13:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU13:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU13:TMIT_SLOW") {
#alias("HU1:CBPM:HU13:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU13: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:HU13:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU13:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU13:SIMC PP")
}

record(calcout, "HU1:CBPM:HU13: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:HU13:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU13:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU13:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU13: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:HU13:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU13: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:HU13:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU13:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU13:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU13: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:HU13:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU13: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:HU13: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:HU13:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU13:TMIT")
  field(INPB, "HU1:CBPM:HU13:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU13:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU13: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:HU13:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU13:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU13:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU13:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU13:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU13:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU13:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU13:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU13:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU13:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU13:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13: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:HU13:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU13:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU13:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU13:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU13: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:HU13:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:UOFF")
	field(DOL2, "HU1:CBPM:HU13:UOFF")
	field(DOL3, "HU1:CBPM:HU13:UOFF")
	field(DOL4, "HU1:CBPM:HU13:UOFF")
	field(DOL5, "HU1:CBPM:HU13:UOFF")
	field(DOL6, "HU1:CBPM:HU13:UOFF")
	field(DOL7, "HU1:CBPM:HU13:UOFF")
	field(DOL8, "HU1:CBPM:HU13:UOFF")
	field(DOL9, "HU1:CBPM:HU13:UOFF")
	field(DOLA, "HU1:CBPM:HU13:UOFF")
	field(LNK1, "HU1:CBPM:HU13:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU13:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU13:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:VOFF")
	field(DOL2, "HU1:CBPM:HU13:VOFF")
	field(DOL3, "HU1:CBPM:HU13:VOFF")
	field(DOL4, "HU1:CBPM:HU13:VOFF")
	field(DOL5, "HU1:CBPM:HU13:VOFF")
	field(DOL6, "HU1:CBPM:HU13:VOFF")
	field(DOL7, "HU1:CBPM:HU13:VOFF")
	field(DOL8, "HU1:CBPM:HU13:VOFF")
	field(DOL9, "HU1:CBPM:HU13:VOFF")
	field(DOLA, "HU1:CBPM:HU13:VOFF")
	field(LNK1, "HU1:CBPM:HU13:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU13:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU13:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:USCL")
	field(DOL2, "HU1:CBPM:HU13:USCL")
	field(DOL3, "HU1:CBPM:HU13:USCL")
	field(DOL4, "HU1:CBPM:HU13:USCL")
	field(DOL5, "HU1:CBPM:HU13:USCL")
	field(DOL6, "HU1:CBPM:HU13:USCL")
	field(DOL7, "HU1:CBPM:HU13:USCL")
	field(DOL8, "HU1:CBPM:HU13:USCL")
	field(DOL9, "HU1:CBPM:HU13:USCL")
	field(DOLA, "HU1:CBPM:HU13:USCL")
	field(LNK1, "HU1:CBPM:HU13:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:VSCL")
	field(DOL2, "HU1:CBPM:HU13:VSCL")
	field(DOL3, "HU1:CBPM:HU13:VSCL")
	field(DOL4, "HU1:CBPM:HU13:VSCL")
	field(DOL5, "HU1:CBPM:HU13:VSCL")
	field(DOL6, "HU1:CBPM:HU13:VSCL")
	field(DOL7, "HU1:CBPM:HU13:VSCL")
	field(DOL8, "HU1:CBPM:HU13:VSCL")
	field(DOL9, "HU1:CBPM:HU13:VSCL")
	field(DOLA, "HU1:CBPM:HU13:VSCL")
	field(LNK1, "HU1:CBPM:HU13:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:PHI")
	field(DOL2, "HU1:CBPM:HU13:PHI")
	field(DOL3, "HU1:CBPM:HU13:PHI")
	field(DOL4, "HU1:CBPM:HU13:PHI")
	field(DOL5, "HU1:CBPM:HU13:PHI")
	field(DOL6, "HU1:CBPM:HU13:PHI")
	field(DOL7, "HU1:CBPM:HU13:PHI")
	field(DOL8, "HU1:CBPM:HU13:PHI")
	field(DOL9, "HU1:CBPM:HU13:PHI")
	field(DOLA, "HU1:CBPM:HU13:PHI")
	field(LNK1, "HU1:CBPM:HU13:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU13:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU13:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:PSI")
	field(DOL2, "HU1:CBPM:HU13:PSI")
	field(DOL3, "HU1:CBPM:HU13:PSI")
	field(DOL4, "HU1:CBPM:HU13:PSI")
	field(DOL5, "HU1:CBPM:HU13:PSI")
	field(DOL6, "HU1:CBPM:HU13:PSI")
	field(DOL7, "HU1:CBPM:HU13:PSI")
	field(DOL8, "HU1:CBPM:HU13:PSI")
	field(DOL9, "HU1:CBPM:HU13:PSI")
	field(DOLA, "HU1:CBPM:HU13:PSI")
	field(LNK1, "HU1:CBPM:HU13:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU13:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU13:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:UPHAS")
	field(DOL2, "HU1:CBPM:HU13:UPHAS")
	field(DOL3, "HU1:CBPM:HU13:UPHAS")
	field(DOL4, "HU1:CBPM:HU13:UPHAS")
	field(DOL5, "HU1:CBPM:HU13:UPHAS")
	field(DOL6, "HU1:CBPM:HU13:UPHAS")
	field(DOL7, "HU1:CBPM:HU13:UPHAS")
	field(DOL8, "HU1:CBPM:HU13:UPHAS")
	field(DOL9, "HU1:CBPM:HU13:UPHAS")
	field(DOLA, "HU1:CBPM:HU13:UPHAS")
	field(LNK1, "HU1:CBPM:HU13:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU13:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU13:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:VPHAS")
	field(DOL2, "HU1:CBPM:HU13:VPHAS")
	field(DOL3, "HU1:CBPM:HU13:VPHAS")
	field(DOL4, "HU1:CBPM:HU13:VPHAS")
	field(DOL5, "HU1:CBPM:HU13:VPHAS")
	field(DOL6, "HU1:CBPM:HU13:VPHAS")
	field(DOL7, "HU1:CBPM:HU13:VPHAS")
	field(DOL8, "HU1:CBPM:HU13:VPHAS")
	field(DOL9, "HU1:CBPM:HU13:VPHAS")
	field(DOLA, "HU1:CBPM:HU13:VPHAS")
	field(LNK1, "HU1:CBPM:HU13:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU13:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU13:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:QSCL")
	field(DOL2, "HU1:CBPM:HU13:QSCL")
	field(DOL3, "HU1:CBPM:HU13:QSCL")
	field(DOL4, "HU1:CBPM:HU13:QSCL")
	field(DOL5, "HU1:CBPM:HU13:QSCL")
	field(DOL6, "HU1:CBPM:HU13:QSCL")
	field(DOL7, "HU1:CBPM:HU13:QSCL")
	field(DOL8, "HU1:CBPM:HU13:QSCL")
	field(DOL9, "HU1:CBPM:HU13:QSCL")
	field(DOLA, "HU1:CBPM:HU13:QSCL")
	field(LNK1, "HU1:CBPM:HU13:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:URSCL")
	field(DOL2, "HU1:CBPM:HU13:URSCL")
	field(DOL3, "HU1:CBPM:HU13:URSCL")
	field(DOL4, "HU1:CBPM:HU13:URSCL")
	field(DOL5, "HU1:CBPM:HU13:URSCL")
	field(DOL6, "HU1:CBPM:HU13:URSCL")
	field(DOL7, "HU1:CBPM:HU13:URSCL")
	field(DOL8, "HU1:CBPM:HU13:URSCL")
	field(DOL9, "HU1:CBPM:HU13:URSCL")
	field(DOLA, "HU1:CBPM:HU13:URSCL")
	field(LNK1, "HU1:CBPM:HU13:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:VRSCL")
	field(DOL2, "HU1:CBPM:HU13:VRSCL")
	field(DOL3, "HU1:CBPM:HU13:VRSCL")
	field(DOL4, "HU1:CBPM:HU13:VRSCL")
	field(DOL5, "HU1:CBPM:HU13:VRSCL")
	field(DOL6, "HU1:CBPM:HU13:VRSCL")
	field(DOL7, "HU1:CBPM:HU13:VRSCL")
	field(DOL8, "HU1:CBPM:HU13:VRSCL")
	field(DOL9, "HU1:CBPM:HU13:VRSCL")
	field(DOLA, "HU1:CBPM:HU13:VRSCL")
	field(LNK1, "HU1:CBPM:HU13:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13: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:HU13:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU13:QRSCL")
	field(DOL2, "HU1:CBPM:HU13:QRSCL")
	field(DOL3, "HU1:CBPM:HU13:QRSCL")
	field(DOL4, "HU1:CBPM:HU13:QRSCL")
	field(DOL5, "HU1:CBPM:HU13:QRSCL")
	field(DOL6, "HU1:CBPM:HU13:QRSCL")
	field(DOL7, "HU1:CBPM:HU13:QRSCL")
	field(DOL8, "HU1:CBPM:HU13:QRSCL")
	field(DOL9, "HU1:CBPM:HU13:QRSCL")
	field(DOLA, "HU1:CBPM:HU13:QRSCL")
	field(LNK1, "HU1:CBPM:HU13:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU13:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU13:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU13:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU13:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU13:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU13:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU13:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU13:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU13:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU13: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:HU13: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:HU13: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:HU13:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU13:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU13:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU13:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU13:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU13:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU13:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU13:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU13: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:HU14: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:HU14: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:HU14: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:HU14:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU14: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:HU14:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU14: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:HU14:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU14: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:HU14: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:HU14:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU14: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:HU14:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU14: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:HU14:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU14: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:HU14:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU14: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:HU14:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU14: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:HU14:PRENV")
}

record(waveform, "HU1:CBPM:HU14: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:HU14:ENVU")
}

record(subArray, "HU1:CBPM:HU14:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU14:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU14:ENVV")
}

record(subArray, "HU1:CBPM:HU14:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU14:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU14: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:HU14:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU14:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU14: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:HU14:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU14:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU14:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU14:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU14:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU14:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU14:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU14:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU14:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU14: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:HU14:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU14: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:HU14:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "13")
#field(INPB, "HU1:CBPM:HU14:FC_REF")
#field(INPC, "HU1:CBPM:HU14: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:HU14:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU14:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU14:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU14:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU14:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU14:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU14:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU14:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU14:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU14:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU14:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU14:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU14:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU14:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU14:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU14: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:HU14:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU14:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU14:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU14:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU14: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:HU14:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU14:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU14:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU14:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU14:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU14:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU14:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU14:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU14:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU14:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU14: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:HU14:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU14: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:HU14:URER_SLOW")
}

record(ai, "HU1:CBPM:HU14:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU14: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:HU14:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU14:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU14: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:HU14:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU14:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU14: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:HU14:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU14:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU14: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:HU14:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S12")
  field(FLNK, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14:V")
}

record(ai, "HU1:CBPM:HU14: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:HU14:PINC")
}

record(ai, "HU1:CBPM:HU14:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C13 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU14: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:HU14:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU14:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU14: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:HU14: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:HU14:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU14: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:HU14:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU14:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU14:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU14: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:HU14: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:HU14:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU14: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:HU14:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU14:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU14:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H14")
  field(PINI, "YES")
}

record(stringin, "CBPM_H14:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU14")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU14:X_SLOW") {
#alias("HU1:CBPM:HU14:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU14:X MS")
  field(FLNK, "HU1:CBPM:HU14:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU14:Y_SLOW") {
#alias("HU1:CBPM:HU14:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU14:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU14:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU14:TMIT_SLOW") {
#alias("HU1:CBPM:HU14:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU14: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:HU14:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU14:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU14:SIMC PP")
}

record(calcout, "HU1:CBPM:HU14: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:HU14:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU14:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU14:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU14: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:HU14:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU14: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:HU14:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU14:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU14:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU14: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:HU14:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU14: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:HU14: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:HU14:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU14:TMIT")
  field(INPB, "HU1:CBPM:HU14:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU14:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU14: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:HU14:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU14:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU14:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU14:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU14:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU14:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU14:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU14:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU14:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU14:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU14:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14: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:HU14:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU14:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU14:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU14:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU14: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:HU14:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:UOFF")
	field(DOL2, "HU1:CBPM:HU14:UOFF")
	field(DOL3, "HU1:CBPM:HU14:UOFF")
	field(DOL4, "HU1:CBPM:HU14:UOFF")
	field(DOL5, "HU1:CBPM:HU14:UOFF")
	field(DOL6, "HU1:CBPM:HU14:UOFF")
	field(DOL7, "HU1:CBPM:HU14:UOFF")
	field(DOL8, "HU1:CBPM:HU14:UOFF")
	field(DOL9, "HU1:CBPM:HU14:UOFF")
	field(DOLA, "HU1:CBPM:HU14:UOFF")
	field(LNK1, "HU1:CBPM:HU14:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU14:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU14:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:VOFF")
	field(DOL2, "HU1:CBPM:HU14:VOFF")
	field(DOL3, "HU1:CBPM:HU14:VOFF")
	field(DOL4, "HU1:CBPM:HU14:VOFF")
	field(DOL5, "HU1:CBPM:HU14:VOFF")
	field(DOL6, "HU1:CBPM:HU14:VOFF")
	field(DOL7, "HU1:CBPM:HU14:VOFF")
	field(DOL8, "HU1:CBPM:HU14:VOFF")
	field(DOL9, "HU1:CBPM:HU14:VOFF")
	field(DOLA, "HU1:CBPM:HU14:VOFF")
	field(LNK1, "HU1:CBPM:HU14:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU14:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU14:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:USCL")
	field(DOL2, "HU1:CBPM:HU14:USCL")
	field(DOL3, "HU1:CBPM:HU14:USCL")
	field(DOL4, "HU1:CBPM:HU14:USCL")
	field(DOL5, "HU1:CBPM:HU14:USCL")
	field(DOL6, "HU1:CBPM:HU14:USCL")
	field(DOL7, "HU1:CBPM:HU14:USCL")
	field(DOL8, "HU1:CBPM:HU14:USCL")
	field(DOL9, "HU1:CBPM:HU14:USCL")
	field(DOLA, "HU1:CBPM:HU14:USCL")
	field(LNK1, "HU1:CBPM:HU14:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:VSCL")
	field(DOL2, "HU1:CBPM:HU14:VSCL")
	field(DOL3, "HU1:CBPM:HU14:VSCL")
	field(DOL4, "HU1:CBPM:HU14:VSCL")
	field(DOL5, "HU1:CBPM:HU14:VSCL")
	field(DOL6, "HU1:CBPM:HU14:VSCL")
	field(DOL7, "HU1:CBPM:HU14:VSCL")
	field(DOL8, "HU1:CBPM:HU14:VSCL")
	field(DOL9, "HU1:CBPM:HU14:VSCL")
	field(DOLA, "HU1:CBPM:HU14:VSCL")
	field(LNK1, "HU1:CBPM:HU14:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:PHI")
	field(DOL2, "HU1:CBPM:HU14:PHI")
	field(DOL3, "HU1:CBPM:HU14:PHI")
	field(DOL4, "HU1:CBPM:HU14:PHI")
	field(DOL5, "HU1:CBPM:HU14:PHI")
	field(DOL6, "HU1:CBPM:HU14:PHI")
	field(DOL7, "HU1:CBPM:HU14:PHI")
	field(DOL8, "HU1:CBPM:HU14:PHI")
	field(DOL9, "HU1:CBPM:HU14:PHI")
	field(DOLA, "HU1:CBPM:HU14:PHI")
	field(LNK1, "HU1:CBPM:HU14:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU14:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU14:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:PSI")
	field(DOL2, "HU1:CBPM:HU14:PSI")
	field(DOL3, "HU1:CBPM:HU14:PSI")
	field(DOL4, "HU1:CBPM:HU14:PSI")
	field(DOL5, "HU1:CBPM:HU14:PSI")
	field(DOL6, "HU1:CBPM:HU14:PSI")
	field(DOL7, "HU1:CBPM:HU14:PSI")
	field(DOL8, "HU1:CBPM:HU14:PSI")
	field(DOL9, "HU1:CBPM:HU14:PSI")
	field(DOLA, "HU1:CBPM:HU14:PSI")
	field(LNK1, "HU1:CBPM:HU14:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU14:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU14:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:UPHAS")
	field(DOL2, "HU1:CBPM:HU14:UPHAS")
	field(DOL3, "HU1:CBPM:HU14:UPHAS")
	field(DOL4, "HU1:CBPM:HU14:UPHAS")
	field(DOL5, "HU1:CBPM:HU14:UPHAS")
	field(DOL6, "HU1:CBPM:HU14:UPHAS")
	field(DOL7, "HU1:CBPM:HU14:UPHAS")
	field(DOL8, "HU1:CBPM:HU14:UPHAS")
	field(DOL9, "HU1:CBPM:HU14:UPHAS")
	field(DOLA, "HU1:CBPM:HU14:UPHAS")
	field(LNK1, "HU1:CBPM:HU14:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU14:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU14:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:VPHAS")
	field(DOL2, "HU1:CBPM:HU14:VPHAS")
	field(DOL3, "HU1:CBPM:HU14:VPHAS")
	field(DOL4, "HU1:CBPM:HU14:VPHAS")
	field(DOL5, "HU1:CBPM:HU14:VPHAS")
	field(DOL6, "HU1:CBPM:HU14:VPHAS")
	field(DOL7, "HU1:CBPM:HU14:VPHAS")
	field(DOL8, "HU1:CBPM:HU14:VPHAS")
	field(DOL9, "HU1:CBPM:HU14:VPHAS")
	field(DOLA, "HU1:CBPM:HU14:VPHAS")
	field(LNK1, "HU1:CBPM:HU14:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU14:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU14:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:QSCL")
	field(DOL2, "HU1:CBPM:HU14:QSCL")
	field(DOL3, "HU1:CBPM:HU14:QSCL")
	field(DOL4, "HU1:CBPM:HU14:QSCL")
	field(DOL5, "HU1:CBPM:HU14:QSCL")
	field(DOL6, "HU1:CBPM:HU14:QSCL")
	field(DOL7, "HU1:CBPM:HU14:QSCL")
	field(DOL8, "HU1:CBPM:HU14:QSCL")
	field(DOL9, "HU1:CBPM:HU14:QSCL")
	field(DOLA, "HU1:CBPM:HU14:QSCL")
	field(LNK1, "HU1:CBPM:HU14:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:URSCL")
	field(DOL2, "HU1:CBPM:HU14:URSCL")
	field(DOL3, "HU1:CBPM:HU14:URSCL")
	field(DOL4, "HU1:CBPM:HU14:URSCL")
	field(DOL5, "HU1:CBPM:HU14:URSCL")
	field(DOL6, "HU1:CBPM:HU14:URSCL")
	field(DOL7, "HU1:CBPM:HU14:URSCL")
	field(DOL8, "HU1:CBPM:HU14:URSCL")
	field(DOL9, "HU1:CBPM:HU14:URSCL")
	field(DOLA, "HU1:CBPM:HU14:URSCL")
	field(LNK1, "HU1:CBPM:HU14:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:VRSCL")
	field(DOL2, "HU1:CBPM:HU14:VRSCL")
	field(DOL3, "HU1:CBPM:HU14:VRSCL")
	field(DOL4, "HU1:CBPM:HU14:VRSCL")
	field(DOL5, "HU1:CBPM:HU14:VRSCL")
	field(DOL6, "HU1:CBPM:HU14:VRSCL")
	field(DOL7, "HU1:CBPM:HU14:VRSCL")
	field(DOL8, "HU1:CBPM:HU14:VRSCL")
	field(DOL9, "HU1:CBPM:HU14:VRSCL")
	field(DOLA, "HU1:CBPM:HU14:VRSCL")
	field(LNK1, "HU1:CBPM:HU14:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14: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:HU14:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU14:QRSCL")
	field(DOL2, "HU1:CBPM:HU14:QRSCL")
	field(DOL3, "HU1:CBPM:HU14:QRSCL")
	field(DOL4, "HU1:CBPM:HU14:QRSCL")
	field(DOL5, "HU1:CBPM:HU14:QRSCL")
	field(DOL6, "HU1:CBPM:HU14:QRSCL")
	field(DOL7, "HU1:CBPM:HU14:QRSCL")
	field(DOL8, "HU1:CBPM:HU14:QRSCL")
	field(DOL9, "HU1:CBPM:HU14:QRSCL")
	field(DOLA, "HU1:CBPM:HU14:QRSCL")
	field(LNK1, "HU1:CBPM:HU14:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU14:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU14:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU14:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU14:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU14:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU14:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU14:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU14:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU14:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU14: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:HU14: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:HU14: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:HU14:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU14:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU14:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU14:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU14:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU14:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU14:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU14:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU14: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:HU15: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:HU15: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:HU15: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:HU15:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU15: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:HU15:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU15: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:HU15:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU15: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:HU15: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:HU15:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU15: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:HU15:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU15: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:HU15:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU15: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:HU15:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU15: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:HU15:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU15: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:HU15:PRENV")
}

record(waveform, "HU1:CBPM:HU15: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:HU15:ENVU")
}

record(subArray, "HU1:CBPM:HU15:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU15:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU15:ENVV")
}

record(subArray, "HU1:CBPM:HU15:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU15:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU15: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:HU15:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU15:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU15: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:HU15:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU15:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU15:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU15:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU15:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU15:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU15:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU15:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU15:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU15: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:HU15:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU15: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:HU15:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "14")
#field(INPB, "HU1:CBPM:HU15:FC_REF")
#field(INPC, "HU1:CBPM:HU15: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:HU15:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU15:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU15:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU15:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU15:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU15:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU15:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU15:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU15:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU15:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU15:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU15:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU15:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU15:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU15:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU15: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:HU15:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU15:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU15:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU15:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU15: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:HU15:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU15:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU15:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU15:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU15:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU15:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU15:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU15:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU15:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU15:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU15: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:HU15:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU15: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:HU15:URER_SLOW")
}

record(ai, "HU1:CBPM:HU15:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU15: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:HU15:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU15:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU15: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:HU15:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU15:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU15: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:HU15:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU15:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU15: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:HU15:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S12")
  field(FLNK, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15:V")
}

record(ai, "HU1:CBPM:HU15: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:HU15:PINC")
}

record(ai, "HU1:CBPM:HU15:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C14 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU15: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:HU15:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU15:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU15: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:HU15: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:HU15:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU15: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:HU15:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU15:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU15:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU15: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:HU15: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:HU15:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU15: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:HU15:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU15:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU15:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H15")
  field(PINI, "YES")
}

record(stringin, "CBPM_H15:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU15")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU15:X_SLOW") {
#alias("HU1:CBPM:HU15:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU15:X MS")
  field(FLNK, "HU1:CBPM:HU15:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU15:Y_SLOW") {
#alias("HU1:CBPM:HU15:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU15:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU15:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU15:TMIT_SLOW") {
#alias("HU1:CBPM:HU15:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU15: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:HU15:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU15:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU15:SIMC PP")
}

record(calcout, "HU1:CBPM:HU15: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:HU15:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU15:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU15:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU15: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:HU15:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU15: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:HU15:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU15:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU15:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU15: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:HU15:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU15: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:HU15: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:HU15:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU15:TMIT")
  field(INPB, "HU1:CBPM:HU15:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU15:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU15: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:HU15:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU15:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU15:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU15:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU15:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU15:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU15:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU15:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU15:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU15:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU15:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15: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:HU15:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU15:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU15:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU15:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU15: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:HU15:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:UOFF")
	field(DOL2, "HU1:CBPM:HU15:UOFF")
	field(DOL3, "HU1:CBPM:HU15:UOFF")
	field(DOL4, "HU1:CBPM:HU15:UOFF")
	field(DOL5, "HU1:CBPM:HU15:UOFF")
	field(DOL6, "HU1:CBPM:HU15:UOFF")
	field(DOL7, "HU1:CBPM:HU15:UOFF")
	field(DOL8, "HU1:CBPM:HU15:UOFF")
	field(DOL9, "HU1:CBPM:HU15:UOFF")
	field(DOLA, "HU1:CBPM:HU15:UOFF")
	field(LNK1, "HU1:CBPM:HU15:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU15:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU15:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:VOFF")
	field(DOL2, "HU1:CBPM:HU15:VOFF")
	field(DOL3, "HU1:CBPM:HU15:VOFF")
	field(DOL4, "HU1:CBPM:HU15:VOFF")
	field(DOL5, "HU1:CBPM:HU15:VOFF")
	field(DOL6, "HU1:CBPM:HU15:VOFF")
	field(DOL7, "HU1:CBPM:HU15:VOFF")
	field(DOL8, "HU1:CBPM:HU15:VOFF")
	field(DOL9, "HU1:CBPM:HU15:VOFF")
	field(DOLA, "HU1:CBPM:HU15:VOFF")
	field(LNK1, "HU1:CBPM:HU15:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU15:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU15:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:USCL")
	field(DOL2, "HU1:CBPM:HU15:USCL")
	field(DOL3, "HU1:CBPM:HU15:USCL")
	field(DOL4, "HU1:CBPM:HU15:USCL")
	field(DOL5, "HU1:CBPM:HU15:USCL")
	field(DOL6, "HU1:CBPM:HU15:USCL")
	field(DOL7, "HU1:CBPM:HU15:USCL")
	field(DOL8, "HU1:CBPM:HU15:USCL")
	field(DOL9, "HU1:CBPM:HU15:USCL")
	field(DOLA, "HU1:CBPM:HU15:USCL")
	field(LNK1, "HU1:CBPM:HU15:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:VSCL")
	field(DOL2, "HU1:CBPM:HU15:VSCL")
	field(DOL3, "HU1:CBPM:HU15:VSCL")
	field(DOL4, "HU1:CBPM:HU15:VSCL")
	field(DOL5, "HU1:CBPM:HU15:VSCL")
	field(DOL6, "HU1:CBPM:HU15:VSCL")
	field(DOL7, "HU1:CBPM:HU15:VSCL")
	field(DOL8, "HU1:CBPM:HU15:VSCL")
	field(DOL9, "HU1:CBPM:HU15:VSCL")
	field(DOLA, "HU1:CBPM:HU15:VSCL")
	field(LNK1, "HU1:CBPM:HU15:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:PHI")
	field(DOL2, "HU1:CBPM:HU15:PHI")
	field(DOL3, "HU1:CBPM:HU15:PHI")
	field(DOL4, "HU1:CBPM:HU15:PHI")
	field(DOL5, "HU1:CBPM:HU15:PHI")
	field(DOL6, "HU1:CBPM:HU15:PHI")
	field(DOL7, "HU1:CBPM:HU15:PHI")
	field(DOL8, "HU1:CBPM:HU15:PHI")
	field(DOL9, "HU1:CBPM:HU15:PHI")
	field(DOLA, "HU1:CBPM:HU15:PHI")
	field(LNK1, "HU1:CBPM:HU15:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU15:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU15:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:PSI")
	field(DOL2, "HU1:CBPM:HU15:PSI")
	field(DOL3, "HU1:CBPM:HU15:PSI")
	field(DOL4, "HU1:CBPM:HU15:PSI")
	field(DOL5, "HU1:CBPM:HU15:PSI")
	field(DOL6, "HU1:CBPM:HU15:PSI")
	field(DOL7, "HU1:CBPM:HU15:PSI")
	field(DOL8, "HU1:CBPM:HU15:PSI")
	field(DOL9, "HU1:CBPM:HU15:PSI")
	field(DOLA, "HU1:CBPM:HU15:PSI")
	field(LNK1, "HU1:CBPM:HU15:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU15:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU15:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:UPHAS")
	field(DOL2, "HU1:CBPM:HU15:UPHAS")
	field(DOL3, "HU1:CBPM:HU15:UPHAS")
	field(DOL4, "HU1:CBPM:HU15:UPHAS")
	field(DOL5, "HU1:CBPM:HU15:UPHAS")
	field(DOL6, "HU1:CBPM:HU15:UPHAS")
	field(DOL7, "HU1:CBPM:HU15:UPHAS")
	field(DOL8, "HU1:CBPM:HU15:UPHAS")
	field(DOL9, "HU1:CBPM:HU15:UPHAS")
	field(DOLA, "HU1:CBPM:HU15:UPHAS")
	field(LNK1, "HU1:CBPM:HU15:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU15:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU15:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:VPHAS")
	field(DOL2, "HU1:CBPM:HU15:VPHAS")
	field(DOL3, "HU1:CBPM:HU15:VPHAS")
	field(DOL4, "HU1:CBPM:HU15:VPHAS")
	field(DOL5, "HU1:CBPM:HU15:VPHAS")
	field(DOL6, "HU1:CBPM:HU15:VPHAS")
	field(DOL7, "HU1:CBPM:HU15:VPHAS")
	field(DOL8, "HU1:CBPM:HU15:VPHAS")
	field(DOL9, "HU1:CBPM:HU15:VPHAS")
	field(DOLA, "HU1:CBPM:HU15:VPHAS")
	field(LNK1, "HU1:CBPM:HU15:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU15:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU15:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:QSCL")
	field(DOL2, "HU1:CBPM:HU15:QSCL")
	field(DOL3, "HU1:CBPM:HU15:QSCL")
	field(DOL4, "HU1:CBPM:HU15:QSCL")
	field(DOL5, "HU1:CBPM:HU15:QSCL")
	field(DOL6, "HU1:CBPM:HU15:QSCL")
	field(DOL7, "HU1:CBPM:HU15:QSCL")
	field(DOL8, "HU1:CBPM:HU15:QSCL")
	field(DOL9, "HU1:CBPM:HU15:QSCL")
	field(DOLA, "HU1:CBPM:HU15:QSCL")
	field(LNK1, "HU1:CBPM:HU15:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:URSCL")
	field(DOL2, "HU1:CBPM:HU15:URSCL")
	field(DOL3, "HU1:CBPM:HU15:URSCL")
	field(DOL4, "HU1:CBPM:HU15:URSCL")
	field(DOL5, "HU1:CBPM:HU15:URSCL")
	field(DOL6, "HU1:CBPM:HU15:URSCL")
	field(DOL7, "HU1:CBPM:HU15:URSCL")
	field(DOL8, "HU1:CBPM:HU15:URSCL")
	field(DOL9, "HU1:CBPM:HU15:URSCL")
	field(DOLA, "HU1:CBPM:HU15:URSCL")
	field(LNK1, "HU1:CBPM:HU15:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:VRSCL")
	field(DOL2, "HU1:CBPM:HU15:VRSCL")
	field(DOL3, "HU1:CBPM:HU15:VRSCL")
	field(DOL4, "HU1:CBPM:HU15:VRSCL")
	field(DOL5, "HU1:CBPM:HU15:VRSCL")
	field(DOL6, "HU1:CBPM:HU15:VRSCL")
	field(DOL7, "HU1:CBPM:HU15:VRSCL")
	field(DOL8, "HU1:CBPM:HU15:VRSCL")
	field(DOL9, "HU1:CBPM:HU15:VRSCL")
	field(DOLA, "HU1:CBPM:HU15:VRSCL")
	field(LNK1, "HU1:CBPM:HU15:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15: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:HU15:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU15:QRSCL")
	field(DOL2, "HU1:CBPM:HU15:QRSCL")
	field(DOL3, "HU1:CBPM:HU15:QRSCL")
	field(DOL4, "HU1:CBPM:HU15:QRSCL")
	field(DOL5, "HU1:CBPM:HU15:QRSCL")
	field(DOL6, "HU1:CBPM:HU15:QRSCL")
	field(DOL7, "HU1:CBPM:HU15:QRSCL")
	field(DOL8, "HU1:CBPM:HU15:QRSCL")
	field(DOL9, "HU1:CBPM:HU15:QRSCL")
	field(DOLA, "HU1:CBPM:HU15:QRSCL")
	field(LNK1, "HU1:CBPM:HU15:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU15:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU15:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU15:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU15:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU15:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU15:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU15:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU15:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU15:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU15: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:HU15: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:HU15: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:HU15:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU15:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU15:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU15:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU15:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU15:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU15:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU15:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU15: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:HU16:REFR") {
  field(DESC, "Raw Ref. Ampl.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S0")
  field(EGU, "raw")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "HU1:CBPM:HU16: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:HU16:URER") {
  field(DESC, "Re{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S1")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:UIMR")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU16:UIMR") {
  field(DESC, "Im{Cmplx Ampl. U/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S5")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:VRER")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU16:VRER") {
  field(DESC, "Re{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:VIMR")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

record(ai, "HU1:CBPM:HU16:VIMR") {
  field(DESC, "Im{Cmplx Ampl. V/REF}")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S6")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
  field(TSE, "-1")
}

##############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "HU1:CBPM:HU16:RRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S0")
  field(EGU, "Nel")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "HU1:CBPM:HU16:URMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
  field(ASLO, "1E5")
}

record(ai, "HU1:CBPM:HU16:URMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S1")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:VRMS")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU16:VRMS") {
  field(DESC, "Ref. Raw RMS")
  field(DTYP, "Cavity Bpm Diag")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S2")
  field(EGU, "mm")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:TDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "4")
}

record(ai, "HU1:CBPM:HU16:TDEL") {
  field(DESC, "Ref. Peak Dly.")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S4")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:PDEL")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(ai, "HU1:CBPM:HU16:PDEL") {
  field(DESC, "Ref. Phase")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects type of signal
  field(INP, "#C15 S7")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:SFFT")
  field(PREC, "2")
  field(LOPR, "0")
  field(HOPR, "0")
  field(LOLO, "0")
  field(LOW, "0")
}

record(waveform, "HU1:CBPM:HU16:SFFT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C15 S1")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:PRENV")
}

record(waveform, "HU1:CBPM:HU16:PRENV") {
  field(DESC, "Filtered Preenvelope")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'beam-FFT', 'filter-FFT', 'filter-t-dom'
  field(INP, "#C15 S4")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "0")
  field(SCAN, "Passive")
  field(FLNK, "HU1:CBPM:HU16:ENVU")
}

record(subArray, "HU1:CBPM:HU16:ENVU") {
  field(DESC, "Preenvelope U")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU16:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "128")
  field(FLNK, "HU1:CBPM:HU16:ENVV")
}

record(subArray, "HU1:CBPM:HU16:ENVV") {
  field(DESC, "Preenvelope V")
  field(FTVL, "FLOAT")
  field(EGU,  "Counts")
  field(INP,  "HU1:CBPM:HU16:PRENV NPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "256")
}



# Filter frequency response
# (updated/scanned by driver)
record(waveform, "HU1:CBPM:HU16:FFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C15 S2 @wbscan")
  field(NELM, "192")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

record(subArray, "HU1:CBPM:HU16:REFW") {
  field(DESC, "Raw Ref. Waveform")
  field(FTVL, "FLOAT")
  field(INP,  "HU1:CBPM:HU16:RWAV CPP")
  field(MALM, "512")
  field(NELM, "128")
  field(INDX, "385")
}

record(waveform, "HU1:CBPM:HU16:TFILT") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
  field(INP, "#C15 S3 @wbscan")
  field(NELM, "384")
  field(FTVL, "FLOAT")
  field(EGU, "Counts")
  field(SCAN, "Passive")
}

##############################################
# Slowly-scanned diagnostics & status
##############################################
record(sel, "HU1:CBPM:HU16:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "HU1:CBPM:HU16:RSTA.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU16:TMIT.SEVR MS NPP")
  field(INPC, "HU1:CBPM:HU16:Y.SEVR    MS NPP")
  field(INPD, "HU1:CBPM:HU16:X.SEVR    MS NPP")
  field(SCAN, "1 second")
}

record(calc, "HU1:CBPM:HU16:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "HU1:CBPM:HU16:RSTA_ALH.SEVR MS NPP")
  field(INPB, "HU1:CBPM:HU16:CHK.SEVR MS NPP")
# for optional alarms:
  info(autosaveFields, "INPC INPD INPE") 
}

##############################################
# Input Parameters to Filter Bank (passive)
##############################################
#record(ao,  "HU1:CBPM:HU16:FC_REF")
#{
#field(DESC, "Fc - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU16: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:HU16:BW_REF")
#{
#field(DESC, "BW - Ref. Cavity")
#field(DTYP, "Soft Channel")
#field(OUT,  "HU1:CBPM:HU16: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:HU16:FILT") {
  field(INAM, "bpmCavFilterSubInit")
  field(SNAM, "bpmCavFilterSubProc")
  field(A, "15")
#field(INPB, "HU1:CBPM:HU16:FC_REF")
#field(INPC, "HU1:CBPM:HU16: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:HU16:TS_R") {
  field(DESC, "Sampling Time Ref")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:TS_R_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU16:FILT.D PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU16:TS_U") {
  field(DESC, "Sampling Time U")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:TS_U_ADJ") {
  field(DESC, "U Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU16:FILT.G PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

record(ao, "HU1:CBPM:HU16:TS_V") {
  field(DESC, "Sampling Time V")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:TS_V_ADJ") {
  field(DESC, "V Smpl. Time Scale")
  field(OUT, "HU1:CBPM:HU16:FILT.J PP")
  field(CALC, "A/1000")
  field(EGU, "us")
}

#record(seq, "HU1:CBPM:HU16:FILTUPD") {
#field(DESC, "Filt. Parm. Propagator")
#field(DOL1, "HU1:CBPM:HU16:FILT.B NPP")
#field(LNK1, "HU1:CBPM:HU16:FC_REF NPP")
#field(DOL2, "HU1:CBPM:HU16:FILT.C NPP")
#field(LNK2, "HU1:CBPM:HU16:BW_REF NPP")
#field(SELM, "Mask")
#field(SELN, "0x3ff")
#}
record(ao, "HU1:CBPM:HU16:UPHAS") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU16:UPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU16:VPHAS") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Soft Channel")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU16:VPHAS_SEQ")
}

record(ao, "HU1:CBPM:HU16:UPHAS_OUT") {
  field(DESC, "Detector Phase U")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C15S0")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU16:UPHAS_FB")
}

# If the UPHAS_OUT record updates its
# value then feed back into UPHAS
record(ao, "HU1:CBPM:HU16:UPHAS_FB") {
  field(DESC, "Det. Phase U (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU16:UPHAS_OUT")
  field(OUT, "HU1:CBPM:HU16:UPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU16:VPHAS_OUT") {
  field(DESC, "Detector Phase V")
  field(DTYP, "Cavity Phase")
  field(OUT, "#C15S1")
# value > 360 means 'auto-init'
#  field(VAL,  "1000")
  field(PREC, "1")
  field(EGU, "deg")
  field(FLNK, "HU1:CBPM:HU16:VPHAS_FB")
}

# If the VPHAS_OUT record updates its
# value then feed back into VPHAS
record(ao, "HU1:CBPM:HU16:VPHAS_FB") {
  field(DESC, "Det. Phase V (FB)")
  field(OMSL, "closed_loop")
  field(DOL, "HU1:CBPM:HU16:VPHAS_OUT")
  field(OUT, "HU1:CBPM:HU16:VPHAS PP")
  field(PREC, "1")
  field(EGU, "deg")
}

record(ao, "HU1:CBPM:HU16:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU16:QSCL_SEQ")
}

record(ao, "HU1:CBPM:HU16:URSCL") {
  field(DESC, "RMS U Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:URSCL_SEQ")
}

record(ao, "HU1:CBPM:HU16:VRSCL") {
  field(DESC, "RMS V Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:VRSCL_SEQ")
}

record(ao, "HU1:CBPM:HU16:QRSCL") {
  field(DESC, "RMS Charge Scale")
  field(DTYP, "Soft Channel")
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(FLNK, "HU1:CBPM:HU16:QRSCL_SEQ")
}

record(sub, "HU1:CBPM:HU16:CALC") {
  field(SNAM, "drvBpmBvectSetupSub")
# E: phi F: psi
# BPM channel number in L
  field(INPL, "15")
  field(SCAN, "Passive")
}

# Use CA links to keep these records
# out of beam-rate locksets
record(ai, "HU1:CBPM:HU16:REFR_SLOW") {
  field(DESC, "Slow Raw Ref. Ampl.")
  field(INP, "HU1:CBPM:HU16: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:HU16:URER_SLOW")
}

record(ai, "HU1:CBPM:HU16:URER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU16: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:HU16:UIMR_SLOW")
}

record(ai, "HU1:CBPM:HU16:UIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. U/REF}")
  field(INP, "HU1:CBPM:HU16: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:HU16:VRER_SLOW")
}

record(ai, "HU1:CBPM:HU16:VRER_SLOW") {
  field(DESC, "Slow Re{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU16: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:HU16:VIMR_SLOW")
}

record(ai, "HU1:CBPM:HU16:VIMR_SLOW") {
  field(DESC, "Slow Im{Cmplx Ampl. V/REF}")
  field(INP, "HU1:CBPM:HU16: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:HU16:RCVR_GAIN") {
  field(DESC, "Signal gain for restore")
  field(OUT, "HU1:CBPM:HU16: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:HU16:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "HU1:CBPM:HU16: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:HU16:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S12")
  field(FLNK, "HU1:CBPM:HU16: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:HU16:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "HU1:CBPM:HU16: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:HU16:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C15 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

record(ai, "HU1:CBPM:HU16:U") {
  field(DESC, "Raw U Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S8")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "HU1:CBPM:HU16:V")
}

record(ai, "HU1:CBPM:HU16:V") {
  field(DESC, "Raw V Position")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S9")
  field(SCAN, "Passive")
  field(PREC, "5")
  field(EGU,  "mm")
  field(LOPR, "-0.7")
  field(HOPR, "+0.7")
  field(FLNK, "HU1:CBPM:HU16:PINC")
}

record(ai, "HU1:CBPM:HU16:PINC") {
  field(DESC, "Pin Cushion Corr.")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C15 S10")
  field(SCAN, "Passive")
}

record(longin, "HU1:CBPM:HU16:RSTA") {
  field(DESC, "Status of Raw Processor")
  field(DTYP, "Bpm Raw Status")
  field(INP, "#C15S0")
  field(SCAN, "1 second")
  field(LOLO, "-1")
  field(HIHI, "+1")
  field(HHSV, "INVALID")
  field(LLSV, "INVALID")
  field(FLNK, "HU1:CBPM:HU16:RSTA_ALH")
}


record(calc, "HU1:CBPM:HU16:RSTA_ALH") {
  field(CALC, "A & B")
  field(INPA, "HU1:CBPM:HU16: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:HU16: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:HU16:PHI_SEQ")
}

record(ao, "HU1:CBPM:HU16: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:HU16:PSI_SEQ")
}

#record(dfanout, "HU1:CBPM:HU16:PCMM") {
#  field(DESC, "BPM Scale")
#  field(OUTA, "HU1:CBPM:HU16:USCL PP MS")
#  field(OUTB, "HU1:CBPM:HU16: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:HU16: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:HU16:UOFF_SEQ")
}

record(ao, "HU1:CBPM:HU16: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:HU16:VOFF_SEQ")
}

record(ao, "HU1:CBPM:HU16:USCL") {
  field(DESC, "BPM U Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:USCL_SEQ")
}

record(ao, "HU1:CBPM:HU16:VSCL") {
  field(DESC, "BPM V Scale")
  field(DTYP, "Soft Channel")
  field(VAL,  "1")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:VSCL_SEQ")
}


record(mbbo, "HU1:CBPM:HU16:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C15 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "HU1:CBPM:HU16: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:HU16: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:HU16:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "CBPM_H16")
  field(PINI, "YES")
}

record(stringin, "CBPM_H16:NAME") {
  field(DESC, "BPM Name")
  field(VAL, "HU1:CBPM:HU16")
  field(PINI, "YES")
}

record(ai, "HU1:CBPM:HU16:X_SLOW") {
#alias("HU1:CBPM:HU16:X1H")
  field(DESC, "X snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU16:X MS")
  field(FLNK, "HU1:CBPM:HU16:Y_SLOW")
  field(PREC, "4")
  field(SCAN, "1 second")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU16:Y_SLOW") {
#alias("HU1:CBPM:HU16:Y1H")
  field(DESC, "Y snapshot for display")
  field(EGU, "mm")
  field(INP, "HU1:CBPM:HU16:Y NPP MS")
  field(FLNK, "HU1:CBPM:HU16:TMIT_SLOW")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

record(ai, "HU1:CBPM:HU16:TMIT_SLOW") {
#alias("HU1:CBPM:HU16:TMIT1H")
  field(DESC, "TMIT snapshot for display")
  field(INP, "HU1:CBPM:HU16: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:HU16:SIMOFF") {
  field(DESC, "Sim Off Propagator")
  field(INPA, "HU1:CBPM:HU16:ACCESS.RVAL")
  field(CALC, "A")
  field(OCAL, "0")
  field(OOPT, "When Zero")
  field(DOPT, "Use OCAL")
  field(OUT,  "HU1:CBPM:HU16:SIMC PP")
}

record(calcout, "HU1:CBPM:HU16:SIM") {
  field(DESC, "BPM Pos. Simulation")
  field(DTYP, "Strip Signal Simulator")
  field(OUT, "15")
#CALC & VAL unused; the real calculation is done
#        in device support. The reason this is a
#        calcout rather than sub is that we want
#        to use the OUT link...
  field(CALC, "A")
  field(INPA, "HU1:CBPM:HU16:USCL")
  field(INPL, "0")
}

# Switch simulation record HU1:CBPM:HU16:SIMCSEQ moved to
# bpmCavity.db.part and bpmStripl.db.part 

record(mbbo, "HU1:CBPM:HU16:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "HU1:CBPM:HU16: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:HU16:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:YSIM") {
  field(DESC, "BPM Y Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "HU1:CBPM:HU16: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:HU16:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

record(ao, "HU1:CBPM:HU16:PSIS") {
  field(DESC, "BPM Angle. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "HU1:CBPM:HU16:SIM.F PP")
  field(VAL, "90")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "0")
}

record(aao, "HU1:CBPM:HU16:DIGISIMW") {
  field(DESC, "VME Digi Sim. Waveform")
  field(DTYP, "VmeDigi Sim Wav")
  field(OUT,  "#C15 S0")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32678")
  field(LOPR, "-32768")
# 16384 samples/channel * 4 channels
  field(NELM, "65536")
  field(PINI, "NO")
}

#Used by model/database folks to verify BPM

record(ao, "HU1:CBPM:HU16:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# MPS interface
record(bo, "HU1:CBPM:HU16:MPSBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@bpmMPS+0,m32")
  field(MASK, "0x8000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "MAJOR")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(bo, "HU1:CBPM:HU16:MPSLTBYP") {
  field(DESC, "MPS Bypass")
  field(DTYP, "BusAddress")
  field(OUT,  "#C1S2@bpmMPS+0,m32")
  field(MASK, "0x8000")
  field(ZNAM, "BYPASSED")
  field(ONAM, "NOT_BYPASSED")
  field(ZSV,  "NO_ALARM")
  field(OSV,  "NO_ALARM")
  field(VAL,  "0")
  field(PINI, "YES")
  field(ASG,  "")
  info(autosaveFields, "VAL")
}

record(calc, "HU1:CBPM:HU16:MPSIGNRCALC") {
  field(DESC, "MPS ignore if TMIT too low")
  field(CALC, "A<B")
  field(INPA, "HU1:CBPM:HU16:TMIT")
  field(INPB, "HU1:CBPM:HU16:T_MPS_THRES_L")
  field(HIHI, "1")
  field(HHSV, "MAJOR")
  field(ASG, "")
}

record(bi, "HU1:CBPM:HU16:MPSIGNORE") {
  field(DESC, "MPS ignore if TMIT too low")
  field(DTYP, "Raw Soft Channel")
  field(SCAN, "1 second")
  field(INP, "HU1:CBPM:HU16: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:HU16:XAOFF") {
  field(DESC, "X.AOFF val")
#  field(OUT, "HU1:CBPM:HU16:X.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:XOFF")
  info(autosaveFields, "VAL")
}

record(ao, "HU1:CBPM:HU16:YAOFF") {
  field(DESC, "Y.AOFF val")
#  field(OUT, "HU1:CBPM:HU16:Y.AOFF")
  field(PINI, "YES")
  field(EGU, "mm")
  field(PREC, "4")
  field(FLNK, "HU1:CBPM:HU16:YOFF")
  info(autosaveFields, "VAL")
}

# Add CALC to allow users to maintain
# multiple offsets per plane per BPM

record(calcout, "HU1:CBPM:HU16:XOFF") {
  field(DESC, "Add X offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU16:XAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU16:X.AOFF")
  info(autosaveFields, "B C D E")
}

record(calcout, "HU1:CBPM:HU16:YOFF") {
  field(DESC, "Add Y offsets")
  field(PREC, "4")
  field(CALC, "A+B+C+D")
  field(INPA, "HU1:CBPM:HU16:YAOFF")
# B-E reserved for undulator offsets
  field(INPB, "")
  field(INPC, "")
  field(INPD, "")
  field(INPE, "")
  field(EGU, "mm")
  field(OUT, "HU1:CBPM:HU16:Y.AOFF")
  info(autosaveFields, "B C D E")
}


# Records to set MPS thresholds
record(ao, "HU1:CBPM:HU16:X_MPS_THRES_L") {
  field(DESC, "MPS X Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S0 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "HU1:CBPM:HU16:X_MPS_THRES_H") {
  field(DESC, "MPS X Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S0 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "HU1:CBPM:HU16:Y_MPS_THRES_L") {
  field(DESC, "MPS Y Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S1 @Lo")
  field(VAL,  "-1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "HU1:CBPM:HU16:Y_MPS_THRES_H") {
  field(DESC, "MPS Y Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S1 @Hi")
  field(VAL,  "1")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "HU1:CBPM:HU16:T_MPS_THRES_L") {
  field(DESC, "MPS TMIT Threshold Lo")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S2 @Lo")
  field(VAL,  "9.375e7")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}
record(ao, "HU1:CBPM:HU16:T_MPS_THRES_H") {
  field(DESC, "MPS TMIT Threshold Hi")
  field(DTYP, "Bpm Mps Threshold")
  field(OUT,  "#C15 S2 @Hi")
  field(VAL,  "+1.0E20")
  field(EGU,  "mm")
  field(PREC, "4")
  field(PINI, "YES")
  field(ASG, "")
  info(autosaveFields, "VAL")
}

record(bi, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:SIM.L     PP")
  field(LNK4, "HU1:CBPM:HU16:SIM.SCAN  PP")

  field(LNK5, "HU1:CBPM:HU16:SIM.SCAN  PP")
  field(LNK6, "HU1:CBPM:HU16:SIM.L     PP")
  field(LNK7, "HU1:CBPM:HU16: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:HU16:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:UOFF")
	field(DOL2, "HU1:CBPM:HU16:UOFF")
	field(DOL3, "HU1:CBPM:HU16:UOFF")
	field(DOL4, "HU1:CBPM:HU16:UOFF")
	field(DOL5, "HU1:CBPM:HU16:UOFF")
	field(DOL6, "HU1:CBPM:HU16:UOFF")
	field(DOL7, "HU1:CBPM:HU16:UOFF")
	field(DOL8, "HU1:CBPM:HU16:UOFF")
	field(DOL9, "HU1:CBPM:HU16:UOFF")
	field(DOLA, "HU1:CBPM:HU16:UOFF")
	field(LNK1, "HU1:CBPM:HU16:UOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:UOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:UOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:UOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:UOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:UOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:UOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:UOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:UOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:UOFF_SEL")
	field(OUTA, "HU1:CBPM:HU16:U.AOFF CA")
	field(OUTB, "HU1:CBPM:HU16:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:UOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:VOFF")
	field(DOL2, "HU1:CBPM:HU16:VOFF")
	field(DOL3, "HU1:CBPM:HU16:VOFF")
	field(DOL4, "HU1:CBPM:HU16:VOFF")
	field(DOL5, "HU1:CBPM:HU16:VOFF")
	field(DOL6, "HU1:CBPM:HU16:VOFF")
	field(DOL7, "HU1:CBPM:HU16:VOFF")
	field(DOL8, "HU1:CBPM:HU16:VOFF")
	field(DOL9, "HU1:CBPM:HU16:VOFF")
	field(DOLA, "HU1:CBPM:HU16:VOFF")
	field(LNK1, "HU1:CBPM:HU16:VOFF_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:VOFF_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:VOFF_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:VOFF_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:VOFF_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:VOFF_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:VOFF_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:VOFF_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:VOFF_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:VOFF_SEL")
	field(OUTA, "HU1:CBPM:HU16:V.AOFF CA")
	field(OUTB, "HU1:CBPM:HU16:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:VOFF_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:USCL")
	field(DOL2, "HU1:CBPM:HU16:USCL")
	field(DOL3, "HU1:CBPM:HU16:USCL")
	field(DOL4, "HU1:CBPM:HU16:USCL")
	field(DOL5, "HU1:CBPM:HU16:USCL")
	field(DOL6, "HU1:CBPM:HU16:USCL")
	field(DOL7, "HU1:CBPM:HU16:USCL")
	field(DOL8, "HU1:CBPM:HU16:USCL")
	field(DOL9, "HU1:CBPM:HU16:USCL")
	field(DOLA, "HU1:CBPM:HU16:USCL")
	field(LNK1, "HU1:CBPM:HU16:USCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:USCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:USCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:USCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:USCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:USCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:USCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:USCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:USCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:USCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:U.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:USCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:VSCL")
	field(DOL2, "HU1:CBPM:HU16:VSCL")
	field(DOL3, "HU1:CBPM:HU16:VSCL")
	field(DOL4, "HU1:CBPM:HU16:VSCL")
	field(DOL5, "HU1:CBPM:HU16:VSCL")
	field(DOL6, "HU1:CBPM:HU16:VSCL")
	field(DOL7, "HU1:CBPM:HU16:VSCL")
	field(DOL8, "HU1:CBPM:HU16:VSCL")
	field(DOL9, "HU1:CBPM:HU16:VSCL")
	field(DOLA, "HU1:CBPM:HU16:VSCL")
	field(LNK1, "HU1:CBPM:HU16:VSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:VSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:VSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:VSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:VSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:VSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:VSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:VSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:VSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:VSCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:V.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:VSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:PHI")
	field(DOL2, "HU1:CBPM:HU16:PHI")
	field(DOL3, "HU1:CBPM:HU16:PHI")
	field(DOL4, "HU1:CBPM:HU16:PHI")
	field(DOL5, "HU1:CBPM:HU16:PHI")
	field(DOL6, "HU1:CBPM:HU16:PHI")
	field(DOL7, "HU1:CBPM:HU16:PHI")
	field(DOL8, "HU1:CBPM:HU16:PHI")
	field(DOL9, "HU1:CBPM:HU16:PHI")
	field(DOLA, "HU1:CBPM:HU16:PHI")
	field(LNK1, "HU1:CBPM:HU16:PHI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:PHI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:PHI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:PHI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:PHI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:PHI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:PHI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:PHI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:PHI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:PHI_SEL")
	field(OUTA, "HU1:CBPM:HU16:CALC.E CA")
	field(OUTB, "HU1:CBPM:HU16:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:PHI_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:PSI")
	field(DOL2, "HU1:CBPM:HU16:PSI")
	field(DOL3, "HU1:CBPM:HU16:PSI")
	field(DOL4, "HU1:CBPM:HU16:PSI")
	field(DOL5, "HU1:CBPM:HU16:PSI")
	field(DOL6, "HU1:CBPM:HU16:PSI")
	field(DOL7, "HU1:CBPM:HU16:PSI")
	field(DOL8, "HU1:CBPM:HU16:PSI")
	field(DOL9, "HU1:CBPM:HU16:PSI")
	field(DOLA, "HU1:CBPM:HU16:PSI")
	field(LNK1, "HU1:CBPM:HU16:PSI_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:PSI_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:PSI_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:PSI_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:PSI_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:PSI_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:PSI_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:PSI_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:PSI_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:PSI_SEL")
	field(OUTA, "HU1:CBPM:HU16:CALC.F CA")
	field(OUTB, "HU1:CBPM:HU16:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:PSI_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:UPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:UPHAS")
	field(DOL2, "HU1:CBPM:HU16:UPHAS")
	field(DOL3, "HU1:CBPM:HU16:UPHAS")
	field(DOL4, "HU1:CBPM:HU16:UPHAS")
	field(DOL5, "HU1:CBPM:HU16:UPHAS")
	field(DOL6, "HU1:CBPM:HU16:UPHAS")
	field(DOL7, "HU1:CBPM:HU16:UPHAS")
	field(DOL8, "HU1:CBPM:HU16:UPHAS")
	field(DOL9, "HU1:CBPM:HU16:UPHAS")
	field(DOLA, "HU1:CBPM:HU16:UPHAS")
	field(LNK1, "HU1:CBPM:HU16:UPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:UPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:UPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:UPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:UPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:UPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:UPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:UPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:UPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:UPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:UPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:UPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU16:UPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU16:UPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:UPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:VPHAS_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:VPHAS")
	field(DOL2, "HU1:CBPM:HU16:VPHAS")
	field(DOL3, "HU1:CBPM:HU16:VPHAS")
	field(DOL4, "HU1:CBPM:HU16:VPHAS")
	field(DOL5, "HU1:CBPM:HU16:VPHAS")
	field(DOL6, "HU1:CBPM:HU16:VPHAS")
	field(DOL7, "HU1:CBPM:HU16:VPHAS")
	field(DOL8, "HU1:CBPM:HU16:VPHAS")
	field(DOL9, "HU1:CBPM:HU16:VPHAS")
	field(DOLA, "HU1:CBPM:HU16:VPHAS")
	field(LNK1, "HU1:CBPM:HU16:VPHAS_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:VPHAS_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:VPHAS_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:VPHAS_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:VPHAS_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:VPHAS_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:VPHAS_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:VPHAS_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:VPHAS_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:VPHAS_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:VPHAS_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:VPHAS_SEL")
	field(OUTA, "HU1:CBPM:HU16:VPHAS_OUT PP NMS")
	field(OUTB, "HU1:CBPM:HU16:VPHAS PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:VPHAS_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:QSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:QSCL")
	field(DOL2, "HU1:CBPM:HU16:QSCL")
	field(DOL3, "HU1:CBPM:HU16:QSCL")
	field(DOL4, "HU1:CBPM:HU16:QSCL")
	field(DOL5, "HU1:CBPM:HU16:QSCL")
	field(DOL6, "HU1:CBPM:HU16:QSCL")
	field(DOL7, "HU1:CBPM:HU16:QSCL")
	field(DOL8, "HU1:CBPM:HU16:QSCL")
	field(DOL9, "HU1:CBPM:HU16:QSCL")
	field(DOLA, "HU1:CBPM:HU16:QSCL")
	field(LNK1, "HU1:CBPM:HU16:QSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:QSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:QSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:QSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:QSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:QSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:QSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:QSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:QSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:QSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:QSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:QSCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:TMIT.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:QSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:QSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:URSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:URSCL")
	field(DOL2, "HU1:CBPM:HU16:URSCL")
	field(DOL3, "HU1:CBPM:HU16:URSCL")
	field(DOL4, "HU1:CBPM:HU16:URSCL")
	field(DOL5, "HU1:CBPM:HU16:URSCL")
	field(DOL6, "HU1:CBPM:HU16:URSCL")
	field(DOL7, "HU1:CBPM:HU16:URSCL")
	field(DOL8, "HU1:CBPM:HU16:URSCL")
	field(DOL9, "HU1:CBPM:HU16:URSCL")
	field(DOLA, "HU1:CBPM:HU16:URSCL")
	field(LNK1, "HU1:CBPM:HU16:URSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:URSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:URSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:URSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:URSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:URSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:URSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:URSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:URSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:URSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:URSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:URSCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:URMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:URSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:URSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:VRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:VRSCL")
	field(DOL2, "HU1:CBPM:HU16:VRSCL")
	field(DOL3, "HU1:CBPM:HU16:VRSCL")
	field(DOL4, "HU1:CBPM:HU16:VRSCL")
	field(DOL5, "HU1:CBPM:HU16:VRSCL")
	field(DOL6, "HU1:CBPM:HU16:VRSCL")
	field(DOL7, "HU1:CBPM:HU16:VRSCL")
	field(DOL8, "HU1:CBPM:HU16:VRSCL")
	field(DOL9, "HU1:CBPM:HU16:VRSCL")
	field(DOLA, "HU1:CBPM:HU16:VRSCL")
	field(LNK1, "HU1:CBPM:HU16:VRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:VRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:VRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:VRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:VRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:VRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:VRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:VRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:VRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:VRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:VRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:VRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:VRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:VRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:VRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16: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:HU16:QRSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "HU1:CBPM:HU16:QRSCL")
	field(DOL2, "HU1:CBPM:HU16:QRSCL")
	field(DOL3, "HU1:CBPM:HU16:QRSCL")
	field(DOL4, "HU1:CBPM:HU16:QRSCL")
	field(DOL5, "HU1:CBPM:HU16:QRSCL")
	field(DOL6, "HU1:CBPM:HU16:QRSCL")
	field(DOL7, "HU1:CBPM:HU16:QRSCL")
	field(DOL8, "HU1:CBPM:HU16:QRSCL")
	field(DOL9, "HU1:CBPM:HU16:QRSCL")
	field(DOLA, "HU1:CBPM:HU16:QRSCL")
	field(LNK1, "HU1:CBPM:HU16:QRSCL_SEL.A PP")
	field(LNK2, "HU1:CBPM:HU16:QRSCL_SEL.B PP")
	field(LNK3, "HU1:CBPM:HU16:QRSCL_SEL.C PP")
	field(LNK4, "HU1:CBPM:HU16:QRSCL_SEL.D PP")
	field(LNK5, "HU1:CBPM:HU16:QRSCL_SEL.E PP")
	field(LNK6, "HU1:CBPM:HU16:QRSCL_SEL.F PP")
	field(LNK7, "HU1:CBPM:HU16:QRSCL_SEL.G PP")
	field(LNK8, "HU1:CBPM:HU16:QRSCL_SEL.H PP")
	field(LNK9, "HU1:CBPM:HU16:QRSCL_SEL.I PP")
	field(LNKA, "HU1:CBPM:HU16:QRSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "HU1:CBPM:HU16: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:HU16: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:HU16: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:HU16:QRSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "HU1:CBPM:HU16:QRSCL_SEL")
	field(OUTA, "HU1:CBPM:HU16:RRMS.ASLO CA")
	field(OUTB, "HU1:CBPM:HU16:QRSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "HU1:CBPM:HU16:QRSCL_CTRL")
{
	field(INPA, "HU1:CBPM:HU16:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "HU1:CBPM:HU16:QRSCL_SEL.L PP")
}
record(longout,"HU1:CBPM:HU16:PARMSEL") {
	field(OMSL,"closed_loop")
	field(DOL, "HU1:CBPM:HU16:RCVR_GAIN CP")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "HU1:CBPM:HU01: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:HU01: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:HU01: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:HU01: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:HU02: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:HU02: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:HU02: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:HU02: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:HU03: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:HU03: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:HU03: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:HU03: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:HU04: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:HU04: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:HU04: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:HU04: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:HU05: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:HU05: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:HU05: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:HU05: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:HU06: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:HU06: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:HU06: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:HU06: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:HU07: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:HU07: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:HU07: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:HU07: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:HU08: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:HU08: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:HU08: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:HU08: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:HU09: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:HU09: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:HU09: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:HU09: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:HU10: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:HU10: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:HU10: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:HU10: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:HU11: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:HU11: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:HU11: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:HU11: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:HU12: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:HU12: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:HU12: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:HU12: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:HU13: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:HU13: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:HU13: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:HU13: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:HU14: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:HU14: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:HU14: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:HU14: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:HU15: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:HU15: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:HU15: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:HU15:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C14S0@0x4FC(8)")
	field(PINI, "YES")
}
# Registers on Struck AMC

# Digitizer AMC FW version
record(stringin, "HU1:CBPM:HU16:DIGIVERS") {
	field(DESC, "Digitizer Firmware Vers.")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4F8(8)")
	field(PINI, "YES")
}

# Firmware date
record(stringin, "HU1:CBPM:HU16:DIGIVERS_DATE") {
	field(DESC, "Firmware Vers. Date")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FE(8)")
	field(PINI, "YES")
}

# System ID
record(stringin, "HU1:CBPM:HU16:DIGI_SYSID") {
	field(DESC, "Digitizer System ID")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FA(8)")
	field(PINI, "YES")
}

# Sub Type
record(stringin, "HU1:CBPM:HU16:SUBSYS") {
	field(DESC, "Subsystem type")
	field(DTYP, "sis8300Digi")
# address is digitizer base address + register
	field(INP,  "#C15S0@0x4FC(8)")
	field(PINI, "YES")
}
