How to Automate Wonderware InTouch Alarm Printing

Tech Note: ISS-TN068
Published Date: July 30, 2008
Primary Product: InTouch HMI
Revision Date:

Applies to

  • Wonderware InTouch Alarm Subsystem
  • Wonderware Alarm Printer Utility
  • Wonderware PacWest AutoPrint Utility

Summary

The Wonderware Alarm Printer Utility can be used for the printing of alarms and events from your InTouch application. The utility was primarily designed for dot-matrix type printers, and with default settings may not work properly with laser or networked printers. It is common practice to configure the Wonderware Alarm Printer Utility to log the alarms and events to a CSV file to cut down on the information printed, and easier reporting capabilities. However, to print a hard copy the user must print the information from a CSV editor like MS Excel.

This document will list the procedures necessary to log your alarms and events to a CSV file, and then print the file to your default printer at a desired time interval automatically using Wonderware PacWest AutoPrint Utility.

Part 1 – Configuring the Wonderware Alarm Printer Utility

1. To launch the Wonderware Alarm Printer utility open Wonderware InTouch WindowMaker, expand Applications from the application explorer (left-hand pane), right-click on Alarm Printer and select Run. The Alarm Printer window will open.

2. When the Alarm Printer window opens select Configure from the menu.

3. The first tab of the Configuration Settings window is the Query tab. Here, similar to configuring an alarm display query, we can specify parameters that must be met for the alarms/events to be logged such as priority or even a specific alarm group (for instance $System).

Note: If you are using the Wonderware InTouch Hot Backup Manager for centralized alarming and alarm provider redundancy, then, similar to an alarm display, you can enter the name of your hot backup pair in the Alarm Query: section.

4. In the Message tab we can modify the columns displayed in the file printout as well as date/time stamp format. Configure the columns and time stamps as you please and select File Logging tab.

5. Within the File Logging tab check the Enable Alarm File Logging checkbox (otherwise the alarm log file will NOT be created). Next specify the directory to which the alarm files will be created, the desired time span of the alarm file, how long the alarm file will be kept, the desired extension of the file, and the Field Separator Character.

NOTE:

  • Because the directory to the alarm logs is not encapsulated within double-quotes in the batch file it is recommended that you utilize a directory without spaces for file logging, or modify the batch file accordingly.
  • Make sure you specify 0 as the Starting at Hour field otherwise any alarms generated before X am/pm will not be logged to the file, where X is the number configured in this field.

6. In the Printing tab select None if you are using this procedure for automated printing of a file. Otherwise you will have the default alarm information being printed as well as your alarm file. Click Apply and then OK.

7. To save the configuration for future instances or for quicker configuration applicability should the system be restarted select File->Save As.

Note: It is recommended to save the configuration here since the Wonderware Alarm Printer utility cannot be configured to run as a service.

8. When the Save As window appears, select your desired directory, give the file a name, and finish by selecting the Save button.

9. When the configuration is complete you can click on the green ! button to execute the Alarm Printer query.

10. You will know that the query is running successfully if the Alarm Printer utility looks similar to the following. Specifically referencing the green highlight in theAlarm Log File: section.

11. Next create a Wonderware InTouch application On Startup script to verify that the Alarm Printer utility is running the query during runtime. Within Wonderware InTouch WindowMaker right-click on Scripts->Application, and select Open.

12. Enter a script similar to the following to start the alarm query as soon as the application is launched into runtime.

Note: If utilizing this document for one alarm printer query and one alarm log file, then you can use 0‘s as all parameters of the APUStartQuery() function.

13. Upon validating the script you will be asked to define the tagname called APUInstance. Select the OK button.

14. Create the tag as a memory integer with an initial value of zero.

Note: Multiple instances of the Alarm Printer Utility can be running at any given time. The initial value here will represent the instance of the alarm printer utility. If you are only using one instance (for the purpose of this Tech Note for example), then the initial value will be 0. If you already have one instance of the utility running for another purpose, then the initial value here will be 1 and so on.

15. When finished switch the script editor from On Startup to On Shutdown. Enter a script similar to the following.

Note: For more information about the APU functions, with examples, navigate to the link provided in the References section, or go to the InTouch Reference Guide (Wonderware InTouch 9.5) or InTouch Alarms and Events Guide (Wonderware InTouch 10).

Part 2 – Installing the Wonderware PacWest AutoPrint Utility

1. The Wonderware PacWest AutoPrint utility is a command-line software that invisibly prints a file passed as an input parameter. This utility can be used from within an InTouch script, an Application Server script, a Historian (InSQL) Event, or directly from the Command Prompt. To install the Wonderware PacWest AutoPrint utility simply navigate to the site pasted below, and then click on the Wonderware PacWest AutoPrint – Automatic Excel Report Printing Tool link.

2. When the File Download window appears you can either select Save to save a copy of the self-extracting file to your hard drive, or Run to launch the installation immediately. For the purpose of this document the Run option is selected.

3. If you are prompted with an Open File Security Warning window, simply select the Run button to proceed.

4. The first of five steps for the installation process is an informational screen. Click Next “ to continue.

5. The next step is to specify the directory to where the utility will be installed. For the purpose of this document the default installation path was accepted. Click Next >.

6. You can alter the Start Menu folder to which a text file and uninstall package will be located. For the purpose of this document the default folder name and location was accepted.

7. The final step before the utility will be installed is another informational window. To install the utility select the Install button.

8. When the installation completes a new window will appear letting you know that the installation has been completed successfully. Click Finish.

9. Now we need to copy the “AutoPrnt.exe file to the System32 folder. This is because the Command Prompt shell needs to recognize the autoprnt command, and the System32 folder is a part of the Windows Environment Variable Path. Navigate to the installation directory of the Wonderware PacWest Auto Print utility, right-click on the AutoPrnt.exe file, and select Copy.

10. Navigate to the C:\WINDOWS\system32 folder, right-click in a blank area of the window, and select Paste.

Part 3 – Creating a batch file to print the alarm files

1. To automate the printing of our alarms we need to create a batch file that Wonderware InTouch can call on to print the alarm file generated by the Alarm Printer utility. Navigate to a directory where you want the batch file to reside. Select File→New→Text Document.

2. Name the batch file as you please, and proceed by double-clicking on it to open it in a text editor like Notepad.

3. Enter the contents of the file. When finished, save and close the file.

Note: The example below is available for copying in Part 5 – Batch File Example of this tech note.

4. Right-click on the newly created script file, and select Properties.

5. In the first editable text field change the file extension from .txt to .bat. This will change the text file into a batch file. When finished click the OK button.

6. A prompt will appear letting you know that changing the extension of a file may cause the file to become unusable. Select Yes.

7. To verify that the change was successful you can simply observe the file’s icon, as displayed below.

Part 4 – Calling the batch file from a Microsoft Scheduled Task or a Wonderware InTouch Script
Method 1 – Microsoft Scheduled Task

1. First open the Control Panel, and then double-click on Scheduled Tasks.

2. This will open the Scheduled Tasks window. To create the scheduled task double-click on Add Scheduled Task. This will start Scheduled Task Wizard.

3. The first wizard window is informational. Click Next to continue.

4. Next select the program that you want to run at a scheduled interval. Click on the Browse button to locate the batch file.

5. Locate the batch file, select it and click on the Open button.

6. The next step is to give the scheduled task a name. Name the task as you please, and select your desired interval for alarm printing. Click Next >.

7. The next step will vary based upon the Perform this task: option selected from the last step. In our example the Daily option was selected. When finished select theNext > button to proceed.

8. Next apply the user credentials that will be used to run the task. Enter the information as needed and continue by selecting Next.

9. In the final step you can select the Open advanced properties for this task when I click Finish checkbox to apply even more detailed task properties (e.g. stopping the task if it runs for to long of a time frame, only run the task if the system is idle, etc). Click Finish to complete the setup.

Method 2 – Wonderware InTouch Script

1. To call the batch file from InTouch first create an InTouch QuickScript that will call the batch file based upon criteria we define. In the Wonderware InTouch WindowMaker, expand Scripts, right-click on Condition and select New…. The Condition Scripts window will open.

Note: For the purpose of this document a condition script will be created to print the alarm file at 11:30pm every day.

2. For the condition script enter $Hour == 23 AND $Minute == 30 meaning that both the system time hour and minute must be equal to 23:30 (11:30pm) for the script to execute. Then utilize the StartApp function to call the newly created batch file.

Notes:
– The text in red needs to be changed to the alarm log directory (e.g. FilePath=C:\AlarmInfo);
– The text in blue represents the Starting at Hour field within the alarm printer utility configuration; if “0” was defined, then no changes need to be made to the blue text.

@echo off
REM Remove the “off” statement from the preceding line
REM for troubleshooting purposes
title Custom AutoPrint Script
color 0a
REM
REM This command will assign the alarm log directory
REM to a variable called “FilePath”
REM
REM This command will tell the batch file where the alarm log files reside
REM NOTE: replace the text in red with the directory of the alarm log files
set FilePath=DirectoryWhereTheAlarmLogFilesReside
REM
REM The following command will assign the result of the
REM “date /t” command to a variable called “stuff”
for /F “delims=,” %%x in (‘date/t’) do set stuff=%%x
REM Setting variables “A”, “B”, and “C”
REM Assigning 2-digit year to variable “A”
set A=%stuff:~12,2%
REM Assigning 2-digit month to variable “B”
set B=%stuff:~4,2%
REM Assigning 2-digit day to variable “C”
set C=%stuff:~7,2%
REM Launching the “AutoPrint” (autoprnt) command
autoprnt %FilePath%\%A%%B%%C%00.CSV
REM
cls
echo AutoPrint is Complete
REM For troubleshooting purposes remove the “REM” statement
REM from the proceeding line (for “pause”)
REM pause
REM
exit


All Industrial Software Solutions Tech Notes are provided "as is" without warranty of any kind.