# Where am I?
pwd()

ld("watchdog.obj")
wdStart(20)

ld("rtems-gdb-stub.obj")
rtems_gdb_start(0,0)

# if using TSS version
ld("lanIpBasic.obj") #check that it finds this

# if using local version
#chdir("/boot/lcls/epics/iocTop/LLRF/drvLan9118/drvLan9118")
#ld("o-optimize-beatnik/lanIp2Basic.obj")
lanIpSetup("172.27.206.23","255.255.255.0",0,0) #check def of 1st parm
lanIpDebug=0
padProtoDebug=0

chdir("/boot/lcls/epics/iocTop/LLRF/Llrf2-Prod")
ld("bin/RTEMS-beatnik/llrf2RESTApp.obj")

#lsmod()

< /boot/lcls/epics/iocCommon/All/Prod/pre_st.cmd

epicsEnvSet("EPICS_CA_MAX_ARRAY_BYTES","1000000")


#mRouteAdd(getenv("SLC_PROXY_IP"),getenv("SLC_PROXY_GATEWAY_IP"),0xfffffc00,0,0x3)

dbLoadDatabase("dbd/llrf2RESTApp.dbd")
llrf2RESTApp_registerRecordDeviceDriver(pdbbase)

drvPadUdpCommSetup("172.27.206.255:0000")
drvPadUdpCommTimeout=1000

# hack around the EPICS memory tester
free(malloc(1024*1024*32))

dbLoadTemplate("db/llrfIN20.fdbk_template")
dbLoadTemplate("db/llrfIN20.gnt_template")
dbLoadTemplate("db/llrfIN20.gnt_phas_template")
#dbLoadTemplate("db/llrfIN20.l0a_template")
#dbLoadTemplate("db/llrfIN20.tc0_template")
#dbLoadTemplate("db/llrfIN20.l0b_template")
dbLoadTemplate("db/llrfIN20.kly_template")
dbLoadTemplate("db/llrfIN20.ref_template")
dbLoadTemplate("db/llrfIN20.lsr_ref_template")
dbLoadTemplate("db/llrfIN20.lsr_ph1_template")
dbLoadTemplate("db/llrfIN20.clk_template")
dbLoadTemplate("db/llrfIN20.l2ref_template")
dbLoadTemplate("db/llrfIN20.gbl_template")
dbLoadTemplate("db/llrfLI21.gbl_template")
#dbLoadTemplate("db/llrfLI21.l1x_template")
dbLoadTemplate("db/llrfLI21.kly_template")
#dbLoadTemplate("db/llrfLI21.ph2_template")
dbLoadRecords("db/IOC-IN20-RF01evr.db") # has all three EVRs' recs
dbLoadRecords("db/IOC-IN20-RF01trig.db") # has all three EVRs' recs
dbLoadRecords("db/IOC-IN20-RF01pattern.db")
dbLoadRecords("db/IOC-IN20-RF01bsa.db")
dbLoadRecords("db/IOC-LI21-RF01bsa.db")

dbLoadRecords("db/iocAdmin.db","IOC=IOC:IN20:RF01")

dbLoadRecords("db/access.db","DEV=LASR:IN20:1,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=GUN:IN20:1,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=GUN:IN20:2,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=ACCL:IN20:300,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=ACCL:IN20:400,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=TCAV:IN20:490,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=PCAV:IN20:365,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=ACCL:LI21:1,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=ACCL:LI21:180,MANAGE=IOCMANAGERS")
dbLoadRecords("db/access.db","DEV=PCAV:LI21:300,MANAGE=IOCMANAGERS")

# bspExtMemProbe only durint init. clear this to avoid the lecture.
bspExtVerbosity=0

# hardware initialization
drvMrfErFlag=2
# ErConfigure(slot #, address, irq vec, irq level, EVR type(0=VME,1=PMC))
ErConfigure(0,0x300000,0x60,4,0)
ErConfigure(1,0x400000,0x62,4,0)
ErConfigure(2,0x500000,0x64,4,0)

devAiLlrfFlag=2
devAoLlrfFlag=2
devWaveformLlrfFlag=2
devWaveformLlrfDebug=0

# Works if /data mountpoint maps to $LCDATA/epics/ioc/data/LLRF
dbRestore("/data/IOC-IN20-RF01trig.sav")
dbRestore("/data/IOC-IN20-RF01.sav")

iocInit()

devAiLlrfFlag=2
dbSendFlag=2
dbCtlFlag=2
dbRecvFlag=2
msgHdlrFlag=2

## Initial processing for Laser Station

# 5/5/8 new (next 3 lines)
dbpf("LASR:IN20:1:LSR_PDES119.PROC","1")
dbpf("LASR:IN20:1:LSR_PDES2856.PROC","1")
dbpf("LASR:IN20:1:LSR_PDES2805.PROC","1")

dbpf("LASR:IN20:1:LSR_ADES.PROC","1")
dbpf("LASR:IN20:1:LSR_SEND","1")
dbpf("LASR:IN20:1:LSR_P_FB_PND","0")
dbpf("LASR:IN20:1:LSR_SOURCE","0")
dbpf("LASR:IN20:1:LSR_0_POC.PROC","1")
dbpf("LASR:IN20:1:LSR_1_POC.PROC","1")
dbpf("LASR:IN20:1:LSR_2_POC.PROC","1")
dbpf("LASR:IN20:1:LSR_3_POC.PROC","1")
dbpf("LASR:IN20:1:LSR_0_AVC.PROC","1")
dbpf("LASR:IN20:1:LSR_1_AVC.PROC","1")
dbpf("LASR:IN20:1:LSR_2_AVC.PROC","1")
dbpf("LASR:IN20:1:LSR_3_AVC.PROC","1")
dbpf("LASR:IN20:1:LSR_0_APC.PROC","1")
dbpf("LASR:IN20:1:LSR_1_APC.PROC","1")
dbpf("LASR:IN20:1:LSR_2_APC.PROC","1")
dbpf("LASR:IN20:1:LSR_3_APC.PROC","1")
dbpf("LASR:IN20:1:LSR_PSMOOTH.PROC","1")
dbpf("LASR:IN20:1:LSR_PCORMAX.PROC","1")
dbpf("LASR:IN20:1:LSR_PCORMIN.PROC","1")

## Initial processing for Reference Station
# keep MDL not sending to PAD ### 5/5/8: this may need to change now
dbpf("LLRF:IN20:RH:REF_2_SEND","1")
#5/8/8: uncomment next two lines
dbpf("LLRF:IN20:RH:REF_2_ISET.PROC","1")
dbpf("LLRF:IN20:RH:REF_2_QSET.PROC","1")

# 5/5/8 new. needed for ops as well. at least until it's known that calcout triggering
# PSET processing is the way to go. If it's good, add OOPT to llrfcalcout.db and# fix ALL templates that include it
dbpf("LLRF:IN20:RH:REF_2_CONVERGE.OOPT","When Non-zero")

#6/10/8: new. to fix UDF
dbpf("LLRF:IN20:RH:REF_0_POC.PROC","1")
dbpf("LLRF:IN20:RH:REF_1_POC.PROC","1")
dbpf("LLRF:IN20:RH:REF_2_POC.PROC","1")
dbpf("LLRF:IN20:RH:REF_3_POC.PROC","1")

dbpf("LLRF:IN20:RH:REF_0_ISET.PROC","1")
dbpf("LLRF:IN20:RH:REF_0_QSET.PROC","1")
dbpf("LLRF:IN20:RH:REF_3_ISET.PROC","1")
dbpf("LLRF:IN20:RH:REF_3_QSET.PROC","1")
dbpf("LLRF:IN20:RH:CLK_ISET.PROC","1")
dbpf("LLRF:IN20:RH:CLK_QSET.PROC","1")

# explicitly enable (intentionally don't want to restore what was before boot)
dbpf("LLRF:IN20:RH:REF_0_SEND","0")
dbpf("LLRF:IN20:RH:REF_3_SEND","0")
dbpf("LLRF:IN20:RH:CLK_SEND","0")

# explicitly disable (intentionally don't want to restore what was before boot)
dbpf("LLRF:IN20:RH:L2_SEND","1")
# 5/14/8 next five lines are new
dbpf("LLRF:IN20:RH:L2_PDES.PROC","1")
dbpf("LLRF:IN20:RH:L2_POC.PROC","1")
dbpf("LLRF:IN20:RH:L2_ADES.PROC","1")
dbpf("LLRF:IN20:RH:L2_ISET.PROC","1")
dbpf("LLRF:IN20:RH:L2_QSET.PROC","1")

## Initial processing for RF Gun Cell Station

dbpf("GUN:IN20:1:GN1_PHAS_FB","0") # moved from st-prod.cmd
dbpf("GUN:IN20:1:GN1_AMPL_FB","0")
dbpf("GUN:IN20:1:GN1_0_PWT.PROC","1")
dbpf("GUN:IN20:1:GN1_1_PWT.PROC","1")
dbpf("GUN:IN20:1:GN1_2_PWT.PROC","1")
dbpf("GUN:IN20:1:GN1_3_PWT.PROC","1")
dbpf("GUN:IN20:1:GN1_0_AWT.PROC","1")
dbpf("GUN:IN20:1:GN1_1_AWT.PROC","1")
dbpf("GUN:IN20:1:GN1_2_AWT.PROC","1")
dbpf("GUN:IN20:1:GN1_3_AWT.PROC","1")
dbpf("GUN:IN20:1:GN1_TOT_PWT.PROC","1")
dbpf("GUN:IN20:1:GN1_TOT_AWT.PROC","1")
dbpf("GUN:IN20:1:GN1_1_POC.PROC","1")
dbpf("GUN:IN20:1:GN1_2_POC.PROC","1")
dbpf("GUN:IN20:1:GN1_3_POC.PROC","1")
dbpf("GUN:IN20:1:GN1_0_APC.PROC","1")
dbpf("GUN:IN20:1:GN1_1_APC.PROC","1")
dbpf("GUN:IN20:1:GN1_2_APC.PROC","1")
dbpf("GUN:IN20:1:GN1_3_APC.PROC","1")
dbpf("GUN:IN20:1:GN1_0_AVC.PROC","1")
dbpf("GUN:IN20:1:GN1_1_AVC.PROC","1")
dbpf("GUN:IN20:1:GN1_2_AVC.PROC","1")
dbpf("GUN:IN20:1:GN1_3_AVC.PROC","1")
dbpf("GUN:IN20:1:GN1_PSMOOTH.PROC","1")
dbpf("GUN:IN20:1:GN1_ASMOOTH.PROC","1")
dbpf("GUN:IN20:1:GN1_PCORMIN.PROC","1")
dbpf("GUN:IN20:1:GN1_PCORMAX.PROC","1")
dbpf("GUN:IN20:1:GN1_ACORMIN.PROC","1")
dbpf("GUN:IN20:1:GN1_ACORMAX.PROC","1")
# 3/19/2007 new. need to get set for other stations still!!!
dbpf("GUN:IN20:1:GN1_PSETMIN.PROC","1")
dbpf("GUN:IN20:1:GN1_PSETMAX.PROC","1")
dbpf("GUN:IN20:1:GN1_ASETMIN.PROC","1")
dbpf("GUN:IN20:1:GN1_ASETMAX.PROC","1")
dbpf("GUN:IN20:1:GN1_QSCALE.PROC","1")
dbpf("GUN:IN20:1:GN1_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
dbpf("GUN:IN20:1:GN1_SEND","1")
dbpf("GUN:IN20:1:GN1_PHAS_FB.PROC","1")
dbpf("GUN:IN20:1:GN1_AMPL_FB.PROC","1")
dbpf("GUN:IN20:1:GN1_PRV_ASET.PROC","1") # don't let it go below 100
dbpf("GUN:IN20:1:GN1_PDES.PROC","1")
dbpf("GUN:IN20:1:GN1_ADES.PROC","1")
# 5/14/8 new
dbpf("GUN:IN20:1:GN1_PWR_THLD.PROC","1")
dbpf("GUN:IN20:1:GN2_PID_SUM.OMSL", "closed_loop")
dbpf("GUN:IN20:1:GN2_PID_SUM.HOPR", "10")
dbpf("GUN:IN20:1:GN2_PID_SUM.LOPR", "-10")
dbpf("GUN:IN20:1:GN2_PID_ENABLE", "Auto")
dbpf("GUN:IN20:1:GN2_PID_CTL", "ON")
dbpf("GUN:IN20:1:GN2_TEMP_PID.SCAN", "1 second") # do this last, after PID enable is Manual and control is OFF
dbpf("GUN:IN20:1:GN2_TEMP_SP.PROC","1")

## Initial settings for S-Band GN2 Station's RF Phase loop before save/restored

dbpf("GUN:IN20:1:GN2_KP2", "1.0")
dbpf("GUN:IN20:1:GN2_KI2", "0.03")
dbpf("GUN:IN20:1:GN2_PHAS_SP", "0.") # I have no idea what to set this to
dbpf("GUN:IN20:1:GN2_PID2_SUM.OMSL", "closed_loop")
dbpf("GUN:IN20:1:GN2_PID2_SUM.HOPR", "10")
dbpf("GUN:IN20:1:GN2_PID2_SUM.LOPR", "-10")
dbpf("GUN:IN20:1:GN2_PID2ENABLE", "Manual")
dbpf("GUN:IN20:1:GN2_PID2_CTL", "OFF")
dbpf("GUN:IN20:1:GN2_PHAS_PID.SCAN", "1 second") # do this last, after PID enable is Manual and control is OFF
dbpf("GUN:IN20:1:GN2_PHAS_SP.PROC","1")

## Initial processing for S-Band L0-A Station

dbpf("ACCL:IN20:300:L0A_PHAS_FB","0") # moved from st-prod.cmd
dbpf("ACCL:IN20:300:L0A_AMPL_FB","0")
dbpf("ACCL:IN20:300:L0A_0_PWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_1_PWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_0_AWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_1_AWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_TOT_PWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_TOT_AWT.PROC","1")
dbpf("ACCL:IN20:300:L0A_0_POC.PROC","1")
dbpf("ACCL:IN20:300:L0A_1_POC.PROC","1")
dbpf("ACCL:IN20:300:L0A_0_APC.PROC","1")
dbpf("ACCL:IN20:300:L0A_1_APC.PROC","1")
dbpf("ACCL:IN20:300:L0A_0_AVC.PROC","1")
dbpf("ACCL:IN20:300:L0A_1_AVC.PROC","1")
dbpf("ACCL:IN20:300:L0A_PSMOOTH.PROC","1")
dbpf("ACCL:IN20:300:L0A_ASMOOTH.PROC","1")
dbpf("ACCL:IN20:300:L0A_PCORMIN.PROC","1")
dbpf("ACCL:IN20:300:L0A_PCORMAX.PROC","1")
dbpf("ACCL:IN20:300:L0A_ACORMIN.PROC","1")
dbpf("ACCL:IN20:300:L0A_ACORMAX.PROC","1")
# 3/19/2007 new. need to get set for other stations still!!!
dbpf("ACCL:IN20:300:L0A_PSETMIN.PROC","1")
dbpf("ACCL:IN20:300:L0A_PSETMAX.PROC","1")
dbpf("ACCL:IN20:300:L0A_ASETMIN.PROC","1")
dbpf("ACCL:IN20:300:L0A_ASETMAX.PROC","1")
dbpf("ACCL:IN20:300:L0A_QSCALE.PROC","1")
dbpf("ACCL:IN20:300:L0A_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
dbpf("ACCL:IN20:300:L0A_SEND","1")
dbpf("ACCL:IN20:300:L0A_PHAS_FB.PROC","1")
dbpf("ACCL:IN20:300:L0A_AMPL_FB.PROC","1")
dbpf("ACCL:IN20:300:L0A_PRV_ASET.PROC","1") # don't let it go below 100
dbpf("ACCL:IN20:300:L0A_PDES.PROC","1")
dbpf("ACCL:IN20:300:L0A_ADES.PROC","1")
# 5/14/8 new
dbpf("ACCL:IN20:300:L0A_PWR_THLD.PROC","1")

## Initial processing for S-Band L0-B Station

dbpf("ACCL:IN20:400:L0B_PHAS_FB","0") # moved from st-prod.cmd
dbpf("ACCL:IN20:400:L0B_AMPL_FB","0")
dbpf("ACCL:IN20:400:L0B_2_PWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_3_PWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_2_AWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_3_AWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_TOT_PWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_TOT_AWT.PROC","1")
dbpf("ACCL:IN20:400:L0B_2_POC.PROC","1")
dbpf("ACCL:IN20:400:L0B_3_POC.PROC","1")
dbpf("ACCL:IN20:400:L0B_2_APC.PROC","1")
dbpf("ACCL:IN20:400:L0B_3_APC.PROC","1")
dbpf("ACCL:IN20:400:L0B_2_AVC.PROC","1")
dbpf("ACCL:IN20:400:L0B_3_AVC.PROC","1")
dbpf("ACCL:IN20:400:L0B_PSMOOTH.PROC","1")
dbpf("ACCL:IN20:400:L0B_ASMOOTH.PROC","1")
dbpf("ACCL:IN20:400:L0B_PCORMIN.PROC","1")
dbpf("ACCL:IN20:400:L0B_PCORMAX.PROC","1")
dbpf("ACCL:IN20:400:L0B_ACORMIN.PROC","1")
dbpf("ACCL:IN20:400:L0B_ACORMAX.PROC","1")
dbpf("ACCL:IN20:400:L0B_PSETMIN.PROC","1")
dbpf("ACCL:IN20:400:L0B_PSETMAX.PROC","1")
dbpf("ACCL:IN20:400:L0B_ASETMIN.PROC","1")
dbpf("ACCL:IN20:400:L0B_ASETMAX.PROC","1")
dbpf("ACCL:IN20:400:L0B_QSCALE.PROC","1")
dbpf("ACCL:IN20:400:L0B_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
dbpf("ACCL:IN20:400:L0B_SEND","1")
dbpf("ACCL:IN20:400:L0B_PHAS_FB.PROC","1")
dbpf("ACCL:IN20:400:L0B_AMPL_FB.PROC","1")
dbpf("ACCL:IN20:400:L0B_PRV_ASET.PROC","1") # don't let it go below 100
dbpf("ACCL:IN20:400:L0B_PDES.PROC","1")
dbpf("ACCL:IN20:400:L0B_ADES.PROC","1")
# 5/14/8 new
dbpf("ACCL:IN20:400:L0B_PWR_THLD.PROC","1")

## Initial processing for S-Band TCav Station

#dbpf("TCAV:IN20:490:TC0_PHAS_FB","0") # NEW 5/11/7
#dbpf("TCAV:IN20:490:TC0_AMPL_FB","0") # NEW 5/11/7
#dbpf("TCAV:IN20:490:TC0_0_PWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_1_PWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_0_AWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_1_AWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_TOT_PWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_TOT_AWT.PROC","1")
#dbpf("TCAV:IN20:490:TC0_0_POC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_1_POC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_2_POC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_3_POC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_0_APC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_1_APC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_2_APC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_3_APC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_0_AVC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_1_AVC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_2_AVC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_3_AVC.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PSMOOTH.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ASMOOTH.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PCORMIN.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PCORMAX.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ACORMIN.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ACORMAX.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PSETMIN.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PSETMAX.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ASETMIN.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ASETMAX.PROC","1")
#dbpf("TCAV:IN20:490:TC0_QSCALE.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
#dbpf("TCAV:IN20:490:TC0_SEND","1")
#dbpf("TCAV:IN20:490:TC0_PHAS_FB.PROC","1")
#dbpf("TCAV:IN20:490:TC0_AMPL_FB.PROC","1")
#dbpf("TCAV:IN20:490:TC0_PRV_ASET.PROC","1") # don't let it go below 100
#dbpf("TCAV:IN20:490:TC0_PDES.PROC","1")
#dbpf("TCAV:IN20:490:TC0_ADES.PROC","1")
# 5/14/8 new
#dbpf("TCAV:IN20:490:TC0_PWR_THLD.PROC","1")

## Initial processing for S-Band L1-S Station

dbpf("ACCL:LI21:1:L1S_PHAS_FB","0") # moved from st-prod.cmd 5/29/7
dbpf("ACCL:LI21:1:L1S_AMPL_FB","0")
dbpf("ACCL:LI21:1:L1S_0_PWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_1_PWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_2_PWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_3_PWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_0_AWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_1_AWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_2_AWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_3_AWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_TOT_PWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_TOT_AWT.PROC","1")
dbpf("ACCL:LI21:1:L1S_0_POC.PROC","1")
dbpf("ACCL:LI21:1:L1S_1_POC.PROC","1")
dbpf("ACCL:LI21:1:L1S_2_POC.PROC","1")
dbpf("ACCL:LI21:1:L1S_3_POC.PROC","1")
dbpf("ACCL:LI21:1:L1S_0_APC.PROC","1")
dbpf("ACCL:LI21:1:L1S_1_APC.PROC","1")
dbpf("ACCL:LI21:1:L1S_2_APC.PROC","1")
dbpf("ACCL:LI21:1:L1S_3_APC.PROC","1")
dbpf("ACCL:LI21:1:L1S_0_AVC.PROC","1")
dbpf("ACCL:LI21:1:L1S_1_AVC.PROC","1")
dbpf("ACCL:LI21:1:L1S_2_AVC.PROC","1")
dbpf("ACCL:LI21:1:L1S_3_AVC.PROC","1")
dbpf("ACCL:LI21:1:L1S_PSMOOTH.PROC","1")
dbpf("ACCL:LI21:1:L1S_ASMOOTH.PROC","1")
dbpf("ACCL:LI21:1:L1S_PCORMIN.PROC","1")
dbpf("ACCL:LI21:1:L1S_PCORMAX.PROC","1")
dbpf("ACCL:LI21:1:L1S_ACORMIN.PROC","1")
dbpf("ACCL:LI21:1:L1S_ACORMAX.PROC","1")
dbpf("ACCL:LI21:1:L1S_PSETMIN.PROC","1")
dbpf("ACCL:LI21:1:L1S_PSETMAX.PROC","1")
dbpf("ACCL:LI21:1:L1S_ASETMIN.PROC","1")
dbpf("ACCL:LI21:1:L1S_ASETMAX.PROC","1")
dbpf("ACCL:LI21:1:L1S_QSCALE.PROC","1")
dbpf("ACCL:LI21:1:L1S_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
dbpf("ACCL:LI21:1:L1S_SEND","1")
dbpf("ACCL:LI21:1:L1S_PHAS_FB.PROC","1")
dbpf("ACCL:LI21:1:L1S_AMPL_FB.PROC","1")
dbpf("ACCL:LI21:1:L1S_PRV_ASET.PROC","1") # don't let it go below 100
dbpf("ACCL:LI21:1:L1S_PDES.PROC","1")
dbpf("ACCL:LI21:1:L1S_ADES.PROC","1")
dbpf("ACCL:LI21:1:L1S_PWR_THLD.PROC","1")

## Initial processing for X-Band L1-X Station
## Notes:
## - channels 2 and 3 are not part of feedback, so they have no weighting factors
## - channel 2 is a simple average (voltage), so it has no offset or scale factors

dbpf("ACCL:LI21:180:L1X_PHAS_FB","0")
dbpf("ACCL:LI21:180:L1X_AMPL_FB","0")
#dbpf("ACCL:LI21:180:L1X_0_PWT.PROC","1")
#dbpf("ACCL:LI21:180:L1X_1_PWT.PROC","1")
dbpf("ACCL:LI21:180:L1X_0_AWT.PROC","1")
dbpf("ACCL:LI21:180:L1X_1_AWT.PROC","1")
#dbpf("ACCL:LI21:180:L1X_TOT_PWT.PROC","1")
dbpf("ACCL:LI21:180:L1X_TOT_AWT.PROC","1")
dbpf("ACCL:LI21:180:L1X_0_POC.PROC","1")
dbpf("ACCL:LI21:180:L1X_1_POC.PROC","1")
dbpf("ACCL:LI21:180:L1X_3_POC.PROC","1")
dbpf("ACCL:LI21:180:L1X_0_APC.PROC","1")
dbpf("ACCL:LI21:180:L1X_1_APC.PROC","1")
dbpf("ACCL:LI21:180:L1X_3_APC.PROC","1")
dbpf("ACCL:LI21:180:L1X_0_AVC.PROC","1")
dbpf("ACCL:LI21:180:L1X_1_AVC.PROC","1")
dbpf("ACCL:LI21:180:L1X_3_AVC.PROC","1")
dbpf("ACCL:LI21:180:L1X_PSMOOTH.PROC","1")
dbpf("ACCL:LI21:180:L1X_ASMOOTH.PROC","1")
dbpf("ACCL:LI21:180:L1X_PCORMIN.PROC","1")
dbpf("ACCL:LI21:180:L1X_PCORMAX.PROC","1")
dbpf("ACCL:LI21:180:L1X_ACORMIN.PROC","1")
dbpf("ACCL:LI21:180:L1X_ACORMAX.PROC","1")
dbpf("ACCL:LI21:180:L1X_ASETMIN.PROC","1")
dbpf("ACCL:LI21:180:L1X_ASETMAX.PROC","1")
dbpf("ACCL:LI21:180:L1X_QSCALE.PROC","1")
dbpf("ACCL:LI21:180:L1X_ISCALE.PROC","1")
# Default is for values to be sent. Convention is non-intuitive so that
# DISV=1 can be used. Val of this bo record compared to DISV and if they
# match, then sending to PAC is disabled. Therefore enabled = 0.
dbpf("ACCL:LI21:180:L1X_SEND","1")
dbpf("ACCL:LI21:180:L1X_PHAS_FB.PROC","1")
dbpf("ACCL:LI21:180:L1X_AMPL_FB.PROC","1")
dbpf("ACCL:LI21:180:L1X_PRV_ASET.PROC","1") # don't let it go below 100
dbpf("ACCL:LI21:180:L1X_PDES.PROC","1")
dbpf("ACCL:LI21:180:L1X_ADES.PROC","1")
dbpf("ACCL:LI21:180:L1X_PWR_THLD.PROC","1")

# Set initial values for global feedback

dbpf("LLRF:IN20:RH:G_L0_FB_CTL", "OFF")
dbpf("LLRF:LI21:RH:G_L1_FB_CTL", "OFF")

# 7/3/8: Needed for BSA
# LASER dbpf("_PAVG.MDEL","-1")
# LASER dbpf("_AAVG.MDEL","-1")
dbpf("GUN:IN20:1:GN1_PAVG.MDEL","-1")
dbpf("GUN:IN20:1:GN1_AAVG.MDEL","-1")
dbpf("ACCL:IN20:300:L0A_PAVG.MDEL","-1")
dbpf("ACCL:IN20:300:L0A_AAVG.MDEL","-1")
dbpf("ACCL:IN20:400:L0B_PAVG.MDEL","-1")
dbpf("ACCL:IN20:400:L0B_AAVG.MDEL","-1")
dbpf("PCAV:IN20:365:PH1_PAVG.MDEL","-1")
dbpf("PCAV:IN20:365:PH1_AAVG.MDEL","-1")
#dbpf("TCAV:IN20:490:TC0_PAVG.MDEL","-1")
#dbpf("TCAV:IN20:490:TC0_AAVG.MDEL","-1")
dbpf("ACCL:LI21:1:L1S_PAVG.MDEL","-1")
dbpf("ACCL:LI21:1:L1S_AAVG.MDEL","-1")
dbpf("ACCL:LI21:180:L1X_PAVG.MDEL","-1")
dbpf("ACCL:LI21:180:L1X_AAVG.MDEL","-1")

