#==============================================================
#
#  Abs:  Common Soft IOC startup script
#
#  Name: st.cmd.soft
#
#  Side:  This script expectes the following 
#         environment variables tobe defined upon entry
#           IOC_NAME   - IOC Device nme,            (ie. SIOC:BSY0:MC01)
#           ENGINEER   - IOC Engineer               (ie. Mitch D'Ewart)
#
#         Some of the above macros are defined by the script 
#         envPaths, which is generated during the build and 
#         saved at: iocBoot/<nodename>
# 
#         Upon exit, this script will leave the ioc sitting
#         at the application TOP directory when the following
#         is defined in the Makefile:
#
#        TARGET = envPaths
#
#  Facility: SLAC Motion Controls
#
#  Auth: 02-Dec-2015, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#         17-Oct-2019, Namrata Balakrishnan (NAMRATA)
#           add devSeqCar.db
#           add log_init.cmd.soft
#           add SUBSYS env var
#
#==============================================================
#
# Set environment variables
< envPaths

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

# Define subsystem, used by iocLogPrefix
setenv("SUBSYS","motion")

# required for large waveforms, used for BSA pvs
epicsEnvSet("EPICS_CA_MAX_ARRAY_BYTES", "30000")

# required for streamdevice
epicsEnvSet("STREAM_PROTOCOL_PATH", "$(TOP)/db")

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

#==============================================================
# Load standard databases3
#==============================================================

# Initialize EPICS errlog message queue size.  This needs to be
# done before any dbLoad calls are made. Note the default is
# 1260 bytes - too many messages are being discarded making it 
# hard to debug.
errlogInit(5000)

# Load the database definitions file
dbLoadDatabase("dbd/MotionControlSoft.dbd")
MotionControlSoft_registerRecordDeviceDriver(pdbbase)

# Load iocAdmin databases to support IOC Health and monitoring
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}")

# Load sequence admin
dbLoadRecords("db/devSeqCar.db","SIOC=${IOC_NAME}")

#==============================================================
#  Load Channe Access Security if configuration file exists
#==============================================================
< ${ACF_INIT}

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

# End of script

