#==============================================================
#
#  Abs:  Generic piece of startup script for 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:
#
#           EPICS_IOC_APP - Top of IOC Application
#           EPICS_IOCS    - Top level boot dir for all iocs
#           IOC_NAME      - IOC Device name   (ie. SIOC:MCC0:KN00)
#           LOCATION      - Location of IOC   (ie. cpu-mcc0-kn00)
#           ACF_FILE      - Access Control File with path
#           INIT_ACF      - CA security seutp file including path
#           INIT_LOG      - log message seutp file including path
#           KNOB_TYPE     - Knob dbd/program name (knobCtrl,knobUserEpics)
#
#        All other macros used within this script
#        are set from the file iocBoot/<ioc>/envPaths,
#        which is loaded in this script.
#
#  Facility:  EED Knob Controls
#
#  Auth: 07-Jun-2021, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        14-Oct-2022, K. Luchini      (LUCHINI):
#         add env var IOC_BOOT
#         add env var KNOB_TYPE
#
#==============================================================
#
# Set environment variables
< envPaths

# Get current iocBoot directory path so we can return easily
epicsEnvSet("IOC_BOOT" ,"${EPICS_IOC_APP}")

# iocAdmin environment variables
epicsEnvSet("ENGINEER"   , "Sonya Hoobler")
epicsEnvSet("IOC_BOOT"   , "${EPICS_IOC_APP}")
epicsEnvSet("STARTUP"    , "${EPICS_IOCS}/${IOC}")
epicsEnvSet("ST_CMD"     , "startup.cmd")

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

#==============================================================
# Load standard databases
#==============================================================
cd ${TOP}
dbLoadDatabase("dbd/${KNOB_TYPE}.dbd",0,0)
${KNOB_TYPE}_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}")

#==============================================================
# 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






