Tech Note 663 HMI Reports: Creating Alarm Database (WWALMDB) Reports All Tech Notes, Tech Alerts and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information. Topic#: 002427 Created: October 2009 Introduction This Tech Note explains configuring HMI Reports to easily connect to and create reports against the Wonderware Alarm Database (WWAlmdb). Recommendations The following recommendations ensure the best results: Use Consolidated Mode for your Alarm Database (wwalmdb). Create a new SQL View and DSN Connection for the Alarm Database (wwalmdb) reporting. Application Versions HMI Reports Microsoft SQL Server 2008 Creating the SQL View and the DSN Connection Before you can generate the reports, you must create a SQL View and a DSN (Data Source Name) connection. To create a new SQL View Create a new SQL View for your Alarm Database reports. You will connect to and create reports using this new View. 1. Open SQL Management Studio and click New Query. FIGURE 1: NEW SQL QUERY 2. Copy the following SQL Query and paste it into the query editor, 3. Click Execute (above the active query tab) to run it. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 1/13
The query creates a new SQL View in the Alarm Database. In this example, the View is called v_hmireportsalarms. USE [WWALMDB] GO /****** Object: View [dbo].[v_hmireportsalarms] Script Date:09/15/09 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE VIEW [dbo].[qv_hmireportsalarms] AS SELECT dbo.alarmconsolidated.alarmid, dbo.alarmmaster.tagname, dbo.alarmconsolidated.alarmtime, CASE WHEN dbo.alarmconsolidated.returntime = '9999-12-12 23:59:59.997' THEN NULL WHEN dbo.alarmconsolidated.returntime = '1900-01 -01 00:00:00.000' THEN NULL ELSE dbo.alarmconsolidated.returntime END AS ReturnTime, dbo.alarmmaster.groupname, dbo.alarmconsolidated.priority, CASE WHEN dbo.alarmconsolidated.acktime = '9999-12-12 23:59:59.997' THEN NULL WHEN dbo.alarmconsolidated.acktime = '1900-01-01 00:00:00.000' THEN NULL ELSE dbo.alarmconsolidated.acktime END AS AckTime FROM dbo.alarmmaster INNER JOIN dbo.alarmconsolidated ON dbo.alarmmaster.alarmid = dbo.alarmconsolidated.alarmid WHERE (dbo.alarmconsolidated.alarmtime > DATEADD(dd, - 90, GETDATE())) AND (dbo.alarmconsolidated.returntime < DATEADD(mi, ABS(dbo.AlarmConsolidated.AlarmTimeZoneOffset), GETDATE())) When the view is created, you see the Command completed successfully message (Figure 2 below). https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 2/13
FIGURE 2: CREATE VIEW QUERY SUCCESSFUL You can then see your new View in the list of WWALMDB Views: FIGURE 3: NEW VIEW IN WWALMDB To create an ODBC DSN https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 3/13
For this Tech Note, we will create a System DSN; however, you can create a User, System or File DSN for this purpose. 1. Click Start > Control Panel > Administrative Tools > Data Sources (ODBC). 2. Click the System DSN tab, then click Add to create a new Data Source. 3. Select the SQL Native Client driver, then click Finish (Figure 4 below). FIGURE 4: CREATE A SYSTEM DSN 4. Name your DSN and select your server. The description is optional (Figure 5 below). FIGURE 5: CREATE A NAME AND SERVER CONNECTION 5. Click Next and use SQL Server authentication. Type your Login ID and Password. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 4/13
FIGURE 6: LOGIN ID AND STRONG PASSWORD 6. Click Next. Note: It is highly recommended you replace the defaults with strong Login ID and Passwords. Consult your system administrator for their direction. 7. Click the Change the default database to option and choose WWAlmdb from the list. If necessary, click the ANSI options shown in Figure 7 (below). FIGURE 7: DEFAULT DATABASE IS WWALMDB 8. Click Next, then Finish. 9. Click Test Data Source to make sure the connection was configured correctly (Figure 8 below). 10. When the test completes successfully, click OK to close the dialog. If the test completes unsuccessfully, repeat the previous steps and recheck your settings for correctness. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 5/13
FIGURE 8: TEST THE DATA SOURCE CONNECTION Configure the Driver Definition for the Alarm Database Now that you've created a DSN, you can configure the Alarm Database Driver Definition. 1. Open HMI Reports Studio and select Logger/Driver Configuration from the main menu. 2. Type a Source Name in the Source Definition area. This can be any name. 3. To define the Alarm Database Driver, select ODBC History Access from the History Driver list. FIGURE 9: DEFINE THE DATA SOURCE 4. Click the Configure button to the right of the History Driver field. The Database Definition window appears. 5. Select the DSN you created from the DSN File list and type the User Name and strong Password (SQL). 6. In the Select database type area, select Column-Item structure from the list. 7. Click the Connect button to make sure the connection is successful. The Alarm History Data and Item History Data fields are populated automatically. 8. Highlight the new view Qv_HMIReportsAlarms, in the Alarm History Data area. 9. Configure the Table Fields for Alarm ID, Alarm Text, Alarm Priority, Start Time, Ack Time and End Time from their lists. 10. Click Done when you finish. Your database definition should look similar Figure 10 (below). https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 6/13
FIGURE 10: DATABASE DEFINITION WINDOW 11. Click the Add Definition button. The new Definition appears in the Source Name column (Figure below). https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 7/13
FIGURE 11: NEW SOURCE DEFINITION Note: Be sure to click the Add Definition button after configuring your Source Definition or the definition will not be saved. Now you are ready to connect to Alarm Database Data for use in your reports. Create a Simple Alarm Database Report In this section we will create two different types of Alarm Reports. One using the Free SQL Query Table and One using the Alarm Table. In HMI Reports Report Design Studio 1. Create a Free SQL Query Table and run a query against the View you just created. 2. Create a Report (default settings are ok). 3. Add the Free SQL Table to the report and configure it as shown in Figure 12 (below): https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 8/13
FIGURE 12: FREE SQL QUERY TABLE REPORT Note: You will need to include the user name and password with the DSN as shown above when using SQL Server authentication in your DSN. The user interface for the Free SQL Query Table will be slightly modified to include a separate box for user ID and password in a future release. 4. Click Appearance to configure column names and sorting preferences. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 9/13
FIGURE 13: CONFIGURE APPEARANCE OPTIONS 5. Figure 14 (below) shows the data returned using the Free SQL Query Table. FIGURE 14: FREE SQL QUERY TABLE RESULTS 6. To configure an Alarm Table, add the object to the report canvas and configure it to Get Data From an External History Server and make sure to Define Time Period as appropriate. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 10/13
FIGURE 15: ADD AND CONFIGURE THE ALARM OBJECT 7. Click Edit List button to configure the priority filter. 8. Define a Filter by naming your filter, choosing the Source, and specifying the Priority From and To selections. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 11/13
FIGURE 16: CONFIGURE ALARM FILTER OPTIONS 9. Click Add Filter to add it, then OK to close the Alarm Filter Manager window. Figure 17 (below) shows a sample of data returned in this report using the Alarm Table. FIGURE 17: SAMPLE REPORT USING THE ALARM TABLE Additional Resources Tech Note 601: HMI Reports: Creating a Historian (InSQL) Driver Configuration Tech Note 620: Preventing Column Misalignment with HMI Reports Generated by Free SQL Table Click the following icon to view this file in.pdf format: A. Rantos Tech Notes are published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc., 26561 Rancho Parkway South, Lake Forest, CA 92630. There is also technical information on our software products at Wonderware Technical Support. For technical support questions, send an e-mail to support@wonderware.com. Back to top https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 12/13
2013 Invensys Systems, Inc. All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording, broadcasting, or by anyinformation storage and retrieval system, without permission in writing from Invensys Systems, Inc. Terms of Use. https://wdnresource.wonderware.com/support/kbcd/html/1/t002427.htm 13/13