You are on page 1of 13

TIA Add-In Tester

Siemens
TIA Portal / TIA Add-Ins / V1.1 Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109783096 Support
Legal information

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

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

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

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

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

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 2
Table of Contents

Table of Contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 4
1.1 Boundary Conditions ............................................................................ 4
1.2 Restrictions ........................................................................................... 4
2 Preparations ....................................................................................................... 5
2.1.1 Installing the Application....................................................................... 5
2.1.2 Integration into the Project ................................................................... 5
3 Testing a TIA Add-In .......................................................................................... 7
3.1.1 Providing the Objects to be Tested ...................................................... 7
3.1.2 Starting the Test ................................................................................... 8
3.1.3 Defining Breakpoints ............................................................................ 9
3.1.4 Simulation of the UpdateUI delegate timeout..................................... 10
3.1.5 Additional Options .............................................................................. 10
3.1.6 Final Test ............................................................................................ 11
4 Appendix .......................................................................................................... 12
4.1 Service and support ........................................................................... 12
4.2 Industry Mall ....................................................................................... 13
4.3 Links and literature ............................................................................. 13
4.4 Change documentation ...................................................................... 13
© Siemens AG 2022 All rights reserved

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 3
1 Introduction

1 Introduction
The TIA Add-In Tester allows you to test a TIA Add-In during development without
having to install & activate it in the TIA Portal. The TIA Add-In to be tested is
loaded in the TIA Add-In Tester as an Openness Application, connected to the TIA
Portal, and executed.

Figure 1-1 Function principle

attached
TIA Add-In Tester
executes

*.addin

Using the TIA Add-In Tester, it is possible to set breakpoints in the TIA Add-In. The
code of the TIA Add-In can, therefore, be run through line by line, and errors can
be identified before it is installed and activated in the TIA Portal.
© Siemens AG 2022 All rights reserved

1.1 Boundary Conditions


For the use of the TIA Add-In Tester and this documentation, basic knowledge of
the handling and functionality of TIA Add-Ins in the TIA Portal is assumed.
Further information:
• TIA Add-Ins manual
https://support.industry.siemens.com/cs/ww/en/view/109773506/128474251915
• Getting Started with TIA Add-Ins
https://support.industry.siemens.com/cs/ww/en/view/109779415
• TIA Add-Ins overview
https://support.industry.siemens.com/cs/ww/en/view/109773999

Basic knowledge of use and debugging in Microsoft Visual Studio is required.

Note The following describes how to set up and use the TIA Add-In Tester in Microsoft
Visual Studio. The use of other development environments has not been tested,
but is possible, in principle.

1.2 Restrictions
The permissions of a TIA Add-In and VCI providers cannot be simulated.

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 4
2 Preparations

2 Preparations
The TIA Add-In Tester can be integrated into your own TIA Add-In project in just a
few steps. After the initial setup, testing of a TIA Add-In can be started by simply
"starting" the project within Visual Studio.

2.1.1 Installing the Application

Download the TIA Add-In Tester from the entry page (see \2\) and extract the zip
file to a local folder.

2.1.2 Integration into the Project

The following steps integrate the TIA Add-In Tester into your own TIA Add-In
project:
1. Open the project properties of the Add-In in the Solution Explorer.
2. Switch to the "Debug" option.
3. In the "Start external program" field, add the complete path to the file
"TiaAddInTester.exe" in the unpacked local folder from section 2.1.1.
4. In the "Command line arguments" field, add the attribute "--path" followed by
the full path of the TIA Add-In to be tested. At this point, specify the path of the
© Siemens AG 2022 All rights reserved

*.addin file that is generated when using the TIA Add-In Publisher.
5. In the "Working Directory" field, add the full path of the unzipped local folder
from section 2.1.1.
6. Add the following method to all classes in which the TIA Add-In class
"ContextMenuAddIn" is inherited:
public IEnumerable<IEngineeringObject> GetSelection(string label) { }
This method is executed by the TIA Add-In Tester to generate the selection for
the MenuSelectionProvider. Return the Openness objects to be tested here. In
the Click and Update delegate, these objects are then available via
menuSelectionProvider.GetSelection().

Figure 2-1 Example configuration

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 5
2 Preparations

Figure 2-2 Example ContextMenuAddIn class

6
© Siemens AG 2022 All rights reserved

Code 2-3 Copy template of a GetSelection method


/// <summary>
/// This method will be invoked by the TIA Add-In Tester. The return value of this
/// method will be provided in the Click- and UpdateDelegate's MenuSelectionProvider
/// </summary>
/// <param name="label">Label of the context menu item</param>
/// <returns>Objects to provide for the MenuSelectionProvider</returns>
public IEnumerable<IEngineeringObject> GetSelection(string label)
{
// go to project settings -> Debug -> command line arguments
// specify which context menu item to test at --item

var project = TiaPortal.Projects.FirstOrDefault();

switch (label)
{
case "Item 1":
var myPlc = project
.Devices[0]
.DeviceItems.FirstOrDefault(plc => plc.Name == "MyPlc")
.GetService<SoftwareContainer>().Software as PlcSoftware;
// return the program blocks folder
return myPlc?.BlockGroup.Blocks;
case "Item 2":
// return all Startdrive devices in the project
return project.Devices
.Where(x => x.DeviceItems.Any(y => y.GetService<DriveObjectContainer>() != null));
default:
return Enumerable.Empty<IEngineeringObject>();
}
}

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 6
3 Testing a TIA Add-In

3 Testing a TIA Add-In


After the preparations from section 2 have been completed, the TIA Add-In can be
started in Visual Studio via the menu "Debug" → "Start Debugging" (F5).
The TIA Add-In to be tested is loaded by the TIA Add-In Tester and automatically
connects to the TIA Portal. By default, the first context menu Add-In and entry
found is executed. A specific Add-In and/or menu item can be selected using the
optional parameters (see section 3.1.5).

During the first execution of the TIA Add-In Tester, the TIA Openness Firewall for
"TiaAddInTester.exe" must be confirmed with "Yes, all" if necessary.

Note Only one TIA Portal instance may be active during the test. Close all other
instances before testing.

3.1.1 Providing the Objects to be Tested

As described in section 2.1.2, the method "GetSelection" is used to create the


selection of objects to be tested.
With this method, pass the objects that would be selected when executing a
© Siemens AG 2022 All rights reserved

context menu item of the TIA Add-In in the TIA Portal.


The method parameter "label" is used to pass the text of the context menu item to
be tested. Therefore, it is possible to provide different selections for each context
menu entry.

Figure 3-1 GetSelection method example

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 7
3 Testing a TIA Add-In

3.1.2 Starting the Test

The test of a TIA Add-In can be started via the menu "Debug" → "Start
Debugging", or by pressing the F5 key in Visual Studio.
After loading the TIA Add-In and establishing the connection to the TIA Portal, the
Openness objects provided from the GetSelection method are passed to UpdateUI
and the Click delegate of the specified context menu item. By default, the first Add-
In and the first context menu entry are executed (see section 3.1.5).
The Click delegate of a context menu item is only executed if the return value of
the UpdateUI delegate was "MenuStatus.Enabled". This simulates the behavior in
the TIA Portal that a context menu entry can only be executed if it has the status
"MenuStatus.Enabled". If no UpdateUI delegate was implemented, the Click
delegate is always executed. If Openness objects are provided in the GetSelection
method that do not correspond to the type of the context menu item, then this
results in the status "MenuStatus.Hidden". The Click delegate is not executed in
this case.

Figure 3-2 Program sequence

Start

Loading the TIA


© Siemens AG 2022 All rights reserved

Add-In

Connection to the
TIA Portal

Call
GetSelection
method

Preserved
objects

UpdateUI
yes Call UpdateUI
dele gate
Imp lemented? delegate

no

Call Click
Enabled MenuStatus?
delegate

Disabled/Hidden
End

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 8
3 Testing a TIA Add-In

3.1.3 Defining Breakpoints

Set a breakpoint at the points in the code that you want to analyze.

Figure 3-3 Setting a breakpoint

Program execution is paused when the breakpoint is reached so that the states of
the variables can be analyzed.
While the program sequence is paused at the defined breakpoint, the status can be
read out by pointing the mouse at a variable to be analyzed (1) and updating the
status (2).
© Siemens AG 2022 All rights reserved

Figure 3-4 Analysis of one variable

The remaining program sequence can be controlled as follows:


1. Continue program sequence (to the next breakpoint) - F5
2. End program sequence - Shift + F5
3. Execute current line (Step over) - F10
4. Jump into the current line (Step into) - F11

1 2 3 4

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 9
3 Testing a TIA Add-In

3.1.4 Simulation of the UpdateUI delegate timeout

In the TIA Portal, the maximum execution time of the UpdateUI delegate is limited
to 250 ms. After the time limit has expired, the context menu entry is set to
"Hidden" in the TIA Portal and is not displayed.
Therefore, the execution time of the UpdateUI delegate is measured and displayed
in the TIA Add-In Tester. Exceeding the time limit has no effect on the test, but a
warning is issued.

Figure 3-5 Warning when timeout is exceeded


© Siemens AG 2022 All rights reserved

3.1.5 Additional Options

By default, the first context menu Add-In and the first context menu entry found are
tested. The Add-In and/or context menu entry of the Add-In to be tested can be
specified with optional parameters (see point 4 in section 2.1.2).

Table 3-1 Command line options


Option Description
--path Required
Complete path of the TIA Add-In (*.addin) to be tested
--provider Type name of the class of the addin provider to test (e.g.
MyProjectTreeProvider)
--menu Name of the context menu Add-In (1)
--item Name of the context menu item (2)

Figure 3-6 Example of transfer arguments

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 10
3 Testing a TIA Add-In

In Figure 3-6, the context menu item "InOut" is tested. The arguments are specified
as follows:
--path "D:\FCFBConverter\bin\Debug\FCFBConverter.addin" --menu
"FC-FB Converter" --item "InOut"
The parameter "--menu" is only necessary if several Add-Ins have been
implemented in the TIA Add-In to be tested.

Note Regardless of the cascading of the context menu entry, only the context menu
entry text (2) must be specified in each case.

3.1.6 Final Test

Since the TIA Add-In Tester does not execute the TIA Add-In like a common TIA
Add-In, but instead like an Openness Application, the final test of a TIA Add-In to
be published should always be done in the TIA Portal.

Note Debugging a TIA Add-In in the TIA Portal is described in the FAQ "How to debug
a TIA Add-In".
https://support.industry.siemens.com/cs/ww/en/view/109790393
© Siemens AG 2022 All rights reserved

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 11
4 Appendix

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

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

SITRAIN – Digital Industry Academy


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

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

Industry Online Support app


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

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 12
4 Appendix

4.2 Industry Mall

The Siemens Industry Mall is the platform on which the entire siemens Industry
product portfolio is accessible. From the selection of products to the order and the
delivery tracking, the Industry Mall enables the complete purchasing processing –
directly and independently of time and location:
mall.industry.siemens.com

4.3 Links and literature


Table 4-1
No. Subject
\1\ Siemens Industry Online Support
https://support.industry.siemens.com
© Siemens AG 2022 All rights reserved

\2\ Link to the entry page of the application example


https://support.industry.siemens.com/cs/ww/en/view/109783096
\3\ FAQ: How can I debug a TIA Add-In?
https://support.industry.siemens.com/cs/ww/en/view/109790393
\4\ TIA Add-Ins overview
https://support.industry.siemens.com/cs/ww/en/view/109773999

4.4 Change documentation


Table 4-2
Version Date Change
V1.0 01/2021 First version
V1.1 06/2022 --provider Option, Bug fixes

TIA Add-In Tester


Entry ID: 109783096, V1.1, 06/2022 13

You might also like