AutoSaveRestore
From CID
Contents |
AutoSave, Auto Restore, Manual Restore of IOC Setpoint PV's
Current Version
Each IOC can have a file in the '/home/control/autosave' directory which lists PV's to get an hourly snapshot. These files are named 'IOCNAME.pvlist'. The files generated from these pvlist files are named WEEKDAY/IOCNAME.HH.settings', where WEEKDAY is the three-letter representation of the day of the week, IOCNAME corresponds to the IOCNAME part of the pvlist file, and HH is the hour (00-23) when the snapshot was taken.
An application, pvMonitor2, monitors for changes to a list of PV's specified in a configuration file (currently test.config, put eventually the name should be PV.config) and runs commands based on the change in PV value. The most common use of this is to list a PV named IOCNAME:Init, and watch for this PV to change to a value of '1'. When this occurs, the pvMonitor2 software runs the following sequence of commands: IOCNAME:Init is set to 0. "/home/control/bin/IOCrestore IOCNAME" is run.
The IOCrestore process finds the most recent 'good' save of process variables, and resets the PV's to the values found in the settings file.
Restoring an explicit .settings file: restoring an explicit file (or list of files) may be done by running IOCrestore file1.settings file2.settings file3.settings .... and all the named files will be reloaded.
Format of .pvlist and .settings files The pvlist files can have comments; all lines starting with '#' are ignored. If a PV is listed with the keyword 'norestore', this keyword is copied to any generated .settings files. The .settings files look like a pvlist file, but each line has an additional entry, which is the value of the PV. When restoring, any PV line with the keyword 'norestore' is not reset.
Next Revision
Each accelerator and services IOC can have a file in the '/home/control/autosave' directory which lists PV's to get an hourly snapshot. These files are named 'IOCNAME.pvlist'. The files generated from these pvlist files are named WEEKDAY/IOCNAME.HH.settings', where WEEKDAY is the three-letter representation of the day of the week, IOCNAME corresponds to the IOCNAME part of the pvlist file, and HH is the hour (00-23) when the snapshot was taken.
For beamline related save/restore files should be stored in the associated beamline administrative account. e.g., ~hxma/autosave; ~sgm/autosave
The save and restore files will be reconfigured to use the following structure:
- Beamline file that include each IOC
- IOC file that include each VME Crate, PLC etc.
- VME Crate or PLC file containing itâ??s own pvlist.
pvMonitor2
An application, pvMonitor2, monitors for changes to a list of PV's specified in a configuration file (currently test.config, put eventually the name should be PV.config) and runs commands based on the change in PV value. The most common use of this is to list a PV named IOCNAME:Init, and watch for this PV to change to a value of '1'. When this occurs, the pvMonitor2 software runs the following sequence of commands: IOCNAME:Init is set to 0. "/home/control/bin/IOCrestore IOCNAME" is run.
IOCrestore
The IOCrestore process finds the most recent 'good' save of process variables, and resets the PV's to the values found in the settings file.
Restoring an explicit .settings file: restoring an explicit file (or list of files) may be done by running IOCrestore file1.settings file2.settings file3.settings .... and all the named files will be reloaded.
clsSave
The clsSave program is used to save pv values from a .pvlist file and restore pv values from a .settings file.
Usage
clsSave [-r -d] file1 file2
-r restore -d print debug information
If the -r option is given and if 1 file is given, the file extension must be ".settings". If 2 files are given then the first file is ignored and the second file must have the ".settings" file extension. This is for backwards compatability for older versions where both files were required.
clsSave -r file.settings clsSave -r file.pvlist file.settings
If the -r option is not given and a single file is given, this file must have a file extension of ".pvlist", and the resulting save will go to STDOUT. If two files are given, the first again must have a ".pvlist" extension and the second a ".settings" extension. This second file will be used to save the data.
clsSave file.pvlist clsSave file.pvlist file.settings
Format of .pvlist and .settings files
There are 5 different save/restore command types. This shows how a line will look in each file.
Save/Restore Commands
- pvName
- This is the same as the previous version of clsSave. A single pvName is given with format options following
.pvlist pvName (format) .settings pvName (format) value
- $overwrite
- The value of pv1 will be stored during a save to be restored into pv2
.pvlist $overwrite pv1 pv2 (format) .settings $overwrite pv1 pv2 (format) value
- If a connection to pv2 can not be made during a save, the save will still be considered valid but a warning comment will appear in the saved file. During a restore if a connection to pv2 still can not be made the restore for this pv will fail.
.pvlist $overwrite pv1 pv2 .settings $overwrite pv1 pv2 value #***Warning pvName could not connect***
- $return
- Used to restore the current date and time to a pv
.pvlist $return pvName $year $return pvName $month $return pvName $day $return pvName $hour $return pvName $min .settings $return pvName $year $return pvName $month $return pvName $day $return pvName $hour $return pvName $min
- $year causes the current year i.e. 2006 to be restored
- $month causes the current month to be restored (01->12)
- $day causes the current day of the month to be restored (01->31)
- $hour causes the current hour of the day to be restored (00->23)
- $min causes the current minute of the hour to be restored (00->59)
- $month causes the current month to be restored (01->12)
- NOTE: there are no formatting options fr this command
- $write
- Used to write a specified value during restoration
.pvlist $write pvName (format) (format) value .settings $write pvName (format) (format) value
- $run
- This command give the ability to run a user written script or program during restore process. Notice that each pv can have its own (format). With this command you can also pass static values by placing "$" before the value. i.e. $4 will pass "4" and $Hello will pass "Hello" to the script.
.pvlist $run function(pv1 (format), pv2 (format), $val) .settings $run function(pv1 (format) value, pv2 (format) value, $val)
- NOTE: It is recommended that a full file path be used to indicate the location of the script to prevent accidental execution of system programs or any other unintended applications.
- $include
- The $include command allows for nesting of pvlist files. This way a .pvlist file can be created to contain other .pvlist files.
.pvlist $include file.pvlist .settings #$include file.pvlist pvName value #end $include file.pvlist
- NOTE: It is recommended that a full file path be used to indicate the location of the pvlist files.
Comments
Comments begin with a '#'. Everything after a line after the # will be considered part of the comment. Comments will be copied to the saved file. They can appear as a line on its own, or after any restore command. Comments after or within $run command will be ignored and will not be copied to the saved file. All other comments will be copied to the saved .settings file.
.pvlist #Comments in file.pvlist pvName #Comment after a restore command $run programName(pv1 #comment, $10) #comment after $run command .settings #Comments in file.pvlist pvName value #Comment after a restore command $run programName(pv1 value, $10)
Format
There are several special keywords that can be used to specify formatting options for pv's. Be carefull with the format options, trying to restore an incorect data type to a pv may cause a CA error and the restore for that pv will fail.
- prec || precision
- Used to specify the precision of the value to be saved. will be saved to 'prec' decimal places.
.pvlist pvName prec=X .settings pvName value
- Note: precision is ignored with strings and integers
- string
- Used to specify a string type of pv. If the keyword string is used the value saved will be within quotes i.e. "23" or "On"
.pvlist pvName string .settings pvName string "value"
- int || integer
- Used to specify a value of type integer.
.pvlist pvName int .settings pvName int value
- real || double
- Used to specify a value of type double. This is the default case. The keyword will not be copied to the .settings file.
.pvlist pvName real .settings pvName value
Additional Keywords
- norestore
- The norestore keyword in a .pvlist file indicates that the value should be saved but should not be restored. This keyword will also appear in a .settings file if an error occurred during the save and a valid restore can not be done.
pvName norestore
- unknown
- This keyword indicates that a connection the the specified pv could not be made and therefore can not be restored and should only appear in the .settings file.
.pvlist pvName .settings pvName unknown norestore
Error Handling
When conflicting format keywords are found the first one is used, any subsequent keyword will be ignored and added to a comment at the end of the line.
.pvlist pvName string int .settings pvName string "value" #Rejected tokens: int
Any line within a pvlist file that can not be parsed will appear in the .settings file as a comment. In the following example the line can not be parsed due to incorrect numberof arguments.
.pvlist $overwrite pv1 .settings #Parse Error: $overwrite pv1