Clean up a big, over-grown strategy

Got a huge strategy you’ve inherited from someone else? Just want to clean up a little before you call it “done”? What methods do you use to clean out some of the deadwood to get your strategy clean, lean, and easy to maintain?

Of course, we always suggest backing up strategies, especially working ones, before making major changes, and on a regular basis in case something goes wrong: [URL=“http://www.opto22.com/site/optonews/2009/optonews_09092009.aspx#PSGTip”]BACK IT UP (Click here for more on backing up)!

Here’s one thing to look at if you suspect there may be unused variables taking up space and using extra memory:

  1. When looking at your strategy tree in PAC Control in Configure Mode, you can double-click on many parts of the strategy tree, including: Variables, I/O Units, Points and PIDs. When you double-click on one of these yellow folder icons, you will see a summary list, including how often each is referred to in the strategy.

  2. Then click on the column heading Ref Count to sort by that column, putting the possibly unused items, those with Ref Count 0, at the top.


[FYI - if this image doesn’t appear, log into My.Opto22 to see all OptoForum images]

Note: Before you start deleting all those with Ref Count zero, consider whether something else (PAC Display, a third-party HMI/SCADA like Wonderware, etc.) might be using that tag to store some data not referenced by the strategy itself.

Also remember to add lots of comments and variable descriptions as you go. While YOU may know what this chart or variable does TODAY, the next person to work on it may appreciate a clue. Also remember that next person could be you, in 22 months or 22 years!

Write on…
Mary

Here’s another reason, I just learned, why you might have a ref count of 0–even though your tag is being used in your strategy somewhere. If you have a POINTER to your tag, and that pointer is initialized in the strategy tree using that “Initialize Value” drop-down option (vs. initialized in the strategy somewhere), you’ll get a ref count of zero, even if the pointed-to tag/variable’s value is assigned or changed (indirectly) via that pointer. Ben will claim this is Yet Another Reason to avoid pointers. :eek:

I’d still disagree (why/when/where to use pointers is a whole other topic), and say “pointers are your friend” in many cases. But you might consider initializing any of those pointers you are using from within a block in your Powerup Chart so you’ll see a non-zero reference out for the thing(s) you’re pointing to.

Thoughts? Comments? Favorite reasons to use a pointer?

-OptoMary