#==============================================================
#
#  Abs:  Generic piece of startup script for BSA Service 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:SYS0:BA01)
#            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:  BSA Service
#
#  Auth: 14-Nov-2022, Ernest Williams  (ernesto)
#  Rev:  dd-mmm-yyyy, Reviewer's Name  (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        09-Mar-2022, K. Luchini       (luchini):
#         uncommented  LOG_INIT and copying
#         ioc archive file to the data directory 
#         remove IOC_RESTORE env variable, orignally
#         used for channel watcher restore files  
# 
#==============================================================
#
# Set environment variables
< envPaths

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

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

#==============================================================
# Load standard databases
#==============================================================
cd ${TOP}
dbLoadDatabase("dbd/bsas.dbd")
bsas_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 Channel Access Security
#==============================================================
< ${ACF_INIT}

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

# End of script






