5. Support for Persistent PV State

This EPICS Device module provides a mechanism for persistent PV state which is quite different from the mechanism provided by autosave/restore. If autosave/restore is used then this functionality can be ignored, and no PVs should be marked as persistent internally.

The functionality described here is defined in the header file persistence.h.

The mechanism here works by saving a single file containing the persistent state of each PV marked for persistence. Note that only epics_device PVs can be marked as persistent, and the persistence marking is performed at the time the PVs are published to the device by the IOC.

The following functions provide the persistence interface.

error__t load_persistent_state(const char *file_name, int save_interval, bool check_parse)

This should be called once after publishing all PVs to EPICS device but before calling iocInit(). The given file_name will be loaded, if present, to determine initial values for all PVs marked for persistence. After this point updates to PVs will be written back to the state file at the interval determined by save_interval, in seconds.

If check_parse is false then this function will return success even if there are parsing errors while loading the persistence file.

This function can be called from the IOC shell, but in this case the return code is lost.

error__t update_persistent_state(void)

This can be called to force the state file to be written if any persistent PVs have changed their state.

void terminate_persistent_state(void)

This can be called during IOC shutdown to force an orderly termination of the persistence state and ensure that the state file is up to date.