#!../../iiocSpecificRelease/bin/linux-x86/BucketJump

## You may have to change sioc-b34-bc01 to something else
## everywhere it appears in this file

< envPaths

cd ${TOP}

## Register all support components
dbLoadDatabase("dbd/BucketJump.dbd")
BucketJump_registerRecordDeviceDriver pdbbase

# ====================================================================
# Setup some additional environment variables
# ====================================================================
# Setup environment variables
epicsEnvSet("ENGINEER","Eric Tse")
epicsEnvSet("LOCATION","ACR")

# tag log messages with IOC name
epicsEnvSet("EPICS_IOC_LOG_CLIENT_INET","${IOC}")

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

# END: Additional environment variables
# ====================================================================


########################################################################
# BEGIN: Initialise all hardware and devices
## Define serial port to be used by SR620 Bucket Jump Application
# Port number one of the Digi should be setup for raw mode:
# Raw mode port = 2100 + channel number
# Digi Terminal Server Info:
# Digi Model: PortServer TS 16 MEI
# Digi Server name is "ts-in20-ev51"
# Digi IP address:  172.27.12.126
# Digi channel Number used: channel 1
drvAsynIPPortConfigure ("SRS_620_1","172.27.12.126:2102",0,0,0)

# The following would be for a second SRS620:
drvAsynIPPortConfigure ("SRS_620_2","172.27.12.127:2101",0,0,0)


## Asyn messages
#asynSetTraceMask("SRS_620_1",-1,0x0F)
#asynSetTraceIOMask("SRS_620_1",-1,0x6)

#asynSetTraceMask("SRS_620_2",-1,0x9)
#asynSetTraceIOMask("SRS_620_2",-1,0x2)
#END: Initialisation of the hardware
########################################################################


########################################################################
# BEGIN: Load the record databases
#######################################################################
# =====================================================================
# Load iocAdmin databases to support IOC Health and monitoring
# =====================================================================
dbLoadRecords("db/iocAdminSoft.db","IOC=SIOC:SYS0:BJ00")
dbLoadRecords("db/iocAdminScanMon.db","IOC=SIOC:SYS0:BJ00")

# 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=SIOC:SYS0:BJ00")

# =====================================================================
# Load database for autosave status
# =====================================================================
dbLoadRecords("db/save_restoreStatus.db", "P=SIOC:SYS0:BJ00:")

# =====================================================================
# Load record database for asynRecord
# =====================================================================
dbLoadRecords("db/asynRecord.db", "P=SIOC:SYS0:BJ00:,R=ASYNDRIVER,PORT=SRS_620_1,ADDR=0,IMAX=0,OMAX=0")
dbLoadRecords("db/asynRecord.db", "P=SIOC:SYS0:BJ00:,R=ASYNDRIVER,PORT=SRS_620_2,ADDR=0,IMAX=0,OMAX=0")

dbLoadRecords("db/BucketJump.db") 

# =====================================================================
#Load Additional databases:
# =====================================================================

# END: Loading the record databases
########################################################################

# =====================================================================
## Begin: Setup autosave/restore
# =====================================================================
set_requestfile_path("${IOC_DATA}/${IOC}/autosave-req")
set_savefile_path("${IOC_DATA}/${IOC}/autosave")
save_restoreSet_status_prefix("SIOC:SYS0:BJ00:")

## Restore datasets
set_pass0_restoreFile("info_settings.sav")
set_pass1_restoreFile("info_settings.sav")

# =====================================================================
# End: Setup autosave/restore
# =====================================================================


cd ${TOP}/iocBoot/${IOC}
iocInit()

## Start any sequence programs
#seq sncExample, "user=FredandMary"

## Start autosave process:
create_monitor_set("info_settings.req",60,"")

dbpf("SIOC:SYS0:BJ00:ASYNDRIVER.IEOS","\r")
dbpf("SIOC:SYS0:BJ00:ASYNDRIVER.OEOS","\r")
dbpf("SIOC:SYS0:BJ00:ASYNDRIVER.AOUT","*IDN?")

