#==============================================================
#
#  Abs:  Generic piece of startup script for HPRF soft IOCs
#
#  Name: st.cmd.soft
#
#  Side: Upon entry to this script expect to be at the
#        iocBoot directory for the IOC. In addition the
#        following macros are expected:
#
#            IOC_NAME - IOC devices name (i.e. SIOC:LI20:KY01)
#            ACF_FILE - channel access initalization script,
#                       including path       
#
#        All other macros used within this script
#        are set from the file iocBoot/<ioc>/envPaths,
#        which is loaded in this script.
#
#  Facility:  Klystron Controls
#
#  Auth: 27-Nov-2018, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        01-Apr-2021, K. Luchini      (LUCHINI):
#          replace ca sercurity command with ACF_INIT
#          cp archive file to data directory 
#        09-Dec-2019, K. Luchini      (LUCHINI):
#          load log init
#          add SUBSYS env var
#
#==============================================================
#
# Set environment variables
< envPaths

# iocAdmin environment variables
epicsEnvSet("ENGINEER"   , "Kristi Luchini")
epicsEnvSet("IOC_RESTORE", "${IOC_DATA}/${IOC}/restore")
epicsEnvSet("IOC_BOOT"   , "${EPICS_IOC_APP}")
epicsEnvSet("STARTUP"    , "${EPICS_IOCS}/${IOC}")
epicsEnvSet("ST_CMD"     , "startup.cmd")

# Define subsystem, used by iocLogPrefix
epicsEnvSet("SUBSYS","rf")

# Location of stream protocol files
epicsEnvSet("STREAM_PROTOCOL_PATH", "${TOP}/db")

#==============================================================
# Load standard databases
#==============================================================
cd ${TOP}
dbLoadDatabase("dbd/HighPowerRF.dbd")
HighPowerRF_registerRecordDeviceDriver(pdbbase)

# Load IOC Administration Databse
dbLoadRecords("db/iocAdminSoft.db","IOC=${IOC_NAME}")

# The following database is a result of a python parser
# which looks at RELEASE_SITE and RELEASE to discover
# versions of software your IOC is referencing
# The python parser is part of iocAdmin
dbLoadRecords("db/iocRelease.db"  ,"IOC=${IOC_NAME}")

# Sequence statatistics
dbLoadRecords("db/devSeqCar.db"   ,"SIOC=$(IOC_NAME)")

#==============================================================
# Update archive pv list in the data area
#==============================================================
system("cp archive/${IOC}.archive ${IOC_DATA}/${IOC}/archive/${IOC}.archive")

#==============================================================
#  Load Channe Access Security
#==============================================================
< ${ACF_INIT}

#==============================================================
# Start IOC Log Client
#==============================================================
< ${LOG_INIT}

# End of script






