citectscada reports v4 · pdf filethe intention of this training is to give all citect ......

85
CitectSCADA Reports v4.0 Technical Training European Distributor edition 2006 “The fast and correct way of getting plant data visible in a SQL2005 reporting services report” by Rien van Geffen, 19-11-2006

Upload: lamdien

Post on 06-Feb-2018

224 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

CitectSCADA Reports v4.0 Technical Training European Distributor edition 2006 “The fast and correct way

of getting plant data visible

in a SQL2005 reporting services report”

by Rien van Geffen, 19-11-2006

Page 2: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Notes: The intention of this training is to give all Citect Distributors the technical know-how to get a installation of CitectSCADA Reports up and running in the most minimal amount of time on a single standalone PC. On top of this we will only utilize the standard stored procedures of the product to query our historian database to produce some reports. When you finish this course; the aim is that you are confident to go out to the customer to do a successful installation of the product and produce some reports. Day outline: 9:30 – Arrival at the training room + word of welcome by Jan-Willem Nijman 9:45 – Presentation of CitectSCADA Reports v4 titled “a re-introduction” 10:00 – Start of hands-on training -> Installing the product 12:00 – Lunchbreak 13:00 – Start of 2nd part of hands on -> Using the product to produce SQL reports 16:00 – End of training

Page 3: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Hands on training part 1: How to install CitectSCADA Reports v4.0 The very first step into getting a working CitectSCADA Reports installation is to install the product. Please note that CitectSCADA Reports is 100% depending on the existence of SQL2005 therefore we must tune our PC to get ready for the loading of SQL2005. From now on this whole training is oriented to produce 1 single PC that runs CitectSCADA Reports + CitectSCADA together with SQL2005 and Microsoft IIS. We start with the PC; we require a Microsoft Windows XP + SP2 or WindowsServer 2003 + SP1 to run on. ( this you all have running on your laptop as was communicated in your personal training confirmation ). The supported operating system languages are English / German / French or Korean. On top of the OS language; in windows runtime we support all other languages that the logged user has set. So in theory all languages are supported! The next step down the list is checking if the required Windows components needed to run CitectSCADA Reports are installed. Microsoft Message Queuing. The PC must have Microsoft Message Queuing installed without Active Directory support. To achieve this we must open the Control Panel, go to Add or Remove Programs and Windows components and click on Add/Remove Windows Components:

Page 4: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

The following dialogue box pops up:

Make sure that the Internet Information Services (IIS) are checked and please also check Message Queuing. Once Message Queuing is checked; click on details and uncheck Active Directory Integration:

Page 5: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Once you have completed the installation of Microsoft IIS and Messages Queuing please reboot the PC. As soon as the PC is rebooted we will install the Microsoft .Net Framework 2.0 Your trainer will hand the redistributable package to you so you can install it. Again once this setup is completed; please reboot again.

( even if you already have the .Net framework installed; please re-install it using the repair option only in this way we can force it to register on your IIS installation )

Page 6: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Before we install CitectSCADA Reports we will install CitectSCADA. Please insert the CitectSCADA installation DVD and follow these settings:

Page 7: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 8: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Once CitectSCADA is installed it is key that we implement new functions to CitectSCADA in order to allow the CTAPI to be accessed to retrieve alarmdata from CitectSCADA Reports. By default this functionality is NOT existent in current version of CitectSCADA therefore a hotfix must be applied. This hotfix is a small cicode file that can be found in the HOTFIX directory of the CitectSCADA Reports DVD. Please copy the CSRFunctions.ci file into your computer’s include folder of CitectSCADA and do a full compile of your project.

For CitectSCADA versions prior to 7.00: 1) Locate the file CSRFunctions.ci in the \HOTFIX directory located on the CSR 4.0 installation disk

or ZIP file. 2) Add the file to the Include project directory for the CitectSCADA installation. The default locations are:

• Version 6.10 - C:\Documents and Settings \All Users \Application Data \Citect \CitectSCADA \User \include

• Version 6.0 - C:\program files\citect\citectSCADA\user\include • Earlier versions - C:\Citect\user\include

3)Recompile and restart CitectSCADA.

Page 9: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Hands on training part 1.1 -> Installing CitectSCADA Reports at last…. Right, as we now managed to complete prepare our machine for the loading of CitectSCADA Reports, it is time to install the product! There are 2 ways to install CitectSCADA Reports: - Install SQL2005 by hand and then install CitectSCADA Reports. or - Install CitectSCADA Reports and have CitectSCADA Reports install SQL2005 for you. Both ways of installation have the exact same end result however when you manually install SQL2005 you can add various extra options to the product. ( by installing by hand you need to acquire a SQL Server 2005 from Microsoft, the SQL2005 license that comes with CitectSCADA Reports does not cover this! ) In point 1.1.1 you can view how manual installation of SQL should be done, for what this training concerns please now skip to point 1.1.2 to follow the default installation.

Page 10: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.1.1 Manual SQL2005 server installation. If you decide to install SQL Server 2005 manually please follow the following steps as soon in the screenshots:

Page 11: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 12: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

( Remember Default instance name = your PC name ! )

Page 13: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

( any password here for the SA account will work, please do not forgot it ! )

Page 14: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 15: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.1.2 Installing SQL Sever 2005 the automated way (via the CitectSCADA Reports installer) Welcome back, I hope you did not look too much at the screendumps at point 1.1.1 because installing SQL2005 from within the CitectSCADA Reports installer is much simpler. Please insert your CitectSCADA Reports DVD and follow the following steps:

Page 16: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 17: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Make sure EVERYTHING IS SELECTED

Click Next; the localhost setting is okay.

Page 18: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Click Next

Leave the Default Instance; this is also fine

Page 19: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 20: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 21: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 22: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

When the integrated SQL2005 installer has finished, the install of CitectSCADA Reports continues automatically:

And finishes automatically:

Please reboot!

Page 23: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.2 Familiarizing yourself with SQL2005 and CitectSCADA Reports v4 By now we have successfully prepared a PC for CitectSCADA Reports installation and we have succeeded in installing CitectSCADA Reports together with SQL2005. The big feature CitectSCADA Reports v4 is that in essence the product does nothing for you! The one thing you get out of the box is software which is able to connect into multiple datasources, acquire their data real-time or on fixed events and put them in a SQL2005 table. The above fact is by far best feature ever! Because now we are all able to visualize our process information in whatever form or shape we want it to be; or in whatever form or shape we are obliged to put it in. (quite often there is a need to interchange data between the plant floor and the corporate IT, this is the best tool to do it with!) Now back to the trenches, all those SQL2005 things are about to get scary now…. Why? Because SQL2005 is substantially different in look and feel then SQL2000/MSDE. For starters the SQL Enterprise Viewer is gone….. The list goes on and on but we will now spend some time to get you re-acquainted or introduced for the first time with SQL2005.

Page 24: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.2.1 Something feels different…. Have you noticed once SQL2005 has been installed and you have rebooted that things feel different in your PC? In the old days of SQL2000/MSDE after installation you would get a fixed icon in the taskbar in Windows next to your clock. The icon allowed you to stop and start the SQL server service. It is now gone; you can only control the SQL2005 server by hand:

(screenshot of the service manager of windows) Or you can use the new SQL Server Configuration Manager:

Page 25: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.2.2 Okay I now know how to stop start the SQL2005 Server, how can I administer it? To administer your SQL2005 Server we can rely on a new tool: the SQL Server Management Studio

The first time you run the SQL Server Management Studio it will still do some configuring:

Page 26: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

The next screen show is the login window:

Please observe that the SQL Server Management Studio offers a single interface onto the multiple aspects of your SQL2005 Server:

Page 27: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Expand your databases folder, note that apart from some example databases there has not been one database created for CitectSCADA Reports. In part 2 of the training we will come back to SQL the Management Studio in order to verify if we actually are logging data in our historian and we will use it to run / verify our queries for our reports.

Page 28: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.2.3 All the “renewed” interfaces; can it get any worse? Yes….. In the new light of Microsoft’s supremacy, a decision was made to uphold all development software from Microsoft to run the same interface > Visual Studio.

Visual Studio might seem odd to come with SQL2005 Server but when you realize we will be designing reports, we are in need of a good development tool. Hence we get Microsoft Visual Studio to come with SQL 2005 Sincere apologies to give this scare; please do not be afraid of all these tools that have different names and look + feel. They will work for you! Now we go on with finalizing our installation.

Page 29: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.3 Finishing our setup and putting our software in ready-to-go mode. Right now we have installed the software and we became a bit familiar with the look and feel of SQL Server 2005. Let’s take a closer look into CitectSCADA Reports. From this point on the training will now change into a guide on how to use the new features of CitectSCADA Reports in comparison to the previous Plant2Business product. Many of you have in the past worked with Plant2Business and some of even with it’s predecessor Plant2SQL. During the technical distributor training 2003 we have paid extensive effort into training you all on Plant2Business therefore we will not repeat this training. So topics on how to use the Excel client, how to configure a task, how to run events and using Plant2Net remain untouched. We will only focus on the new and strong point of CitectSCADA Reports v4: SQL Server 2005 and related services (reporting). ( the “old” Plant2Business functionality and interfaces have not changed, everything still works as it was done in the past ) Okay now what did we get new?

It is a bit strange but another new thing is something we are missing; we have dropped the reports client. The old reports client was based on a free and limited web-runtime of Crystal Reports version 8.0 As we where unable to upgrade this engine without overcoming serious problems, the decision was made to completely remove this client and switch to SQL2005 Reporting Services. Legacy P2B customers are not left out in the cold; as Crystal Reports is able to interface to SQL2005; older reports can still be run! However by default the product is focused on Microsoft SQL Reporting Services integration and no longer on Crystal Reports. Also observe another new tool; the Historian Maintainer, we will use this in a while to create our Historian table in the SQL2005 Server.

Page 30: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.3.1 Creating the CitectSCADA Reports Configuration table. CitectSCADA Reports works always with a configuration table. This table stores the complete configuration of our product, it has a list of the datasources, all events and tasks are stored here and keeps track of users and permissions. To create this table we only have to do one thing, start the Server Manager:

If you start the Server Manager for the very first time, immediately this wizard is shown:

Page 31: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Click Next and select your local SQL Server Instance ( get from pull down list or enter the name by hand ):

Page 32: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Now chose a name for your configuration database and click next.

The wizard finishes and we now see something like this:

Congratulations you have just created your configuration table! Reconfirm using the SQL Management Studio that you now have 3 new databases in your SQL2005 server. What are the names??????

Page 33: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.3.2 Create your historian table Once we have created our configuration table we need to create our historian table and connect this table to our historian configuration in the Server Manager. To create our Historian table we need to start our Historian Maintainer:

Page 34: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Click on the “New Server” button:

Enter your correct SQL2005 server instance name or pull it down, click test & click OK

Page 35: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Click the “Create Historian Database” button:

In the next window please give your Historian table a sensible name:

Never-ever make the mistake of calling this table Historian! The use of the name Historian for the table can become very confusing further on. So remember; DO NOT call your Historian Database => Historian !!!!!!!

Page 36: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Once you have decided on a nice name; click OK and wait a while for the table to be created:

Now go to the Database tab in the Historian maintainer

Page 37: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Observe above the two small clickable extra options: Maintenance plan & User Functions Click first on the User Functions to upgrade your Historian table with nice functions (stored procedures) to query our historian table later on; After the installation of the User Functions click on the Maintenance Plan to set very specific SQL database re-indexing that will give your Historian a weekly re-index that guarantees absolute best SQL performance of your Historian table. Close the Historian Maintainer; we have just properly setup our Historian table. ( confirm again using the SQL Sever Management Studio that you now have gotten another table created in your database! )

Page 38: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1.3.3 Linking your Historian table to your CitectSCADA Reports server. So at the moment we have one CitectSCADA Reports configuration database and one Historian table that need to be linked to each other. Please re-launch the Server Manager and open the properties of the Historian:

Now make the connection to your Historian table and click OK > We are done now!

Page 39: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.0.0 Installing the example projects As I already stated before, we anticipated that you already have some Plant2Business knowledge hence we will not setup a configuration from scratch. Instead we will load to official CitectSCADA Reports examples into CitectSCADA and CitectSCADA Reports. The example project that we will be using has 3 parts: - A CitectSCADA Project - A Database for storing separate process data - A CitectSCADA Reports Project connecting into both previous mentioned items The Scada project is a modified version of the normal CitectSCADA example project. So it has the steel plant functionality but a new page has been added (Water Tower). The Water Tower page is ideal for us in terms of getting heaps of data to play with. ( there are 2 towers being filled and drained constantly by various trucks, a lot of flow and total volume data is generated ) The Database will be used to read out setpoints for the trucks in the SCADA project and there is also a 2nd table that will be used to dump process data of produced coils of steel. Our CitectSCADA Reports project sits in between the database and CitectSCADA but also links into your historian table. With 2 pre configured tasks we will download coildata into our Database and upload our setpoints from the database into SCADA. Meanwhile we log every bit of process related data in out historian. At the end of the day we should have produced 3 reports taking data out of both the Historian and the Database containing some process data. These reports (queries) will be executed via a Internet Explorer web browser that connects into your local Microsoft SQL 2005 Reports Server. Now that we know what our end goal is; we now will go and get started!

Page 40: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.0.1 Restoring the SCADA project From your trainer you will receive the “Reports_Example2.zip” file. Please restore this in CitectSCADA and run computer setup to have project setup properly. ( note; please put the Startup function as the Startup Cicode )

Before you can run the project; you need to also add some entries in your citect.ini file that can be found in your C:\Widows directory. You can do this by hand or you can use the computer setup editor:

Please make sure that in the ini file you have specified the NumFiles parameter under the [AlarmLog] section to match any value but 0! CitectSCADA defaults to 0 but for CitectSCADA Reports this value must be minimal 1 ! Also make sure that the [alarm] saveprimary data path is correct. If this entry points to a non-existent directory; you will not be able to retrieve alarms from CitectSCADA. Now run this project

Page 41: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.0.2 Restoring the BusinessDB database. By now some of you have installed the SCADA project and it is time to create a new database to store process information of the coil process. Again from your trainer you will receive a file called “BusinessDB.sql” All that is needed to done is that you double click on this file: Your SQL Sever Management Studio will open up and you are asked to log in to your SQL Server

Once you are connected please execute the query:

Page 42: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

The result should be:

Please verify in the SQL Server Management Studio that indeed a new database has been created that holds 2 tables:

Page 43: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Please view the TruckCapacity table to verify that some records with setpoints have been created:

Okay; we are all done on the database side. Continue to the next chapter

Page 44: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.0.3 Restoring the CitectSCADA Reports project The last part of the installation of the product is where we restore our CitectSCADA Reports project. For this you need the “Reports_Example.zip” file. This file can be restored only via the Backup and Restore Utility:

Please go into the Restore tab, select the zip file and point it to be restored in your CitectSCADA Reports instance:

When a message dialogue box comes up asking about and upgrade; please click ok.

Page 45: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Now have to start up our CitectSCADA Reports Server Manager again and adjust the backup to work with your setup. Go to the datasources tab and expand it:

You now need to match the properties for every datasource to the actual sources in your PC. Do this via the following screenshots:

Page 46: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 47: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Just to be safe; re-check your Historian settings again:

Also make a note that per DATASOURCE you can specify separate setting in regards to how quickly data must/can be acquired:

Page 48: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.1.1 Starting data acquisition Now that all projects are configured and put into place it is time to start our engines and get the data flow going. A final check is now needed. Please open your SQL Server Management studio and view your tags table (dbo.tags):

Do you see 62 entries? If not please contact your trainer. If you do have 62 entries; it is time to bring the complete system online in the following order on the next page.:

Page 49: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

1) Startup CitectSCADA like we setup it in chapter 2.0.1 2) Open the CitectSCADA Reports Services Control Manager:

3) Start both the Event Service and the Historian Data services 4) Sit back -> you are now logging data; please have it run unattended for at least 10 minutes ( take a coffee break )

Page 50: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.1.2 Confirming that the system is logging data. In order to confirm that you are indeed logging data from your data source in CitectSCADA Reports; we need to do some digging in the system. There are 2 ways to confirm data transfer: 1) Open the KERNEL in CitectSCADA and enter “CTAPI 1” followed by an enter. The result should be like this:

Page 51: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

And we can view our Historian to see if it is collecting data; Just view the table NumericSamples from our Historian database:

Please confirm and reconfirm that data is being stored.. Then continue to the next chapter. ( hint also open the table CoilData from the BusinessDB database. What do you see??????? )

Page 52: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.2.0 Extracting data from our (historian) database. Before we start with doing exercises; I want to put some things in perspective. From the viewpoint of the product CitectSCADA Reports; we are now done. For what CitectSCADA Reports is designed to do; it is doing now. We are putting our data in SQL Server 2005!!!!! However we do supply you the tools to extract the data and make it represent able in a proper fashion. You are getting from us the tools (stored procedures; see point 1.3.2) to query the Historian database so that from a field of sparse data; one can get fitting results back. (this refers to the Historian principle where we only log changes not the continues value of the tag if it does not change when time passes!) So the key thing here is to remember: If you can write a decent query; the sky is the limit! (tools which are query-based (Reports) can represent the outcome in every possible desired format!) Please make another note; not only SQL Reports can do magical tricks with results from queries; all other 3rd party tools that can talk to our SQL server can access our data in it’s own way….. ( Crystal Reports for example can do this also! ) We will now practice your query skills in 3 set-ups: 1) Run a stock standard query on the BusinessDB database 2) Run a standard query on the historian table where we convert the date field 3) Run a query on the historian data with Citect’s stored procedures to get statistical data We will go into the actual query making itself first of all 3 tasks before we finally switch to using our developed queries in SQL2005 Reports and publishing those reports to the IIS server and viewing the results in your Internet Explorer. This is what everyone has been waiting for: action! Go to point 2.2.1 to develop your first query.

Page 53: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.2.1 Query a standard database To develop a query not much is needed. Just some common sense and access to the SQL Server Management Studio is needed. Please open this and click on the “new query” button after you have expanded the BusinessDB database:

A blank window now opens and we can now enter our query:

But things can be much much simpler; locate the “Design query in Editor” button and push it:

Page 54: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

As you can see, we get and instant representation of the complete contents of our database. For instance our 2 tables are listed; ( CoilData and TruckCapacity ). Add the CoilData table and close the “Add table” window:

Select from top to bottom the fields “UploadTimestamp”, “CoilID”, “ProductID”, “CoilLength”, “CoilWidth”, “CoilThickness” and “CoilWeight”

Page 55: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Observe that already by clicking your whole query is being created:

Click on OK and look; your first query has been created:

Page 56: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

In order to “see” the result one can simply press the “Execute” button and view the results.

Does your query comes back with information like this?

Congratulations; your first query is done. Please save the query somewhere as we will need it in the future.

Page 57: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.2.2 Query our historian database where we change our date field A word of warning now, I told you before that the only thing that CitectSCADA Reports does is putting data into SQL. This is true but again slightly complicated. Due to the need of sparse data logging and the fact that we must be able to cope with time related issues (daylight savings etc), we do use a SQL table to put our data in but we have modified the fields in the table. If we did not do this; would be have major problems in terms of data consistency. For example; start the SQL Server Management Studio and open your historian database. Open the table AlarmSamples. What do you see????

Well it is quite obvious this table holds the right information but in its present state we can not do a thing with it. The reason for this “strange” data is that we have specific tables that are connected to each other form a proper end result. There are properties tables, as well as tables where we store the samples. If we connect them; we can make sense of it. Let’s just make that happen!

Page 58: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Please create a new query and go into design-mode; ADD both the Alarms and the AlarmSamples Table and click OK.

As you can see these tables are connected and therefore automatically joined.

Page 59: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Please now check from Alarms the AlarmName and the Description; from the AlarmSamples please check SampleDataTime, Enabled and Acknowledged.

Execute your query; what is your result?

Yes; the date-time field is strange… This due to the fact we store the time in UTC format. ( counting the number of nanoseconds since 1900 00:00:00 hours )

Page 60: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

What we need to do is re-calculate this field. For this we have supplied some SCALAR functions in your historian table.

If we use the scalar function called “ToDate” on our SampleDateTime field; the information that is returned to us is not the time in UTC format; but in normal format! Only a small change in the query is required: Change

AlarmSamples.SampleDateTime Into: dbo.ToDate(AlarmSamples.SampleDateTime) AS SampleDateTime Now execute your query again! Are you happy with the result? Then save your query!

Page 61: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

A bit more zoomed in:

Page 62: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.2.3 Using the CitectSCADA Reports stored procedures to generate statistics. Well this is the fun bit. Honestly people, we are now going to start to play with the capabilities of the Microsoft SQL Reporting Services and to be quite frankly; this is a world on its on. Up until now we have played with simple queries that allowed us to quite bluntly generate a list of everything that was stored in some tables. But we use the Historian because it is the Historian and out of the most minimal data we would like to see a complete dataset returned. Even though quite often the required data is absent in the database. What has to be done to overcome this? Very simple; the logic that was needed to calculate complete record sets back out from just a handful of actual records is already in the product. We have created a handful of stored procedures that has powerful logic! A stored procedure is nothing more then a pre-configured query that via means of a couple of parameters produces quite nice results. So you feed it only a handful of input in order to get a complete record set back. In our case; we get only 2 stored procedures to work with…. And they are enough. We have usr.HistorianStats() and the usr.HistorianGraph() to work with. To cut things short, both procedures return the same data but the number of samples returned by the HistorianGraph is much more so a very detailed graph ( with heaps of points ) can be created. Today we will only play with the usr.HistorianStats() stored procedure and before we start with it; a little more insight in this procedure is required. Please read the below details and now read all about the HistorianStats reference in the CitectSCADA Reports help:

Page 63: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 64: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

As the stored procedure requires input to be able to produce a nice record set returned to us it is more beneficial to now go and make the step to go and work with the SQL Reports. Please start the “Report Development Tools”

Visual Studio will now start and we can now configure a Reports Project. The main thing to remember here is that a report project is a standalone application. We will (again) have to tell the system where data can be gotten, what data we want to see (by means of a query) and how we want it visualized (graph, table etc). Also a report is not one way, yes there are 100% automated reports but some require user input first in order to then complete a query and place it back at the user. Okay so our reports server needs to know where the data is coming from. Please right click on the shared data sources and add a new datasource:

Page 65: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

The following window opens up:

use the edit button to select your Historian database:

Once changed; click on test and OK to close the window.

Page 66: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Our reports project now knows on where to find the data, let’s create our first report. Right click on Reports in the project explorer and create a new Report:

The following wizard appears:

click on next

Page 67: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Now by default the shared data source is selected, please click next to continue:

Page 68: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

A very very familiar screen comes up:

Yes, right now we could for instance copy-paste our queries of exercises 2.1.1 and 2.1.2; but we will swim in the deep straight away. As I just before reference to the explanation of the usr.HistorianStats I would like you to paste the following query: SELECT IntervalName, TagName, OnCount, OnTime / 10000000 AS RunTime FROM usr.HistorianStats(@Location + '.' + @Tags, CONVERT(nvarchar(30), @Start) + ' > ' + CONVERT(nvarchar(30), @End), 'TIME', @Interval, DEFAULT) AS HistorianStats_1

Click on next

Page 69: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Now select the Matrix view:

And click Next:

Page 70: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Complete the following design:

And finish

Page 71: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

We are now taken to our report:

Every report has 3 tabs: Data -> Here we can play with our queries Layout -> Here can setup our report in a WYSIWYG editor Preview -> Here we can test our report Go to the Data tab and click on “Generic Query Designer”:

Does this look a bit familiar?

Page 72: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

If you browse through the fields in the HistorianStats function; you can see that only 4 items are selected where we could get returned a whole lot more. ( the stored procedure is very powerful! ) Okay so that we know what we want to see returned it is time play with what we need to put in (remember once more the help on this function a couple of pages ago!). Go to the preview tab:

our report knows we need to parse 5 parameters ( location, tags, start, end, interval ) but it requests them in pure text…. Not helpful. Lets improve that: Go into the Layout tab of the report and select the “report” in the properties field:

We get these details:

Page 73: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Open the ReportParameters:

We are now getting all our reports parameters returned. As you can see; all 5 parameters that belong to the usr.HistorianStats procedure are here:

Please change them to the following settings on the next 5 pages:

Page 74: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 75: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 76: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 77: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports
Page 78: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Click on OK and close the ReportParameter properties. Go back to the preview tab; what do you see????

Now run a “fast” report on today over “all towers” that have “open” tags. What do you get?

Page 79: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Our report in text now looks great but we are still missing some very important things. Because not only is it very easy to create and with queries in a report; all returning data can be represented in more then one ways. Go back to your report Layout make your work area a bit bigger:

Now press CTRL-ALT-X and select Chart.

Page 80: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Now draw a chart in your workspace:

Put the “RunTime” in the datafield, put the “Tagname” in the categoriy field and place the “IntervalName” in the series field:

Run your report again!

Page 81: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Can you see how simple it is to enhance your reports?

Page 82: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.2.4 Exercise -> create 2 more reports with the use of queries 2.2.1 and 2.2.2 Just to get a bit more feeling I would you to now create 2 more reports that use your queries from exercises 2.2.1 and 2.2.2

Page 83: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.3.0 Publishing your reports. Now that we finally have 3 proper reports; it is time to make them life. We will put them on our IIS server so that people can browse to it and use them. In the Solution Explorer, go to the properties of your Report Project:

Change the TargetServerURL to http://localhost/ReportServer$SCADAReports

Page 84: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

Right mouse click again your Reports Project and choose deploy:

This should follow:

Now go to the following website: http://localhost/ReportServer$SCADAReports Can you find and run your Reports? Please check this site also: http://localhost/Reports$SCADAReports

Page 85: CitectSCADA Reports v4 · PDF fileThe intention of this training is to give all Citect ... Start of hands -on training ... The very first step into getting a working CitectSCADA Reports

2.4.0 In conclusion I would like to recap some items that have been spoken through in the last 84 pages. For starters CitectSCADA Reports is a product that covers a very big and complex area of today’s IT industry. The core package this product relies on (Microsoft SQL Server 2005 + Reporting Services) is intensely powerful as we have seen by now. This course covers quite a lot of ground on the SQL area but by far not enough. Please use this course only as a guideline, nothing more. The actual maintenance / setup and running of SQL is separate day-job that can not be underestimated. The same counts for the SQL Reporting Services. What is good to know and understand is that CitectSCADA Reports can fully use this new technology. Even more important, we can use it reliably. And on top of that; the performance (thanks to the CTAPI) is incredibly big. This course was created in a rather hurry, all in all there are still many topics missing. For instance we can build a report to view live data out of any CitectSCADA system as every single CTAPI command is mapped into the historian and can be queried directly! The main thing that I want to point out it is that the sky is the limited. There is not much CitectSCADA Reports now can not do or produce. And all data is accessible for everyone now! I wish you all a happy time selling / installing and support CitectSCADA Reports, if you have any questions you know where to find me! Thank you for your attention Rien van Geffen