0% found this document useful (0 votes)
271 views24 pages

Creating An OS Report With PH Data: SIMATIC PCS 7 / Process Historian

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
271 views24 pages

Creating An OS Report With PH Data: SIMATIC PCS 7 / Process Historian

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Creating an OS Report

with PH data
Siemens
Industry
SIMATIC PCS 7 / Process Historian Online
Support
https://support.industry.siemens.com/cs/ww/en/view/109770734
Legal information

Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG ("Siemens"). They are
non-binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.

Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent
non-disclosure of a defect, or culpable breach of material contractual obligations. Claims for
damages arising from a breach of material contractual obligations shall however be limited to the
© Siemens AG 2019 All rights reserved

foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or is based on loss of life, bodily injury or damage to health. The foregoing provisions
do not imply any change in the burden of proof to your detriment. You shall indemnify Siemens
against existing or future claims of third parties in this connection except where Siemens is
mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.

Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.

Security information
Siemens provides products and solutions with Industrial Security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the Internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: https://www.siemens.com/industrialsecurity.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 2
Table of contents

Table of contents
Legal information ..................................................................................................... 2
1 Introduction .................................................................................................... 4
1.1 Benefits of accessing the Process Historian ....................................... 6
1.2 Report requirement ............................................................................ 6
2 Create ODBC data source .............................................................................. 7
3 Example SQL database queries ................................................................... 11
3.1 Database views that can be used for PH database queries .............. 11
3.2 Determine Tag UIDs in the Process Historian Database................... 11
3.3 Read tag values............................................................................... 12
Read the latest value from the PH archive ....................................... 12
3.4 Reading Aggregated Values ............................................................ 12
3.4.1 Read minute aggregates.................................................................. 12
3.4.2 Read daily aggregates ..................................................................... 13
3.5 Read messages............................................................................... 13
4 WinCC report generation ............................................................................. 15
5 Create a WinCC Print Job ............................................................................ 19
5.1 Printing reports via the OS Runtime ................................................. 21
6 Report Example ............................................................................................ 22
© Siemens AG 2019 All rights reserved

7 Appendix....................................................................................................... 23
7.1 Service and support ......................................................................... 23
7.2 Links and literature .......................................................................... 24
7.3 Change documentation .................................................................... 24

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 3
1 Introduction

1 Introduction
Core contents of the Application Example
The Process Historian is the long-term archive of a PCS 7 system. The Process
Historian data is stored in a SQL Server database. The stored data of the Process
Historian can be accessed using the Information Server or the PCS 7 OS Trend
and Alarm Control.
The application example explains how to create a PCS 7 OS Report with WinCC
Report Designer, which displays data from the Process Historian. This is especially
interesting for systems that use a PH but not an IS.

Validity:
• SIMATIC Process Historian 2014 SP3
In combination with:
• SIMATIC PCS 7 V8.0 SP2
• SIMATIC PCS 7 V8.1
• SIMATIC PCS 7 V8.2
• SIMATIC PCS 7 V9.0

Requirement
• The experienced handling of the PCS 7 OS and the WinCC Report Designer
© Siemens AG 2019 All rights reserved

and the Process Historian database is assumed.


• A PDF printer must be set up.

Uses
• PDF report creation for attachments that do not use an information server.
• Direct creation of reports from the WinCC Runtime environment.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 4
1 Introduction

NOTE For detailed information about the WinCC Report Designer, please refer to the
chapter "Documentation of Configuration and Runtime Data" in the "WinCC
Information System".
© Siemens AG 2019 All rights reserved

NOTE Due to PCS 7 Engineering changes, the TagUIDs in the Process Historian
database may change. As a result, the WinCC Report must be adapted.

NOTE This application example was created with a PCS 7 OS Single Station V 9.0 SP1
and a Process Historian 2014 SP3 Upd3.
Operating system OS Single Station = Microsoft Windows Server 2012 R2
Standard
Operating System Process Historian = Microsoft Windows Server 2012 R2
Standard

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 5
1 Introduction

1.1 Benefits of accessing the Process Historian


Compared to accessing data from an OS server, accessing the Process Historian
database has the following advantages.

1. You can display variables from all servers that store data on the PH.
2. Messages can be displayed from all servers that store data on the PH.
3. Values are typically available over long periods of time.
4. Access to the aggregation tables of the Process Historian is possible.
5. Data from both the PH database and the OS server can be displayed in one
report.

1.2 Report requirement


A WinCC report should be created for the following plant area.
© Siemens AG 2019 All rights reserved

Content of the report:


Daily minimum and maximum values of the tank levels of the last 7 days are to
be represented in a table.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 6
2 Create ODBC data source

2 Create ODBC data source


1. Open the Server Manager on the OS system (OS Single Station or OS Server).
2. In the "Tools" menu, click "ODBC Data Source (64-bit)".
© Siemens AG 2019 All rights reserved

3. Click on the "Add" button.

4. Select "SQL Server".


5. Click the "Finish" button.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 7
2 Create ODBC data source

6. Specify the name of the ODBC data source, a description, and the SQL Server
of the Process Historian.
7. Click the "Next" button.
© Siemens AG 2019 All rights reserved

8. Select the authentication method and click the "Next" button.

9. Set the checkbox "Change the default database to:" and select the database
"HistorianStorage".

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 8
2 Create ODBC data source

10. Click the "Finish" button.


© Siemens AG 2019 All rights reserved

11. Click the "Test Data Source" button to test the ODBC database connection.

12. Click "OK".

Result:
The ODBC data source has been created.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 9
2 Create ODBC data source

NOTE • Using the IS Stored Procedures against the ODBC data source does not work.
• Only stored procedure calls with fixed parameters can be used.
• Only direct database queries against PH tables or PH views can be used.
• More complex database queries often do not work with the ODBC data source.
© Siemens AG 2019 All rights reserved

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 10
3 Example SQL database queries

3 Example SQL database queries


The following chapter contains examples of database queries that can be used
against the ODBC data source.

NOTE For more information on the PH database, see the article "Creating Report
Templates with Report Builder".
https://support.industry.siemens.com/cs/ww/en/view/64906050

3.1 Database views that can be used for PH database


queries
The following PH DB views can in principle be used for database queries.
PH DB Views
PH DB View Data
IS.VTagBrowsing Tag UIDs of the PH
ALG.VMessage Messages of the PH
TLG.VTagValue Variables Values of the PH
© Siemens AG 2019 All rights reserved

TLG.VAggregateValue Aggregated values of the PH

NOTE When converting the time stamp to the local time of the OS server, rounding
errors occur in the millisecond range!

3.2 Determine Tag UIDs in the Process Historian Database


With the help of the following database query you can determine the required
TagUIDs.
SELECT TOP 1000 [GroupTypeUID]
,[TagUID]
,[Archivename]
,[Tagname]
,[ArcTimeInt]
,[ArcTime]
,[ScanTime]
,[CompressTime]
,[AggregationID]
,[Unit]
,[PhysicalDataSourceName]
,[RedundantPhysicalDataSourceName]
FROM [HistorianStorage].[IS].[VTagBrowsing] where Tagname like '%Tank1%' and
Archivename = 'SystemArchive'

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 11
3 Example SQL database queries

3.3 Read tag values


Read the latest value from the PH archive
/****** Reading current value ******/
use HistorianStorage

SELECT top 1 [Timestamp], [ValueFloat] as Value, [Quality]


FROM [HistorianStorage].[TLG].[VTagValue] where TagUID = '8333E584-
E13E-4F6B-84C9-F53B96D14DFE'
order by TimeStamp desc

Result

3.4 Reading Aggregated Values


You can use the following database query to determine the most current
aggregated value. If AggregateID = 1, then the last minute aggregated value is
returned.
AggregateID = 1 = Minute aggregates
© Siemens AG 2019 All rights reserved

AggregateID = 2 = Hours aggregates


AggregateID = 3 = Daily aggregates

3.4.1 Read minute aggregates

In the following example, the last stored minute aggregate is returned. The UTC
timestamp is converted to the local OS server time.

Max Value:
Use HistorianStorage
SELECT TOP 1
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeSta
mp_MAX])) as Local_Time_Calculated
,[TimeStamp_MAX] as UTC_Time_Recorded
,[Agg_MAX] as Max_Value_Last_Minute
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE' and AggregateID = 1
order by TimeStamp desc

Min Value:
Use HistorianStorage
SELECT TOP 1
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeSta
mp_MIN])) as Local_Time_Calculated
,[TimeStamp_MIN] as UTC_Time_Recorded
,[Agg_MIN] as Min_Value_Last_Minute
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE' and AggregateID = 1
order by TimeStamp desc

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 12
3 Example SQL database queries

Result:

3.4.2 Read daily aggregates

In the following example, the last 7 tag aggregates are read. The UTC timestamp is
converted to the local OS server time.

use HistorianStorage
Select
convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeStamp_
MAX])) as Local_Time_Calculated
--,[TimeStamp_MAX] as Time_Max_UTC
,[Agg_MAX] as Max_Value
,convert(datetime,DATEADD(SECOND,DATEDIFF(SECOND,getutcdate(),GETDATE()),[TimeStamp
_MIN])) as Local_Time_Calculated
--,[TimeStamp_Min] as Time_Min_UTC
© Siemens AG 2019 All rights reserved

,[Agg_MIN] as Min_Value
FROM [HistorianStorage].[TLG].[VAggregateValue]
where TagUID = '8333E584-E13E-4F6B-84C9-F53B96D14DFE'
-and AggregateID = 3
and TimeStamp_max >= DATEADD(DD,-7,Sysutcdatetime()) and TimeStamp <=
Sysutcdatetime()
order by TimeStamp desc

Result

3.5 Read messages


In this example the messages of the last hour of the OS area "MatCount" are read.

/****** Reading messages of the last hour of one OS area ******/


use HistorianStorage
SELECT
convert(datetime,[TimeStamp]) as Local_Time
--,[TimeStamp]
,[MsgNr]
--,[ServerName]
,substring(convert(nvarchar(max),[MessageTexts]),(charindex('<TB No="3"
LCID="1033">',convert(nvarchar(max),[MessageTexts]))+23),100) as MessageText

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 13
3 Example SQL database queries

FROM [HistorianStorage].[ALG].[VMessage]
where TimeStamp >= DATEADD(hh,-1,Sysutcdatetime()) and TimeStamp <=
Sysutcdatetime()
and convert(nvarchar(max),MessageTexts) like '%MatCount%'
order by TimeStamp desc

Result

NOTE Messages can be displayed more comfortably with the WinCC Report function.
© Siemens AG 2019 All rights reserved

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 14
4 WinCC report generation

4 WinCC report generation


1. Open the WinCC Explorer on the OS Runtime machine.
2. For example, navigate to the "Report Designer>Layouts>English" object if your
selected runtime language is English.
3. For example, open the layout "@CCFunctionTrendCtrl-CP_ENU".
© Siemens AG 2019 All rights reserved

4. Remove the "WinCC Function Trend Control (Classic).Picture" Object


5. Open the Static Part of the Report Layout.

6. Modify the Header report to suit your requirements.


7. Save the report as "WeeklyTankfarmReport.RPL".

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 15
4 WinCC report generation

8. Select the "Dynamic Part" the report layouts.

9. Insert a static text from the "Standard Object" palette into the report.

10. Configure the string "Tank1".


© Siemens AG 2019 All rights reserved

11. Insert an "ODBC Database Table" from the "Standard Object" palette into the
report.

12. Open the "Object Properties" of the "ODBC Database Tables" via the context
menu.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 16
4 WinCC report generation

13. Select the "Database link" and click on the "Edit" button.

14. Configure the "Data Connection" as follows.


© Siemens AG 2019 All rights reserved

NOTE The SQL Query can be found in the chapter "Reading daily aggregates".
The TagUID must be determined on the Process Historian and adjusted
accordingly.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 17
4 WinCC report generation

15. Click the "Test SQ "L Statement" button.

Result
The SQL query is executed and returns the result.
© Siemens AG 2019 All rights reserved

16. Click the "Close" button.


17. Click the "OK" button.
18. Close the "Object Properties".
19. Copy the two created objects 4 times.
20. Adjust the copied objects for the other four tanks as described above.
21. Save the Layout report.

Result

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 18
5 Create a WinCC Print Job

5 Create a WinCC Print Job


1. Open the WinCC Explorer on the Runtime machine.
2. Create a new "Print Job".
© Siemens AG 2019 All rights reserved

3. Open the "Properties" of the print job.

4. Define the name "WeeklyTankFarmReport".


5. Define the layout file "WeeklyTankFarmReport.RPL".

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 19
5 Create a WinCC Print Job

6. Switch to the "Printer Setup" tab and configure your PDF printer.
© Siemens AG 2019 All rights reserved

7. Click the "OK" button to complete the configuration.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 20
5 Create a WinCC Print Job

5.1 Printing reports via the OS Runtime


1. Open the WinCC Explorer on the Runtime machine.
2. Select the "Graphics Designer" menu.
3. Open the process screen from which you want to print the report.
4. Navigate to the "Standard" object palette.
5. Add a "Button" object to the process image.
6. Configure the name "Print Tank Report" for the button.
7. Open the "Properties" of the button Object.
8. Insert a "C-Action" for the "Mouse Click Event".
9. Configure the following function in the C action:
RPTJobPrint( "WeeklyTankFarmReport");
© Siemens AG 2019 All rights reserved

10. Compile the C action.


11. Click the "OK" button.
12. Save the process image.

Result
After you have performed a screen change on the OS Runtime, you can print the
report.

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 21
6 Report Example

6 Report Example
© Siemens AG 2019 All rights reserved

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 22
7 Appendix

7 Appendix
7.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com

Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2019 All rights reserved

SITRAIN – Training for Industry


We support you with our globally available training courses for industry with
practical experience, innovative learning methods and a concept that’s tailored to
the customer’s specific needs.
For more information on our offered trainings and courses, as well as their
locations and dates, refer to our web page:
www.siemens.com/sitrain

Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc

Industry Online Support app


You will receive optimum support wherever you are with the "Siemens Industry
Online Support" app. The app is available for Apple iOS, Android and Windows
Phone:
support.industry.siemens.com/cs/ww/en/sc/2067

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 23
7 Appendix

7.2 Links and literature


Table 7-1
No. Topic
\1\ Siemens Industry Online Support
Fehler! Linkreferenz ungültig.
\2\ Link to this entry page of this application example
https://support.industry.siemens.com/cs/ww/en/view/109770734
\3\

7.3 Change documentation


Table 7-2
Version Date Modifications
V1.0 08/2019 First version
© Siemens AG 2019 All rights reserved

OS Report with PH data


Entry ID: 109770734, V1.0, 08/2019 24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy