#==============================================================
#
#  Abs:  Start the autosave task (for a soft IOC)
#
#  Name: restore.cmd
#
#  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.
#
#         TOP      - IOC Application path
#         IOC      - IOC name               ex) sioc-sys1-bc01
#         IOC_DATA - IOC Data pat
#
#  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:  EED CUD Control
#
#  Auth: 08-Sep-2010, Danielle Sanzone (SANZONE) 
#  Rev:  dd-mmm-yyyy, Reviewer's Name  (USERNAME)
#--------------------------------------------------------------
#  Mod:
#        09-Oct-2019, Kristi Luchini   (LUCHINI):
#          extract from st.cmd.  If we don't want to
#          use autosave when checking out a release it's
#          easier to comment out a file in st.cmd than
#          to comment out a bunch of lines.
#
#==============================================================
#
# 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" , 30 )

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

# End of script
