#==============================================================
#
#  Abs:  Common Laser startup script for linuxRT IOCs
#
#  Name: st.cmd.soft
#
#  Rem:  Upon entry we expect to be at location TOP
#        and the following macros must be defined.
#        Note that all other environment variables #
#        used within this file are defined in envPaths.
#
#           IOC_NAME - IOC Device name    (ie. SIOC:SYS1:BC01)
#           LOCATION - Rack location  
#
#        Upon exiting this script the directory
#        will be set to the TOP of the IOC Application.
#
#  Facility: EED Laser Controls
#
#  Auth: 13-Mar-2019, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        17-Mar-2023, K. Luchini      (LUCHINI):
#         add errlogInit
#        20-Sep-2021, K. Luchini      (LUCHINI):
#         chg extensions arConfig to archive
#         cp ioc specific autosave files 
#
#==============================================================
#
# Set environment variables
< envPaths

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

# iocAdmin environment variables
# the environment variable LOCATION must
# be defined upon entry.
epicsEnvSet("ENGINEER"  , "Shawn Alverson")
epicsEnvSet("STARTUP"   , "${EPICS_IOCS}/${IOC}")
epicsEnvSet("ST_CMD"    , "startup.cmd")

# Setup environment variable for iocLogPrefix
epicsEnvSet("SUBSYS", "lasr")

# Set path for stream devices 
epicsEnvSet("STREAM_PROTOCOL_PATH","${TOP}/db")

# Support for large arrays (i.e. cameras)
epicsEnvSet("EPICS_CA_MAX_ARRAY_BYTES", "20000000")

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

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

# 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}")

# Load sequence admin
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")

#==============================================================
# Update ioc specific pv for autosave in the data area
#==============================================================
system("cp autosave/${IOC}.req  ${IOC_DATA}/${IOC}/autosave-req/${IOC}.req")

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

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


# End of script






