Storing remanent memory values in a file

Is there an efficient way to locate and consolidate all remanent (retained) variables in a large project, aside from globally searching for VAR RETAIN or manually checking each .var file?

Our projects contain numerous retained variables, which become quite time consuming to restore after a cold start. My goal is to systematically identify all retained variables outside of Automation Studio, possibly using a script to scan .var files at startup. I am very open to other suggestions if there is a better way.

One approach I’m considering is deploying a Bash script in each directory to detect retained variables and periodically compare their values against the startup state, updating them as needed. This would help ensure that most retained values remain accurate after a restart.

Has anyone implemented a similar solution, or is there a more efficient way to handle this? Given some project path as an argument, here is the example code and output:

/mnt/c/.../Logical/...RunAxes/FeedHopper.var:17:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/Variables.var:14:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_P76TransferVacuum/Variables.var:9:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_TransferVacuum/Variables.var:9:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_TransferVacuum/Variables.var:23:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_UpperRoll/Variables.var:14:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_Vacuum/Variables.var:8:VAR RETAIN
/mnt/c/.../Logical/...RunAxes/FE_Vacuum/Variables.var:18:VAR RETAIN

I figure with this output, it is now just a matter of searching from the line number, then removing duplicates? Please let me know your thoughts!

Hi Garrett,

Im not sure if I understand what you want…
Do your retain variables have initial values in the .var file? and you want to update those with the current values from the CPU?

Also: What do ou mean by “duplicates”?

You could have a look at the Runtime Utility Center, and use PVI functions to read/write predifined watchlists… maybe this could be a solution for you? (Just as a hint in this direction)

2 Likes

Hi,

maybe this post goes your way?

Easy and quick way to save/restore values of permanent variables? - Ask Questions - B&R Community

1 Like