#==============================================================
#
#  Abs:  Start autosave
#
#  Name: start_restore.cmd.soft
#
#  Rem:  The following environment variabloes must be
#        defined upon entry to this script:
#
#         TOP      - IOC Application path
#         IOC      - IOC name               ex) sioc-li20-ky01
#         IOC_DATA - IOC Data path
#
#       The autosave restore PV list is generated from the database
#       info field and the PV list is written to the standard filenames:
#         info_settings.req
#         info_positions.req
#       These files can be found in in the directory defined
#       in init_restore.soft.cmd 
#
#       Upon existing this script the directory will be set to
#       the IOC Application TOP.
#
#
#  Side: load this script after iocInit
#
#       "In the lore that has built up around autosave, 
#        PV's that should be restored only before record
#        initialization have been termed "positions".
#        All other PV's have been termed "settings".
#
#        Thus, you might run across a file called
#        'auto_positions.req', and now you'll know that 
#        the parameters in this file are intended to be 
#        restored only during autosave's pass-0."
#           - from autosave documentation
#
#  Facility:  SLAC Magnet Controls
#
#  Auth: 21-Aug-2014, Kristi Luchini  (LUCHINI)
#  Rev:  dd-mmm-yyyy, Reviewer's Name (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        28-Aug-2019, K. Luchini      (LUCHINI):
#          rename from start_restore.soft.cmd to
#          start_restore.cmd.soft
#
#==============================================================
#
# Wait before building autosave files
epicsThreadSleep(1)

# Generate the autosave PV list
# Note we need change directory to 
# where we are saving the restore 
# request file.
cd("${IOC_DATA}/${IOC}/autosave-req")
makeAutosaveFiles()

# Start the save_restore task 
# save changes on change, but no faster
# than every 5 seconds.
# Note: the last arg cannot be set to 0
create_monitor_set("info_positions.req", 5 )
create_monitor_set("info_settings.req" , 5 )

# change directory to TOP of application
cd("${TOP}")
pwd()

# End of script
