#==============================================================
#
#  Abs:  EPICS RTEMS Startup Script for LTU thru UND PPS
#
#  Name: st.cmd
#
#  Facility:  PPS controls
#
#  Auth: 18-Feb-2009, K. Turner       (KKUBLER)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        29-Dec-2019, K. Luchini       (LUCHINI):
#         chg getennv to getenv
#        15-Oct-2019, K. Luchini       (LUCHINI):
#         move from iocBoot/ioc-xrt1-pp01 to ioc-xrth-pp01
#         chg IOC name from IOC:XRT1:PP01 to IOC:XRTH:PP01
#         remove the following dbs, now included in pps-und.db
#            pps-und-sum3.db
#            pps-sys0-bsioc-warning.vdb
#            pps-sys0-btm-warning.vdb
#       14-Oct-2019, K. Luchini        (LUCHINI):
#         load common scripts
#         load caPutLogInit
#       01-Mar-2018, K. Luchini        (LUCHINI):
#         load common scripts
#       02-Apr-2009, K. Luchini        (luchini):
#         install pps-und-loopi.db
#       06-Mar-2009, K. Turner         (kkubler):
#         cleanup
#       13-Feb-2007, arturo alarcon    (alarcon)
#         added nfs mount env, plc stat db
#
#==============================================================
#
# Set environment variables
setenv("LOCATION", "B913-4547")
setenv("IOC_NAME", "IOC:LTUH:PP01")
setenv("PLC_NAME", "PLC:UND0:PPS1")
setenv("PLC_NODE", "172.27.12.89")
cexpsh("../common/st.cmd.rtems")

# Load record instances
dbLoadRecords("db/pps-und.db")

# Initialize PLC
cexpsh("iocBoot/common/init_plc.cmd")
chdir(getenv("IOC_BOOT"))
cexpsh("init_ipac.cmd")
cexpsh("init_bkhf.cmd")
chdir(getenv("TOP"))

# Setup autosave/restore 
cexpsh("iocBoot/common/init_restore.cmd")

# Start EPICS
iocInit()

#  Start caPut logging
caPutLogInit(getenv("EPICS_CA_PUT_LOG_ADDR"),0)

# Start ip330 adc convertion
ip330StartConvertByName("AI1-UND0-1-PPS")

# Start autosave routines to save our data
cexpsh("iocBoot/common/restore.cmd")

# End of script
