Thursday, May 12, 2016

Automatically Generate Screenshots of Foxboro I/A Graphics

At work we have a Foxboro I/A control system. I was getting a lot of requests to take screenshots of control system graphics - which I don't mind fulfilling, because usually someone wants to make something better.

I wanted a better way to fulfill these requests! Something that can do everything at once.

I found an old post on the "Foxboro Freelist", a user-run mailing list for Foxboro system maintainers. Back in November I posted an improved version, but I have improved it again since (continue reading).
for DISP in $(find /opt/graphics/disp/ /opt/graphics/control/ /opt/graphics/trend/ /opt/graphics/loadout/disp/ /opt/graphics/powerhouse/ -name "*.fdf")
cd d:
pref -SPR1SR dmcmd /opt/graphics/disp/BLANKSCRN.fdf
sleep 2
echo $DISP
pref -SPR1SR dmcmd $DISP
sleep 5
cd 'C:/Program Files (x86)/HyperSnap 6'
echo $PWD
FILE=$(echo `date +%Y-%m-%d`$DISP | sed 's/\//-/g')
echo $FILE
echo $SAV
HprSnap6 -snap:awin -save:png $SAV
pref -SPR2SR dmcmd close

  • In the first FOR statement, you can specify as many graphics subfolders as you want. 
  • Replace SPR1SR with the DM (Display Manager) name of the FoxView instance you will be working on. The script calls the graphic to the DM you specify, then calls HyperSnap via its command line interface to take a screenshot. 
    • Just to be clear, the script WILL open these graphics live on your AW (application workstation) and take a screenshot. It won't happen in the background. So if you have any graphics that invoke scripts when opened or closed, exclude those folders from the FOR statement. 
    • This will tie up your AW for however long it takes to open all of your graphics. I like to run the script at the end of the day. If the screensaver comes on, it does not seem to matter. 
  • Create a blank graphic (BLANKSCRN.fdf) for the script to call in between live process graphics. 
  • The sleep commands are necessary because Foxboro users know that graphics don't load instantly - graphics need to query data from the OM (Object Manager) before they're usable. 
  • Assumes you have HyperSnap 6 installed (should ship with all AW's)
  • The output file is named with the date, folder path and filename. For example, 2016-05-12-path-to-graphic-filename.fdf.png. 
  • The echo statements are unnecessary, but it is useful to see their output for debugging. 
  • Save the above as a .ksh file and run in the Kornshell environment. 
  • If you want to generate screenshots of overlay files (popups), change this:
    • pref -SPR1SR dmcmd $DISP
    • to this:
    • pref -SPR1SR dmcmd "dmcmd ov $DISP -l MIDDLE -move"
Since coming up with this script, we generate screenshots of 200+ graphics on a monthly basis and drop them in a network folder on our Business LAN. This way, anyone who is interested can take a look at the current state of the control graphics, find errors and suggest improvements. 

Drop me a line if you find this through Google - I'd love to know if this helped you out!

Update 2016-05-27: I've put this up on Github so people can download the .ksh directly, or contribute to making it better!