TIA Openness GettingStartedAndDemo V14SP1 en

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

TIA Portal Openness:

Introduction and
Demo Application
Siemens
TIA Portal V14 SP1 Industry
Online
https://support.industry.siemens.com/cs/ww/de/view/108716692 Support
Warranty and liability

Warranty and liability

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
 Siemens AG 2017 All rights reserved

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
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
informa- support the 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.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 2
Table of Contents

Table of Contents
Warranty and liability ................................................................................................... 2
1 Task ..................................................................................................................... 4
2 Solution............................................................................................................... 5
2.1 Overview............................................................................................... 5
2.2 Hardware and software components ................................................... 5
2.2.1 Validity .................................................................................................. 5
2.2.2 Components used ................................................................................ 5
3 Mode of Operation ............................................................................................. 7
3.1 TIA Portal Openness ............................................................................ 7
3.1.1 Range of functions ............................................................................... 7
3.1.2 Restrictions ........................................................................................... 9
3.2 "StartOpenness" application example .................................................. 9
3.3 "DemoOpenness" application example ................................................ 9
4 Creating a New TIA Portal Openness Application ....................................... 10
4.1 Installing TIA Portal Openness ........................................................... 10
4.2 Managing user rights .......................................................................... 10
4.3 Creating a project ............................................................................... 12
4.4 Configuration file/AssemblyResolve ................................................... 13
4.5 Permitting access ............................................................................... 14
 Siemens AG 2017 All rights reserved

5 StartOpenness ................................................................................................. 15
5.1 Overview............................................................................................. 15
5.2 "TIA Portal" group ............................................................................... 17
5.3 "Project" group ................................................................................... 18
5.4 "Add" group ........................................................................................ 19
5.5 "Compile" group ................................................................................. 20
6 TIA Openness Demo ........................................................................................ 21
6.1 General ............................................................................................... 21
6.2 Application examples ......................................................................... 21
6.3 Methods .............................................................................................. 22
6.4 Description of the application ............................................................. 23
6.4.1 General settings ................................................................................. 23
6.4.2 Flexible AssemblyResolve ................................................................. 24
6.4.3 TIA Portal functions ............................................................................ 24
6.4.4 Project functions ................................................................................. 26
6.4.5 Importing/exporting objects ................................................................ 29
6.4.6 Libraries .............................................................................................. 31
6.4.7 PLC..................................................................................................... 32
7 Related literature ............................................................................................. 35
8 History............................................................................................................... 35

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 3
1 Task

1 Task
Introduction
In STEP 7 or WinCC V14 SP1 TIA Portal Openness is included in the delivery of
STEP 7 or WinCC in TIA Portal. This enables you to program the applications
which automate the engineering in TIA Portal.

Overview of the automation task


Figure 1-1
 Siemens AG 2017 All rights reserved

Public API

Own Import/
program Export

Scenarios
 Based on a text database, project texts are to be complied program-controlled
automatically and applied in the TIA Portal project. This way, you can quickly
use standardized texts in new projects.
 The visualization is to be created automatically with the help of exported PLC
data.
 Project statistics or backups can be created automatically. With the help of
your program you can check whether programming guidelines were met.
 Projects can be automatically compared with global libraries and if required,
updated and compiled.
 The offline project can be automatically compared with the online projects in
order to ensure plant consistency.
 With the help of a tool the entire project is to be created based on prefabricated
project parts.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 4
2 Solution

2 Solution
2.1 Overview
Advantages
The solution presented here, offers you the following advantages
 More efficiency by executing the task faster
 Accuracy by automating constant processes
 Short commissioning times through configuration setup
 Competitiveness by targeted use of resources

Delimitation
This application does not contain a description of:
 Basics on object-oriented programming
 Basics on programming environment, such as e.g. Microsoft Visual Studio
 Basics on TIA Portal configuration
Basic knowledge of these topics is assumed.
 Siemens AG 2017 All rights reserved

2.2 Hardware and software components


2.2.1 Validity

This application is valid for


 STEP 7 / WinCC TIA Portal V14 SP1

2.2.2 Components used

The application was created with the following components:

Software components
Table 2-1
Component No. Article number Note
STEP 7 Professional 1 6ES7822-1AA04-0YA5
V14 SP1
WinCC Advanced 1 6AV2102-0AA04-0AA5
V14 SP1
TIA Portal Openness 1 Included in the delivery of STEP
7 or WinCC V14 SP1 (in
subfolder "Support" of the
installation files)
Microsoft Visual 1
Studio 2015

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 5
2 Solution

Example files and projects


The following list includes all files and projects that are used in this example.

Table 2-2
Component Note
108716692_TiaPortalOpennessDemo_V14 Demo application for the use of TIA
SP1.zip Portal Openness (see chapter 6)
108716692_StartOpenness_V14SP1.zip Introductory example for the use of TIA
Portal Openness (see chapter 5)
108716692_TIA_Openness_GettingStartedAnd This document.
Demo_V14SP1_en.pdf
 Siemens AG 2017 All rights reserved

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 6
3 Mode of Operation

3 Mode of Operation
3.1 TIA Portal Openness
In STEP 7 or WinCC V14 SP1 TIA Portal Openness is available for free on the
respective product DVDs. Prerequisite for the use is an installation of STEP 7 or
WinCC V14 SP1.
TIA Portal Openness provides DLLs via which you can access the TIA Portal
platform. These DLLs are based on .NET Framework 4.6.1.

3.1.1 Range of functions

Table 3-1
Further
Device Function see
information/restrictions
Throughout Opening TIA Portal P. 24
the project
Throughout Closing/separating TIA P. 25
the project Portal
Throughout Connecting TIA Portal P. 24
the project process
 Siemens AG 2017 All rights reserved

Throughout Opening project P. 26


the project
Throughout Saving project P. 26
the project
Throughout Closing project P. 26
the project
Throughout Numerating devices and P. 27
the project subnets
Throughout Opening network and P. 27
the project topology editor
Throughout Creating folder P. 28
the project
Throughout Deleting elements P. 29
the project
Throughout Exporting/importing project P. 29
the project graphics

Libraries Opening global library P. 31


Libraries Closing global library P. 31
Libraries Types: Update check of P. 32
instances

HMI Compiling hardware and/or P. 29


software
HMI Exporting screen as XML P. 29 Restrictions: TIA Portal
Openness help chap. 8.3.7.1
Overview of exportable screen
objects
HMI Importing screens from P. 29
XML
HMI Exporting of the screen P. 29 Exception: Pop-up and slide-in

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 7
3 Mode of Operation

Further
Device Function see
information/restrictions
management as XML windows
HMI Importing elements of the P. 29 Exception: Pop-up and slide-in
screen management from windows
XML
HMI Exporting tags/tag tables as P. 29
XML
HMI Importing tags/tag tables P. 29
from XML
HMI Exporting connections as P. 29 Non-integrated connections
XML
HMI Importing connections from P. 29 Non-integrated connections
XML
HMI Exporting scripts as XML P. 29
HMI Importing scripts from XML P. 29
HMI Exporting cycles as XML P. 29
HMI Importing cycles from XML P. 29
HMI Exporting text and graphic P. 29
lists as XML
HMI Importing text and graphic P. 29
 Siemens AG 2017 All rights reserved

lists from XML

PLC Compiling hardware and/or P. 29


software
PLC Connecting/separating P. 32
controller online
PLC Online/offline comparison P. 33
PLC Offline/offline comparison P. 33
PLC Displaying blocks in the P. 27
editor
PLC Exporting blocks as XML P. 29 No SCL blocks
PLC Importing blocks from XML P. 29 Only with enabler file
PLC Importing external sources P. 33
PLC Generating blocks from P. 34
sources.
PLC Generating sources from P. 34 STL and SCL blocks
blocks
PLC Displaying tag tables and P. 27
data types in the editor
PLC Exporting tag tables and P. 29
data types as XML
PLC Exporting tag tables and P. 29
data types as XML
PLC Exporting individual tags P. 29

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 8
3 Mode of Operation

3.1.2 Restrictions

 With TIA Portal Openness V14 SP1 you can only access projects and libraries
with version V14 SP1. If required, upgrade your project or your library before
using TIA Portal Openness.
 Compatibility between the TIA Portal Openness versions cannot be
guaranteed. A new version may require changes in your program.
 At present, it is not possible to access the WinCC Runtime Professional
configuration or the data from Startdrive objects via TIA Portal Openness.

3.2 "StartOpenness" application example


The "StartOpenness" program is to facilitate access to programming your first
independent Openness application.
Some basic functions are already programmed in the program (e.g. starting TIA
Portal) so that you can develop your own applications, based on this.

3.3 "DemoOpenness" application example


The "Demo_Openness" program includes many fully programmed functions of TIA
 Siemens AG 2017 All rights reserved

Portal Openness. This is to give you a function overview as well as detailed


programming help.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 9
4 Creating a New TIA Portal Openness Application

4 Creating a New TIA Portal Openness


Application
4.1 Installing TIA Portal Openness
In STEP 7 or WinCC V14 SP1 TIA Portal Openness can be installed via the
product DVD.

Table 4-1
No. Action
1. Open the STEP 7 or WinCC V14 SP1 product DVD. Start the installation setup
"Siemens_TIA_Openness_V14SP1" in the "Support" folder.
2. Follow the instructions of the installation setup.

4.2 Managing user rights


In order to use or create a TIA Portal Openness application, the user has to be
added to the "Siemens TIA Openness" user group.
 Siemens AG 2017 All rights reserved

Table 4-2
No. Action
1. Right click "Computer" in the windows taskbar and select "Manage".

2. Open "Local Users and Groups and Groups > Users" and double click the user.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 10
4 Creating a New TIA Portal Openness Application

No. Action
3. Go to the "Member Of" tab and click the "Add" button.

4. Enter "Siemens TIA Openness" and confirm by pressing OK.


 Siemens AG 2017 All rights reserved

5. Close the opened dialog boxes and log in again.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 11
4 Creating a New TIA Portal Openness Application

4.3 Creating a project


Table 4-3
No. Action
1. Create a new project (e.g. in Microsoft Visual Studio).
2. Create the references for the Openness DLLs ((Siemens.Engineering.dll and
Siemens.Engineering.HMI.dll). They are located in the TIA Portal installation
directory in "... > Siemens > Automation > Portal V14 > PublicAPI > V14 SP1".
3. Set the property "Copy Local" of the two DLLs to "False".
 Siemens AG 2017 All rights reserved

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 12
4 Creating a New TIA Portal Openness Application

4.4 Configuration file/AssemblyResolve


To detect the path of the Openness DLLs, you can either use a configuration file or
the "AssemblyResolve" event.
Table 4-4
No. Action
1. Configuration file
If you have selected a different path for the installation of WinCC or STEP 7 (TIA
Portal), replace the default path in the configuration file by your installation path.
Store the application configuration file in the same directory as the Openness
application.
2. AssemblyResolve
In order to establish the connection to the TIA Portal, the "AssemblyResolve"
method was used here.
 Siemens AG 2017 All rights reserved

The installation path of the TIA Portal is read out of the registry so that the
program can be used irrespective of the installation path.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 13
4 Creating a New TIA Portal Openness Application

4.5 Permitting access


Table 4-5
No. Action
1. When starting your application for the first time, the following security message
will appear:

System manual
(https://support.industry.siemens.com/cs/ww/en/view/109477163)
 Siemens AG 2017 All rights reserved

2. Confirm the message with "Yes" in order to permit the access once.
Confirm the message with "Yes to all" in order to always permit access to this
application.
Click "No" to deny the access.

Note If you are working with Microsoft Visual Studio, it can happen that you will
receive the message, although you have already clicked "Yes to all". In order to
avoid this, follow the instructions in entry \5\.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 14
5 StartOpenness

5 StartOpenness
5.1 Overview
The "StartOpenness" program is to facilitate access to programming your first
independent Openness application.

Note You find a ready compiled "exe"-file in the download


"108716692_StartOpenness_V14.zip" with the path
"…\StartOpenness\StartOpenness\bin\Debug".

Figure 5-1
 Siemens AG 2017 All rights reserved

The status information is output via the text field (1).

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 15
5 StartOpenness

Table 5-1
No. Action
1. Open the project "StartOpenness".
2. Open the "Form1" class.

3. In order to establish the connection to the TIA Portal, the "AssemblyResolve"


method was used here.
4. Two tags were created:
 Siemens AG 2017 All rights reserved

 "MyTiaPortal" of the "TiaPortal" type


 "MyProject" of the "Project" type

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 16
5 StartOpenness

5.2 "TIA Portal" group


Figure 5-2

Table 5-2
No. Description
1. Select whether the TIA Portal is to be started with or without user interface via
the option boxes "With User Interface" and "Without User Interface".
 Siemens AG 2017 All rights reserved

In the "StartTIA()" method, the state of the option boxes is requested.

2. Click the "Start TIA" button in order to start the TIA Portal.
The "StartTIA()" method is called.
The "MyTiaPortal" tag is assigned a new TIA Portal instance.

3. Click the "Dispose TIA" button in order to end the TIA Portal or the connection to
the TIA Portal.
The "DisposeTIA()" method is called.
With "mytiaportal.Dispose()" the connection to the TIA Portal is terminated (if the
TIA Portal was not started with the user interface) or the TIA Portal was
terminated (if the TIA Portal was started without user interface).

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 17
5 StartOpenness

5.3 "Project" group


Figure 5-3

Table 5-3
No. Description
1. Click the "Open Project" button in order to open a new project. Select the project
 Siemens AG 2017 All rights reserved

you would like to open in the file browser.


The "SearchProject()" method is called.
The file browser is opened. If a project has been selected the "OpenProject()"
method is called.

The "MyProject" project tag is initialized via "MyTiaPortal.Projects.Open(new


FileInfo(ProjectPath))".

2. Click the "Connect to Open TIA Project" button in order to connect to an open
TIA Project.

3. Click the "Save Project" button to save the project.


The "SaveProject()" method is called.
The project is saved via "MyProject.Save()".

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 18
5 StartOpenness

No. Description
4. Click the "Close Project" button to close the project.
The "CloseProject()" method is called.
The project is closed via "MyProject.Close()".

5.4 "Add" group


Figure 5-4

3
 Siemens AG 2017 All rights reserved

Tabelle 5-4
Nr. Beschreibung
1. Enter in the text field the name of the device you would like to add.
2. Enter in the text field the order number of the device you would like to add.
3. Enter in the text field the version of the device you would like to add.
4. Click the "Add Device" button to add the device.
The "btn_AddHW_Click()" is called.
If no device with the entered name is found, the device is added and output in the
status field.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 19
5 StartOpenness

5.5 "Compile" group


Figure 5-5

Table 5-5
No. Description
1. Enter in the text field the name of the controller or the operator panel you would
like to compile.
 Siemens AG 2017 All rights reserved

In the method Compile() the name of all devices and their DeviceItems are
compared with the entered names.

2. Click the "Compile" button in order to compile the device.


The "Compile()" method is called.
If a controller or an operator panel with this name is found, the device is
compiled. The result is saved in the "result" tag of the "CompilerResult" type and
output via the status field.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 20
6 TIA Openness Demo

6 TIA Openness Demo


6.1 General
The "TIAPortalOpennessDemo" application consists of two projects.
 TiaOpennessHelper
Some, especially the recurring methods were realized in the
"TiaOpennessHelper". With the help of a reference to "TiaOpennessHelper.dll",
you can use these methods in your own applications.
 TIAPortalOpennessDemo
The demo application is to give you an overview of the functions that can be
used with TIA Portal Openness. Due to the multitude of fully programmed
examples, the application also provides detailed help for programming.
Below, you will find two directories which are to make handling of the application
easier. If you are looking for a specific function or a specific application, you can
use one of the following directories.
In order to comprehend the description start the "TIAPortalOpennessDemo.exe"
program and open the project with Microsoft Visual Studio.

Note You find a ready compiled "exe"-file in the download


 Siemens AG 2017 All rights reserved

"108716692_TiaPortalOpennessDemo_V14SP1.zip" with the path


"…\TiaPortalOpennessDemo_V14SP1\TIAPortalOpennessDemo\TIAPortalOpen
nessDemo\bin\Release".

6.2 Application examples


Flexible AssemblyResolve ................................................................. 24
Starting the TIA Portal........................................................................ 24
Connecting with the active TIA Portal instance ................................. 24
Separating from TIA Portal ................................................................ 25
Opening/saving/closing project .......................................................... 26
Reading out devices .......................................................................... 27
Opening editors .................................................................................. 27
Creating folder ................................................................................... 28
Deleting elements .............................................................................. 29
Compiling .......................................................................................... 29
Importing/exporting objects ................................................................ 29
Opening/closing global libraries ......................................................... 31
Update check ..................................................................................... 32
Online connection to controller .......................................................... 32
Comparing controllers ........................................................................ 33
Integrating external sources .............................................................. 33
Generating block from source ............................................................ 34
Generating source from block ............................................................ 34

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 21
6 TIA Openness Demo

6.3 Methods
CompareTo(Object) ........................................................................... 33
CompareToOnline() ........................................................................... 33
CreateFromFile(sourcename, filename) ............................................ 34
Delete() .............................................................................................. 29
ShowInEditor ...................................................................................... 28
Compile() ........................................................................................... 29
Dispose() ............................................................................................ 25
Export(path, exportOption) ................................................................ 30
Groups.Create(FolderName) ............................................................. 28
GenerateBlockFromSource() ............................................................. 34
GenerateSourceFromBlocks(blocklist, filepath) ................................ 34
TiaPortal.GetProcesses() .................................................................. 25
GlobalLibraries.Open(fileName) ........................................................ 32
GoOffline() ......................................................................................... 33
GoOnline() ......................................................................................... 33
Import(file, importOption) ................................................................... 30
 Siemens AG 2017 All rights reserved

Project.Close() ................................................................................... 26
Project.Save() .................................................................................... 26
Project.ShowHwEditor(Siemens.Engineering.HW.View.Network) .... 28
Project.ShowHwEditor(Siemens.Engineering.HW.View.Topology) .. 28
Projects.Open(new FileInfo(filename)) .............................................. 26
process.Attach() ................................................................................. 25
ShowInEditor ...................................................................................... 28
TiaPortal ............................................................................................. 24
UpdateCheck ..................................................................................... 32

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 22
6 TIA Openness Demo

6.4 Description of the application


6.4.1 General settings

Table 6-1
No. Action
1. Click the "File->Settings".
 Siemens AG 2017 All rights reserved

2. Select whether the TIA Portal is to be started with or without user interface.
3. Select the export settings.
4. Select the default path for the export and import files.
5. Click the "Save" button to save the settings.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 23
6 TIA Openness Demo

6.4.2 Flexible AssemblyResolve

Open the "General.cs" class of the "TiaOpennessHelper" project.


In order for you to be able to use the application on any PC with the TIA Portal, the
TIA Portal installation path is read out from the registry and is thus passed on
flexibly.

6.4.3 TIA Portal functions

Starting the TIA Portal


You can open a new TIA Portal instance via "File > Start TIA Portal". Depending on
your settings the TIA Portal is started with or without user interface.

Figure 6-1
 Siemens AG 2017 All rights reserved

Open the "OpenTiaPortalCommand_Executed" method in the


"MainWindowViewModel.cs" class.
The "tiaPortal" tag from the "TiaPortal" type is initialized. With the parameter
"TiaPortalMode.WithoutUserInterface" or "TiaPortalMode.WithUserInterface" you
specify whether the TIA Portal is started with or without user interface.

Connecting with the active TIA Portal instance


Via the "File->Connect Portal" the active TIA Portal instances are displayed.

Figure 6-2

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 24
6 TIA Openness Demo

Figure 6-3

By clicking the instance, the demo application connects with this instance.
 Siemens AG 2017 All rights reserved

Open the "CreateInstanceTreeView" method in the "MainWindowViewModel"


class.
For this purpose the "TiaPortal.GetProcesses()" method is used.
In the "ShowConnectCommand_Executed" method, the connection to the selected
instance is established.
For this purpose, the TIA Portal tag is assigned a value via "process.Attach()".

Separating from TIA Portal


You can end the connection to the TIA Portal instance again via "File > Dispose
TIA Portal". If you have started the TIA Portal instance without user interface, the
instance is terminated. Otherwise the connection between your application and the
TIA Portal instance is terminated.

Figure 6-4

Open the "DisposeTiaPortalCommand_Executed" method in the


"MainWindowViewModel.cs" class.
The connection is separated via the "Dispose()" method of the TIA Portal tag.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 25
6 TIA Openness Demo

6.4.4 Project functions

Opening/saving/closing project
If no project is opened yet, you can open a project via "File > Open project".
Figure 6-5

Open the "OpenProjectCommand_Executed" method in the


"MainWindowViewModel.cs" class.
For this purpose, a tag of the "Project" type is initialized with the
.Projects.Open(new FileInfo(filename)) method of the TIA Portal tag.
 Siemens AG 2017 All rights reserved

If a TIA Portal project is opened, you can save or close the project via "File > Save
project" or "File > Close project".

Figure 6-6

Open the method "SaveProjectCommand_Executed" or


"CloseProjectCommand_Executed" in the "MainWindowViewModel.cs" class.
Via the method "Project.Save()" or "Project.Close()" of the project tag, the project is
saved or closed.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 26
6 TIA Openness Demo

Reading out devices


On the left side of the application, the devices and their elements are shown,
similar to a project tree in the TIA Portal.
Figure 6-7
 Siemens AG 2017 All rights reserved

For this purpose, all "Devices" and their "DeviceItems" included in the project are
read out.
Open the class "General.cs" in the "TiaOpennessHelper" project.
In this class the project contents are read out and provided as lists.
In the "MainWindowViewModel.cs" class of the "TIAPortalOpennessDemo" project
this list is accessed in the "CreateDeviceTreeViewItem ()" method.
When listing the elements, please note the following:
 Many elements can be located in user-defined folders. The nesting depth is not
necessarily known here. For this reason the functions should be recursive.

Opening editors
You can start the topology and the network editor in the user interface of the TIA
Portals with "Project > Editor".
Figure 6-8

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 27
6 TIA Openness Demo

Open the method "OpenTopologyViewCommand_Executed" in the


"MainWindowViewModel.cs" class.
You can start the topology and the network editor via
"Project.ShowHwEditor(Siemens.Engineering.HW.View.Topology)" or
"Project.ShowHwEditor(Siemens.Engineering.HW.View.Network)"
You can open other editors (e.g. block editor) via the "Project > Editor > Open
editor" menu if the focus is on a respective object.
Figure 6-9

Open the "OpenEditorCommand_Executed" method in the


"MainWindowViewModel.cs" class.
For this purpose, the "ShowInEditor()" method is called on a respective object (e.g.
a block).
 Siemens AG 2017 All rights reserved

Creating folder
Depending on your selection in the project tree of the TIA Portal Openness
application, you can create new folders (e.g. block folder).

Figure 6-10

Figure 6-11

Open the "CreateFolderCreateCommand_Executed" method in the


"MainWindowViewModel.cs" class.
A new folder is created via the "Groups.Create(FolderName)" method of the
selected object. In order to do this, it is checked beforehand, whether a folder can
be created in the selected object.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 28
6 TIA Openness Demo

Deleting elements
Depending on your selection in the project tree of the TIA Portal Openness
application, you can delete folders.

Figure 6-12

You find the "DeleteCommand_Executed" method in the


"MainWindowViewModel.cs" class.
You can delete it via the "Delete()" method of the respective element.

Compiling elements
The device can be compiled with TIA Portal Openness.
 Siemens AG 2017 All rights reserved

Figure 6-13

Open the class "Compile.cs" in the "TiaOpennessHelper" project.


The call of this method can be found in the "MainWindowViewModel.cs" class in
the "Compiler" region.
You can start compiling via the "Compile()" method.

6.4.5 Importing/exporting objects

The following objects can be exported and imported as XML file.


 Project graphics
 Blocks (apart from SCL), PLC tag tables and data types
 Screens, screen management, tags, (non-integrated) connections, scripts,
cycles, text and graphics lists
For this purpose, select "Project > Import/Export" from the menu.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 29
6 TIA Openness Demo

Figure 6-14

Note You can only export consistent blocks. Compile the blocks before exporting.

In the "TiaOpennessHelper" project the classes "Export.cs" and "Import.cs" are


included.
An element is imported or exported with the "Import(file, importOption)" or
"Export(path, exportOption) method.
With the ImportOptions you can select whether a file is to be overwritten
 Siemens AG 2017 All rights reserved

("Override") automatically or whether the import is to be cancelled with an error


message ("None"), if the object already exists.
With the ExportOptions it is specified which data is to be exported. With
"ExportOptions.None", all settings that were changed are exported. With
"ExportOptions.WithDefaults" additional default values are exported. With
"ExportOptions.WithReadOnly" additional write-protected values are exported.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 30
6 TIA Openness Demo

6.4.6 Libraries

Opening/closing global libraries


If the TIA Portal is opened you can open the global library via the "File > Open
global library" menu.

Figure 6-15
 Siemens AG 2017 All rights reserved

Note The global library is opened for access via Openness. It is not displayed in the
user interface of the TIA Portal.

With the "Libraries" button on the right side of the demo application, the project
library and global library that has been opened with Openness is shown.

Figure 6-16

Open the "OpenGlobalLibraryCommand_Executed" method in the


"MainWindowViewModel.cs" class.

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 31
6 TIA Openness Demo

For this purpose, a tag of the "GlobalLibrary" type is initialized with the
"GlobalLibraries.Open(fileName)" method of the TIA Portal tag.
If a global library is opened and selected in the application, you can close the
global library with "File > Close global Library".
You find the "CloseGlobalLibraryCommand_Executed" function in the
"MainWindowViewModel.cs" class.
The library is closed with the "Close()" method of the library tag.

Update check
With the "Edit > Update global library" you can perform an update check.

Figure 6-17
 Siemens AG 2017 All rights reserved

The result of the check is displayed in the status bar of the application.

Open the "UpdateGlobalLibraryCommand_Executed" method in the


"MainWindowViewModel.cs" class.
The "UpdateCheck" method of the global library provides the update event as tag
from the "UpdateCheckResult" tag.
With the help of the "UpdateCheckMode.ReportOutOfDateAndUpToDate"
parameter, identical and non-identical types are output. With the
"UpdateCheckMode.ReportOutOfDateOnly" parameter, only the non-identical
types are output.

6.4.7 PLC

Online connection to controller


You can establish an online connection to a connected controller. Select "PLC >
Connect/Disconnect" in the menu.

Figure 6-18

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 32
6 TIA Openness Demo

Open the "ConnectPlcCommand_Executed" method in the


"MainWindowViewModel.cs" class
A tag of the "OnlineProvider" type is created. With the "GoOnline()" method, an
online connection is established.
Prerequisite is, that a connection between TIA Portal and controller has already
been configured (e.g. by downloading the configuration). Otherwise an error
message will be output in the status line of the application.
With the "GoOffline()" method the connection is separated again.

Comparing controllers
 Online/offline
You can compare the selected controller with the online connected controller with
"PLC > Compare > Compare to online".
Figure 6-19
 Siemens AG 2017 All rights reserved

The result of the comparison is displayed in the status bar of the application.
Open the "CompareOnlineCommand_Executed" method in the
"MainWindowViewModel.cs" class.
The "CompareToOnline()" method of the control tag compares the controllers and
provides the result of the comparison of the "CompareResult" type as return value.
 Online/offline
With "PLC > Compare > Compare to offline" you can compare a controller in the
project with a controller of a global library. Open the global library and select the
controller. Select the controller you want to compare in the project tree of the
application. The result of the comparison is displayed in the status bar of the
application.
Open the "CompareOfflineCommand_Executed" method in the
"MainWindowViewModel.cs" class.
The "CompareTo(Object)" method compares the controllers and provides the result
of the comparison of the "CompareResult" type as return value.

Integrating external sources


When the "External source" folder is selected you can integrate an external source
via "PLC > Source files > Add external Source".

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 33
6 TIA Openness Demo

Figure 6-20

With the filter settings, you can select whether STL or SCL sources are to be
displayed.
Figure 6-21

Open the "AddExternalSourceCommand_Executed" method in the


"MainWindowViewModel.cs" class.
 Siemens AG 2017 All rights reserved

The source is adopted in the TIA Portal project with "CreateFromFile(sourcename,


filename)".

Generating block from source


When a source is selected you can generate a block from the source with "PLC >
Source files > Generate blocks from external source".
Open the "GenerateBlockfromSourceCommand_Executed" method in the
"MainWindowViewModel.cs" class.
A block is generated with "GenerateBlockFromSource()".

Generating source from block


You can generate a source file from a SCL or an STL block with "PLC > Source
files > Generate source from block".
Specify the storage path via the file browser.

Open the "GeneratesourcefromBlockCommand_Executed" method in the


"MainWindowViewModel.cs" class.

A source is generated with the "GenerateSourceFromBlocks(blocklist, filepath)".

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 34
7 Related literature

7 Related literature
Table 7-1
Topic
\1\ Siemens Industry Online Support
http://support.industry.siemens.com
\2\ Download page of the entry
https://support.industry.siemens.com/cs/ww/de/view/108716692
\3\ Support Request
http://www.siemens.com/automation/support-request
\4\ Delivery release STEP 7 V14 SP1
https://support.industry.siemens.com/cs/ww/de/view/109745984
\5\ Why does your TIA Portal Openness application not work as expected?
http://support.industry.siemens.com/cs/ww/en/view/109251656
\6\ Why, when using a TIA Portal Openness application, do you get the error message
"Cannot connect to TIA Portal"?
http://support.industry.siemens.com/cs/ww/en/view/109038214
\7\ System manual
https://support.industry.siemens.com/cs/ww/en/view/109477163
 Siemens AG 2017 All rights reserved

8 History
Table 8-1
Version Date Modifications
V1.0 02/2015 First version
V1.0 09/2015 Fixed minor problems
V1.1 12/2016 Version for TIA Portal V14
V1.2 05/2017 Version für TIA Portal V14 SP1

TIA Portal Openness


Entry ID: 108716692, V1.2, 05/2017 35

You might also like