0% found this document useful (0 votes)
37 views

OpennessScripter Intro DOC V116 en

Uploaded by

anderson.ferraz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

OpennessScripter Intro DOC V116 en

Uploaded by

anderson.ferraz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

OpennessScripter:

Introduction
Siemens
TIA Portal / Openness API Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109742322 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 AG 2021 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.

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 2
Table of Contents

Table of Contents
Legal information ......................................................................................................... 2
1 Introduction ........................................................................................................ 4
1.1 The TIA Portal programming interface ................................................. 4
1.2 Application examples ........................................................................... 4
1.3 Until now: Creation of own applications ............................................... 5
1.4 New: Create scripts with OpennessScripter ......................................... 6
1.5 Advantages .......................................................................................... 6
2 Requirements ..................................................................................................... 7
2.1 Required know-how.............................................................................. 7
2.2 System requirements ........................................................................... 7
2.3 Enabler file and usage file .................................................................... 7
3 Installation .......................................................................................................... 8
4 The first start ...................................................................................................... 9
4.1 Structure of the start screen ................................................................. 9
4.2 Structure of the editor ......................................................................... 10
4.3 Creating a script ................................................................................. 11
4.3.1 General ............................................................................................... 11
4.3.2 "Hello World" script ............................................................................. 12
4.3.3 "Open TIA Portal" script ..................................................................... 12
© Siemens AG 2021 All rights reserved

5 Examples .......................................................................................................... 13
5.1 Generating a project ........................................................................... 13
5.2 Updating a project .............................................................................. 14
6 Appendix .......................................................................................................... 15
6.1 Service and support ........................................................................... 15
6.2 Links and literature ............................................................................. 16
6.3 Change documentation ...................................................................... 16

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 3
1 Introduction

1 Introduction
This introduction gives you a brief insight into the OpennessScripter.

NOTE The detailed documentation including the command set can be found in the
OpennessScripter menu "Help".

1.1 The TIA Portal programming interface


The TIA Portal Openness API (Application Programming Interface) provided by TIA
Portal allows you to automate recurring steps in your projects. This is useful as
manual adjustments in projects involve a high susceptibility to errors. Moreover,
this automation allows you to save time, enabling you to work more efficiently.

Note Using the interfaces incorrectly can result in loss of data and production
downtime.
© Siemens AG 2021 All rights reserved

1.2 Application examples


The interface provides the user with many options for automating actions.
Table 1-1
Action Scenario
Import and compile program blocks You can modify reusable programs externally and
integrate them into a new project.
Export data • Create project statistics and backups based
on your own rules.
• Check programming guidelines using
external tools.
• Match projects to global libraries.
Compare projects Check the consistency of local projects using an
online comparison with the project on the plant.
Generate and import visualizations Automatically generate the visualization for the
via exported program structures HMI from the existing project.

NOTE Further ready-to-use application examples, partly including source code for own
adaptations, can be found on the Siemens Industry Online-Support topic
page "TIA Portal Openness" \5\.

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 4
1 Introduction

1.3 Until now: Creation of own applications


Until now, you had to develop an application to use the TIA Portal interface. This
required programming skills in a high-level language such as C# or VB.NET.
Figure 1-1
© Siemens AG 2021 All rights reserved

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 5
1 Introduction

1.4 New: Create scripts with OpennessScripter


The OpennessScripter allows you to automate simple tasks in TIA Portal projects
without programming skills. Easy script commands allow you to avoid complex
programming.
Figure 1-2: Custom application (right) compared to an OpennessScripter script (left)

Instead of programming commands, you use a meta language. This reduces the
writing work. In the example shown in Figure 1-2, this results in saving of about
© Siemens AG 2021 All rights reserved

95 % of the pure programming work. This example does not yet include other
savings such as incorporation into the high-level language.

1.5 Advantages
Using the OpennessScripter provides several advantages over an in-house
development.
Table 1-2
Characteristic Evaluation
Functionality The OpennessScripter provides only the basic functionality of the
TIA Portal Openness API.
Reliability When writing a script, the number of potential errors caused by the
user is significantly reduced.
Usability An elegant user interface and commands that are oriented towards
English make the OpennessScripter easier.
Efficiency No differences regarding execution time.
(performance)
Changeability Customizing scripts is considerably easier and quicker than
modifying an application developed in a high-level language.
Portability Scripts are text files and can be transferred more easily. A special
development environment is not necessary.

NOTE Portal Openness in combination with high-level languages (C#, VB.NET) offers
far more possibilities than this application example "OpennessScripter".

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 6
2 Requirements

2 Requirements
2.1 Required know-how
• TIA Portal user knowledge (beginner’s level)
• No programming skills

2.2 System requirements


• No development environment necessary, e.g., Microsoft Visual Studio.
• The OpennessScripter requires at least the "Microsoft .NET 4.8" runtime. This
runtime is provided for free by Microsoft \4\.
• TIA Portal is not required for writing and checking scripts.
• Running scripts requires that TIA Portal or a product based on TIA Portal be
installed, for example STEP 7 Professional or WinCC Professional. In addition,
TIA Portal Openness V13 SP1, V13 SP2, V14, V14 SP1, V15, V15.1, V16, or
V17 must be installed. The installation is described in the System Manual \3\,
Chapter 4.1.2.
• To run scripts, the Windows user must be a member of the local "Siemens TIA
Openness" group. The setup is described in the System Manual \3\, Chapter
© Siemens AG 2021 All rights reserved

4.1.3. More information is also available in the OpennessScripter, "Settings >


Local users and groups".
• Whether Windows and TIA Portal are based on 32- or 64-bit versions has no
effect on the OpennessScripter.
• The OpennessScripter and TIA Portal must run in the same Windows
environment, i.e., on the same Windows PC / the same virtual machine.

NOTE Please install all available TIA Portal Service Packs and updates.

2.3 Enabler file and usage file

NOTE Importing blocks and user data types into a PLC device requires the "Enabler-
File" and "Usage-File" license files only for TIA Openness Versions < V14
SP1.

The enabler file, "SiemensTIAOpennessCustomerID.xml", must be in the program


folder of the OpennessScripter:
C:\Program Files (x86)\Siemens\Automation\OpennessScripter\

The usage file, "SiemensTIAOpennessUsage.xml", must be in the PublicAPI folder


of TIA Portal:
C:\Program Files (x86)\Siemens\Automation\Portal V13\PublicAPI\
C:\Program Files\Siemens\Automation\Portal V14\PublicAPI\

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 7
3 Installation

3 Installation
Setup
A setup is provided for the OpennessScripter. It allows you to install the software
on the computer.
In the start menu, a shortcut is created in "Programs > Siemens Automation >
OpennessScripter".
During the installation process, you should select the following options:
1. Enter the current Windows user in the local "Siemens TIA Openness" Windows
group.
2. Add the application to the TIA Portal Openness whitelist.
3. Perform a system check to check the TIA Portal dependencies.

Uninstalling
You can use Control Panel > "Programs and Features" > "OpennessScripter" to
uninstall the software.

Installation of a new version


The setup detects the previous versions of OpennessScripter automatically and
uninstalls these before installing the new version.
© Siemens AG 2021 All rights reserved

Sequence
You can install the OpennessScripter, even if TIA Portal and the Openness option
package are not installed on your system.
In this case, you can write scripts but not run them.
If you install TIA Portal or the Openness option package later, you must manually
perform the above steps 1. and 2. or reinstall the OpennessScripter.

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 8
4 The first start

4 The first start


4.1 Structure of the start screen
When you start the OpennessScripter, the start screen opens. The left part
displays the recently used scripts. In this area, you can also pin scripts using a pin.
The right part displays several script templates you base your script on.
Figure 4-1
© Siemens AG 2021 All rights reserved

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 9
4 The first start

4.2 Structure of the editor


Once you have created a new script, opened a script or selected a template, the
Script Editor starts in the same window. A text field where you write the commands
line by line takes up most of the user interface. The left part provides a sidebar for
the recently used files. The bottom part provides a sidebar for the output. You can
change the sidebar sizes and collapse and hide the sidebars.
The "Close" option in the "File" menu takes you to the start screen.
Figure 4-2
© Siemens AG 2021 All rights reserved

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 10
4 The first start

4.3 Creating a script


This chapter provides you with insight into the scripting language.

4.3.1 General

Rules
There are three rules for the script commands:
• Each command is in a separate line.
• A comment starts with a "#" and can be at both the start and end of a line.
• Upper/lower-case letters or indenting commands do not affect the script’s
functionality.

Working with projects


There are two ways of working with a TIA Portal project:
Table 4-1
Start a new TIA Portal instance and open Connect to a TIA Portal project that has
the project already been opened
open Portal connect Portal "project path"
open Project "project Path"
# Your script code ...
© Siemens AG 2021 All rights reserved

# Your script code ...


close Project
close Project disconnect Portal
disconnect Portal

Note At the end of the script, disconnect from TIA Portal.


The TIA Portal user interface cannot be terminated automatically.

Command types
The following types of commands exist:
• Command with optional parameters
• Command without parameters
• Hybrids of these two types (for commands with multiple parameters).

Note If you do not specify optional parameters, defaults will be used.


Use straight quotation marks, for example "name"; do not use smart quotation
marks, for example „name“.
All defaults and the command set can be found in the detailed
documentation (in the OpennessScripter menu "Help").

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 11
4 The first start

4.3.2 "Hello World" script

Follow the below instructions to write a script that outputs the text "Hello World".
1. Start the OpennessScripter and click the "Empty script" template. Delete the
entire default text in the Editor so that the text field is blank. Write the following
new line:
print "Hello World!"
2. In the "Run" menu, click the "Run" option to start the script. Keep an eye on the
below "Output" window. It displays the output text "Hello World!"
3. You have successfully completed your Hello World script. In the "File" menu,
click the "Close" option to return to the start screen.

4.3.3 "Open TIA Portal" script

Follow the below instructions to write a script that opens TIA Portal.
1. Start the OpennessScripter and click the "Empty script" template.
2. The template already contains texts that start with a diamond "#". These texts
are comments for your own documentation. Add your name and a description,
for example "My first script", to the comment:
# Description: My first script
Go to the end of the script and write a new line. Make sure not to enter a
diamond "#":
© Siemens AG 2021 All rights reserved

open Portal
Insert a line break at the end of the line and write the next line:
disconnect Portal
3. In the "Run" menu, click the "Check" option to check the script for errors. Read
the information in the output. If the error check finds errors in your script,
correct them.
4. In the "File" menu, click the "Save" option to save the script on your computer.
The file gets the ".opns" extension.
5. In the "Run" menu, click the "Run" option to start the script. An animated
progress bar at the bottom left indicates that the script is currently being
executed. No changes are possible during execution. In the OpennessScripter,
the specific line that is currently being executed is indicated in color to the left
of the line number.
6. The script starts TIA Portal. Depending on the computing power, this step may
take some time. The script disconnects from TIA Portal. Please note: This does
not terminate TIA Portal. You cannot close the TIA Portal user interface
automatically. As soon as the script is done, the status displayed in the bottom
left part of the OpennessScripter has returned to "Ready".
7. You have successfully written your first script. In the "File" menu, click the
"Close" option to return to the start screen.

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 12
5 Examples

5 Examples
5.1 Generating a project
Scenario
After production planning and before engineering: A machine manufacturer
produces a series of machines. The manufacturer can use the OpennessScripter
as a product configurator and generate projects on an automated basis.

Steps
The individual steps are as follows:
1. Start TIA Portal and open a project
2. Select a controller
3. Create a group for a tag table
4. Import a single tag table
5. Import several program blocks
6. Compile the controller
7. Save and close the project
8. Finally disconnect from TIA Portal
© Siemens AG 2021 All rights reserved

Script
The commands for the script are as follows:
# Start TIA Portal and open project
open Portal
open Project "D:\Projects\AssemblyLine\AssemblyLine.ap17"

# Select controller
select Plc "PLC_1"

# Import a single tag table in a subgroup


create PlcTagTableFolder /group1/
import PlcTagTables "D:\Sources\tag tables\tagtable1.xml" /group1/

# Import all program blocks from the file directory


import ProgramBlocks "D:\Sources\program blocks\"

# Compile controller
compile Plc SoftAndHardware

# Save and close project


save Project
close Project

# Disconnect
disconnect Portal

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 13
5 Examples

5.2 Updating a project


Scenario
During engineering: The user can match and update the blocks used in a project
from global libraries on an automated basis.

Steps
The individual steps are as follows:
1. Connect to an already open project in TIA Portal
2. Open a global library
3. Select a controller
4. Update the controller using the global library
5. Close the global library
6. Save the project
7. Finally disconnect from TIA Portal

Script
The commands for the script are as follows:
# Reuse an already opened TIA Portal project
connect Portal "D:\Projects\AssemblyLine\AssemblyLine.ap17"
© Siemens AG 2021 All rights reserved

# Open library
open GlobalLibrary "D:\Libraries\LGF\LGF.al17"

# Select controller and update from the global library


select Plc "PLC_1"
update Plc GlobalLibrary

# Close library
close GlobalLibrary

# Save project
save Project

# Disconnect
disconnect Portal

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 14
6 Appendix

6 Appendix
6.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:
siemens.com/SupportRequest
© Siemens AG 2021 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/en/sc/2067

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 15
6 Appendix

6.2 Links and literature


Table 6-1
No. Topic
\1\ Siemens Industry Online Support
https://support.industry.siemens.com
\2\ Link to the entry page of the application example
https://support.industry.siemens.com/cs/ww/en/view/109742322
\3\ TIA Portal Openness System Manual (API for automation of engineering workflows)
https://support.industry.siemens.com/cs/ww/en/view/109798533 (V17)
\4\ Download: Microsoft .NET Framework 4.8 Runtime (runtime environment)
https://dotnet.microsoft.com/download/dotnet-framework/net48
\5\ Topic page: TIA Portal Openness: Automation of engineering workflows
https://support.industry.siemens.com/cs/ww/en/view/109792902

6.3 Change documentation


Table 6-2
Version Date Modifications
V1.0.0 08/2016 First version
© Siemens AG 2021 All rights reserved

V1.1.0 09/2016 • System requirements: License files for user data types
• Settings "Local users and groups"
• Figure: Editor
• Figure: Hello World script
• Examples
• Installation
• System requirements: .NET Framework 4.6.1
V1.1.1 01/2017 • Entry ID
• Chapter on enabler file and usage file
• Uninstalling and installation order
V1.1.2 02/2017 • Examples for TIA Portal V14
04/2017 • Revision of the document
05/2017 • Support for TIA Portal V14 SP1 and V13 SP2 and
notes
06/2017 • Copyediting and translation
V1.1.3 01/2018 • Support for TIA Portal V15 and notes
V1.1.4 10/2018 • Support for TIA Portal V15.1 and notes
V1.1.5 02/2020 • Support for TIA Portal V16 and notes
V1.1.6 11/2021 • Support for TIA Portal V17 and notes
• System requirements: .NET Framework 4.8
• Notes for working with projects (chapter 4.3)
• Revision of the examples (chapter 5)

OpennessScripter: Introduction
Entry ID: 109742322, V1.1.6, 11/2021 16

You might also like