#==============================================================
#
#  Abs:  Generic piece startup script for AL0x soft IOCs
#
#  Name: st.alh00.cmd
#
#  Side: Upon entry to this script expects to be
#        in the iocBoot/<ioc> directory, and the
#        the following macros have been defined:
#
#        LOCATION  - host soft ioc boots     ex) testfac-daemon1
#        SUBSYSIOC - IOC devices name        ex) SIOC:ALH0:MGNT00
#        EPICS_CA_PUT_LOG_ADDR - ip address or nodename of host to log msgs.  
#
#        All other macros used within this script
#        are set from the file iocBoot/<ioc>/envPaths
#
#        This script is loaded by the following scripts
#        iocBoot/<ioc>/st.cmd
#
#  Facility:  Alarm Controls 
#
#  Auth: 31-Jan-2017, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        01-Nov-2017, K. Luchini      (LUCHINI):
#          load iocBoot/<ioc>/envPaths
#          add CA security, caPutLog
#          remove envStats.db, now loaded by st.cmd
#
#==============================================================
#
# iocAdmin environment variables
< envPaths
epicsEnvSet("ENGINEER" , "Garth Brown")
epicsEnvSet("IOC_BOOT" , "${TOP}/iocBoot/${IOC}")
epicsEnvSet("STARTUP"  , "${EPICS_IOCS}/${IOC}")
epicsEnvSet("ST_CMD"   , "startup.cmd")

# Change to the top of the app
cd ${TOP}

# Load EPICS Database
dbLoadDatabase("dbd/alhPV.dbd")
alhPV_registerRecordDeviceDriver(pdbbase)

# Load record instances
dbLoadRecords("db/iocAdminSoft.db","IOC=${SUBSYSIOC}")
dbLoadRecords("db/iocRelease.db"  ,"IOC=${SUBSYSIOC}")

# Load Channel Access Security File (for caPutLog)
asSetFilename("db/alarmAccessControl.acf")

# Add additional databases specific to this ioc.
< iocBoot/${IOC}/db.cmd

# Initialize autosave
< iocBoot/common/init_restore.cmd

# Start EPICS
# Note: must be at TOP, required by CA Secirity acf file
iocInit()

# Generate autosave files from db and start monitoring PVs
< iocBoot/common/restore.cmd

# Turn on caPut logging
# Note: Log values only on change to the iocLogServer.
caPutLogInit("${EPICS_CA_PUT_LOG_ADDR}")
caPutLogShow(2)

# End of file



