Professional Documents
Culture Documents
Note The Application Examples are not binding and do not claim to be complete regarding the
circuits shown, equipping and any eventuality. The Application Examples do not represent
customer-specific solutions. They are only intended to provide support for typical
applications. You are responsible for ensuring that the described products are used
correctly. These Application Examples do not relieve you of the responsibility to use safe
practices in application, installation, operation and maintenance. When using these
Application Examples, you recognize that we cannot be made liable for any
damage/claims beyond the liability clause described. We reserve the right to make
changes to these Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these Application
Examples and other Siemens publications – e.g. Catalogs – the contents of the other
documents have priority.
We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
deficiency or breach of a condition which goes to the root of the contract
(“wesentliche Vertragspflichten”). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
Siemens AG 2018 All rights reserved
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.
Security Siemens provides products and solutions with industrial security functions that support the
informa- secure operation of plants, systems, machines and networks.
tion 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 only form one element of such a
concept.
Customer is responsible to prevent unauthorized access to its plants, systems, machines
and networks. Systems, machines and components should only be connected to the
enterprise network or the internet if and to the extent necessary and with appropriate
security measures (e.g. use of firewalls and network segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be taken into
account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more
secure. Siemens strongly recommends to apply product updates as soon as available and
to always use the latest product versions. Use of product versions that are no longer
supported, and failure to apply latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security
RSS Feed under http://www.siemens.com/industrialsecurity.
Table of Contents
Warranty and Liability ................................................................................................. 2
1 Introduction ........................................................................................................ 4
1.1 Overview............................................................................................... 4
1.2 Mode of operation ................................................................................ 5
1.3 Description of the WinCC application ................................................... 6
1.3.1 Overview and description of the reverse osmosis plant ....................... 6
1.3.2 Functionality of the reverse osmosis plant ........................................... 9
1.4 Components used .............................................................................. 13
2 Exporting archive data with WinCC ............................................................... 14
2.1 Mode of operation .............................................................................. 14
2.2 Configuration and Settings ................................................................. 15
2.2.1 Configurations in the sample project .................................................. 15
2.2.2 Configuring the scripts for exporting archive data .............................. 16
2.2.3 Script for exporting archived tags ....................................................... 16
2.2.4 Script for exporting archived alarms ................................................... 28
2.3 Operation ............................................................................................ 40
2.3.1 Export of archived tags using VBS script ........................................... 40
2.3.2 Export of archived alarms using VBS script ....................................... 40
3 Exporting archive data with Excel ................................................................. 41
3.1 Mode of operation - overview ............................................................. 41
Siemens AG 2018 All rights reserved
1 Introduction
1.1 Overview
Motivation
Numerous process variables are required for the visualization of modern
automation systems. Alarms notify the user of events that occur during the
process. Past process variables and alarms are stored in archives and are always
available to the user.
WinCC stores the data in the archives in a compressed and binary-coded format.
WinCC allows the user to display the archived process variables and alarms.
However, the data format cannot be used for analysis and further processing.
Task
The requirement is to export the data to other formats, e.g. “*.csv” or “*.xls”. Then
they can be conveniently used in office applications, ERP systems and MES.
Figure 1-1
Visualization
Siemens AG 2018 All rights reserved
*.c sv
*.xls
Archi ve
Assumed knowledge
Basic knowledge of WinCC V7 is assumed.
Note Basics can be acquired in the “SIMATIC WinCC, system course” in the SITRAIN
series.
SIMATIC WinCC, Systemkurs (de)
SIMATIC WinCC, System Course (en)
Figure 1-2
WinCC
Application
Of f ice ap p lication ,
Arch ive
ERP, MES systems
Project d at a
Arch ive
SlowTag Log g in g
Note The reverse osmosis plant is designed as a WinCC project and is contained in
the application example as a download.
VB scripts simulate all operating conditions. WinCC archives store the process
variables and alarms.
Figure 1-3
Siemens AG 2018 All rights reserved
The application example has several buttons to control the plant and to export
archive data.
Visualization of:
Valves
Several pressure indicators
An outlet and motor
Depending on the status, the associated valve and motor HMI tags are set to “ON”
(1) or “OFF” (0). When active, the color of the objects changes. Fehler!
Unbekanntes Schalterargument. gives a short description of the buttons.
Table 1-1
Buttons Description
This button changes the language from English to German and vice
versa.
Table 1-2
Valves (V) / pump (P) Description
V700 Raw water valve
V701 Process water valve
V702 Tank outlet valve
V703 Concentrate valve
V704 CO2 valve
V705 Chemicals valve
V706 Outlet valve
P800 Motor/pump for raw water
The current states of the simulated process variables are displayed via analog
measuring points (I/O fields). The process variables (Fehler! Unbekanntes
Schalterargument.) describe:
Flows in the tubing
Conductivity of the liquids
Pressure states at different measuring points within the tank
Table 1-3
Analog Unit Description
measuring points
3
FI100 m /h Raw water inlet
3
FI101 m /h Tank outlet
3
FI102 m /h Outlet outside tank
FI300 l/h CO2 inlet
FI500 l/h Chemicals inlet
QI901 µs/cm Concentrate conductivity
QI900 µs/cm Process water conductivity
PI200 bar Tank pressure sensor1
PI201 bar Tank pressure sensor2
PI202 bar Tank pressure sensor3
Siemens AG 2018 All rights reserved
Table 1-4
No. Mode Note
1. OFF After starting the application example in WinCC Runtime, the
plant is in “Off” mode.
The valves and motors are in their initial position (state: “0”).
Analog measuring points have either their start value or the
value “0”.
The “STOP” button simulates an emergency intervention in the
running plant. The plant is shut down and goes to “Off”.
2. Startup After the “startup” process, the plant automatically goes to the
“production” process.
The valves and the motor close/stop gradually. Simulated
values are written to all analog measuring points.
3. Production All valves and the motor are activated. Simulated, slightly
varying values continue to be written to the analog measuring
points.
4. Shutdown After “shutting down” the plant, it returns to “Off”.
The valves and the motor close/stop gradually. Simulated
values are written to measuring points that are still
technologically active.
Actions
Table 1-5
Action Call – trigger Description
Measurement.bac cyclically - Controls the calculation of values of
Timer = 1 s the individual analog measuring
points by calling the “MeasMode” and
“Measurement” scripts. The required
simulation parameters are transferred
within the action.
SimReverseOsmosis.bac cyclically - Simulates the process of the reverse
Timer = 1 s osmosis plant by calling the
“StepControl” and “ActuatorControl”
scripts.
Siemens AG 2018 All rights reserved
Procedures
Table 1-6
Procedure Call Description
StepControl.bmo Action Simulates the individual steps of
“SimReverseOsmosis” the plant through different
sequences (StartupSequence,
ShutdownSequence,
StopSequence).
MeasMode.bmo “Measurement” action Simulates the status of the
individual analog measuring points.
Measurement.bmo “Measurement” action Simulates the values of the
individual analog measuring points.
ActuatorControl.bmo “SimReverseOsmosis” Simulates the states of valves and
action motor, depending on the plant
status.
WriteArchiveToCSV.bmo Trigger button Creates a *.csv file, accesses the
“WriteArchiveToCSV” archive using the WinCC OLE DB
Provider and writes the archive
entries for the
“QI901_ConductivityPermeatIn” tag
to this file. Only the tag name, time
of measurement, tag ID and value
are saved.
WriteMessagesToCSV. Trigger button Creates a *.csv file, accesses the
bmo “WriteMessagesToCSV” archive using the WinCC OLE DB
Provider and writes the archive
entries with an alarm number <4 to
this file. Only the time of
measurement, alarm number, alarm
type and alarm class are saved.
“Startup” button
The start time is determined and entered in the “Start” output field.
The “StartupSequence” is started.
The “Status” display changes to “Startup” mode.
The valves and the motor open/start gradually. Simulated values are written to
all analog measuring points. The Startup process consists of the following five
steps:
Figure 1-4
Status:
Startup
1
Status:
P800: active Current step = 3 Production
Simulated values are written to all analog measuring points. The values selected for this
example can be customized in the script at any time.
Tags
Table 1-7
Tags Set value Min Max Step size
FI100_FlowRawwater 0 60 150 9
FI101_FlowConcentrate 0 10 7 120
= FI100 –
FI101 +
FI102_SupplyWater - - -
(FI300/1000) +
(FI500/1000)
FI300_FlowCO2 0 1 19 2
FI500_FlowChemicals 0 1 11 1.5
QI900_ConductivityPermeatIn 1511 1310 1556 33
QI901_ConductivityConcentrate 1900 1300 2000 56
PI200_Tank 0 1.1 5.5 0.35
PI201_Tank 0 1.1 5.4 0.32
PI202_Tank 0 1.1 5.3 0.31
PI203_Tank 0 1.1 5.2 0.30
Trend recording starts on an event-triggered basis when the plant is started up.
The startup process takes approx. 25 seconds until the plant goes to
“Production” mode.
Siemens AG 2018 All rights reserved
SHUTDOWN button
The “Status” display changes to “Shutdown” mode.
The “ShutdownSequence” is started.
The valves and the motor close/stop gradually. Simulated values continue to
be written to analog measuring points that are still technologically active. The
Shutdown process consists of the following seven steps (steps 6-12):
Figure 1-5
Status:
Shutdown
1
Current step
P800: inactive Current step = 8 V706: closed
= 12
Status:
Current step OFF
V700: closed
=9
The shutdown process takes approx. 25 seconds until the plant goes to “Off”
mode.
Trend recording stops on an event-triggered basis when the plant goes to “Off”.
The stop time is determined and entered in the “Off” output field.
"Stop" button
The “Status” display changes to “Off” mode.
The “StopSequence” is started.
The valves and motors close/stop immediately, analog measuring points are
reset to their start value.
Trend recording stops on an event-triggered basis when the plant stops.
The stop time is determined and entered in the “Off” output field.
The plant goes to “OFF” mode.
“Production” button
All valves and the motor are active (“1” state). Simulated, slightly varying values continue to be
written to the analog measuring points (see Fehler! Unbekanntes Schalterargument.).
“Off” button
The valves and motors are in their initial position (state: “0”). Analog measuring points have
either their start value (see Fehler! Unbekanntes Schalterargument.) or the value “0”.
Table 1-8
Component Numbe Article number Note
r
Engineering Station 1 Development computer
with Windows 7x64 SP1
SIMATIC WinCC V7.4 SP1 1 6AV63.1-....7-4...
SIMATIC
WinCC/Connectivity Pack 1 6AV6371-1DR07-4...
V7.4 SP1
MS SQL Server 2008 R2 1
MS Excel 2007, 2010,
1
2013
Table 1-9
Component File name Note
WinCC project This compressed file
38132261_Application_Reverse_Osmosis_PR
contains the WinCC
OJ.zip
project.
Excel file 38132261_Application_Reverse_Osmosis_XL This compressed file
S.zip contains the WinCC
project.
Documentation This document is the
38132261_ documentation for
Application_Reverse_Osmosis_DOC_de.pdf the application
example.
Figure 2-1
Siemens AG 2018 All rights reserved
WinCC/Connectivity Pack
OLE DB Provider
*.csv
Exported data
• Tag
“QI900_ConductivityPermeatIn”
• All messages in the last
24 hrs with MsgNo. < 4
Archive
Note The scripts shown in chapter 2 are examples and have already been created in
the WinCC project. The WinCC is therefore ready for operation immediately after
customizing the computer name.
Script debugger
If you would like to debug the VB scripts, you can use a script debugger. For
licensing reasons, is not supplied with SIMATIC WinCC for SIMATIC WinCC V6.2
or higher.
To enable the display and debugging of script errors, make the following settings
under “Computer properties” in the “Runtime” tab:
Figure 2-2
Note The MS script debugger is part of your WinCC installation pack. More
information on WinCC can be found in the online help in chapter “Testing with
the debugger”.
After the end of a production cycle of the reverse osmosis plant, the measured
values archived between the start and stop time are entered in a *.csv file.
The stop, startup and shutdown times of the osmosis plant are entered into the
message archive as operational messages. They have the message numbers 1, 2,
and 3. In this application example, the startup, shutdown and stop alarms of the
last 24hrs are to be written to a *.csv file.
The solution of this task is shown using a script. It was created with the Global
Script Editor from WinCC. It can be called up on an event-triggered basis (by
pressing a button or with a tag trigger).
To make this clearer, this example looks only at measuring point QI900
(conductivity of the generated process water). Its archived values are written to a
CSV file by pressing a button.
Alternatively, it is possible to simultaneously retrieve multiple measured values in
VB code.
Table 2-1
No. Action
1. Start the Global Script VBS Editor.
2. Select the “Project Modules” tab and create a new folder named
“WriteArchiveToCSV”.
Siemens AG 2018 All rights reserved
No. Action
4. Change the sub-procedure to a function. Add the “ArchiveName” and
“MeasuringPoint” parameters to this function. Save the project module as
“WriteArchiveValuesToCSV”.
Table 2-2
No. Action
1. Start the code by declaring the following tags:
'Declaration of local Tags
Dim fso 'FileSystemObject
Dim f 'File
Dim ts 'TextStream
Dim path 'Path
Dim StartArchive 'Starttime of Archiving
Dim StopArchive 'Stoptime of Archiving
Dim TimeStamp 'Timestamp for bulding filename
2. Then use the following code to read the start and stop times of the reverse osmosis
plant. The internal WinCC tags for this are “DateTimeLastStart” and
“DateTimeLastStop”. When the plant starts and stops, the respective times (format:
dd.mm.yyyy hh:mm:ss) are saved to these tags.
'Read Start- and Stoptime of Osmosis
Set StartArchive = HMIRuntime.Tags("DateTimeLastStart")
Set StopArchive = HMIRuntime.Tags("DateTimeLast")
If the start and stop times are missing, an alarm is to be displayed and processing
the function is to be terminated.
If StartArchive.Read = "" Or StopArchive.Read = "" Then
MsgBox "Start- or Stoptime of Archiving is missing"
Exit Function
End If
No. Action
3. Define the path and file name. The “path” tag contains the complete file name,
including the path in the following form:
C:\Temp\Osmosis_ + Start time + _Measuring point name
In the application example, the start time is used to generate the file name and must
first be converted to a suitable format.
'Generate String for the csv-filename and replace ":" with
"_"
TimeStamp = FormatDateTime(StartArchive.Read, vbGeneralDate)
TimeStamp = Replace(TimeStamp,":", "_")
'Path and name for the *.csv file
path = "C:\Temp\" & "Osmosis_" & TimeStamp & "_" &
MeasuringPoint & ".csv"
4. Subsequently, you use the following code to generate the file system object (fso)
and the file object (f) using the previously formed path and file name (path). Before
doing so, the system checks whether the file already exists and, if this is the case,
processing the function is terminated after displaying a message.
'Create FileSystemObject and *.csv file if it not exist:
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(path) Then
fso.CreateTextFile(path)
Else
Siemens AG 2018 All rights reserved
Table 2-3
FieldNo. Field name Type Meaning
0 ValueID (4-byte) integer ID of the process value
1 TimeStamp DateTime Time stamp of the process value
2 RealValue (8-byte) real Process value
3 Quality (4-byte) integer QualityCode of the process value
Note Access is also possible without specifying the computer name (.\WinCC). This
decreases the access speed, however.
For transparent access, enter the WinCC project name for “Catalog”, e.g.
“Catalog = WinCC_Project_Name”.
contain:
The action (R = read access)
The ValueID or the symbolic name of the archive tag
The start and stop time (Starttime and Endtime)
Note To query multiple archived values at the same time, enter the ValueIDs or tag
names in parentheses, separated by semicolons, e.g.
“TAG:R,('ValueName_1';'ValueName_2';'ValueName_x'), <TimeBegin>,
<TimeEnd>”.
The times (start time or stop time) can be transferred as absolute or relative values.
Table 2-4
Start time Stop time Queried time range
Note The time stamp of the process values is stored as UTC (Coordinated Universal
Time). Therefore, the regional time zone and, if necessary, daylight saving
time/standard time must be considered when entering the start and end times as
absolute values.
For information on converting the local computer’s time to UTC, please use the
following link:
https://support.industry.siemens.com/cs/ww/en/view/24201113
Note The query using “ValueID” has a higher performance than the query using
“ArchiveName\Tagname”. However, the ValueID is not identical to the tag order
in the Tag Logging editor. The ValueID of a tag can be determined using SQL
Server Management Studio. Go to the SQL Server Management Studio and
open the table “dbo.Archive” in the runtime database of the project. The ValueID
is listed in the first column of the table.
Table 2-5
No. Action
Siemens AG 2018 All rights reserved
No. Action
2. Use the following code to read the computer name and the GUID of the project
from the environment tags “@LocalMachineName” and “@DataSourceNameRT”
into the previously declared local tags.
'Read the name of the PC-Station and the DSN-Name from
'WinCC-RT
Set MachineNameRT = HMIRuntime.Tags("@LocalMachineName")
Set DSNRT = HMIRuntime.Tags("@DatasourceNameRT")
Create the “ConnectionString” with the aid of these tags.
'Preparing the Connection-String
'First instance of WinCCOLEDB
Pro="Provider=WinCCOLEDBProvider.1;"
'Name of Runtime-Database
DSN="Catalog=" & DSNRT.Read & ";"
'Data Source
DS= "Data Source=" & MachineNameRT.Read & "\WinCC"
'Build the complete String:
ConnString = Pro + DSN + DS
3. Then use the “ConnectionString” to establish the connection to the database:
'Make Connection
Set Conn = CreateObject("ADODB.Connection")
Siemens AG 2018 All rights reserved
Conn.ConnectionString = ConnString
Conn.CursorLocation = 3
Conn.open
Note:
To define the RecordSet location for the query of archive data, assign a value to
the “CursorLocation” property. The value “3” is assigned in the example.
Therefore, the RecordSet is created on the client.
No. Action
4. The “CommandText” is required to query the data in the WinCC database.
In this application example, the relative time is used for the query. The start time
is the difference between start time and end time. Therefore, the query comprises
the period “end of archive minus time difference until end of archive” (see Table 2-
4).
The complete time difference is first calculated in seconds and only then
converted to the time format “days:hours:minutes:seconds”. Formatting also
generates the leading zeros for number values larger than 10.
'Duration between Start an Stop in seconds:
Duration = DateDiff ("s",StartArchive.Read,StopArchive.Read)
'Split the Duration in days, hours, minutes and seconds:
DurationMin = Fix(Duration/60)
DurationSec = Duration - (DurationMin * 60)
DurationHour = Fix(DurationMin/60)
DurationMin = DurationMin -(DurationHour * 60)
DurationDay = Fix(DurationHour/ 24)
DurationHour = DurationHour - (DurationDay * 24)
'Creating leading zeros:
DurationSec = Right("00" & DurationSec,2)
DurationMin = Right("00" & DurationMin,2)
DurationHour = Right("00" & DurationHour,2)
Siemens AG 2018 All rights reserved
Note Please note: When using time and date in WinCC and Visual Basic, the date
format depends on the regional settings in Windows. The VBS code is designed
so that the date and time can be evaluated independently of these computer-
specific settings.
Siemens AG 2018 All rights reserved
Table 2-6
No. Action
1. The subsequent loop writes the data sets (measuring point name, tag ID, time
stamp (UTC), process value) into the .csv file row by row. Before that, a row with the
column headers is generated once. This process considers the current Runtime
language setting (HMIRuntime.Language; 1031 = German, 1033 = English)
In each run, the RecordSet is set to the next data record.
'write recordsets To *.csv-File
'Header in *.csv-File
Language = HMIRuntime.Language
Select Case Language
Case 1031 'German = 1031
ts.WriteLine ("Tag-Name;ValueID;Datum/Zeit;Prozesswert")
'MsgBox "Tag-Name;ValueID;Datum/Zeit;Prozesswert"
Case 1033 'English = 1033
ts.WriteLine ("Tag-Name;ValueID;Date/Time;Process-Value")
Siemens AG 2018 All rights reserved
'MsgBox "Tag-Name;ValueID;Date/Time;Process-Value"
End Select
No. Action
2. At the end of the script, the connection to the database is closed and the objects are
released.
' Close all
ts.Close
RecSet.Close
Set ReCset = Nothing
Set Command = Nothing
conn.Close 'Close connection
Set Conn = Nothing
Set fso = Nothing
Set f = Nothing
Set ts = Nothing
End Function
3. Save the script. The script is now available for calling.
Siemens AG 2018 All rights reserved
Table 2-7
No. Action
1. Open the “Reverse_Osmosis.pdl” screen in the Graphics Designer.
2. Open the Properties dialog of the “Export Tags” button and select “Events -> Mouse
-> Mouse Click -> VBS-Action” to open the VBS editor.
Siemens AG 2018 All rights reserved
The startup and shutdown times and the stop time of the osmosis plant are entered
in the alarm archive as an operational message. Their alarm numbers are 1-3. In
this application example, the startup, shutdown and stop alarms of the last 24h are
to be written to a *.csv file.
Table 2-8
No. Action
1. In the WinCC application example, start the global VBS editor.
Siemens AG 2018 All rights reserved
No. Action
2. Step 2 can be skipped if chapter Fehler! Unbekanntes Schalterargument. has
already been processed.
Select the “Project Modules” tab and create a new folder named
“WriteArchiveToCSV”.
4. Change the name of the procedure and save the project module as
“WriteArchiveMessagesToCSV”.
Table 2-9
No. Action
1. Declare the following tags:
'Declaration of local Tags
Dim fso 'FileSystemObject
Dim f 'File
Dim ts 'TextStream
Dim path 'path
Dim StartTime 'Date and Time when writing is triggered
Dim TimeStamp 'Timestamp for bulding filename
2. Define the path and file name. The “path” tag contains the complete file name,
including the path in the following form:
C:\users\<UserName>\Documents\Osmosis_ + StartTime + _Messages.csv
Use the following code to read the current system time and set this time as the start
time. In the application example, the start time is used to generate the file name and
Siemens AG 2018 All rights reserved
No. Action
3. Then, use the following code to generate the file system object (fso) and the file
object (f) using the previously formed path and file name (path). Before doing so,
the system checks whether the file already exists and, if this is the case, processing
the function is terminated after displaying a message.
'Create FileSystemObject and *.csv file if it not exist:
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(path) Then
fso.CreateTextFile(path)
Else
MsgBox "File already exist:" & vbCrLf & path
Exit Sub
End If
Then the .csv file opens with the TextStream object (ts) for writing.
'Create File-Object and open this File
Set f = fso.GetFile(path)
Set ts = f.OpenAsTextStream(2,-2)
'iomode = 2, Writing
'format = -2, TristateUseDefault
'*.csv-File is now ready for Writing
Siemens AG 2018 All rights reserved
A set of SQL commands is created to query the alarm archive data. A message
archive data record is structured according to Fehler! Unbekanntes
Schalterargument.. The field names can be accessed directly in the SQL query.
Table 2-10
FieldNo. Field name Type Meaning
1 MsgNr (4-byte) integer Alarm number
2 State Small 2-byte integer Status of the message
3 DateTime 8-byte DateTime Time stamp of the alarm (date,
time without milliseconds)
4 Ms Small 2-byte integer Time stamp of the alarm
(milliseconds)
5 Instance VarChar(255) Instance name of the alarm
6 Flags1 4-byte integer (For internal use only)
7 PValueUsed 4-byte integer Process values used
8-17 PValue1 to 8-byte real Numerical process value 1 to 10
PValue10
18-28 PText1 to PText10 VarChar(255) Process value text 1 to 10
Note Access is also possible without specifying the computer name (.\WinCC).
However, this means lower-performance access.
For transparent access, enter the WinCC project name for “Catalog”, e.g.
“Catalog=WinCC_Project_Name”.
Table 2-11
Parameter Description
ViewName Name of the database table. The table must be specified in the desired
language. For example, the “ViewName” for the five
European languages is:
Parameter Description
Condition Indicates the condition(s) for querying the message archive.
Examples of queries:
DateTime>'2003-06-01' AND DateTime<'2003-07-01'
DateTime>'2003-06-01 17:30:00'
MsgNr = 5
MsgNr in (4, 5)
State = 2
Note
Only absolute time values can be used for DateTime.
Example:
The “CommandText” reads all German entries of alarm number 5 acquired after
01.01.2016:
“ALARMVIEWEX:Select * FROM ALGVIEWEXDEU WHERE MsgNr=5 and DateTime >
‘2016-01-01’”
The languages installed in the WinCC basic system or configured in the WinCC
Text Library are supported. Information on the possible query languages or the
respective “ViewName” is available in the SQL server in the connected alarm
archives in “Views”. “Views” displays all languages with their IDs, e.g.
“ALGVIEWEXENU”, that are supported in the respective archive.
Note The start and stop times can be transferred as absolute or relative values (see
Fehler! Unbekanntes Schalterargument.).
Table 2-12
No. Action
1. Declare the other tags:
'Declaration of Script Tags
Dim Pro 'Provider
Dim DSN 'Data Source Name
Dim DS 'Data Source
Dim ConnString 'Connection String
Dim MachineNameRT 'Name of the PC from WinCC-RT
Dim DSNRT 'Data Source Name from WinCC-RT
Dim Conn 'Connection to ADODB
Dim CommandText 'Command-Text
Dim SqlSec 'Duration of Production-Cycle
Dim SqlMin 'Duration of Production-Cycle
Dim SqlHour 'Duration of Production-Cycle
Dim SqlDay 'Duration of Production-Cycle
Dim SqlMonth 'Duration of Production-Cycle
Dim SqlYear 'Duration of Production-Cycle
Siemens AG 2018 All rights reserved
No. Action
4. The “CommandText” is required to query the data in the WinCC database.
This example records the previously saved start time of the query (selection of the
button). This time must be reformatted to “YYYY-MM-DD hh:mm:ss”.
Here, too, the leading zeros for number values smaller than 10 must be generated
when formatting.
'FormatStarttime for SQL command
‘Format needed for StartTime: yyyy-mm-dd hh:mm:ss
'Date and time 24 hours before
StartTime = DateAdd("h", -24, StartTime)
'Split in years, months, days, hours, minutes, seconds
SqlSec = Second(StartTime)
SqlMin = Minute(StartTime)
SqlHour = Hour(StartTime)
SqlDay = Day(StartTime)
SqlMonth = Month(StartTime)
'Creating leading zeroes
SqlSec = Right("00" & sqlSec,2)
SqlMin = Right("00" & sqlMin,2)
SqlHour = Right("00" & sqlHour,2)
SqlDay = Right("00" & sqlDay,2)
Siemens AG 2018 All rights reserved
No. Action
6. Then the command object is generated and the query is executed with the
previously generated CommandText.
The RecordSet is set to the command object and then set to the first data record in
which the first acquired and therefore oldest alarm is stored.
'Create the recordset, read the records and set the first
recordset:
Set Command = CreateObject("ADODB.Command")
Command.CommandType = 1
Set Command.ActiveConnection = Conn
Command.CommandText = CommandText
Set RecSet = Command.Execute
RecSet.MoveFirst
Note Please note: When using time and date in WinCC and Visual Basic, the date
format depends on the current regional settings in Windows. The VBS code
should be designed so that the date and time can be evaluated independently of
these computer-specific settings.
Siemens AG 2018 All rights reserved
Table 2-13
No. Action
1. The data records are written with the following loop. In the example, the following
Recordset fields are read from the data record and written to the *.csv file.
DateTime (time stamp)
MsgNr (alarm number)
Text1 (event text 1)
Classname (alarm class)
Type name (alarm type)
Before that, a row with the column headers is generated once; this process, too,
considers the currently set Runtime language.
In each run, the RecordSet is set to the next data record.
'write recordsets To *.csv-File
'Header in CSV file
Language = HMIRuntime.Language
Select Case Language
Case 1031 'German = 1031
Siemens AG 2018 All rights reserved
ts.WriteLine
("Datum/Zeit;Meldenr.;Ereignis;Meldeklasse;Meldetyp")
Case 1033 'English = 1033
ts.WriteLine (“Date/Time;MsgNo.;Event;Messages Class;Messages
Type")
End Select
'writing recordsets
Do While Not RecSet.EOF
ts.WriteLine(RecSet.Fields("DateTime").Value & ";" &
RecSet.Fields("MsgNr").Value & ";" &
RecSet.Fields("Text1").Value & ";" &
RecSet.Fields("Classname").Value & ";" &
RecSet.Fields("Typename").Value)
RecSet.MoveNext
Loop
No. Action
2. At the end of the script, the connection to the database is closed and the objects are
released.
' Close all
ts.Close
RecSet.Close
Set RecSet=Nothing
Set Command = Nothing
conn.Close 'Close connection
Set Conn = Nothing
Set fso = Nothing
Set f = Nothing
Set ts = Nothing
3. Save this script.
4. Then the script is available for calling. The script does not required any parameters.
No. Action
1. Open the “ReverseOsmosis.pdl” screen in the Graphics Designer.
2. Open the Properties dialog of the “Export Messages” button and select “Events ->
Mouse -> Mouse Click -> VBS-Action” to open the VBS editor.
3. Create the following code for calling the previously created VBS script:
Sub OnClick(ByVal Item)
WriteArchiveMessagesToCSV
End Sub
4. Save the picture.
2.3 Operation
2.3.1 Export of archived tags using VBS script
Table 2-15
No. Action Remarks
1. Start Runtime.
Note The Excel client is designed as an Excel file and is contained in the application
example as a download.
Figure 3-1
Siemens AG 2018 All rights reserved
WinCC/Connectivity Pack
OLE DB Provider
*.XLS
Excel Client
Archive
This Excel file is a simple tool with which the user can access the process values
and message data archived by WinCC to export it to Excel.
Range of functions
Reading out the data from the WinCC Runtime database of an OS server or a
SIMATIC Process Historian
Individual compiling of the process values and message information
Possibility of interpolation for missing values (process values)
Adjustable time intervals (process values)
Accessing the archives of different languages (messages)
Using filters such as time interval and message type (messages)
Interpreting the wildcards in the message texts (messages)
Note The Excel client is designed for universal use. In this application example, the
reverse osmosis plant serves an exemplary data source.
However, any WinCC archive of any computer can be used as a data source.
To open the script editor of the Excel client, press <Alt> + <F11>.
Note This chapter is only relevant to you if you are interested in the software
implementation or if you want to make changes to the application.
Basic knowledge of VBA programming is assumed.
This section will help you understand the function of the SQL command for reading
out the data. If you have basic knowledge of programming in VBA and the SQL
Siemens AG 2018 All rights reserved
database language, reading this section will enable you to expand the application
in different points if necessary.
Note The SQL command used here contains a modification that is especially required
for communicating with the WinCC OLE DB Provider. Due to this, the command
partly differs from the specified standard.
SQL example
The example below shows an SQL command that uses all filter options of the
application.
"ALARMVIEW: SELECT TOP 65000 * FROM AlgViewEnu WHERE DateTime >
'2009-3-17 0:0:0' AND DateTime < '2009-3-17 23:59:59' AND (CLASS = 1
OR CLASS = 10) AND (Text2 = 'WEIGHT' OR (Text2 = '@2%s@' AND PText2
= 'WEIGHT') ) ORDER BY DateTime ASC"
Table 3-1
1 2
Command element Description Var Opt
ALARMVIEW: The relevant database is the one for Alarmview (provider- (-) (-)
specific supplement).
SELECT * All data fields (columns) in the table or view still to be (-) -
defined are required.
TOP 65000 The number of messages returned by the query is 65000. (-) (-)
FROM AlgViewEnu The data records are located in the x -
“AlgViewEnu” view.
This name contains several pieces of information:
Alg: Prefix for AlarmLogging
View: View (not a table).
Enu: The alarms of the English configuration.
Note:
Unlike a table, a view does not contain data records. It
merely compiles the desired information by means of
references to different tables.
WHERE DateTime > The required messages have occurred in the specified x (-)
Siemens AG 2018 All rights reserved
1
Does the command element change depending on the settings made?
2
Can the element, irrespective of the made settings, be left out?
x – Yes
- – No
(-) – No (relating to the application in unchanged form)
Overview
To change the message language, the user proceeds as described in Fehler!
Unbekanntes Schalterargument.. The language is selected by means of the
“Language” drop-down list the application requests when creating the SQL
command.
The following table provides an overview of the currently available languages, the
associated entries in the drop-down list and the names of the respective views.
Table 3-2
Language Drop-down list entry View name
German German AlgViewDeu
Siemens AG 2018 All rights reserved
Explanation
As you see in the above overview, the view names differ only in their last three
letters that are used to define the message language.
In addition, it becomes clear that the first three letters of the drop-down list entries
correspond to the last three letters of the view names in almost all cases.
Procedure
To create the SQL statement in the required form, the following code is used
(VBAProject -> Microsoft Excel Objects -> Sheet2 -> cmdAlarmRead_Click):
After assigning the constant part of the SQL command, it is checked whether the
selected entry in the drop-down list starts with “Eng”. If this is the case, “Enu” is
added to the command. Otherwise, the first three letters of the drop-down list entry
are added.
Siemens AG 2018 All rights reserved
Adding a language
To add a message language to the existing selection, proceed as follows:
Table 3-3
Step Description
1. Expanding the drop- To expand the drop-down list, edit the initialization
down list statements in the “VBAProject -> Microsoft Excel Objects
-> ThisWorkBook -> Workbook_Open” module.
Add an additional command line in the format
cmbAlarmLang.AddItem "English” to the existing ones.
2. Checking the Use your SQL Server Management Studio to determine
identifiers the name of the view associated with this language.
3. Case 1: No further If the first three letters of your drop-down list entry
change necessary correspond to the last three letters of the view name, no
further change is required.
4. Case 2: Extending the If the letters differ, extend the if command in the code
if command excerpt presented above by a suitable ElseIf element.
Overview
Using the filter for message types has already been described in detail in Fehler!
Unbekanntes Schalterargument.. With the aid of the option box, the individual
types are selected and added to the SQL command when creating it.
Procedure
The following code realizes the necessary expansion of the SQL command
“VBAProject > Microsoft Excel Objects > Sheet2 >
cmdAlarmRead_Click“:
'Apply filter
If chkAlarmAlarms.Value = True Or _
chkAlarmWarnings.Value = True Or _
chkAlarmASPLCMessages.Value = True Or _
chkAlarmOSPLCMessages.Value = True Or _
chkAlarmOperatingMessages.Value = True Or _
chkAlarmSystemMessages.Value = True Then
The program flowchart shown in Figure 3-2 describes the structure of the above
code excerpt. In the application, the area silhouetted in gray is executed once for
each filterable message type, except for the alarms. To improve clarity, this
representative section is included only once.
Figure 3-2
Start
Is
No
filter selected
?
Yes
boolIsFirst = True
Append prefix to strSQL
No
Is
No
element selected
?
Yes
Add suffix to
strSQL
End
Adding a language
To extend the filter elements by an additional message type, follow the instructions
listed in the table below:
Table 3-4
Step Description
1. Unprotecting the Before you can insert the control element necessary for the
sheet extension, you have to remove the Excel sheet protection.
How this is done depends on the version and is described in
the Excel help.
2. Inserting control Insert an additional option box to the already existing ones
element and enter a representative name for it.
Note:
To avoid layout problems, separate the position and size
properties of the control element from the cell properties:
1. Open the “Format -> Control…” menu option.
2. Go to the “Properties” tab.
3. Select “Dont move or size with cells”.
4. Confirm the changes.
3. Extending the Extend the code section shown above by an element of the
source code form:
Siemens AG 2018 All rights reserved
When doing so, change the option box name and the
message type number.
Add the respective condition to the
(If chkAlarmAlarms.Value = True Or …)
higher-level query
(… Or chkAlarmSystemMessages.Value = True …).
Note:
With the aid of SQL Server Management Studio, you find an
overview of the coding of the message types used in the
current project.
1. When starting the application, select your WinCC server.
2. Navigate to the following table (example):
“Databases > CC_OS_1__09_03_19_18_33_31 > Tables
> dbo.MSMsgGroup”
3. For the relevant coding from the “GROUPDAT” column,
refer to this table. The relevant entries are of “TYPE 3”.
4. Protecting the Protect the sheet again. How this is done depends on the
sheet version and is described in the Excel help.
Problem
This application provides the option of displaying all message information
(columns) that is also available in WinCC. However, the archived messages
contain additional information such as “AlarmTag”, “AckType” and “Servername”
that cannot be selected with these settings.
To facilitate understanding, the current implementation is explained first. Based on
this explanation, you are then provided with step-by-step instructions on how the
message structure can be adapted.
Overview
The procedure for adapting the message structure has already been described in
detail in Fehler! Unbekanntes Schalterargument.. The settings are made in a
separate window. After confirming the changes, the workspace of the application is
automatically adjusted.
Siemens AG 2018 All rights reserved
Procedure
The message structure influences the application in most different areas. For the
expansion, it is merely important to know how the necessary basic information is
initialized. All further sequences adapt to the respective settings (as long as they
correspond to the program logic).
Three arrays form the basis for the message structure:
Table 3-5
Array Content
strAlarmDataNames Contains the names that are displayed to the user for
selection. The current entries correspond to the names that
are also used when editing the WinCC message structure
in Graphics Designer.
Note:
These names differ from the ones used in the database.
They are used to provide the user with an intuitive
understanding.
intAlarmRecordSetID Contains the position of each piece of message information
of the record set.
Note:
Siemens AG 2018 All rights reserved
Note:
When adapting the message structure, the width of the
assigned column is automatically adjusted for each
selected piece of message information (see Fehler!
Unbekanntes Schalterargument.). This is done to ensure
optimum display of the messages.
The declaration of the arrays is made with the aid of a constant so that a uniform
structure can be ensured: “VBA-Project -> Modules -> MngAlarmPositions”:
Public strAlarmDataNames(1 To MAX_ALARM_DATA_COLUMNS) As String
This constant corresponds to the number of pieces of message information which
is 38 by default.
The response of the arrays, e.g. during their initialization, occurs via further
constants of which each one corresponds to one message information respectively
“VBA-Project -> Modules -> MngAlarmPositions -> InitializeAlarmArrays”:
strAlarmDataNames(C_DATE_TIME) = "Date / Time"
This improves the readability of the source code and simplifies making changes.
According to their function as an index of the arrays, the constants for the message
information include consecutive numbers “VBA-Project -> Modules -> Constants”
for jointly used constants or “VBA-Project -> Modules -> ConstantsAlarm” for
alarm-specific constants:
Public Const C_DATE_TIME = 1
Public Const C_MS = 2
Public Const C_PRIORITY = 3
The pieces of standard information are sorted according to their sequence in
WinCC Graphics Designer.
Expanding the message structure merely requires that the constants and array
initializations be adapted. To do this, proceed as described in the following table:
Table 3-6
Step Description
1. Adapting the In “VBA-Project -> Modules -> ConstantsAlarm”, enter the
maximum value number of
constant pieces of message information for the MAX_DATA_COLUMNS
constant.
Note:
Via the constant, the application adjusts to the changed
conditions. A correct value for this constant is thus essential.
2. Adding the index In the same module, add as many constants as required to
constants the already existing index constants (e.g., C_PRIORITY).
Note:
Ensure that the new numbers are consecutive and that the
value defined in MAX_ALARM_DATA_COLUMNS is not
exceeded.
3. Extending the The presented arrays are initialized in the “VBA-Project ->
array initialization Modules -> MngPositions -> InitializeArrays” module.
Insert as many elements into each of the three arrays as
pieces of message information you want to add and fill them
with the associated data (see Fehler! Unbekanntes
Schalterargument.).
Storage location
The application does not have to be installed separately. Copy the “OLE-DB Tag
and Alarm Export_V9.xls” file directly to your desired location. The Excel file
contains the entire source code in the form of macros that are run in the
background.
Figure 3-3
Siemens AG 2018 All rights reserved
The reason for this warning is that your macro security level is set to “High”.
Change it if required.
Overview
Fehler! Unbekanntes Schalterargument. and Fehler! Unbekanntes
Schalterargument. show the application after it has been opened. Which interface
is displayed depends on which tab was active during the last storing process. The
entries are also those available when it was last saved.
Figure 3-4
Figure 3-5
Siemens AG 2018 All rights reserved
You can switch between “Tags” and “Alarms” by selecting the respective tab at the
bottom edge of the Excel window.
Figure 3-6
Siemens AG 2018 All rights reserved
Workspace structure
Representing both tabs the structure of the workspace is illustrated here as the
“Alarms” tab.
Figure 3-7
Siemens AG 2018 All rights reserved
Each of the three selected sections performs its own function, which is described in
the following Fehler! Unbekanntes Schalterargument..
Table 3-7
Area Function
Toolbar All required settings are made using the toolbar. These
settings include the selection of the data source and the
definition of message filter or process filter.
For a more detailed description of this section, please refer to
Fehler! Unbekanntes Schalterargument..
Column Headers The column headers define the structure of the displayed
messages.
Note:
You can adapt both the sequence and the structure as
desired. The exact procedure is described in Fehler!
Unbekanntes Schalterargument..
Messages This section contains the read out messages or process
(“Tags” tab: values with your selected structure.
process values)
Note The boxes of the “Toolbar” and “Column Headers” sections are protected to
avoid unintended changes. To ensure that the application’s operating capability
remains unaffected, we recommend that this protection be left unchanged.
In the toolbar, you make all settings that are necessary to display your desired data
in a format of your choice. The design of the toolbar can be subdivided into three
sections (illustrated in Fehler! Unbekanntes Schalterargument. as an example
for the “Alarms” tab):
The basic settings which – once they have been set – remain unchanged for
the entire session in most cases
The filter which allows to describe the required archive data in greater detail
and to thus improve the search result
The action section from which the adaptation of the structure of the displayed
messages (selection of the message blocks) or process values (selection of
static values) and the actual read action can be started.
Each of these sections includes several control elements that are described in
greater detail later in the instructions for operating the application in 3.4.
Figure 3-8
Siemens AG 2018 All rights reserved
The representation of the received archive data varies and enables you to define a
structure which is ideal for you. For process values different static functions can be
executed for example, and their results be displayed.
The table view for displaying the messages is based on the journal list of the
WinCC alarm system. Similar to the original, the display of the different message
blocks can be designed individually (see Fehler! Unbekanntes
Schalterargument.).
3.4 Operation
This section describes how process values and messages can be read out from
the archive. With the exception of the explanation of the filter, this is performed
exemplary at the procedure for messages, since the treatment of process values
differs very little.
Table 3-8
No. Description
1. Start the application.
Note:
After starting the application, it is possible that it does not respond for a short
period of time. This is due to the fact that the network is busy and that the listing of
available computers progresses only slowly.
If several subnets exist, only members of the own work group are determined.
Nevertheless, you can also access computers which are not displayed, as long as
there is a valid connection to them.
You only need to enter the name of the target computer into the text field of the
dropdown menu “Host”.
2. If required, enable macros.
Siemens AG 2018 All rights reserved
In the basic settings, you make settings that in most cases remain identical for the
entire session. This includes defining the source computer and the message
language.
Table 3-9
Description Control element
1. Select the “Alarms” tab.
Note:
It is required that WinCC Runtime be started
on the computer specified here since the
WinCC OLE DB Provider communicates with
its services.
In addition, it must be observed that only the
data is read that is locally available on this
Siemens AG 2018 All rights reserved
Note:
The language selection is not available for
process values.
The filter settings enable you to reduce the returned archive data to the ones you
are actually interested in with regard to tag, time range, time interval (process
values) or time, type and origin (messages). Differences between the procedure for
process values and messages are explained in parallel steps.
Table 3-10
Description Control element
1. In the two input boxes, define the time range
in which the archive data you are searching
for has occurred.
Ensure that the start time is before the end
time.
By default, the current date from 0 - 24 h is
set.
Note:
Time and date have to be entered in a
specific form:
YYYY-MM-DD hh:mm:ss
In addition, it must be ensured that the input
is intrinsically logical (e.g., no February 30, no
70 minutes or similar inputs). If the value is
Siemens AG 2018 All rights reserved
Note:
To be able to perform reading, the relevant
host must have previously been selected.
Error handling:
If the following message is displayed,
communication with the database has failed:
“Area” / “Tag determination failed” + error
description.
Possible causes are:
Network problems (host not accessible)
Insufficient access rights (same user and
same passwords required)
OS not in Runtime
Once you have read out the information, the
respective drop-down list provides them to
you.
3. For the “Tags” tab:
In the dropdown list “Archive Tags” you select
the process value whose archived values you
wish to read out.
Note:
To reduce the amount of read out processed
values without losing too much information,
the time interval can be used.
The time interval enables to summarize all
process values which have occurred in a
certain time interval (e.g. all values in a
minute or hour). For this amount of values
evaluations can then be made (e.g. maximum
value, minimum value, total). This principle is
illustrated in Fehler! Unbekanntes
Schalterargument..
For the “Alarms” tab:
For filtering by different types (classes) of
messages, a total of six option boxes are
available to you that can be combined as
desired. When nothing is selected, filtering by
messages is disabled.
Siemens AG 2018 All rights reserved
Note:
The interpolation requires a time interval
unequal zero.
Note You should use the filter options to limit the selection criteria to the largest extent
possible. By doing so, you reduce the number of relevant archive data and thus
the access time to the database and the subsequent processing time.
For messages, the number of returned data records is additionally restricted to
65000 by the SQL.
Figure 3-9
Assuming the archiving of the process values occurs every second, then the list of
Siemens AG 2018 All rights reserved
The adaptation of the message structure (selection of the message blocks) allows
you to individually display the received messages in the way that suits you best.
If the message structure is as desired, you can skip this point.
Figure 3-10
Siemens AG 2018 All rights reserved
The table below describes how you can adapt the message structure to meet your
individual requirements.
Table 3-11
Description Control element
1. Click on the “Adapt Structure” button.
The “Data Selection” dialog box is opened.
2. In the left list (“Available Data”), select the
element you want to add to the selection and
click on the “->” button.
New elements of the right list (“Selected
Data”) are always inserted after the currently
selected element in this list.
Note:
Adapting the data structure deletes all
currently listed messages. After confirming
the changes, no additional prompt is
displayed.
5. After confirming the changes, all column
Siemens AG 2018 All rights reserved
Note:
If you have not selected a column for display,
the later read process is cancelled
prematurely. The status line displays the text
“No Data to be read”.
Note When starting the application, it automatically determines the settings last used
for the message structure from the entries in the “Column Headers” section of
the workspace.
When selecting the information for process values, ensure that any information
there, apart from the time stamp and the quality code, triggers its own read
process. The cause for this lies in the functionality of the respective SQL query.
Instruction
After you have made all settings, you can now read the desired messages from the
archive.
Table 3-12
Description Control element
1. Click on the “Read” button to read out the
messages from the archive that correspond to
the filter.
Watch out:
Using the “Read” button deletes all currently
listed messages. There is no additional
prompt.
Note:
Listing the messages can be aborted by
pressing the ESC key.
2. If necessary, back up the read data
separately.
Siemens AG 2018 All rights reserved
Note After triggering the read command, the SQL query is first created and executed.
During this time, the application is not reactive since it has to wait for a response
of the SQL server. Depending on the number of requested messages, this can
last up to several minutes.
Subsequently, the individual messages are prepared (replacing the wildcards)
and listed. During this process, the update of the workspace is disabled to
increase message throughput, the status bar displays the progress of the
process.
Reading error
– Action:
Opening the database and reading out the messages
– Message:
“Error during Open” + error description
– Possible cause:
WinCC is not in Runtime on the server.
Siemens AG 2018 All rights reserved
Processing error
– Action:
Sorting and interpreting the message blocks, entering the messages
– Message:
“Error during Processing” + error description
– Possible cause:
The structure of the database and thus the structure of the returned
messages have changed.
Table 4-1
No. Action
Siemens AG 2018 All rights reserved
1. Start the WinCC explorer. Open the WinCC project. Activate Runtime.
Use the “Reverse-Osmosis” button to go to the “ReverseOsmosis.Pdl” screen.
Select “STARTUP” to start the reverse osmosis plant. Wait until the plant has
reached the “Production” status.
After an operating time of several minutes, press the “SHUTDOWN” button to
shut down the plant.
Create a “TagsToCSV.csv” and “AlarmsToCSV.csv” file without content in the
directory of your choice.
2. In “Start > Programs > Microsoft SQL Server”, select “SQL Server Management
Studio”.
3. Log on.
In “Server type”, select “Database Engine”. In “Server name”, select
“<YourComputerName>\WINCC” and in “Authentication”, select “Windows
Authentication” (the current user will be used).
Use the “Connect” button to connect to the SQL server.
No. Action
4. Right-click “Databases > CC_ExternalBrowsing” for runtime data and archive
data.
Select “Tasks > Export Data” to start the SQL Server Import and Export
Wizard.
Siemens AG 2018 All rights reserved
No. Action
6. In “Data source”, select the “WinCC OLE DB Provider for Archives” and then select
the “Properties” button.
7. Enter “.\WinCC” as the data source and the name of the WinCC Runtime
database as the catalog.
Enter “CC_ExternalBrowsing” as WinCC Runtime database.
Then select the “OK” and “Next” buttons to exit the dialogs.
Siemens AG 2018 All rights reserved
No. Action
8. In “Destination”, select “Flat File Destination” and the file “TagsToCSV.csv” (for
tag export).
Check “Column names in the first data row” to write the column headers to the
first row of the *.csv file.
Select the “Next” button to exit the dialog.
Siemens AG 2018 All rights reserved
9. Check “Write a query to specify the data to transfer” to specify the SQL query in
the next dialog.
Use the “Next” button to continue the wizard.
No. Action
10. Now enter the desired SQL query. The query structure corresponds to the
description in chapter Fehler! Unbekanntes Schalterargument. and chapter
Fehler! Unbekanntes Schalterargument..
In this example, the “QI900_ConductivityPearmeatIn” archive tag from the
process value archive is queried over a period of the last 30 minutes:
“TAG:R,‘ProcessValueArchive\QI900_ConductivityPermeatIn’,‘0000-00-00
00:30:00.000’, ‘0000-00-00 00:00:00.000’”
Notice
When entering the text string in American format, observe the format for
inverted comma and quotation marks (see figure).
Then use the “Next” button to exit the dialog.
Siemens AG 2018 All rights reserved
No. Action
11. In “Column delimiter”, select “Semicolon”.
Siemens AG 2018 All rights reserved
No. Action
13. Then check “Save SSIS Package” in the Windows file system without the protection
function and select “Next” to exit the dialog.
Siemens AG 2018 All rights reserved
Note
A protection function is not required for the sample project. In productive mode, this
function should be set up as required by the application.
14. Enter the file name and location for the “SSIS package” and click on “Next”.
No. Action
15. The following screen summarizes the configured parameters. Start the export with
the “Finish” button.
Siemens AG 2018 All rights reserved
Note Instead of the tag name, you can also use the ValueID to access the archive.
This provides higher performance than the symbolic name (e.g., “TAG:R,4,‘0000-
00-00 00:30:00.000’, ‘0000-00-00 00:00:00.000’”).
A list of ValueIDs allows you to query multiple archive tags with one SQL
command. In the SQL command, this list is put in parentheses, the ValueIDs are
separated by semicolons.
(e.g. “TAG:R,(4,8,12),‘0000-00-00 00:30:00.000’, ‘0000-00-00 00:00:00.000’”).
For the ValueID of the archive tags, please refer to the “dbo.Archive” table. Use
the “Select Top 1000 Rows” context menu to open this “Tables>dbo.Archive”.
Note When entering the text string in American format, observe the format for inverted
comma and quotation marks.
5 Valuable Information
5.1 Basics
5.1.1 SIMATIC WinCC/Connectivity Pack
This document and the associated sample project specifically describe the benefits
and use of the WinCC OLE DB Provider. Aside from access to process value and
alarm archives, it provides additional analysis functions to determine, for example,
the minimum and maximum of archive tags.
WinCC V6.0 or higher segments the WinCC archive databases and stores them in
binary, encrypted format. The WinCC OLE DB Provider allows the user to
transparently provide this data in readable form. When accessing this data, the
user is not required to take decryption measures or consider segmentation.
Via the Provider the WinCC/Connectivity Pack Client has direct access to the
archive data. It is therefore irrelevant whether the data is compressed or
uncompressed.
Table 5-1
WinCC
2 Function for data
Product integrated Option Add-on
1 exchange
Note:
WinCC V7.4 or higher
supports *.txt, *.csv, *.html,
*.xml formats.
SIMATIC Information - - x Allows the user to save
Server reports in different formats,
including *.xls format.
PM-OPEN EXPORT - - x Export of online values and
archive data to text files
(*.ascii, *.csv, *.html, *.xml)
1
SIMATIC WinCC RT / RC – license sufficient
2
Add-ons are products from our Premium Add-On Partners
6 Annex
6.1 Service and support
Industry Online Support
Do you have any questions or need support?
Siemens Industry Online Support offers access to our entire service and support
know-how as well as to our services.
Siemens Industry Online Support is the central address for information on our
products, solutions and services.
Product information, manuals, downloads, FAQs and application examples – all
information is accessible with just a few mouse clicks at
https://support.industry.siemens.com
Technical Support
Siemens Industry's Technical Support offers quick and competent support
regarding all technical queries with numerous tailor-made offers
– from basic support right up to individual support contracts.
Please address your requests to the Technical Support via the web form:
www.siemens.de/industry/supportrequest
Siemens AG 2018 All rights reserved
Note Basics can be acquired in the “SIMATIC WinCC, system course” in the SITRAIN
series.
SIMATIC WinCC, Systemkurs (de)
SIMATIC WinCC, System Course (en)
Topics for cross-system communication using the WinCC/Connectivity Pack are
discussed in the “SIMATIC WinCC advanced course”, among many other topics.
SIMATIC WinCC, Aufbaukurs (de)
SIMATIC WinCC, advanced course (en)
Service offer
Our service offer includes:
Plant Data Services
Spare Parts Services
Repair Services
On Site and Maintenance Services
Retrofit & Modernization Services
Service Programs and Agreements
Detailed information on our service offer is available in the Service Catalog:
https://support.industry.siemens.com/cs/sc