#==============================================================
#
#  Abs:  Generic piece of startup script for soft 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.
#
#           EPICS_IOCS - Top level boot dir for all iocs
#           IOC_NAME   - IOC Device name   (ie. SIOC:LI20:CS05)
#           LOCATION   - Rack location
#           LOG_INIT   - Log message file with path
#           ACF_INIT   - Access Control File with path
#
#         Upon exit, this script will leave the ioc sitting
#         at the application TOP directory.
#
#         WARNING!!!
#         The TOP environment variable is defined in
#         envPaths, however in development (afs), the
#         definitionmay include "slac.stanford.edu", which is
#         not understood by linuxRT for example. However, 
#         when "cram" is used to push to production, "slac"
#         is substituted for "slac.stanford.edu", which fixes the problem.
#
#  Facility: EED Profile Monitor Controls
#
#  Auth: 28-Sep-2021, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        dd-mmm-yyyy, First Lastname  (USERNAME):
#         comment
#
#==============================================================
#
# Set environment variables
< envPaths

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

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

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

# Support Large Arrays/Waveforms
epicsEnvSet("EPICS_CA_MAX_ARRAY_BYTES", "20000000")

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

#==============================================================
# Load IOC Application object
#==============================================================
#
# Load EPICS Database
dbLoadDatabase("dbd/orcaUsb.dbd")
orcaUsb_registerRecordDeviceDriver(pdbbase)

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

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

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

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

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

# End of script






