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


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:760:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C0 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:760:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C0 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:760:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C0 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:760:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C0 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:760:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C0 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:760:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C0 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:760:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C0 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:760:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C0 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:760:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C0 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:760:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:760:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:760:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:760:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:760:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:760:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:760:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C0 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:760:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:760:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:760:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:760:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:760:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:760:ATT1 CP")
  field(INPC, "BPMS:LTU1:760:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:760:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:760:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:760:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:760:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:760:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:760:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:760:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:760:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:760:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:760:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:760:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:760:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:760:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:760:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:760:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:760:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:760:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:760:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:760:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:760:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:760:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:760:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:760:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:760:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:760:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:760:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:760:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:760:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:760:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:760:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:760:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:760:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:760:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:760:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:760:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:760:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:760:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:760:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:760:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:760:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:760:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:760:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "1")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:760:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C0S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:760:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:760: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, "BPMS:LTU1:760:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S12")
  field(FLNK, "BPMS:LTU1:760: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, "BPMS:LTU1:760:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C0 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:760: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, "BPMS:LTU1:760:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C0 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:760:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:760:PHI_SEQ")
}

record(ao, "BPMS:LTU1:760:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:760:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:760:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:760:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:760:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:760:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:760:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C0 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:760:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:760: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, "BPMS:LTU1:760:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPME35")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:760:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:760:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:760:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:760:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:760:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:760:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:760:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:760:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:760:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:760: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, "BPMS:LTU1:760: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, "BPMS:LTU1:760: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, "BPMS:LTU1:760: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, "BPMS:LTU1:760: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, "BPMS:LTU1:760: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, "BPMS:LTU1:760:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:760:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:760: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, "BPMS:LTU1:760:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:760:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:760:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:760:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:760:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:760:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:760:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:760:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:760:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:UOFF")
	field(DOL2, "BPMS:LTU1:760:UOFF")
	field(DOL3, "BPMS:LTU1:760:UOFF")
	field(DOL4, "BPMS:LTU1:760:UOFF")
	field(DOL5, "BPMS:LTU1:760:UOFF")
	field(DOL6, "BPMS:LTU1:760:UOFF")
	field(DOL7, "BPMS:LTU1:760:UOFF")
	field(DOL8, "BPMS:LTU1:760:UOFF")
	field(DOL9, "BPMS:LTU1:760:UOFF")
	field(DOLA, "BPMS:LTU1:760:UOFF")
	field(LNK1, "BPMS:LTU1:760:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:760:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:760:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:760:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:VOFF")
	field(DOL2, "BPMS:LTU1:760:VOFF")
	field(DOL3, "BPMS:LTU1:760:VOFF")
	field(DOL4, "BPMS:LTU1:760:VOFF")
	field(DOL5, "BPMS:LTU1:760:VOFF")
	field(DOL6, "BPMS:LTU1:760:VOFF")
	field(DOL7, "BPMS:LTU1:760:VOFF")
	field(DOL8, "BPMS:LTU1:760:VOFF")
	field(DOL9, "BPMS:LTU1:760:VOFF")
	field(DOLA, "BPMS:LTU1:760:VOFF")
	field(LNK1, "BPMS:LTU1:760:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:760:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:760:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:760:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:USCL")
	field(DOL2, "BPMS:LTU1:760:USCL")
	field(DOL3, "BPMS:LTU1:760:USCL")
	field(DOL4, "BPMS:LTU1:760:USCL")
	field(DOL5, "BPMS:LTU1:760:USCL")
	field(DOL6, "BPMS:LTU1:760:USCL")
	field(DOL7, "BPMS:LTU1:760:USCL")
	field(DOL8, "BPMS:LTU1:760:USCL")
	field(DOL9, "BPMS:LTU1:760:USCL")
	field(DOLA, "BPMS:LTU1:760:USCL")
	field(LNK1, "BPMS:LTU1:760:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:760:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:USCL_SEL")
	field(OUTA, "BPMS:LTU1:760:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:760:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:VSCL")
	field(DOL2, "BPMS:LTU1:760:VSCL")
	field(DOL3, "BPMS:LTU1:760:VSCL")
	field(DOL4, "BPMS:LTU1:760:VSCL")
	field(DOL5, "BPMS:LTU1:760:VSCL")
	field(DOL6, "BPMS:LTU1:760:VSCL")
	field(DOL7, "BPMS:LTU1:760:VSCL")
	field(DOL8, "BPMS:LTU1:760:VSCL")
	field(DOL9, "BPMS:LTU1:760:VSCL")
	field(DOLA, "BPMS:LTU1:760:VSCL")
	field(LNK1, "BPMS:LTU1:760:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:760:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:760:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:760:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:PHI")
	field(DOL2, "BPMS:LTU1:760:PHI")
	field(DOL3, "BPMS:LTU1:760:PHI")
	field(DOL4, "BPMS:LTU1:760:PHI")
	field(DOL5, "BPMS:LTU1:760:PHI")
	field(DOL6, "BPMS:LTU1:760:PHI")
	field(DOL7, "BPMS:LTU1:760:PHI")
	field(DOL8, "BPMS:LTU1:760:PHI")
	field(DOL9, "BPMS:LTU1:760:PHI")
	field(DOLA, "BPMS:LTU1:760:PHI")
	field(LNK1, "BPMS:LTU1:760:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:760:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:PHI_SEL")
	field(OUTA, "BPMS:LTU1:760:CALC.E CA")
	field(OUTB, "BPMS:LTU1:760:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:760:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:760:PSI")
	field(DOL2, "BPMS:LTU1:760:PSI")
	field(DOL3, "BPMS:LTU1:760:PSI")
	field(DOL4, "BPMS:LTU1:760:PSI")
	field(DOL5, "BPMS:LTU1:760:PSI")
	field(DOL6, "BPMS:LTU1:760:PSI")
	field(DOL7, "BPMS:LTU1:760:PSI")
	field(DOL8, "BPMS:LTU1:760:PSI")
	field(DOL9, "BPMS:LTU1:760:PSI")
	field(DOLA, "BPMS:LTU1:760:PSI")
	field(LNK1, "BPMS:LTU1:760:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:760:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:760:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:760:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:760:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:760:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:760:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:760:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:760:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:760:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:760:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:760:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:760:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:760:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:760:PSI_SEL")
	field(OUTA, "BPMS:LTU1:760:CALC.F CA")
	field(OUTB, "BPMS:LTU1:760:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:760:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:760:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:760:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:760:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:770:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C1 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:770:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C1 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:770:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C1 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:770:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C1 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:770:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C1 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:770:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C1 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:770:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C1 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:770:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C1 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:770:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C1 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:770:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:770:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:770:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:770:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:770:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:770:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:770:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C1 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:770:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:770:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:770:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:770:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:770:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:770:ATT1 CP")
  field(INPC, "BPMS:LTU1:770:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:770:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:770:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:770:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:770:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:770:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:770:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:770:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:770:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:770:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:770:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:770:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:770:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:770:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:770:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:770:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:770:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:770:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:770:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:770:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:770:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:770:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:770:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:770:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:770:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:770:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:770:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:770:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:770:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:770:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:770:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:770:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:770:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:770:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:770:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:770:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:770:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:770:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:770:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:770:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:770:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:770:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:770:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "2")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:770:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C1S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:770:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:770: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, "BPMS:LTU1:770:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S12")
  field(FLNK, "BPMS:LTU1:770: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, "BPMS:LTU1:770:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C1 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:770: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, "BPMS:LTU1:770:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C1 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:770:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:770:PHI_SEQ")
}

record(ao, "BPMS:LTU1:770:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:770:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:770:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:770:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:770:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:770:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:770:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C1 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:770:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:770: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, "BPMS:LTU1:770:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPME36")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:770:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:770:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:770:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:770:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:770:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:770:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:770:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:770:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:770:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:770: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, "BPMS:LTU1:770: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, "BPMS:LTU1:770: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, "BPMS:LTU1:770: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, "BPMS:LTU1:770: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, "BPMS:LTU1:770: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, "BPMS:LTU1:770:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:770:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:770: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, "BPMS:LTU1:770:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:770:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:770:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:770:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:770:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:770:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:770:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:770:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:770:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:UOFF")
	field(DOL2, "BPMS:LTU1:770:UOFF")
	field(DOL3, "BPMS:LTU1:770:UOFF")
	field(DOL4, "BPMS:LTU1:770:UOFF")
	field(DOL5, "BPMS:LTU1:770:UOFF")
	field(DOL6, "BPMS:LTU1:770:UOFF")
	field(DOL7, "BPMS:LTU1:770:UOFF")
	field(DOL8, "BPMS:LTU1:770:UOFF")
	field(DOL9, "BPMS:LTU1:770:UOFF")
	field(DOLA, "BPMS:LTU1:770:UOFF")
	field(LNK1, "BPMS:LTU1:770:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:770:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:770:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:770:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:VOFF")
	field(DOL2, "BPMS:LTU1:770:VOFF")
	field(DOL3, "BPMS:LTU1:770:VOFF")
	field(DOL4, "BPMS:LTU1:770:VOFF")
	field(DOL5, "BPMS:LTU1:770:VOFF")
	field(DOL6, "BPMS:LTU1:770:VOFF")
	field(DOL7, "BPMS:LTU1:770:VOFF")
	field(DOL8, "BPMS:LTU1:770:VOFF")
	field(DOL9, "BPMS:LTU1:770:VOFF")
	field(DOLA, "BPMS:LTU1:770:VOFF")
	field(LNK1, "BPMS:LTU1:770:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:770:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:770:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:770:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:USCL")
	field(DOL2, "BPMS:LTU1:770:USCL")
	field(DOL3, "BPMS:LTU1:770:USCL")
	field(DOL4, "BPMS:LTU1:770:USCL")
	field(DOL5, "BPMS:LTU1:770:USCL")
	field(DOL6, "BPMS:LTU1:770:USCL")
	field(DOL7, "BPMS:LTU1:770:USCL")
	field(DOL8, "BPMS:LTU1:770:USCL")
	field(DOL9, "BPMS:LTU1:770:USCL")
	field(DOLA, "BPMS:LTU1:770:USCL")
	field(LNK1, "BPMS:LTU1:770:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:770:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:USCL_SEL")
	field(OUTA, "BPMS:LTU1:770:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:770:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:VSCL")
	field(DOL2, "BPMS:LTU1:770:VSCL")
	field(DOL3, "BPMS:LTU1:770:VSCL")
	field(DOL4, "BPMS:LTU1:770:VSCL")
	field(DOL5, "BPMS:LTU1:770:VSCL")
	field(DOL6, "BPMS:LTU1:770:VSCL")
	field(DOL7, "BPMS:LTU1:770:VSCL")
	field(DOL8, "BPMS:LTU1:770:VSCL")
	field(DOL9, "BPMS:LTU1:770:VSCL")
	field(DOLA, "BPMS:LTU1:770:VSCL")
	field(LNK1, "BPMS:LTU1:770:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:770:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:770:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:770:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:PHI")
	field(DOL2, "BPMS:LTU1:770:PHI")
	field(DOL3, "BPMS:LTU1:770:PHI")
	field(DOL4, "BPMS:LTU1:770:PHI")
	field(DOL5, "BPMS:LTU1:770:PHI")
	field(DOL6, "BPMS:LTU1:770:PHI")
	field(DOL7, "BPMS:LTU1:770:PHI")
	field(DOL8, "BPMS:LTU1:770:PHI")
	field(DOL9, "BPMS:LTU1:770:PHI")
	field(DOLA, "BPMS:LTU1:770:PHI")
	field(LNK1, "BPMS:LTU1:770:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:770:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:PHI_SEL")
	field(OUTA, "BPMS:LTU1:770:CALC.E CA")
	field(OUTB, "BPMS:LTU1:770:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:770:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:770:PSI")
	field(DOL2, "BPMS:LTU1:770:PSI")
	field(DOL3, "BPMS:LTU1:770:PSI")
	field(DOL4, "BPMS:LTU1:770:PSI")
	field(DOL5, "BPMS:LTU1:770:PSI")
	field(DOL6, "BPMS:LTU1:770:PSI")
	field(DOL7, "BPMS:LTU1:770:PSI")
	field(DOL8, "BPMS:LTU1:770:PSI")
	field(DOL9, "BPMS:LTU1:770:PSI")
	field(DOLA, "BPMS:LTU1:770:PSI")
	field(LNK1, "BPMS:LTU1:770:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:770:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:770:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:770:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:770:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:770:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:770:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:770:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:770:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:770:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:770:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:770:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:770:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:770:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:770:PSI_SEL")
	field(OUTA, "BPMS:LTU1:770:CALC.F CA")
	field(OUTB, "BPMS:LTU1:770:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:770:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:770:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:770:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:770:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:820:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C2 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:820:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C2 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:820:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C2 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:820:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C2 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:820:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C2 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:820:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C2 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:820:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C2 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:820:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C2 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:820:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C2 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:820:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:820:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:820:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:820:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:820:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:820:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:820:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C2 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:820:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:820:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:820:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:820:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:820:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:820:ATT1 CP")
  field(INPC, "BPMS:LTU1:820:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:820:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:820:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:820:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:820:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:820:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:820:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:820:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:820:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:820:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:820:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:820:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:820:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:820:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:820:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:820:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:820:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:820:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:820:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:820:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:820:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:820:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:820:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:820:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:820:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:820:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:820:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:820:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:820:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:820:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:820:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:820:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:820:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:820:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:820:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:820:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:820:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:820:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:820:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:820:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:820:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:820:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:820:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "4")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:820:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C2S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:820:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:820: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, "BPMS:LTU1:820:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S12")
  field(FLNK, "BPMS:LTU1:820: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, "BPMS:LTU1:820:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C2 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:820: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, "BPMS:LTU1:820:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C2 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:820:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:820:PHI_SEQ")
}

record(ao, "BPMS:LTU1:820:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:820:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:820:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:820:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:820:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:820:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:820:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C2 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:820:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:820: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, "BPMS:LTU1:820:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPMMUM1")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:820:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:820:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:820:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:820:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:820:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:820:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:820:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:820:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:820:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:820: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, "BPMS:LTU1:820: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, "BPMS:LTU1:820: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, "BPMS:LTU1:820: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, "BPMS:LTU1:820: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, "BPMS:LTU1:820: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, "BPMS:LTU1:820:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:820:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:820: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, "BPMS:LTU1:820:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:820:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:820:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:820:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:820:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:820:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:820:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:820:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:820:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:UOFF")
	field(DOL2, "BPMS:LTU1:820:UOFF")
	field(DOL3, "BPMS:LTU1:820:UOFF")
	field(DOL4, "BPMS:LTU1:820:UOFF")
	field(DOL5, "BPMS:LTU1:820:UOFF")
	field(DOL6, "BPMS:LTU1:820:UOFF")
	field(DOL7, "BPMS:LTU1:820:UOFF")
	field(DOL8, "BPMS:LTU1:820:UOFF")
	field(DOL9, "BPMS:LTU1:820:UOFF")
	field(DOLA, "BPMS:LTU1:820:UOFF")
	field(LNK1, "BPMS:LTU1:820:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:820:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:820:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:820:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:VOFF")
	field(DOL2, "BPMS:LTU1:820:VOFF")
	field(DOL3, "BPMS:LTU1:820:VOFF")
	field(DOL4, "BPMS:LTU1:820:VOFF")
	field(DOL5, "BPMS:LTU1:820:VOFF")
	field(DOL6, "BPMS:LTU1:820:VOFF")
	field(DOL7, "BPMS:LTU1:820:VOFF")
	field(DOL8, "BPMS:LTU1:820:VOFF")
	field(DOL9, "BPMS:LTU1:820:VOFF")
	field(DOLA, "BPMS:LTU1:820:VOFF")
	field(LNK1, "BPMS:LTU1:820:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:820:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:820:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:820:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:USCL")
	field(DOL2, "BPMS:LTU1:820:USCL")
	field(DOL3, "BPMS:LTU1:820:USCL")
	field(DOL4, "BPMS:LTU1:820:USCL")
	field(DOL5, "BPMS:LTU1:820:USCL")
	field(DOL6, "BPMS:LTU1:820:USCL")
	field(DOL7, "BPMS:LTU1:820:USCL")
	field(DOL8, "BPMS:LTU1:820:USCL")
	field(DOL9, "BPMS:LTU1:820:USCL")
	field(DOLA, "BPMS:LTU1:820:USCL")
	field(LNK1, "BPMS:LTU1:820:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:820:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:USCL_SEL")
	field(OUTA, "BPMS:LTU1:820:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:820:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:VSCL")
	field(DOL2, "BPMS:LTU1:820:VSCL")
	field(DOL3, "BPMS:LTU1:820:VSCL")
	field(DOL4, "BPMS:LTU1:820:VSCL")
	field(DOL5, "BPMS:LTU1:820:VSCL")
	field(DOL6, "BPMS:LTU1:820:VSCL")
	field(DOL7, "BPMS:LTU1:820:VSCL")
	field(DOL8, "BPMS:LTU1:820:VSCL")
	field(DOL9, "BPMS:LTU1:820:VSCL")
	field(DOLA, "BPMS:LTU1:820:VSCL")
	field(LNK1, "BPMS:LTU1:820:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:820:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:820:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:820:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:PHI")
	field(DOL2, "BPMS:LTU1:820:PHI")
	field(DOL3, "BPMS:LTU1:820:PHI")
	field(DOL4, "BPMS:LTU1:820:PHI")
	field(DOL5, "BPMS:LTU1:820:PHI")
	field(DOL6, "BPMS:LTU1:820:PHI")
	field(DOL7, "BPMS:LTU1:820:PHI")
	field(DOL8, "BPMS:LTU1:820:PHI")
	field(DOL9, "BPMS:LTU1:820:PHI")
	field(DOLA, "BPMS:LTU1:820:PHI")
	field(LNK1, "BPMS:LTU1:820:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:820:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:PHI_SEL")
	field(OUTA, "BPMS:LTU1:820:CALC.E CA")
	field(OUTB, "BPMS:LTU1:820:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:820:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:820:PSI")
	field(DOL2, "BPMS:LTU1:820:PSI")
	field(DOL3, "BPMS:LTU1:820:PSI")
	field(DOL4, "BPMS:LTU1:820:PSI")
	field(DOL5, "BPMS:LTU1:820:PSI")
	field(DOL6, "BPMS:LTU1:820:PSI")
	field(DOL7, "BPMS:LTU1:820:PSI")
	field(DOL8, "BPMS:LTU1:820:PSI")
	field(DOL9, "BPMS:LTU1:820:PSI")
	field(DOLA, "BPMS:LTU1:820:PSI")
	field(LNK1, "BPMS:LTU1:820:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:820:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:820:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:820:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:820:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:820:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:820:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:820:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:820:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:820:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:820:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:820:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:820:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:820:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:820:PSI_SEL")
	field(OUTA, "BPMS:LTU1:820:CALC.F CA")
	field(OUTB, "BPMS:LTU1:820:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:820:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:820:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:820:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:820:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:840:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C3 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:840:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C3 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:840:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C3 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:840:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C3 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:840:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C3 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:840:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C3 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:840:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C3 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:840:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C3 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:840:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C3 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:840:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:840:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:840:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:840:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:840:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:840:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:840:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C3 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:840:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:840:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:840:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:840:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:840:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:840:ATT1 CP")
  field(INPC, "BPMS:LTU1:840:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:840:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:840:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:840:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:840:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:840:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:840:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:840:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:840:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:840:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:840:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:840:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:840:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:840:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:840:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:840:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:840:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:840:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:840:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:840:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:840:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:840:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:840:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:840:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:840:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:840:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:840:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:840:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:840:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:840:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:840:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:840:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:840:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:840:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:840:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:840:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:840:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:840:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:840:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:840:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:840:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:840:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:840:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "8")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:840:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C3S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:840:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:840: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, "BPMS:LTU1:840:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S12")
  field(FLNK, "BPMS:LTU1:840: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, "BPMS:LTU1:840:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C3 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:840: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, "BPMS:LTU1:840:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C3 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:840:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:840:PHI_SEQ")
}

record(ao, "BPMS:LTU1:840:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:840:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:840:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:840:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:840:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:840:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:840:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C3 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:840:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:840: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, "BPMS:LTU1:840:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPMMUM2")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:840:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:840:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:840:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:840:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:840:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:840:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:840:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:840:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:840:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:840: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, "BPMS:LTU1:840: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, "BPMS:LTU1:840: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, "BPMS:LTU1:840: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, "BPMS:LTU1:840: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, "BPMS:LTU1:840: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, "BPMS:LTU1:840:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:840:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:840: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, "BPMS:LTU1:840:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:840:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:840:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:840:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:840:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:840:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:840:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:840:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:840:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:UOFF")
	field(DOL2, "BPMS:LTU1:840:UOFF")
	field(DOL3, "BPMS:LTU1:840:UOFF")
	field(DOL4, "BPMS:LTU1:840:UOFF")
	field(DOL5, "BPMS:LTU1:840:UOFF")
	field(DOL6, "BPMS:LTU1:840:UOFF")
	field(DOL7, "BPMS:LTU1:840:UOFF")
	field(DOL8, "BPMS:LTU1:840:UOFF")
	field(DOL9, "BPMS:LTU1:840:UOFF")
	field(DOLA, "BPMS:LTU1:840:UOFF")
	field(LNK1, "BPMS:LTU1:840:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:840:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:840:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:840:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:VOFF")
	field(DOL2, "BPMS:LTU1:840:VOFF")
	field(DOL3, "BPMS:LTU1:840:VOFF")
	field(DOL4, "BPMS:LTU1:840:VOFF")
	field(DOL5, "BPMS:LTU1:840:VOFF")
	field(DOL6, "BPMS:LTU1:840:VOFF")
	field(DOL7, "BPMS:LTU1:840:VOFF")
	field(DOL8, "BPMS:LTU1:840:VOFF")
	field(DOL9, "BPMS:LTU1:840:VOFF")
	field(DOLA, "BPMS:LTU1:840:VOFF")
	field(LNK1, "BPMS:LTU1:840:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:840:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:840:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:840:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:USCL")
	field(DOL2, "BPMS:LTU1:840:USCL")
	field(DOL3, "BPMS:LTU1:840:USCL")
	field(DOL4, "BPMS:LTU1:840:USCL")
	field(DOL5, "BPMS:LTU1:840:USCL")
	field(DOL6, "BPMS:LTU1:840:USCL")
	field(DOL7, "BPMS:LTU1:840:USCL")
	field(DOL8, "BPMS:LTU1:840:USCL")
	field(DOL9, "BPMS:LTU1:840:USCL")
	field(DOLA, "BPMS:LTU1:840:USCL")
	field(LNK1, "BPMS:LTU1:840:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:840:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:USCL_SEL")
	field(OUTA, "BPMS:LTU1:840:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:840:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:VSCL")
	field(DOL2, "BPMS:LTU1:840:VSCL")
	field(DOL3, "BPMS:LTU1:840:VSCL")
	field(DOL4, "BPMS:LTU1:840:VSCL")
	field(DOL5, "BPMS:LTU1:840:VSCL")
	field(DOL6, "BPMS:LTU1:840:VSCL")
	field(DOL7, "BPMS:LTU1:840:VSCL")
	field(DOL8, "BPMS:LTU1:840:VSCL")
	field(DOL9, "BPMS:LTU1:840:VSCL")
	field(DOLA, "BPMS:LTU1:840:VSCL")
	field(LNK1, "BPMS:LTU1:840:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:840:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:840:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:840:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:PHI")
	field(DOL2, "BPMS:LTU1:840:PHI")
	field(DOL3, "BPMS:LTU1:840:PHI")
	field(DOL4, "BPMS:LTU1:840:PHI")
	field(DOL5, "BPMS:LTU1:840:PHI")
	field(DOL6, "BPMS:LTU1:840:PHI")
	field(DOL7, "BPMS:LTU1:840:PHI")
	field(DOL8, "BPMS:LTU1:840:PHI")
	field(DOL9, "BPMS:LTU1:840:PHI")
	field(DOLA, "BPMS:LTU1:840:PHI")
	field(LNK1, "BPMS:LTU1:840:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:840:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:PHI_SEL")
	field(OUTA, "BPMS:LTU1:840:CALC.E CA")
	field(OUTB, "BPMS:LTU1:840:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:840:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:840:PSI")
	field(DOL2, "BPMS:LTU1:840:PSI")
	field(DOL3, "BPMS:LTU1:840:PSI")
	field(DOL4, "BPMS:LTU1:840:PSI")
	field(DOL5, "BPMS:LTU1:840:PSI")
	field(DOL6, "BPMS:LTU1:840:PSI")
	field(DOL7, "BPMS:LTU1:840:PSI")
	field(DOL8, "BPMS:LTU1:840:PSI")
	field(DOL9, "BPMS:LTU1:840:PSI")
	field(DOLA, "BPMS:LTU1:840:PSI")
	field(LNK1, "BPMS:LTU1:840:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:840:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:840:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:840:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:840:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:840:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:840:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:840:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:840:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:840:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:840:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:840:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:840:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:840:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:840:PSI_SEL")
	field(OUTA, "BPMS:LTU1:840:CALC.F CA")
	field(OUTB, "BPMS:LTU1:840:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:840:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:840:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:840:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:840:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:860:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C4 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:860:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C4 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:860:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C4 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:860:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C4 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:860:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C4 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:860:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C4 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:860:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C4 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:860:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C4 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:860:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C4 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:860:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:860:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:860:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:860:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:860:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:860:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:860:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C4 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:860:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:860:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:860:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:860:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:860:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:860:ATT1 CP")
  field(INPC, "BPMS:LTU1:860:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:860:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:860:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:860:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:860:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:860:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:860:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:860:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:860:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:860:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:860:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:860:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:860:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:860:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:860:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:860:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:860:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:860:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:860:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:860:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:860:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:860:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:860:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:860:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:860:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:860:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:860:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:860:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:860:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:860:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:860:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:860:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:860:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:860:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:860:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:860:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:860:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:860:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:860:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:860:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:860:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:860:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:860:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "16")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:860:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C4S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:860:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:860: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, "BPMS:LTU1:860:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S12")
  field(FLNK, "BPMS:LTU1:860: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, "BPMS:LTU1:860:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C4 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:860: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, "BPMS:LTU1:860:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C4 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:860:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:860:PHI_SEQ")
}

record(ao, "BPMS:LTU1:860:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:860:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:860:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:860:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:860:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:860:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:860:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C4 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:860:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:860: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, "BPMS:LTU1:860:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPMMUM3")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:860:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:860:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:860:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:860:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:860:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:860:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:860:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:860:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:860:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:860: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, "BPMS:LTU1:860: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, "BPMS:LTU1:860: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, "BPMS:LTU1:860: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, "BPMS:LTU1:860: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, "BPMS:LTU1:860: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, "BPMS:LTU1:860:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:860:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:860: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, "BPMS:LTU1:860:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:860:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:860:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:860:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:860:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:860:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:860:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:860:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:860:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:UOFF")
	field(DOL2, "BPMS:LTU1:860:UOFF")
	field(DOL3, "BPMS:LTU1:860:UOFF")
	field(DOL4, "BPMS:LTU1:860:UOFF")
	field(DOL5, "BPMS:LTU1:860:UOFF")
	field(DOL6, "BPMS:LTU1:860:UOFF")
	field(DOL7, "BPMS:LTU1:860:UOFF")
	field(DOL8, "BPMS:LTU1:860:UOFF")
	field(DOL9, "BPMS:LTU1:860:UOFF")
	field(DOLA, "BPMS:LTU1:860:UOFF")
	field(LNK1, "BPMS:LTU1:860:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:860:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:860:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:860:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:VOFF")
	field(DOL2, "BPMS:LTU1:860:VOFF")
	field(DOL3, "BPMS:LTU1:860:VOFF")
	field(DOL4, "BPMS:LTU1:860:VOFF")
	field(DOL5, "BPMS:LTU1:860:VOFF")
	field(DOL6, "BPMS:LTU1:860:VOFF")
	field(DOL7, "BPMS:LTU1:860:VOFF")
	field(DOL8, "BPMS:LTU1:860:VOFF")
	field(DOL9, "BPMS:LTU1:860:VOFF")
	field(DOLA, "BPMS:LTU1:860:VOFF")
	field(LNK1, "BPMS:LTU1:860:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:860:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:860:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:860:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:USCL")
	field(DOL2, "BPMS:LTU1:860:USCL")
	field(DOL3, "BPMS:LTU1:860:USCL")
	field(DOL4, "BPMS:LTU1:860:USCL")
	field(DOL5, "BPMS:LTU1:860:USCL")
	field(DOL6, "BPMS:LTU1:860:USCL")
	field(DOL7, "BPMS:LTU1:860:USCL")
	field(DOL8, "BPMS:LTU1:860:USCL")
	field(DOL9, "BPMS:LTU1:860:USCL")
	field(DOLA, "BPMS:LTU1:860:USCL")
	field(LNK1, "BPMS:LTU1:860:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:860:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:USCL_SEL")
	field(OUTA, "BPMS:LTU1:860:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:860:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:VSCL")
	field(DOL2, "BPMS:LTU1:860:VSCL")
	field(DOL3, "BPMS:LTU1:860:VSCL")
	field(DOL4, "BPMS:LTU1:860:VSCL")
	field(DOL5, "BPMS:LTU1:860:VSCL")
	field(DOL6, "BPMS:LTU1:860:VSCL")
	field(DOL7, "BPMS:LTU1:860:VSCL")
	field(DOL8, "BPMS:LTU1:860:VSCL")
	field(DOL9, "BPMS:LTU1:860:VSCL")
	field(DOLA, "BPMS:LTU1:860:VSCL")
	field(LNK1, "BPMS:LTU1:860:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:860:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:860:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:860:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:PHI")
	field(DOL2, "BPMS:LTU1:860:PHI")
	field(DOL3, "BPMS:LTU1:860:PHI")
	field(DOL4, "BPMS:LTU1:860:PHI")
	field(DOL5, "BPMS:LTU1:860:PHI")
	field(DOL6, "BPMS:LTU1:860:PHI")
	field(DOL7, "BPMS:LTU1:860:PHI")
	field(DOL8, "BPMS:LTU1:860:PHI")
	field(DOL9, "BPMS:LTU1:860:PHI")
	field(DOLA, "BPMS:LTU1:860:PHI")
	field(LNK1, "BPMS:LTU1:860:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:860:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:PHI_SEL")
	field(OUTA, "BPMS:LTU1:860:CALC.E CA")
	field(OUTB, "BPMS:LTU1:860:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:860:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:860:PSI")
	field(DOL2, "BPMS:LTU1:860:PSI")
	field(DOL3, "BPMS:LTU1:860:PSI")
	field(DOL4, "BPMS:LTU1:860:PSI")
	field(DOL5, "BPMS:LTU1:860:PSI")
	field(DOL6, "BPMS:LTU1:860:PSI")
	field(DOL7, "BPMS:LTU1:860:PSI")
	field(DOL8, "BPMS:LTU1:860:PSI")
	field(DOL9, "BPMS:LTU1:860:PSI")
	field(DOLA, "BPMS:LTU1:860:PSI")
	field(LNK1, "BPMS:LTU1:860:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:860:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:860:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:860:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:860:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:860:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:860:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:860:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:860:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:860:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:860:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:860:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:860:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:860:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:860:PSI_SEL")
	field(OUTA, "BPMS:LTU1:860:CALC.F CA")
	field(OUTB, "BPMS:LTU1:860:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:860:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:860:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:860:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:860:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

##############################################
# This is the head of the main processing chain
# that runs at the highest priority.
##############################################

#############################################
# This is the head of the processing chain for
# diagnostics.
##############################################
record(ai, "BPMS:LTU1:880:GRN") {
  field(DESC, "GRN Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C5 S0")
  field(EGU, "raw")
#TODO set HOPR/LOPR, alarm limits
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(FLNK, "BPMS:LTU1:880:RED")
# HOPR for the energy algorithm is determined as follows:
#
#                      inf        inf
#  1) Fourier relation / h^2 dt = / |H|^2 df = 2 B
#                     0         -inf
#
#  1a) It can be shown that the maximum of the impuls response
#      ha is ~ 2 B
#                               
#  2) The digitizer produces the numbers
#
#     Ai = 2^s (hi/ha)
#
#     where ha is the maximum of the impuls response
#     and 2^s is a scale factor.
#     
#  3) 'Energy algorithm' calculates S = sum( Ai^2 )
#
#                                                     inf
#  4) S = (2^s / ha)^2 sum(hi^2) = K sum(hi^2) Dt ~ K / h^2 dt
#                                                    0
#
#     with K = (2^s / ha)^2 fs
#
#  5) From 4) and 1a) ->  S ~ K ha and therefore
#
#  6) S = 2^(2s) fs/ha = 2^(2s) fs/(2 B)
#
#  7) The strip signals are sqrt(S); hence HOPR is about
#
#     HOPR ~ 2^s  sqrt( fs/2/B )
#
#     with 2^s = 32768, fs=120MHz, B=10MHz it follows
#     that HOPR ~ 1E5; we add some margin...
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:RED") {
  field(DESC, "RED Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C5 S1")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:880:BLU")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:BLU") {
  field(DESC, "BLU Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C5 S2")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:880:YLO")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:YLO") {
  field(DESC, "YLO Strip Amplitude")
  field(DTYP, "Raw Bpm Signal")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "#C5 S3")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

##############################################
# Slowly-scanned diagnostics
##############################################

#
record(waveform, "BPMS:LTU1:880:REDW") {
  field(DESC, "Raw CAL RED Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C5 S1")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:880:GRNW") {
  field(DESC, "Raw CAL GRN Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C5 S2")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "1 second")
}

record(waveform, "BPMS:LTU1:880:RAWDBG") {
  field(DESC, "Raw BEAM Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
# do not 'wbscan' for now since e.g., an underrange
# condition on the real signal can happen.
  field(INP, "#C5 S7")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:880:REDDBG") {
  field(DESC, "Raw CAL RED Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C5 S8 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(waveform, "BPMS:LTU1:880:GRNDBG") {
  field(DESC, "Raw CAL GRN Dbg")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP, "#C5 S9 @wbscan")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU, "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
  field(SCAN, "Passive")
}

record(ai, "BPMS:LTU1:880:GRUV") {
  field(DESC, "CAL Gain GRN/RED")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S0")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
}

record(ai, "BPMS:LTU1:880:GRU") {
  field(DESC, "CAL Gain GRN/BLU")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S1")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:880:GRV") {
  field(DESC, "CAL Gain RED/YLO")
  field(DTYP, "Raw Stripl Calp")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S2")
  field(SCAN, "10 second")
  field(PREC, "4")
  field(LOPR, "0.5")
  field(HOPR, "1.5")
  info(autosaveFields, "ASLO")
}

record(ai, "BPMS:LTU1:880:TGRN") {
  field(DESC, "Green arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S4")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:880:TRED") {
  field(DESC, "Red arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S5")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:880:TBLU") {
  field(DESC, "Blue arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S6")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ai, "BPMS:LTU1:880:TYLO") {
  field(DESC, "Yellow arrival time")
  field(DTYP, "Raw Bpm Signal")
  field(EGU, "ADC Clocks")
# 'card' selects PAD number, 'signal' selects cal coeff
  field(INP, "#C5 S7")
  field(SCAN, "10 second")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "128")
  field(LOLO, "5")
  field(LOW, "8")
  field(HIGH, "60")
  field(HIHI, "70")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
  field(HSV, "MINOR")
  field(HHSV, "MAJOR")
}

record(ao, "BPMS:LTU1:880:PINC_ADJ") {
  field(DESC, "Adjust Pinc. Corr.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:880:CALC.K PP MS")
  field(VAL, "0")
  field(DRVL, "0")
  field(DRVH, "2")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# QSCL setting:
#
# Q: charge
# Z: impedance
# F: form factor: phi/(2 pi) sin(2 pi f l/c)
#
# Signal =  Q Z F G h(t) = A h(t)  [A] = Vs
#
#                  inf              inf
# Energy =  A^2   / h^2(t) dt = A^2 / |H(w)|^2 dw/2/pi = A^2 B
#                0                 0
#                        
# Measured energy = Sum{ (Vp/32768 * xi)^2 } / fs = S / fs ~ Energy
#
# -> A^2 B = S/fs
#
# With T = sqrt( Sum{ xi^2 } )
#
#    A = sqrt(S)/sqrt(B*fs) = T/sqrt(B*fs) Vp/32768
#
#                      T/32768 Vp
#    Q = A/F/G/Z = -----------------
#                   F G Z sqrt(B*fs)
#
# Vp = { 1.5Vpp/2 (PGA=1) or 2.25Vpp/2 (PGA=0) } / 2 (transformer)
#
# I believe PGA is off (-> Vp ~ .56V)
#
# Z  = 50
#
# G: (calibration uses GRN/BLU -> signal should have the
#    level of the grn/red channels with the additional switch)
#
# Block diagram / parts / gain:
#
# [filt]    [Att1]    [Amp1]   [Att2]    [BPF]      [Amp2]    [pad] [Amp3]   [switch]
# f-17520  hmc540lp3  SBF-5089 hmc540lp3 MBP-140-6-4 SBF-4089  PAT-0 SBF-4089 HMC-197
#
#  -2dB*    -1dB       20dB     -1dB     -4.5         14.8dB   0dB   14.8dB   -0.4dB
#
# *: 1st filter ATT is a wild guess.
#  BPF loss (RLC Catalog, pp.55): (L (nsect+.5) / (% of 3dB BW) + .2) dB
#  with L ~6.2  10MHz/fc=140Mhz filter-> 4.5
#
#  -> Gtot ~ 40.7dB
#
#  subtract cable loss (2dB); Gtot = 86
# 
#                      T/32768 Vp            .56V/32768
#    Q = A/F/G/Z = ----------------- = T/F  ------------------------
#                   F G Z sqrt(B*fs)        86*50*sqrt(10*140)Mhz
#
#      = T/F = 1.06E-7/F nC
#
#    F for a 7% coverage, 4" BPM at 140MHz   .07 sin(2*pi*140e6 4*.0254/3e8)
#      = .021
#
#      => 1.06E-7/.021 nC = 5E-6 nC
#
# (Faraday cup measurement -> (3600/44)^-1 1e-4 -> 1.22E-6
#
record(ao, "BPMS:LTU1:880:QSCL") {
  field(DESC, "TMIT/Charge Scale")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:880:QSCA.A PP MS")
# 5.0E-6 / 1.6E-10 [nC/e-]
  field(VAL, "31250")
  field(EGU, "Nel")
  field(PREC, "3")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Adjust TMIT scale for AFE attenuation
record(calcout, "BPMS:LTU1:880:QSCA") {
  field(DESC, "TMIT ATT Adj. Scale")
  field(INPB, "BPMS:LTU1:880:ATT1 CP")
  field(INPC, "BPMS:LTU1:880:ATT2 CP")
  field(CALC, "A*10^((B+C+D)/20)")
# use CA link to deposit into TMIT.ASLO so
# that TMIT is not forced into linkset
# of this record
  field(OUT, "BPMS:LTU1:880:TMIT.ASLO CA")
  field(EGU, "Nel")
  field(PREC, "3")
  info(autosaveFields, "D")
}

record(ao,    "BPMS:LTU1:880:ATT1SIMP") {
	field(DESC, "ATT1 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:880:ATT1   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:880:ASIM.A PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

record(ao,    "BPMS:LTU1:880:ATT2SIMP") {
	field(DESC, "ATT2 Propagator")
	field(DTYP, "Soft Channel")
	field(DOL,  "BPMS:LTU1:880:ATT2   CP")
	field(OMSL, "closed_loop")
	field(OUT,  "BPMS:LTU1:880:ASIM.C PP")
  	field(IVOA, "Set output to IVOV")
	field(IVOV, "0")
	field(EGU,  "dB")
}

# Attenuate charge either by
# real attenuator settings or
# by fake ones.
# If B, C >= 0 then their
# values will be used instead
# of ATT1, ATT2
record(calcout, "BPMS:LTU1:880:ASIM") {
  field(DESC, "Q Simul Attenuator")
  field(DTYP, "Soft Channel")
  field(OUT,  "BPMS:LTU1:880:QSIM.ESLO PP")
# ATT1SIM puts value into A
# set to -1 to use real attenuator settings
# and >=0 to use B instead
  field(B,    "-1")
# ATT2SIM puts value into C
# set to -1 to use real attenuator settings
# and >=0 to use D instead
  field(D,    "-1")
  field(CALC, "10^(((B>=0?B:A)+(D>=0?D:C))/20)")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:880:WSIM") {
  field(DESC, "BPM W Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:880:SIM.G PP")
  field(VAL, "0.07")
  field(EGU, "%")
  field(PINI, "YES")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "0.25")
}


record(sel, "BPMS:LTU1:880:STA") {
  field(DESC, "Status Summary")
  field(SELM, "High Signal")
  field(INPA, "BPMS:LTU1:880:RSTA.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:880:TMIT.SEVR MS NPP")
  field(INPC, "BPMS:LTU1:880:Y.SEVR    MS NPP")
  field(INPD, "BPMS:LTU1:880:X.SEVR    MS NPP")
  field(INPE, "BPMS:LTU1:880:TGRN.SEVR MS NPP")
  field(INPF, "BPMS:LTU1:880:TRED.SEVR MS NPP")
  field(INPG, "BPMS:LTU1:880:TBLU.SEVR MS NPP")
  field(INPH, "BPMS:LTU1:880:TYLO.SEVR MS NPP")
  field(INPI, "BPMS:LTU1:880:GRU.SEVR  MS NPP")
  field(INPJ, "BPMS:LTU1:880:GRV.SEVR  MS NPP")
  field(SCAN, "1 second")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:880:ATTO") {
  field(DESC, "AFE Tot. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:880:ATTC.B PP")
  field(DRVL, "-10")
  field(DRVH, "30")
  field(LOPR, "-10")
  field(HOPR, "30")
  field(EGU, "dB")
  field(VAL, "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

# This record really belongs on the
# PAD IOC. We keep them here however
# so we can save/restore. It is more
# confusing but shouldn't matter from
# an efficiency standpoint (they are
# rarely changed).
record(longout, "BPMS:LTU1:880:CLAO") {
  field(DESC, "AFE Cal. Att. Offset")
# fetched via inlink
#field(OUT,  "BPMS:LTU1:880:ATTC.C PP")
  field(DRVL, "-20")
  field(DRVH, "20")
  field(LOPR, "-20")
  field(HOPR, "20")
  field(EGU, "dB")
  field(VAL, "40")
  field(PINI, "YES")
  info(autosaveFields, "VAL DRVH HOPR DRVL LOPR")
}

record(calc, "BPMS:LTU1:880:STA_ALH") {
  field(DESC, "Status Summary")
  field(SCAN, "1 second")
  field(CALC, "0")
  field(INPA, "BPMS:LTU1:880:RSTA_ALH.SEVR MS NPP")
  field(INPB, "BPMS:LTU1:880:GRU.SEVR  MS NPP")
  field(INPC, "BPMS:LTU1:880:GRV.SEVR  MS NPP")
  field(INPD, "BPMS:LTU1:880:CHK.SEVR MS NPP")
  field(INPE, "")
  field(INPF, "BPMS:LTU1:880:AFE_COMM.SEVR MS NPP")  
}

# snapshot PV for the bpm values display
record(ai, "BPMS:LTU1:880:GRN_SLOW") {
  field(DESC, "GRN snapshot for display")
  field(INP, "BPMS:LTU1:880:GRN NPP MS")
  field(EGU, "raw")
  field(SCAN, "1 second")
  field(FLNK, "BPMS:LTU1:880:RED_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:RED_SLOW") {
  field(DESC, "RED snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:880:RED NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:880:BLU_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:BLU_SLOW") {
  field(DESC, "BLU snapshot for display")
# 'card' selects PAD number, 'signal' selects strip
  field(INP, "BPMS:LTU1:880:BLU NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(FLNK, "BPMS:LTU1:880:YLO_SLOW")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

record(ai, "BPMS:LTU1:880:YLO_SLOW") {
  field(DESC, "YLO snapshot for display")
  field(INP, "BPMS:LTU1:880:YLO NPP MS")
  field(EGU, "raw")
  field(SCAN, "Passive")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "1.4E5")
  field(LOLO, "1000")
  field(LOW, "2000")
  field(LLSV, "MAJOR")
  field(LSV, "MINOR")
}

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

record(bo, "BPMS:LTU1:880:PINC_ENA") {
  field(DESC, "Simple Pincushion Alg")
  field(DTYP, "BusAddress")
  field(OUT,  "#C0S2@drvBpmStriplPincEna,m32")
  field(MASK, "32")
  field(ZNAM, "DISABLED")
  field(ONAM, "ENABLED")
  field(VAL,  "0")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

record(ao, "BPMS:LTU1:880:UDR_THRES") {
  field(DESC, "Detection Underrange Threshold")
  field(DTYP, "Bpm Parameters")
  field(OUT,  "#C5S0")
  field(EGU,  "ADC Ticks")
  field(DOL,  "45.26")
  field(PINI, "YES")
  field(DRVL, "0")
  field(DRVH, "32767")
  info(autosaveFields, "VAL")
}
#! Generated by VisualDCT v2.5
#! DBDSTART
#! DBDEND


# per BPM database for stripline BPMs

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

record(ai, "BPMS:LTU1:880:X") {
  field(DESC, "X Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S11")
  field(SCAN, "I/O Intr")
# The priority determines what scan list we are being
# put on (see drvPadUdpComm.c)
  field(PRIO, "HIGH")
  field(FLNK, "BPMS:LTU1:880: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, "BPMS:LTU1:880:Y") {
  field(DESC, "Y Position")
  field(EGU, "mm")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S12")
  field(FLNK, "BPMS:LTU1:880: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, "BPMS:LTU1:880:TMIT") {
  field(DESC, "Charge Estimate")
  field(DTYP, "Raw Bpm Signal")
  field(INP, "#C5 S13")
  field(EGU, "Nel")
  field(PREC, "3")
  field(LOPR, "0")
  field(HOPR, "1E11")
# FLINK into BSA
  field(FLNK, "BPMS:LTU1:880: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, "BPMS:LTU1:880:RWAV") {
  field(DESC, "Raw BPM Data")
  field(DTYP, "WavBuf")
# 'signal' number selects 'beam', 'calX', 'calY'
  field(INP,  "#C5 S0")
  field(SCAN, "I/O Intr")
# use LOW or HIGH to end up on the 'diagnostic' 
# scan list (see drvPadUdpComm.c)
  field(PRIO, "LOW")
  field(NELM, "512")
  field(FTVL, "SHORT")
  field(EGU,  "Counts")
  field(HOPR, "32768")
  field(LOPR, "-32767")
}

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

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

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

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


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

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

record(ao, "BPMS:LTU1:880:PHI") {
  field(DESC, "Rot Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "-180")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:880:PHI_SEQ")
}

record(ao, "BPMS:LTU1:880:PSI") {
  field(DESC, "Axis Sep. Angle")
  field(DTYP, "Soft Channel")
  field(VAL, "90")
  field(EGU, "deg")
  field(PREC, "1")
  field(LOPR, "0")
  field(HOPR, "+180")
  field(FLNK, "BPMS:LTU1:880:PSI_SEQ")
}

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

record(ao, "BPMS:LTU1:880:UOFF") {
  field(DESC, "BPM U Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:880:UOFF_SEQ")
}

record(ao, "BPMS:LTU1:880:VOFF") {
  field(DESC, "BPM V Offset")
  field(DTYP, "Soft Channel")
  field(VAL, "0")
  field(EGU, "mm")
  field(PREC, "4")
  field(LOPR, "-5")
  field(HOPR, "+5")
  field(FLNK, "BPMS:LTU1:880:VOFF_SEQ")
}

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

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


record(mbbo, "BPMS:LTU1:880:ACCESS") {
  field(DESC, "BPM On Line")
  field(DTYP, "StreamSwitch")
  field(OUT, "#C5 S0")
  field(ZRVL, "1")
  field(ZRST, "Running")
  field(ZRSV, "NO_ALARM")
  field(ONVL, "1")
  field(ONST, "Maintenance")
  field(ONSV, "MINOR")
  field(TWVL, "1")
  field(TWST, "Test")
  field(TWSV, "MINOR")
  field(THVL, "0")
  field(THST, "OFFLINE")
  field(THSV, "MAJOR")
# set both, rval and val to get it right
# regardless of whether devsup does conversion
# or not.
  field(RVAL, "0")
  field(VAL,  "0")
  field(PINI, "YES")
  field(FLNK, "BPMS:LTU1:880:SIMOFF")
  info(autosaveFields, "RVAL")
}

#
# Used by higher level software to determine if a PV is in feedback or not.
# May also be used by actuator (magnet and RF) IOC applications to 
# switch output records to "closed_loop" to prevent outside programs from
# changing setpoints when an actuator device is in feedback.
#
record(mbbo, "BPMS:LTU1:880: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, "BPMS:LTU1:880:MADN") {
  field(DESC, "MAD Name")
  field(VAL, "BPMMUM4")
  field(PINI, "YES")
}

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

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

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

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

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

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

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

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

record(mbbo, "BPMS:LTU1:880:SIMC") {
  field(DESC, "Stripl Sim Ctl")
  field(DTYP, "Raw Soft Channel")
  field(OUT,  "BPMS:LTU1:880:SIMCSEQ.SELN PP")
  field(ZRST, "OFF")
  field(ZRVL, "0x0f")
  field(ONST, "ON")
  field(ONVL, "0x1c0")
  field(TWST, "SOFT")
  field(TWVL, "0x030")
  field(MASK, "-1")
  field(NOBT, "16")
  field(VAL,  "0")
  field(RVAL, "0x0f")
  field(PINI, "YES")
}

record(ao, "BPMS:LTU1:880:XSIM") {
  field(DESC, "BPM X Pos. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:880:SIM.B PP")
  field(VAL, "0.5")
  field(EGU, "mm")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "-12")
  field(HOPR, "+12")
}

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

record(ao, "BPMS:LTU1:880:QSIM") {
  field(DESC, "BPM Q Simul.")
  field(DTYP, "Raw Soft Channel")
  field(OUT, "BPMS:LTU1:880:SIM.D PP")
  field(EGU, "Nel")
  field(ASLO, "6000")
#ESLO is used to add attenuation
  field(LINR, "LINEAR")
  field(VAL, "1E9")
  field(PINI, "YES")
  field(PREC, "4")
  field(LOPR, "0")
  field(HOPR, "1E11")
}

record(ao, "BPMS:LTU1:880:ROTS") {
  field(DESC, "BPM Rot. Simul.")
  field(DTYP, "Soft Channel")
  field(OUT, "BPMS:LTU1:880:SIM.E PP")
  field(VAL, "0.")
  field(EGU, "deg")
  field(PINI, "YES")
  field(PREC, "1")
  field(LOPR, "-180")
}

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

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

#Used by model/database folks to verify BPM

record(ao, "BPMS:LTU1:880:Z") {
  field(DESC, "Z Position")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

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

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

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

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

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

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


# Records to set MPS thresholds
record(ao, "BPMS:LTU1:880: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, "BPMS:LTU1:880: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, "BPMS:LTU1:880: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, "BPMS:LTU1:880: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, "BPMS:LTU1:880: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, "BPMS:LTU1:880: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, "BPMS:LTU1:880:FNET") {
  field(DESC, "BPM data on FNET")
  field(VAL, "$(FN,undefined)")
  field(ZNAM, "NO")
  field(ONAM, "YES")
  field(PINI, "YES")
}

# Record to inform users that BPM
# needs TMIT and/or X/Y scale calibration
record(mbbo, "BPMS:LTU1:880:CHK") {
  field(DESC, "Needs cal/iron")
  field(OMSL, "supervisory")
  field(VAL,  "0")
  field(ZRVL, "0")
  field(ONVL, "1")
  field(TWVL, "2")
  field(THVL, "3")
  field(ZRST, " ")
  field(ONST, "Calibrate")
  field(TWST, "Calibrate&iron")
  field(THST, "Iron")
  field(ZRSV, "NO_ALARM")
  field(ONSV, "MINOR")
  field(TWSV, "MINOR")
  field(THSV, "MINOR")
  field(PINI, "YES")
  info(autosaveFields, "VAL")
}

# Switch simulation record 
record(seq, "BPMS:LTU1:880: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, "BPMS:LTU1:880:SIMT.DISA PP")
  field(LNK2, "BPMS:LTU1:880:RAW.RARM  PP")
  field(LNK3, "BPMS:LTU1:880:SIM.L     PP")
  field(LNK4, "BPMS:LTU1:880:SIM.SCAN  PP")

  field(LNK5, "BPMS:LTU1:880:SIM.SCAN  PP")
  field(LNK6, "BPMS:LTU1:880:SIM.L     PP")
  field(LNK7, "BPMS:LTU1:880:SIM.L     PP")
  field(LNK8, "BPMS:LTU1:880:RAW.RARM  PP")
  field(LNK9, "BPMS:LTU1:880:SIMT.DISA PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:UOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:UOFF")
	field(DOL2, "BPMS:LTU1:880:UOFF")
	field(DOL3, "BPMS:LTU1:880:UOFF")
	field(DOL4, "BPMS:LTU1:880:UOFF")
	field(DOL5, "BPMS:LTU1:880:UOFF")
	field(DOL6, "BPMS:LTU1:880:UOFF")
	field(DOL7, "BPMS:LTU1:880:UOFF")
	field(DOL8, "BPMS:LTU1:880:UOFF")
	field(DOL9, "BPMS:LTU1:880:UOFF")
	field(DOLA, "BPMS:LTU1:880:UOFF")
	field(LNK1, "BPMS:LTU1:880:UOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:UOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:UOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:UOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:UOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:UOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:UOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:UOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:UOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:UOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:UOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:UOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:880:UOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:UOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:UOFF_SEL")
	field(OUTA, "BPMS:LTU1:880:U.AOFF CA")
	field(OUTB, "BPMS:LTU1:880:UOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:UOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:UOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:VOFF_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:VOFF")
	field(DOL2, "BPMS:LTU1:880:VOFF")
	field(DOL3, "BPMS:LTU1:880:VOFF")
	field(DOL4, "BPMS:LTU1:880:VOFF")
	field(DOL5, "BPMS:LTU1:880:VOFF")
	field(DOL6, "BPMS:LTU1:880:VOFF")
	field(DOL7, "BPMS:LTU1:880:VOFF")
	field(DOL8, "BPMS:LTU1:880:VOFF")
	field(DOL9, "BPMS:LTU1:880:VOFF")
	field(DOLA, "BPMS:LTU1:880:VOFF")
	field(LNK1, "BPMS:LTU1:880:VOFF_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:VOFF_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:VOFF_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:VOFF_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:VOFF_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:VOFF_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:VOFF_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:VOFF_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:VOFF_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:VOFF_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:VOFF_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:VOFF_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:880:VOFF_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:VOFF_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:VOFF_SEL")
	field(OUTA, "BPMS:LTU1:880:V.AOFF CA")
	field(OUTB, "BPMS:LTU1:880:VOFF PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:VOFF_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:VOFF_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:USCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:USCL")
	field(DOL2, "BPMS:LTU1:880:USCL")
	field(DOL3, "BPMS:LTU1:880:USCL")
	field(DOL4, "BPMS:LTU1:880:USCL")
	field(DOL5, "BPMS:LTU1:880:USCL")
	field(DOL6, "BPMS:LTU1:880:USCL")
	field(DOL7, "BPMS:LTU1:880:USCL")
	field(DOL8, "BPMS:LTU1:880:USCL")
	field(DOL9, "BPMS:LTU1:880:USCL")
	field(DOLA, "BPMS:LTU1:880:USCL")
	field(LNK1, "BPMS:LTU1:880:USCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:USCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:USCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:USCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:USCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:USCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:USCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:USCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:USCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:USCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:USCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:USCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:880:USCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:USCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:USCL_SEL")
	field(OUTA, "BPMS:LTU1:880:U.ASLO CA")
	field(OUTB, "BPMS:LTU1:880:USCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:USCL_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:USCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:VSCL_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:VSCL")
	field(DOL2, "BPMS:LTU1:880:VSCL")
	field(DOL3, "BPMS:LTU1:880:VSCL")
	field(DOL4, "BPMS:LTU1:880:VSCL")
	field(DOL5, "BPMS:LTU1:880:VSCL")
	field(DOL6, "BPMS:LTU1:880:VSCL")
	field(DOL7, "BPMS:LTU1:880:VSCL")
	field(DOL8, "BPMS:LTU1:880:VSCL")
	field(DOL9, "BPMS:LTU1:880:VSCL")
	field(DOLA, "BPMS:LTU1:880:VSCL")
	field(LNK1, "BPMS:LTU1:880:VSCL_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:VSCL_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:VSCL_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:VSCL_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:VSCL_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:VSCL_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:VSCL_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:VSCL_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:VSCL_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:VSCL_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:VSCL_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:VSCL_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "1")
	field(B,    "1")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "4")
	field(FLNK, "BPMS:LTU1:880:VSCL_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:VSCL_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:VSCL_SEL")
	field(OUTA, "BPMS:LTU1:880:V.ASLO CA")
	field(OUTB, "BPMS:LTU1:880:VSCL PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:VSCL_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:VSCL_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:PHI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:PHI")
	field(DOL2, "BPMS:LTU1:880:PHI")
	field(DOL3, "BPMS:LTU1:880:PHI")
	field(DOL4, "BPMS:LTU1:880:PHI")
	field(DOL5, "BPMS:LTU1:880:PHI")
	field(DOL6, "BPMS:LTU1:880:PHI")
	field(DOL7, "BPMS:LTU1:880:PHI")
	field(DOL8, "BPMS:LTU1:880:PHI")
	field(DOL9, "BPMS:LTU1:880:PHI")
	field(DOLA, "BPMS:LTU1:880:PHI")
	field(LNK1, "BPMS:LTU1:880:PHI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:PHI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:PHI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:PHI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:PHI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:PHI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:PHI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:PHI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:PHI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:PHI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:PHI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:PHI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "0")
	field(B,    "0")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:880:PHI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:PHI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:PHI_SEL")
	field(OUTA, "BPMS:LTU1:880:CALC.E CA")
	field(OUTB, "BPMS:LTU1:880:PHI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:PHI_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:PHI_SEL.L PP")
}
# Maintain multiple (up to 10) values of
# a parameter:
# 
# Record holding the parameter $[parm]
# must FLNK -> $[parm]_SEQ
#
# Different values of the parameter 
# $[parm0]..$[parm9] are stored in
# $[parm]_SEL.A .. $[parm]_SEL.J
#
# The actual value of the parameter is
# selected based on the value of a controlling
# PV $[ctrl] using a 'mapping' CALC expression
# $[mapc] to convert the $[ctrl] value into
# the integer range 1..10. 
#
# The selected value of $[parm] is written
# to output link $[outl]
#
# A) When the user writes $[parm] then
#    its value is deposited in the currently
#    selected field of $[parm]_SEL and
#    propagated to $[outl]
#
# B) When the user writes any of $[parm]_SEL.A..J
#    then the value is stored there. If she
#    writes to the currently 'active' field\
#    (as selected by $[ctrl]) then 
#    the $[parm] PV itself is updated and the
#    value is also propagated to $[outl]
#
# C) If the user changes $[ctrl] then the
#    corresponding value $[parm]_SEL.A..J is 
#    propagated to $[outl] and $[parm].
#
# D) At initialization, the value corresponding
#    to the initial setting of $[ctrl] is written
#    to $[outl] and $[parm]
#
# MACROS:
#
# $[parm]  PV holding the parameter
# $[ctrl]  PV that controls the selection of
#          the currently active setting of 
#          $[parm]
# $[outl]  PV where the currently selected 
#          value of $[parm] shall be written-to
#          (if applicable)
# $[prec]  Precision of the $[parm]_SEL variable
#          (should be set to same value as $[parm].PREC)
#
# $[parm0]..$[parm9] initial values of $[parm]
#
# $[mapc]  CALC expression to convert the value
#          of the controlling PV which is available
#          as 'A' to the range 1..10 (or less if
#          less selections are used).
#          E.g., to convert the value of a bo (0/1)
#          you would set mapc to 'A+1' (0..1 -> 1..2)
#
# NOTE:    This sb snippet is loaded/expanded
#          for every parameter under control
#          of $[ctrl]. ALSO, the companion
#          snippet parmCtl.db must be loaded/expanded
#          but only once per controlling PV.
#          

# This record, when scanned (as a result
# of $[parm] being written and processing
# its FLNK to this record] fetches $[parm]
# and deposits the value into the currently
# selected field of the SEL record.
# 
# NOTE: unfortunately, the selection
#       mechanism of the SEQ and SEL
#       records differs: SEQ is 1-based,
#       SEL is 0-based -- now that makes
#       sense, doesn't it?
#
record(seq, "BPMS:LTU1:880:PSI_SEQ")
{
	field(DESC, "Propagate Parm -> SEL")
	field(DOL1, "BPMS:LTU1:880:PSI")
	field(DOL2, "BPMS:LTU1:880:PSI")
	field(DOL3, "BPMS:LTU1:880:PSI")
	field(DOL4, "BPMS:LTU1:880:PSI")
	field(DOL5, "BPMS:LTU1:880:PSI")
	field(DOL6, "BPMS:LTU1:880:PSI")
	field(DOL7, "BPMS:LTU1:880:PSI")
	field(DOL8, "BPMS:LTU1:880:PSI")
	field(DOL9, "BPMS:LTU1:880:PSI")
	field(DOLA, "BPMS:LTU1:880:PSI")
	field(LNK1, "BPMS:LTU1:880:PSI_SEL.A PP")
	field(LNK2, "BPMS:LTU1:880:PSI_SEL.B PP")
	field(LNK3, "BPMS:LTU1:880:PSI_SEL.C PP")
	field(LNK4, "BPMS:LTU1:880:PSI_SEL.D PP")
	field(LNK5, "BPMS:LTU1:880:PSI_SEL.E PP")
	field(LNK6, "BPMS:LTU1:880:PSI_SEL.F PP")
	field(LNK7, "BPMS:LTU1:880:PSI_SEL.G PP")
	field(LNK8, "BPMS:LTU1:880:PSI_SEL.H PP")
	field(LNK9, "BPMS:LTU1:880:PSI_SEL.I PP")
	field(LNKA, "BPMS:LTU1:880:PSI_SEL.J PP")
	field(SELM, "Specified")
	field(SELL, "BPMS:LTU1:880:PSI_CTRL NPP NMS")
}

# The $[parm]_SEL record holds all possible
# values of $[parm] in the 'A..J' fields.
#
# When processed it updates it's own VAL
# to the currently selected input. Input
# 'L' serves as the (1-based) selector,
# i.e., L==1 selects 'A'->'VAL'.
# 
# When the selected value changes (as a 
# result of SEQ depositing a new value OR
# $[ctrl] changing and updating L) then
# the propagator record attached to the
# FLNK is processed.
#

record(sub, "BPMS:LTU1:880:PSI_SEL")
{
#	field(INAM, "parmSelSubInit")
	field(SNAM, "parmSelSubProc")
	field(A,    "90")
	field(B,    "90")
	field(C,    "")
	field(D,    "")
	field(E,    "")
	field(F,    "")
	field(G,    "")
	field(H,    "")
	field(I,    "")
	field(J,    "")
	field(PREC, "1")
	field(FLNK, "BPMS:LTU1:880:PSI_PROP")
  	info(autosaveFields, "A B C D E F G H I J")
}

#
# Finally the dfanout record 
# fetches the currently selected
# value from SEL and propagates it
# to $[outl]. It also updates
# $[parm] itself so that $[parm]
# always reflects the currently
# selected value.
#
record(dfanout,  "BPMS:LTU1:880:PSI_PROP")
{
	field(OMSL, "closed_loop")
	field(DOL,  "BPMS:LTU1:880:PSI_SEL")
	field(OUTA, "BPMS:LTU1:880:CALC.F CA")
	field(OUTB, "BPMS:LTU1:880:PSI PP")
}

# Drive the SEL record when the 'ctrl' PV changes
# Use a CA link to monitor such changes
record(calcout,  "BPMS:LTU1:880:PSI_CTRL")
{
	field(INPA, "BPMS:LTU1:880:PARMSEL CP")
	field(CALC, "A+1")
	field(DOPT, "Use CALC")
	field(OOPT, "On Change")
	field(OUT,  "BPMS:LTU1:880:PSI_SEL.L PP")
}
record(longout, "BPMS:LTU1:880:PARMSEL") {
	field(VAL, "0")
	field(PINI, "YES")
}
# per IOC database for stripline BPMs

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

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

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

