Re: [foxboro] printscreen script

  • From: Brian Bates <batesb@xxxxxxxxxxx>
  • To: foxboro@xxxxxxxxxxxxx
  • Date: Tue, 28 Aug 2007 16:17:55 -0400

Joseph

Here are two options. The first one uses treeware, the second one is
software.

The first script (disp2psc.sh) prefs up displays onto a local DM (modify
DMNAME to suit), then prints them to your IA printer.
Because  our printer takes almost a minute to print, there is a 60 second
wait between displays.

The second script (disp2gif.sh) prefs up displays to a local DM, creates a
raster dump in .xwd format, then converts the .xwd file into .gif files on
your HDD.
You will need to create the xwd and gif directories, and modify the DMNAME
This approach is fast, but you need "convert", a great program from
www.imagemagic.org.


      Regards, Brian Bates.

disp2psc.sh

#!/bin/sh
# This script will open all of the displays in a directory.
SOURCE_DIR=/usr/dispdir
FILE_FILTER=*
TEMP_FILE=/var/tmp/disp_list.txt
PREF=/usr/local/pref
# DMNAME is the DM that the displays will be forced up on.
DMNAME=DM0001
rm $TEMP_FILE
cd $SOURCE_DIR
ls $FILE_FILTER >$TEMP_FILE
for x in `cat $TEMP_FILE`
do
$PREF -$DMNAME dmcmd $SOURCE_DIR/$x
# Wait for display to connect to make connections.
sleep 3
$PREF -$DMNAME DMCMD "dmcmd psc"
# Wait for printer, adjust to suit.
sleep 60
done

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
disp2gif.sh

#!/bin/sh
# This script forces all the displays in a directory up on a DM, captures
the image in a raster dump, then it converts the xwd file to a gif.

SOURCE_DIR=/usr/dispdir
PREF=/usr/local/pref
DMNAME=DM0001
XWD=/usr/xwd
GIF=/usr/gif
CONVERT=/opt/windu/bin/convert

for x in `ls $SOURCE_DIR`
do
echo $x
$PREF -$DMNANE dmcmd $SOURCE_DIR/$x
sleep 3
$XWD -display localhost:0 -root -out $XWD/$x.xwd
$CONVERT $XWD/$x.xwd $GIF/$x.gif
done





                                                                           
             "Joseph M.                                                    
             Riccardi"                                                     
             <joe@xxxxxxxxxxxx                                          To 
             m>                        <foxboro@xxxxxxxxxxxxx>             
             Sent by:                                                   cc 
             foxboro-bounce@fr                                             
             eelists.org                                           Subject 
                                       Re: [foxboro] printscreen script    
                                                                           
             27/08/2007 04:25                                              
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
             foxboro@freelists                                             
                   .org                                                    
                                                                           
                                                                           




Pat,

Thanks for the script.  Sorry I did not mention that I am working on a UNIX
box using DMs.  We are just starting the evolution to Windows; thus the
need
for all of the printscreens to redraw in FoxDraw.

I did make a feeble attempt to UNIXize your 1st script (i.e., deleted the
.fdf reference, etc.) but failed miserably.  1st, it did not even create
the
FILE file, so I created it manually (still did not work).  2nd, the pref
command is not working because the display is not getting called up, so I
entered the pwd manually (still did not work). 3rd, I gave up and am
writing
this response.  Initially, I received a 'do' error, then a "can't get glbl"
error, blah, blah, blah.

Can we start all over again with a UNIX script.  I don't have a need for
the
.pdf stuff any ways.  Sorry, but I do not know the script language very
well...

I would appreciate it.  Thanks.


Joseph M. Riccardi, Inc.
DCS Services - Industrial Process Control

Joe@xxxxxxxxxxxxx

"To give real service you must add something that cannot be bought or
measured with money; and that is sincerity and integrity." - Donald A.
Adams


-----Original Message-----
From: foxboro-bounce@xxxxxxxxxxxxx [mailto:foxboro-bounce@xxxxxxxxxxxxx] On
Behalf Of Pat Martens
Sent: Monday, August 27, 2007 2:39 PM
To: foxboro@xxxxxxxxxxxxx
Subject: Re: [foxboro] printscreen script


Joseph

Below you can find a small script which allows you to print 1 directory of
.fdf files.

I recently installed a adobe .pdf printer driver on our Foxboro terminal
server (it works on XP 7.1 as well) which allows us to print all our
graphics into one (or several, or one/graphic) .pdf file. This save us a
lot
of paper!

I tried several pdf printer drivers (some of them did not work on the
terminal server) but ended up with pdf995 which has some nice features.
Also you can manipulate the corresponding .ini file for this driver so it
allows me to set destination path and filename options for the created .pdf
from a script. See below for an example.


First the simple script. Should work with any installed printer.

Change directory to where your .fdf files are and run this script


#!/bin/sh

echo "Make sure FoxView is in fullview!"
echo "Minimise this window!"

sleep 5

for FILE in `ls *.fdf`
#for FILE in `ls u221_[0][0][0-1]T.fdf`
#for FILE in `ls u309_000.fdf`
do
             echo "/usr/local/pref -$DMNAME dmcmd `pwd`/$FILE"
             # call up the display
             /usr/local/pref -$DMNAME dmcmd `pwd`/$FILE
             # allow some display call-up time
             sleep 5
             # print the display
             /usr/local/pref -$DMNAME dmcmd psc
             # allow some time for the printer to print
             # if you print to fast, the /var partition might
             # fill with printer spool files!
             sleep 22
done


Now the script which requires a windows box and pdf995 driver installed.
You could pass a display manager name as a parameter so the actual call-up
of displays will take place on a remote screen (or if you start it from a
remote terminal, call them on the local screen). In any case, make sure the
corresponding display manager is maximised and not overlapped with other
windows!
You will most likely need to adapt the script as it is based on our display
naming conventions. The problem I had with this is that the printer spooler
only gives the first 4 characters of the filename so I had to find a way to
make sure unique files were printed if each graphic was printed to a
separate .pdf file.


#!/bin/sh

TMP_DIR=/opt/trn/tools/tmp/PrintAllMimics
PDFINIT=c:/pdf995/res/pdf995.ini
PDFDIR=\printouts
PDFDIRUNIX=/printouts


pdf995_init()
{
echo "[Parameters]" > $PDFINIT
echo "Quiet=0" >> $PDFINIT
echo "Install=1" >> $PDFINIT
echo "Use GPL Ghostcript=1" >> $PDFINIT
echo "Output File=SAMEASDOCUMENT" >> $PDFINIT
echo "Output Folder=D:\\$PDFDIR\\$UNIT" >> $PDFINIT
echo "Size=a4       8.3   11.7" >> $PDFINIT
echo "Autolaunch=0" >> $PDFINIT
echo "Stationery File=Stationery" >> $PDFINIT
}

echo "Make sure FoxView is in fullview!"
sleep 2

# check for specified DMNAME
if [ $# -lt 1 ]
then
             DM=$DMNAME
else
             DM=$1
fi

# For all .fdf files in this directory
for FILE in `ls *.fdf`
#for FILE in `ls u221_[0][0][0-1]T.fdf`
#for FILE in `ls u309_000.fdf`
do
             # remove the unit number prefix from the filename
             MIMICNR=`basename $FILE | cut -f2 -d'_'`
             MIMIC=`basename $FILE`
             # get the u309 prefix from the filename
             UNIT=`basename $FILE | cut -f1 -d'_'`
             # create a subdirectory per unit
             if [ ! -d /$TMP_DIR/$UNIT ]
             then
                         mkdir -p $TMP_DIR/$UNIT
             fi
             if [ ! -d $PDFDIRUNIX/$UNIT ]
             then
                         mkdir -p $PDFDIRUNIX/$UNIT
             fi
             # copy the u309_000.fdf file the a temp directory.
             # put it in subdir u309 and call it 000.fdf
             cp $MIMIC $TMP_DIR/$UNIT/$MIMICNR
             echo "/usr/local/pref -$DM dmcmd $TMP_DIR/$UNIT/$MIMICNR"
             /usr/local/pref -$DM dmcmd $TMP_DIR/$UNIT/$MIMICNR
             # set the ini parameters for the pdf995 driver
             pdf995_init
             sleep 5
             /usr/local/pref -$DM dmcmd psc
             # printer spooler needs to be empty before next graphic
             # is printer else pdf995_init will not work correctly
             # (it would use settings for the previous graphic)
             sleep 5
done



Kind regards,
Patrick Martens
Total Raff. Ned. N.V.


-----Original Message-----
From: foxboro-bounce@xxxxxxxxxxxxx [mailto:foxboro-bounce@xxxxxxxxxxxxx] On
Behalf Of Joseph M. Riccardi
Sent: maandag 27 augustus 2007 19:49
To: foxboro@xxxxxxxxxxxxx
Subject: [foxboro] printscreen script

Folks,
I need printscreens of all displays in the entire plant for documentation
(/usr/disp/*/*).  I searched the archives and found the command to call up
a
single display and the printscreen command (/usr/local/pref -DMNAME DMCMD
"dmcmd psc").  Anybody out there already have a script to do it for an
entire directory and/or subdirectories of displays?  I would guess the
script should also include some sort of sleep time inserted between display
call ups; no?

I would appreciate the help.

Thanks.

Joseph M. Riccardi, Inc.
DCS Services - Industrial Process Control

Joe@xxxxxxxxxxxxx

"To give real service you must add something that cannot be bought or
measured with money; and that is sincerity and integrity." - Donald A.
Adams






_____________________________________________________________________



------------------------------------------------------------------------------

Confidentiality Message
This e-mail message is confidential and is intended for the exclusive use
of the addressee. Any other person is strictly prohibited from disclosing,
distributing or reproducing it. If the addressee cannot be reached or is
unknown to you, please inform the sender by return e-mail immediately and
delete this e-mail message and destroy all copies. Thank you.

 
 
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
 
foxboro mailing list:             //www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 

Other related posts: