S7-Plcsim Advanced Function Manual en-US
S7-Plcsim Advanced Function Manual en-US
Guide 1
2
SIMATIC Product overview
Installing 3
S7-1500
S7-PLCSIM Advanced 4
Communication paths
Simulation 5
Function Manual
List of abbreviations A
05/2021
A5E37039512-AD
Legal information
Warning notice system
This manual contains notices you have to observe in order to ensure your personal safety, as well as to prevent
damage to property. The notices referring to your personal safety are highlighted in the manual by a safety alert
symbol, notices referring only to property damage have no safety alert symbol. These notices shown below are
graded according to the degree of danger.
DANGER
indicates that death or severe personal injury will result if proper precautions are not taken.
WARNING
indicates that death or severe personal injury may result if proper precautions are not taken.
CAUTION
indicates that minor personal injury can result if proper precautions are not taken.
NOTICE
indicates that property damage can result if proper precautions are not taken.
If more than one degree of danger is present, the warning notice representing the highest degree of danger will
be used. A notice warning of injury to persons with a safety alert symbol may also include a warning relating to
property damage.
Qualified Personnel
The product/system described in this documentation may be operated only by personnel qualified for the specific
task in accordance with the relevant documentation, in particular its warning notices and safety instructions.
Qualified personnel are those who, based on their training and experience, are capable of identifying risks and
avoiding potential hazards when working with these products/systems.
Proper use of Siemens products
Note the following:
WARNING
Siemens products may only be used for the applications described in the catalog and in the relevant technical
documentation. If products and components from other manufacturers are used, these must be recommended
or approved by Siemens. Proper transport, storage, installation, assembly, commissioning, operation and
maintenance are required to ensure that the products operate safely and without any problems. The permissible
ambient conditions must be complied with. The information in the relevant documentation must be observed.
Trademarks
All names identified by ® are registered trademarks of Siemens AG. The remaining trademarks in this publication
may be trademarks whose use by third parties for their own purposes could violate the rights of the owner.
Disclaimer of Liability
We have reviewed the contents of this publication to ensure consistency with the hardware and software
described. Since variance cannot be precluded entirely, we cannot guarantee full consistency. However, the
information in this publication is reviewed regularly and any necessary corrections are included in subsequent
editions.
Scope
This function manual is valid for the following order versions
• 6ES7823-1FA03-0YA5 SIMATIC S7-PLCSIM Advanced V4.0
• 6ES7823-1FE03-0YA5 SIMATIC S7-PLCSIM Advanced V4.0 (Download)
• 6ES7823-1FA03-0YE5 SIMATIC S7-PLCSIM Advanced V4.0 Upgrade V1.0 to V4.0
• 6ES7823-1FE03-0YE5 SIMATIC S7-PLCSIM Advanced V4.0 Upgrade V1.0 to V4.0
(Download)
The articles each contain one license for two instances.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 3
Preface
Conventions
Conventions STEP 7: In this documentation, "STEP 7" is used as a synonym for all versions of
the configuration and programming software "STEP 7 (TIA Portal)".
We also abbreviate SIMATIC S7-PLCSIM Advanced V4.0 as "PLCSIM Advanced".
Note
A note contains important information on the product described in the documentation, on
the handling of the product or on the section of the documentation to which particular
attention should be paid.
Special information
Note
Readme
You can obtain updates to the function manual as downloads on the Internet
(https://support.industry.siemens.com/cs/us/en/view/109773483).
Application examples
You can find the following application examples for S7-PLCSIM Advanced on the Internet:
• SIMATIC S7-PLCSIM Advanced: Co-Simulation via API (1
(https://support.industry.siemens.com/cs/ww/de/view/109739660/en))
• Digitalization with TIA Portal: Virtual commissioning with SIMATIC and Simulink (2
(https://support.industry.siemens.com/cs/ww/en/document/109749187))
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 customers' exposure to
cyber threats.
S7-PLCSIM Advanced
4 Function Manual, 05/2021, A5E37039512-AD
Preface
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS
Feed visit (https://www.siemens.com/industrialsecurity).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 5
Table of contents
Preface ................................................................................................................................................... 3
1 Guide ................................................................................................................................................... 12
1.1 S7-PLCSIM products ........................................................................................................... 14
2 Product overview ................................................................................................................................. 16
2.1 What is S7-PLCSIM Advanced? ............................................................................................ 16
2.2 Compatibility during upgrade............................................................................................. 17
2.3 Security for S7-PLCSIM Advanced ....................................................................................... 18
2.4 Simulations support ........................................................................................................... 19
2.5 Supported CPUs ................................................................................................................. 20
2.6 Differences between a simulated and a real CPU ................................................................ 21
2.6.1 Restrictions for all supported CPUs ..................................................................................... 22
2.6.2 Notes ................................................................................................................................ 23
2.7 Password to protect confidential configuration data ........................................................... 25
3 Installing .............................................................................................................................................. 27
3.1 Introduction ...................................................................................................................... 27
3.1.1 System requirements ......................................................................................................... 27
3.1.2 Restrictions due to antivirus programs................................................................................ 29
3.1.3 Licenses............................................................................................................................. 30
3.1.4 Trial License....................................................................................................................... 30
3.1.5 Installation log ................................................................................................................... 32
3.2 S7-PLCSIM Advanced ......................................................................................................... 33
3.3 Installing S7-PLCSIM Advanced........................................................................................... 34
3.4 Changing S7-PLCSIM Advanced .......................................................................................... 36
3.5 Repairing S7-PLCSIM Advanced .......................................................................................... 37
3.6 Uninstalling S7-PLCSIM Advanced ...................................................................................... 37
4 Communication paths ......................................................................................................................... 39
4.1 Local communication......................................................................................................... 41
4.2 Communication via TCP / IP ................................................................................................ 42
4.3 Enable distributed communication ..................................................................................... 45
S7-PLCSIM Advanced
6 Function Manual, 05/2021, A5E37039512-AD
Table of contents
5 Simulation............................................................................................................................................ 47
5.1 Simulate CPU ..................................................................................................................... 47
5.1.1 Basic procedure for the simulation ..................................................................................... 47
5.1.2 Control Panel - User interface ............................................................................................. 48
5.1.2.1 S7-PLCSIM Advanced Symbol ............................................................................................. 48
5.1.2.2 Graphical interface............................................................................................................. 49
5.1.2.3 S7-PLCSIM Advanced Control Panel .................................................................................... 50
5.1.2.4 Importing instances ........................................................................................................... 53
5.1.3 Download .......................................................................................................................... 55
5.1.4 Network addresses in the simulation .................................................................................. 57
5.1.4.1 Siemens PLCSIM Virtual Ethernet Adapter ........................................................................... 57
5.1.4.2 PLCSIM Advanced instances ............................................................................................... 58
5.1.5 Simulate peripheral I/O ...................................................................................................... 59
5.1.6 Simulate communication ................................................................................................... 60
5.1.6.1 Communication services that can be simulated .................................................................. 60
5.1.6.2 Communication between instances .................................................................................... 61
5.1.7 Provide project data offline for simulation .......................................................................... 62
5.2 Simulate CPU with ODK functionality.................................................................................. 64
5.2.1 Special features of ODK...................................................................................................... 64
5.2.2 Loading functions .............................................................................................................. 67
5.2.3 Calling functions ................................................................................................................ 68
5.2.4 Unloading functions .......................................................................................................... 68
5.3 Simulating Motion Control ................................................................................................. 69
5.4 Simulating the SIMATIC Drive Controller ............................................................................. 71
5.5 Simulating a redundant S7-1500R/H system ....................................................................... 73
6 Virtual time response .......................................................................................................................... 75
6.1 Speed up and slow down simulation .................................................................................. 77
6.2 Stop simulation ................................................................................................................. 78
6.3 Synchronize simulation partner .......................................................................................... 80
6.3.1 Synchronize simulation partner cycle-controlled ................................................................. 80
6.3.2 Synchronize simulation partner time-controlled ................................................................. 82
7 User interfaces (API) ............................................................................................................................ 84
7.1 Introduction ...................................................................................................................... 84
7.1.1 Access to instances ............................................................................................................ 86
7.1.2 User interfaces (API) .......................................................................................................... 87
7.1.3 Overview of user interfaces for native C++ ......................................................................... 88
7.1.4 Overview of user interfaces for managed code ................................................................... 93
7.1.5 Overview of data types for native C++ ................................................................................ 96
7.1.6 Overview of data types for managed code .......................................................................... 98
7.2 Initialize API ....................................................................................................................... 99
7.2.1 Load API library .................................................................................................................. 99
7.2.2 Native C++....................................................................................................................... 100
7.2.2.1 InitializeApi() ................................................................................................................... 100
7.2.2.2 RuntimeApiEntry_Initialize ............................................................................................... 102
7.2.3 .NET (C#) ......................................................................................................................... 104
7.2.3.1 Initialize........................................................................................................................... 104
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 7
Table of contents
S7-PLCSIM Advanced
8 Function Manual, 05/2021, A5E37039512-AD
Table of contents
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 9
Table of contents
S7-PLCSIM Advanced
10 Function Manual, 05/2021, A5E37039512-AD
Table of contents
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 11
Guide 1
The documentation for the SIMATIC S7-1500 automation system and the SIMATIC
ET 200MP distributed I/O system is arranged into three areas.
This arrangement enables you to access the specific content you require.
Basic information
The System Manual and Getting Started describe in detail the configuration, installation,
wiring and commissioning of the SIMATIC S7-1500 and ET 200MP systems. The STEP 7 online
help supports you in the configuration and programming.
Device information
Product manuals contain a compact description of the module-specific information, such as
properties, wiring diagrams, characteristics and technical specifications.
General information
The function manuals contain detailed descriptions on general topics regarding the SIMATIC
S7-1500 and ET 200MP systems, e.g. diagnostics, communication, motion control, Web
server, OPC UA.
You can download the documentation free of charge from the Internet
(https://support.industry.siemens.com/cs/ww/en/view/109742691).
Changes and supplements to the manuals are documented in a Product Information.
You can download the product information free of charge from the Internet
(https://support.industry.siemens.com/cs/us/en/view/68052815).
S7-PLCSIM Advanced
12 Function Manual, 05/2021, A5E37039512-AD
Guide
1.1 S7-PLCSIM products
"mySupport"
With "mySupport", your personal workspace, you make the best out of your Industry Online
Support.
In "mySupport", you can save filters, favorites and tags, request CAx data and compile your
personal library in the Documentation area. In addition, your data is already filled out in
support requests and you can get an overview of your current requests at any time.
You must register once to use the full functionality of "mySupport".
You can find "mySupport" on the Internet (https://support.industry.siemens.com/My/ww/en).
Application examples
The application examples support you with various tools and examples for solving your
automation tasks. Solutions are shown in interplay with multiple components in the system -
separated from the focus on individual products.
You will find the application examples on the Internet
(https://support.industry.siemens.com/cs/ww/en/ps/ae).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 13
Guide
1.1 S7-PLCSIM products
S7-PLCSIM Advanced
14 Function Manual, 05/2021, A5E37039512-AD
Guide
1.1 S7-PLCSIM products
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 15
Product overview 2
2.1 What is S7-PLCSIM Advanced?
Using S7-PLCSIM Advanced, you can simulate your CPU programs on a virtual controller. You
do not need any real controllers for this. You can configure your CPU with STEP 7 in the
TIA Portal, program your application logic and then load the hardware configuration and the
program into the virtual controller. From there you can run your program logic, observe the
effects of simulated inputs and outputs and adapt your programs.
In addition to communicating via Softbus, S7-PLCSIM Advanced provides a full Ethernet
connection and can thus also communicate distributed.
S7-PLCSIM Advanced enables interaction with native C++/C# programs or simulation software
over the user interface (API).
Application areas
• Verification of the user program (TIA Portal)
• Automatic testing of the STEP 7 program
• Software in the loop simulation for the virtual commissioning of machine tools/production
machines, production cells and production lines in a plant.
Advantages
The use of S7-PLCSIM Advanced offers numerous advantages:
• Improve quality of automation projects by early error detection
• Avoid costs for hardware in simulation environments
• Reduced response times
• Reduce risk for commissioning
• Earlier training of operator is possible
• Increase production efficiency by optimizing program components
• Increase efficiency during replacement of machine components
• Increase efficiency during expansion of existing plants
S7-PLCSIM Advanced
16 Function Manual, 05/2021, A5E37039512-AD
Product overview
2.2 Compatibility during upgrade
Note
An API with a higher version number (e.g. V4.0) cannot connect to an earlier Runtime
Manager version (e.g. V1.0).
Introductory information on the components of the Runtime simulation can be found in the
section User interfaces (API) (Page 84).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 17
Product overview
2.3 Security for S7-PLCSIM Advanced
Authentication
• The user interfaces (API) do not have options for authentication and authorization. There
is no protection using user accounts and passwords.
• The Runtime Manager communication is not protected by authentication.
Communication
• The multi-computer simulation communication is not encrypted.
• A TCP/IP port is opened on the PC for cross-network communication.
• The installed Npcap program library provides access to TCP/IP network communication.
Note
For cross-computer communication, it is recommended to use a closed simulation network
that is not connected to a production network.
Know-how protection
Note
Know-how protected blocks
If know-how-protected blocks for the simulation support are enabled, the know-how
protection is limited.
Note
CPU function libraries for ODK
The SO files for ODK are not know-how-protected. The customer is responsible for the SO
files and its know-how protection.
S7-PLCSIM Advanced
18 Function Manual, 05/2021, A5E37039512-AD
Product overview
2.4 Simulations support
Note
Enable simulation capability
To use a STEP 7 project with simulation, you must select the "Support simulation during block
compilation" option in the "Protection" tab in the properties of the project and confirm with
OK.
Know-how protection
If a know-how-protected block is to be used for the simulation, it must be unlocked by
entering a password. Only through unlocking can the "Simulation with SIMATIC S7-PLCSIM
Advanced" option in the tab "General > Compilation" in the properties of the block be
activated. Additional information can be found on the Internet
(https://support.industry.siemens.com/cs/ww/en/view/109754928).
Global libraries
You cannot use know-how protection with global libraries, because the libraries are write-
protected.
The "Simulation with SIMATIC S7-PLCSIM Advanced" option must be set when generating the
blocks (source of the blocks).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 19
Product overview
2.5 Supported CPUs
Unsupported CPUs
S7-PLCSIM Advanced does not support the simulation of the following CPUs:
• S7-1200 CPUs
• ET 200SP Open Controller CPU 1515SP PC
• Software Controller
S7-PLCSIM Advanced
20 Function Manual, 05/2021, A5E37039512-AD
Product overview
2.6 Differences between a simulated and a real CPU
Deterministic
S7-PLCSIM Advanced runs on a PC with the Windows operating system. Therefore, the scan
cycle time and the exact time of actions in S7-PLCSIM Advanced are not the same as when
these actions run on physical hardware. This is because that several programs share the
processing resources on your PC.
To provide the best possible deterministic behavior under these conditions, S7-
PLCSIM Advanced as of V2.0 requires one free Core (CPU core) per instance. Information on
the minimum requirements for the computer hardware or a virtual machine can be found in
the section System Requirements (Page 27).
If your program depends heavily on the time required to execute actions, then make sure that
you do not evaluate your program based only on the results of the simulation time.
Know-how protection
Projects with know-how protection for blocks can only be simulated if they are enabled for
simulation. You need the block password for this purpose.
Instructions
Instructions are simulated with a few exceptions, see Restrictions for instructions (Page 402).
Programs that are based on the instructions behave different than real CPUs in the
simulation.
S7-1500R/H
For communication with other devices, you may have configured system IP addresses in
STEP 7 for a redundant S7-1500R/H system. System IP addresses are not supported by S7-
PLCSIM Advanced.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 21
Product overview
2.6 Differences between a simulated and a real CPU
Bus systems
S7-PLCSIM Advanced does not simulate bus systems (PROFINET IO, PROFIBUS DP, backplane
bus).
I/O
S7-PLCSIM Advanced simulates the real CPU, but not configured I/O modules and the on-
board I/O of the compact CPUs.
Communication modules
S7-PLCSIM Advanced does not support communication modules and the associated features
such as "Access to PLC via communication module".
Data logging
S7-PLCSIM Advanced does not simulate data logging.
Recipes
S7-PLCSIM Advanced does not simulate the use of recipes.
Copy protection
S7-PLCSIM Advanced does not simulate copy protection.
S7-PLCSIM Advanced
22 Function Manual, 05/2021, A5E37039512-AD
Product overview
2.6 Differences between a simulated and a real CPU
Limited support
S7-PLCSIM Advanced simulates some functions to a limited extent. You can find an overview
in the section Restrictions, messages and solution (Page 399).
2.6.2 Notes
Solution
To establish a connection to the HMI device V13 or earlier, you have to update this HMI
device to version V14.
To establish a connection from the virtual controller that is configured with a firmware
version lower than V2.0 to the HMI device, you have to remove existing protection levels
from the project.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 23
Product overview
2.6 Differences between a simulated and a real CPU
S7-PLCSIM Advanced
24 Function Manual, 05/2021, A5E37039512-AD
Product overview
2.7 Password to protect confidential configuration data
Note
Note that your Windows password protects the password used to protect confidential
configuration data. Therefore, you are not allowed to share the Windows password with
other, untrustworthy users.
Additional information
Detailed information on the protection of confidential configuration data and on secure
communication can be found in the Communication function manual
(https://support.industry.siemens.com/cs/ww/en/view/59192925).
Move the virtual SIMATIC memory card to another virtual machine (e.g. SIMIT)
If you have not set a password to protect confidential configuration data, there are no
restrictions on move operations.
If you have specified the password to protect confidential configuration data, the following
restriction applies:
When you move the virtual memory card from one computer to another, you cannot start the
PLCSIM Advanced instance on the new system.
Note
To ensure maximum security on your systems, the password for protecting confidential
configuration data is not available on a new system. You must reset the password again in
the new system.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 25
Product overview
2.7 Password to protect confidential configuration data
Remedy:
The computer is part of an Active Directory.
The password encryption is linked to the Windows user. When you use the same Active
Directory user in your domain on another computer, you can start PLCSIM Advanced
instances there.
SIMIT archives the virtual SIMATIC memory card as a ZIP file. and another user/computer
is trying to restart this simulation
Remedy:
1. Remove the password for protecting confidential configuration data from the STEP 7 project.
2. Load the project to the virtual controller.
You can move the virtual memory card to other computers without any restrictions.
Remedy:
1. Enter the password to protect the confidential configuration data in STEP 7 or via the
SIMATIC Automation Tool.
2. Restart the instance.
S7-PLCSIM Advanced
26 Function Manual, 05/2021, A5E37039512-AD
Installing 3
3.1 Introduction
S7-PLCSIM Advanced
27 Function Manual, 05/2021, A5E37039512-AD
Installing
3.1 Introduction
Note
Make sure that the Windows operating system you are using is up to date.
Virtualization platforms
You can install STEP 7 and PLCSIM Advanced on a virtual machine. For this purpose, use one
of the following virtualization platforms in the specified version or a newer version:
• VMware vSphere Hypervisor (ESXi) 6.7
• VMware Workstation Pro 15.5.0
• VMware Player 15.5.0
• Microsoft Hyper-V Server 2019
The information that you need to install STEP 7 (TIA Portal) on a virtual machine is available
on the Internet (https://support.industry.siemens.com/cs/ww/en/view/78788417).
S7-PLCSIM Advanced
28 Function Manual, 05/2021, A5E37039512-AD
Installing
3.1 Introduction
NOTICE
Restrictions due to antivirus programs
Virus scanners that monitor the behavior of processes and communication can have a
significant impact on the performance of the runtime and communication of PLCSIM
Advanced.
Remedy
You can decrease restrictions during installation and runtime of PLCSIM Advanced. Also
define exceptions for the virus scanner for secure files and directories.
Procedure
Add the following directories to the exceptions:
• "C:\Program Files\Common Files\Siemens\PLCSIMADV\Drivers"
• "C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV"
• "C:\Program Files (x86)\SIEMENS\Automation\PLCSIMADV\bin"
If the virus scanner only allows files as exceptions, add all files from the listed directories to
the exceptions. The procedure is described in the instructions of the respective manufacturer.
Note
Readme
You can obtain updates to the topic as downloads on the Internet
(https://support.industry.siemens.com/cs/us/en/view/109773483).
Kaspersky
When using the Anti-Virus virus scanner from Kaspersky, the network settings may not be set
correctly during the installation of PLCSIM Advanced. The result is that communication via
TCP/IP cannot be used (error code -50).
Remedy
Check your network settings as described in the section Activating distributed communication
(Page 45).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 29
Installing
3.1 Introduction
3.1.3 Licenses
Floating license
PLCSIM Advanced is supplied with a floating type license which is version and/or time-
dependent. The license can be stored locally and shared for a network.
Note
Validity
A license is valid for two instances within a PLCSIM Advanced installation.
PLCSIM Advanced V4.0 can only be used with a V4.0 license.
Handling of licenses is described in the Help for SIMATIC Automation License Manager (ALM).
S7-PLCSIM Advanced
30 Function Manual, 05/2021, A5E37039512-AD
Installing
3.1 Introduction
A message at the start of the instances shows the remaining number of days.
Note
Remote access
With remote access, the message must be confirmed on the PC on which the instance was
started.
Timeout alarm
If you do not confirm the message for the license in a certain amount of time, the instance is
not started and the following message appears:
Solution
Start the instance again and confirm the message for the license.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 31
Installing
3.1 Introduction
S7-PLCSIM Advanced
32 Function Manual, 05/2021, A5E37039512-AD
Installing
3.2 S7-PLCSIM Advanced
Setup program
You can use the Setup program to change, repair or uninstall your installation, if necessary.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 33
Installing
3.3 Installing S7-PLCSIM Advanced
Installation requirements
The Setup program starts automatically with a double-click on the download package or
when you insert the DVD in the drive. Make sure that the following conditions are met before
you begin the installation process:
• The hardware and software of the computer meet the system requirements.
• You have administrator rights on the installation computer.
• No other programs are active. This also applies to the Siemens Automation License
Manager and other Siemens applications.
• All S7-PLCSIM versions prior or equal to V14 are uninstalled.
Note
Security settings
For licensing via the ALM, you must agree during installation that port 4410 for TCP can be
entered as an exception in the Windows Firewall (procedure step 5).
Note
Use of virus scanners
Note the information provided in section Restrictions due to antivirus programs (Page 29).
S7-PLCSIM Advanced
34 Function Manual, 05/2021, A5E37039512-AD
Installing
3.3 Installing S7-PLCSIM Advanced
7. Click "Next". The window with the security settings is displayed. To continue the installation,
select the check box at the bottom of the screen to accept changes to the security and
permissions settings of your system.
8. Click "Next". The window with the installation settings is displayed. You can save or print a
report of the settings by clicking "Save report" or "Print report". Check the settings for
correctness. If you want to make any changes, click "Back" until you reach the point in the
installation process where you want to make changes. Once you have completed your
changes, click "Next".
9. The overview screen shows your installation details. Click the "Install" button. The
installation then starts.
10.After completion of the setup program, you must restart your computer. Select "Yes, I want
to restart the computer now" to restart the computer immediately or select "No, I will restart
computer later" to restart the computer later.
11.Click "Restart". If the computer is not restarted, click "Finish".
Remedy
Run the setup for S7-PLCSIM prior or equal to V14 and uninstall the program.
When the setup is not available, download the setup files for S7-PLCSIM via Siemens Mall
(https://support.industry.siemens.com/cs/ww/en/view/65601780).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 35
Installing
3.4 Changing S7-PLCSIM Advanced
Requirements
The following conditions must be met before you can start changing the installation:
• The hardware and software of the computer meet the system requirements.
• You have administrator rights on the installation computer.
• No other programs are active.
Procedure
To change your S7-PLCSIM Advanced installation, follow these steps:
1. Double-click the download package or insert the installation medium into the drive. The
setup program starts up automatically, provided you have not disabled the Autostart
function on the computer. If the setup program does not start up automatically, start it
manually by double-clicking the "Start.exe" file.
2. Follow the prompts until you reach the "Configuration" window.
3. Select the "Change upgrade" check box.
4. Follow the remaining prompts to change your installation.
5. Complete the installation operation by restarting your computer.
Note
Target directory
You cannot change the target directory because you are changing an existing installation.
S7-PLCSIM Advanced
36 Function Manual, 05/2021, A5E37039512-AD
Installing
3.5 Repairing S7-PLCSIM Advanced
Requirements
The following conditions must be met before you can start repairing the installation:
• The hardware and software meet the system requirements.
• You have administrator rights on the installation computer.
• No other programs are active.
Procedure
To repair your installation, follow these steps:
1. Double-click the download package or insert the installation medium into the drive. The
setup program starts up automatically, provided you have not disabled the Autostart
function on the computer. If the setup program does not start up automatically, start it
manually by double-clicking the "Start.exe" file.
2. Follow the prompts until you reach the "Configuration" window. Select the "Repair" check
box.
3. Follow the remaining prompts to repair your installation.
4. Complete the repair operation by restarting your computer.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 37
Installing
3.6 Uninstalling S7-PLCSIM Advanced
S7-PLCSIM Advanced
38 Function Manual, 05/2021, A5E37039512-AD
Communication paths 4
Local and distributed communication
The following paths are open for communication between STEP 7 V15 or higher and the
instances of PLCSIM Advanced user interfaces:
Softbus
Softbus is a communication path via a virtual software interface.
The communication is limited to a local PC or a virtual machine. The advantage here is that
no data can be accidentally downloaded to a hardware CPU or communicate with real
hardware.
S7-PLCSIM Advanced
39 Function Manual, 05/2021, A5E37039512-AD
Communication paths
See also
Interfaces - Information and settings (Page 138)
S7-PLCSIM Advanced
40 Function Manual, 05/2021, A5E37039512-AD
Communication paths
4.1 Local communication
Note
Local communication via TCP/IP
Make sure that communication is only local and cannot be downloaded to real hardware. For
this, there must be no other adapters of your Windows PC configured in the physical network
and in the subnet protocol of the PLCSIM Virtual Ethernet adapter. Microsoft KB 175767
provides background.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 41
Communication paths
4.2 Communication via TCP / IP
Additional information
See error code SREC_COMMUNICATION_INTERFACE_NOT_AVAILABLE for the function
PowerOn() in the section Operating state (Page 156).
Distributed communication
Distributed communication via TCP/IP means that the PLCSIM Advanced instances
communicate with the other devices via the Virtual Switch . Communication is possible with
real or simulated CPUs, real or simulated HMIs.
The PLCSIM Virtual Switch must be activated on the PLCSIM Virtual Ethernet Adapter for
instances on the network to be visible.
Each CPU interface can be reached from the PLCSIM Virtual Ethernet Adapter and requires a
unique IP address.
The PLCSIM Virtual Ehternet Adapter must be in the same IP number range (subnet mask) as
the IP address of the controller.
The IP address of the controller must be unique throughout the entire, accessible network.
S7-PLCSIM Advanced
42 Function Manual, 05/2021, A5E37039512-AD
Communication paths
4.2 Communication via TCP / IP
Required settings in the "Virtual Machine Settings" dialog using the VMware
visualization platform as an example
If you have opened STEP 7 (TIA Portal) and your project within the virtual machine, enable
the following options for your online connection as follows:
1. Right-click on the VM and select "Settings" or select the menu "VM > Settings".
2. Open the "Virtual Machine Settings" dialog via the menu command "Player > Manage >
Virtual Machine Settings".
3. Then click "Network Adapter" in the "Hardware" tab and activate the following options in the
right window:
– Connected
– Connect at power on
– Bridged: Connected directly to the physical network
– Replicate physical network connection state
4. Click the "Configure Adapters" button and activate your network connection, for example
"Intel(R)82574L LM Gigabit Network Connection".
5. Confirm the setting with OK and exit the "Virtual Machine Settings" dialog with OK.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 43
Communication paths
4.2 Communication via TCP / IP
S7-PLCSIM Advanced
44 Function Manual, 05/2021, A5E37039512-AD
Communication paths
4.3 Enable distributed communication
Note
Network adapter
Make sure that only one network adapter of the PLCSIM Virtual Switch is activated. The
Control Panel of PLCSIM Advanced checks the activation and may report an incorrect
configuration (error code -50).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 45
Communication paths
4.3 Enable distributed communication
Accessible devices
When the PLCSIM Virtual Switch is activated, STEP 7 shows the devices available on the
Virtual Ethernet Adapter in the project tree.
Remedy
Use the wired network adapter of the PC/notebook and connect a WLAN adapter upstream.
S7-PLCSIM Advanced
46 Function Manual, 05/2021, A5E37039512-AD
Simulation 5
5.1 Simulate CPU
Requirements
The following requirements must be met for starting simulation via local communication:
• STEP 7 as of V14 and S7-PLCSIM Advanced V4.0 are installed on the same PC.
• The CPU hardware is configured in STEP 7.
Note
Enable simulation support
In the "Protection" tab in the properties of the project in STEP 7, select the check box "Support
simulation during block compilation"; see Simulations support (Page 19).
S7-PLCSIM Advanced
47 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
A double-click on the symbol opens the Control Panel for PLCSIM Advanced. If the Control
Panel is in the background, it is moved to the foreground with another double-click.
You can use Windows functions to permanently display the icon in the system tray of the
taskbar.
You can use the mouse-over function to display messages about the current status of the
instances.
S7-PLCSIM Advanced
48 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 49
Simulation
5.1 Simulate CPU
Design
S7-PLCSIM Advanced
50 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
• "Start" button Create with the button and start the instance.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 51
Simulation
5.1 Simulate CPU
TCP/IP communication
You can select a real network adapter from the drop-down list during operation. You thus
activate the PLCSIM Virtual Switch and establish TCP/IP communication between the
instances and the real network.
The <Local> setting disables the PLCSIM Virtual Switch and disconnects the instances from
the real network. Only local TCP/IP communication over virtual adapter is possible in this case.
Virtual time
You must enable the virtual time for each instance using the icon . Use the slider or the
mouse wheel to select the scaling factor for the virtual time.
The selected scaling factor applies to the instances for which the virtual time is enabled.
Clicking on "Off" restores the default (1) again. For further information see Virtual and Real
Time (Page 75).
S7-PLCSIM Advanced
52 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
Instance list
The list contains the instances that are available locally on the PC or virtualization platform.
Instances that have already been started on the runtime API are detected and displayed in the
list.
Select the operating mode of the instance with the "RUN" and "STOP" buttons. Select one or
more instances for this purpose. Perform a memory reset with the "MRES" button.
The LED displays show the status of the instance that corresponds to those of the hardware
CPU.
RUN and STOP are displayed depending on the current operating state of the instance.
You can "operate" the instance with icons:
Enable virtual time, apply scaling factor for the virtual time, disable virtual time,
Switch off instance and log off from Runtime Manager ("Unregister")
Display messages
Each time the Panel starts, help information and messages relating to the Control Panel are
displayed, for example, when changing the IP address or when a license is missing. Disable
the display if you do not need the messages.
Requirement
This function is only available if you do not start the Control Panel with admin rights.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 53
Simulation
5.1 Simulate CPU
Importing instances
You can use the drag-and-drop function to import instances from a folder directly into the
instance list of the Control Panel.
1. Open a folder with instances, for example, using the "Virtual SIMATIC Memory Card" button.
2. Select one or more instances and drag them into the highlighted area.
S7-PLCSIM Advanced
54 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
5.1.3 Download
Requirements
You can download the STEP 7 project to the virtual controller when the following conditions
are met:
• The instance is created via the Control Panel.
• The check box "Support simulation during block compilation" is selected.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 55
Simulation
5.1 Simulate CPU
Perform download
1. Select the PG/PC interface.
2. Click "Download".
→ In the "Load preview" window, STEP 7 shows the message "The downloads are
performed on a simulated CPU".
→ After the first download, the PLCSIM Advanced instance displays the CPU type.
Figure 5-7 Example: Download via the "PLCSIM Virtual Ethernet Adapter" (TCP/IP) after naming
S7-PLCSIM Advanced
56 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
IP address
At the PLCSIM Virtual Ethernet Adapter you assign a static IP address or obtain an IP address
via DHCP (default).
MAC address
A randomly generated MAC address is assigned to the PLCSIM Virtual Ethernet Adapter during
its installation.
PLCSIM Advanced only uses MAC addresses that are designated as "locally administered"
(bit 2 in LSB).
The Siemens-specific prefix is: 02-1B-1B
Three bytes follow, which are determined at random.
Storage location
This MAC address is stored in the registry key "PlcsimvminiMacAddress".
You can overwrite this value.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 57
Simulation
5.1 Simulate CPU
The MAC address tells you the PC on which a PLCSIM Advanced instance has been started.
Table 5- 1 Assignment of the Ethernet interfaces, for example, for a CPU 1518-4 PN/DP
S7-PLCSIM Advanced
58 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
Example
02-C0-A8-00-83-10 means:
02 → locally managed MAC address of a PLCSIM Advanced instance
C0-A8-00-83 → IP of the Siemens PLCSIM Virtual Ethernet adapter = 192.168.0.131
1 → Instance 1
0 → Ethernet interface IE 1
If no Virtual SIMATIC Memory Card is loaded during startup of PLCSIM Advanced, the
interfaces of PLCSIM Advanced display instances with their locally managed MAC address.
Note
Dominance of the API when synchronizing
The API dominates when synchronizing. If the user program writes to the same address range
as the API, the changes of the API overwrite those of the virtual controller.
See also
Deviating I/O values in the STEP 7 user program (Page 408)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 59
Simulation
5.1 Simulate CPU
Special conditions apply when communicating with TUSEND/TURCV, see Restrictions for
communications services (Page 402).
S7-PLCSIM Advanced
60 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
✓ = Communication possible
x = Communication not possible
TMAIL_C
When the TMAIL_C instruction is used, the mail server might not be located on the same PC
as the PLCSIM Advanced instance.
Remedy
Make the mail server available via a different PC in the network.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 61
Simulation
5.1 Simulate CPU
• In the Control Panel, the function "Shutdown instance" , "Log off instance" or the
Exit function "Log off all instances"
S7-PLCSIM Advanced
62 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.1 Simulate CPU
API functions
The project data can be used for an instance via the user interface. Use of the following
functions for this:
API functions
• GetStoragePath() (Page 148)
• StoragePath { get; set; } (Page 149)
• ArchiveStorage() (Page 150)
• RetrieveStorage() (Page 152)
See also
Controller - Information and settings (Page 144)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 63
Simulation
5.2 Simulate CPU with ODK functionality
Introduction
The ODK is an engineering tool that allows the creation of high-level language applications
for S7-1500 CPUs. You use it to generate function libraries that are used in the STEP 7 user
program.
The ODK for PLCSIM Advanced V4.0 supports the programming language C ++.
You can find the description of the ODK in the Programming and Operating Manual "S7-1500
Open Development Kit 1500S", as of V2.5 Edition 12/2017: SIMATIC STEP 7 (TIA Portal)
Options ODK 1500S (https://support.industry.siemens.com/cs/ww/en/ps/13914/man)
Section 6 "Development of a CPU function library for the real-time environment" is relevant
for ODK applications under PLCSIM Advanced.
Supported CPUs
PLCSIM Advanced V4.0 supports the ODK functionality of the following controllers:
• CPU 1518(F)-4 PN/DP ODK
• CPU 1518(F)-4 PN/DP MFP
• After the first download, select the functions "Switch off instance" and "Shutdown
instance" in the Control Panel.
Note
When you perform the first download to a CPU of the "S7-1500" family, for example, via
the PLCSIM Advanced Control Panel, no ODK1500S directory is created on the virtual
SIMATIC Memory Card. The CPU cannot be switched to RUN. In this case, you will find
messages about missing ODK blocks (e.g. SFC 2013) in the diagnostics buffer.
S7-PLCSIM Advanced
64 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.2 Simulate CPU with ODK functionality
Note
Do not mix function libraries
When simulating with PLCSIM Advanced, only function libraries with the same binary format
can be loaded at a time.
If you want to use function libraries with a different binary format, all others must be
unloaded first.
Note
Limitations for the execution of CPU function libraries (Windows Sync) with an infinite
loop in the class constructor
When the CPU function library (DLL file) contains an object of a class in whose constructor an
infinite loop is programmed, the corresponding "ODK client" process gets permanently stuck
in this loop when instantiating the object.
Even after reaching the timeout, the infinite loop cannot be interrupted automatically. The
PLCSIM Advanced instance remains in RUN even though the entry "Time error - CPU changes
to STOP mode" is displayed in the diagnostics buffer.
Note
Limitations for traces in the execution of CPU function libraries (Windows Sync)
Avoid using traces when developing a CPU function library (DLL file) in the class constructor
(call of the "ODK_TRACE()" function) to prevent trace messages with faulty parameter values.
Note
No know-how protection for SO files
The SO files for ODK are not know-how-protected.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 65
Simulation
5.2 Simulate CPU with ODK functionality
Note
PLCSIM Advanced does not support asynchronous ODK functions.
Error codes
The same error codes as described in the Programming and Operating Manual
"S7-1500 Open Development Kit 1500S" apply to the instructions in the real-time
environment. Error codes are also available for PLCSIM Advanced, because the ODK client
processes can be closed unexpectedly and therefore an error handling is required.
Note
Limitations for stack processing in the version of CPU function libraries for real-time-
environment
PLCSIM Advanced ignores the stack size for a CPU function library that is adjusted via the
parameter <SyncCallStackSize>. PLCSIM Advanced always provides the maximum stack size of
1 MB.
See Programming and Operating Manual "S7-1500 Open Development Kit 1500S" V2.5,
section 5.1.4 Defining the runtime properties of a CPU function library.
PLCSIM Advanced cannot catch any Exceptions of the type "Stack Overflow" while
CPU function libraries for the real-time environment (SO files) are being executed.
S7-PLCSIM Advanced
66 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.2 Simulate CPU with ODK functionality
When developing a CPU function library (SO file), make sure that the maximum stack size of
1 MB is not exceeded. An overflow of the stack leads to an undefined behavior and can lead
to the termination of the ODK client process.
Note
Limitations for heap processing in the version of CPU function libraries (Windows Sync)
If a heap corruption occurs when executing a C/C++ function from a CPU function library (DLL
file), then this program error is first ignored and execution of the function continues. Only
after fully processing the function is the corresponding error code returned (0x8090).
When developing a CPU function library (DLL file), make sure to avoid heap corruption. This
way you ensure that after fully processing a C/C++ function no error code is returned.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 67
Simulation
5.2 Simulate CPU with ODK functionality
S7-PLCSIM Advanced
68 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.3 Simulating Motion Control
Restrictions
PLCSIM Advanced simulates the real CPU, but not configured, connected technology modules
or other I/O devices.
It is possible to download a STEP 7 project with technology modules for operation of motion
control. However, the built-in logic of the technology modules is not part of the simulation.
Therefore, the corresponding motion control instructions are not supported.
In contrast to a real CPU, S7-PLCSIM Advanced does not support isochronous mode for
centralized I/O in S7-1500 with local send clock.
OB 91 and OB 92
If you convert a Motion Control project which contains the OB 91 and OB 92 from
STEP 7 V13, then you cannot load this project to a PLCSIM Advanced.
Solution
Delete OB 91 and OB 92 in the project and recompile the project.
The OBs are thus created again with the simulation support required for PLCSIM Advanced.
Compilation resets the properties of the blocks to the default values.
Restore the required settings in the properties.
Why is the "Overflow" message for the OB MC-Servo [OB91] displayed in the diagnostic buffer of
the virtual controller S7-PLCSIM Advanced?
S7-PLCSIM Advanced provides you with the virtual controller of the S7-1500 hardware CPU.
The virtual controller allows you to run the firmware of the S7-1500 under the Windows
operating system.
The wide-ranging communication options and the functions of the API offer you integration
into existing simulation landscapes or co-simulation with other tools. The virtual controller
runs in the Windows environment with the following restrictions. The real hardware CPUs, on
the other hand, are designed for the maximum possible performance without the
compromises required by a general PC operating system.
If there are overflows of the OB MC-Servo [OB91] in the diagnostic buffer, the time for the
application cycle (ms) has been exceeded, because the calculation of this application cycle
could not be completed within the required time.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 69
Simulation
5.3 Simulating Motion Control
Solution
The overflows of OB MC-Servo [OB91] in the diagnostic buffer decrease:
• When fewer additional Windows processes are executed
and
• When the computing power of the CPU is higher
Overflow detection is activated for S7-PLCSIM Advanced as of V3.0 for exact simulation of the
technology objects. If diagnostic buffer overflows occur on your PC for OB MC-Servo [OB91]
and your instance goes into the STOP mode, the following remedies are available to you:
1. Use the virtual time of S7-PLCSIM Advanced and start with the lowest possible scaling factor
for the virtual clock. Increase the value step-by-step until the first overflows occur in the
diagnostic buffer. Repeat this procedure until you have determined the maximum scaling
factor for which you do not yet get any overflows in the diagnostic buffer.
Information on the scaling factor can be found in section Speed up and slow down
simulation (Page 77).
2. Set a longer application cycle (ms) for the OB MC-Servo [OB91] in STEP 7.
Note
In a virtual S7-1500 controller, the technology objects are connected to the process image.
Simulation software can thus access the process image via the user interfaces (API) of
PLCSIM Advanced and simulate the behavior of the other connected axes.
S7-PLCSIM Advanced
70 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.4 Simulating the SIMATIC Drive Controller
Additional information
You can find information on the technology functions of the CPU in the
S7-1500/S7-1500T Motion Control
(https://support.industry.siemens.com/cs/ww/en/view/109751049) function manuals.
For more information, refer to the manuals of the supported SIMATIC controllers.
(https://support.industry.siemens.com/cs/ww/en/view/109744173)
Introduction
The SIMATIC Drive Controller is a drive-based controller in the SIMATIC S7-1500 range.
A SIMATIC Drive Controller combines the following functionalities in a SINAMICS S120
Booksize Compact housing:
• Fail-safe SIMATIC S7-1500 technology CPU with integrated technology I/Os
• SINAMICS S120 drive control
Both components are called "CPU" and "SINAMICS Integrated" in the documentation.
The SIMATIC Drive Controller supports PROFINET and PROFIBUS DP communication.
Special features
Unlike other SIMATIC S7-1500 technology CPUs, the SIMATIC Drive Controllers also have:
• Integrated inputs/outputs (onboard I/O)
• Integrated drive control SINAMICS Integrated
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 71
Simulation
5.4 Simulating the SIMATIC Drive Controller
Restrictions
S7-PLCSIM Advanced only simulates the standard CPU functionality of the
SIMATIC Drive Controller.
Not simulated are:
• the technology functions of the onboard I/O
• the SINAMICS Integrated
• PROFINET IO
• PROFIBUS DP
The integrated inputs/outputs of the X122, X132 and X142 interfaces can only be simulated
as binary inputs/outputs.
Technological functions are not simulated, for example, Timer DI/DQ, Oversampling DI/DQ.
Channel parameter assignments, such as signal inversion, input delay and edge detection are
not possible.
The functionality of the SINAMICS Integrated is not simulated – but the SINAMICS Integrated
is shown as a valid node.
Simulations are possible as with SINAMICS S120 CU320-2 based on the drive telegrams (e.g.
by reading and forcing the telegram addresses).
Note
Leading clock system
Clock synchronization with technology I/Os X142 (local send clock) as leading clock system is
not possible with S7-PLCSIM Advanced. In this case, you configure the PROFINET IO interface
X150 as leading clock system.
The information provided in the section Simulation of Motion Control (Page 69) still applies.
Additional information
The SIMATIC Drive Controller system manual
(https://support.industry.siemens.com/cs/ww/en/view/109766665) describes in detail the
configuration, installation, wiring and commissioning of the SIMATIC Drive Controller. The
STEP 7 online help supports you in the configuration and programming.
The SIMATIC Drive Controller equipment manual
(https://support.industry.siemens.com/cs/ww/en/view/109766666) contains a compact
description of the module-specific information, such as properties, wiring diagrams,
characteristics and technical specifications.
S7-PLCSIM Advanced
72 Function Manual, 05/2021, A5E37039512-AD
Simulation
5.5 Simulating a redundant S7-1500R/H system
Introduction
In a redundant S7-1500R/H system, the CPUs are duplicated, in other words, redundant. The
two CPUs process the same project data and the same user program in parallel. The two CPUs
are synchronized over two redundancy connections. If one CPU fails, the other CPU maintains
control of the process.
Supported CPUs
PLCSIM Advanced V4.0 supports the R/H CPUs of the redundant S7-1500R/H system as of
firmware version V2.9 with the following functional restrictions:
• CPU 1513R-1 PN (6ES7513-1RL00-0AB0)
• CPU 1515R-2 PN (6ES7515-2RM00-0AB0)
• CPU 1515R-2 PN SIPLUS RAIL (6AG2 515-2RM00-4AB0)
• CPU 1515R-2 PN SIPLUS (6AG1 515-2RM00-7AB0)
• CPU 1517H-3 PN (6ES7517-3HP00-0AB0)
• CPU 1517H-3 PN SIPLUS (6AG1 517-3HP00-4AB0)
• CPU 1518HF-4 PN (6ES7518-4JP00-0AB0)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 73
Simulation
5.5 Simulating a redundant S7-1500R/H system
Note
RUN-Solo system state is supported by PLCSIM Advanced
The simulation of a redundant S7-1500R/H system is possible in the RUN-Solo system state
(RUN operating state of the CPU). In the RUN operating state, the (leading) primary CPU
behaves just like an S7-1500 standard CPU. The MAINT LED on the CPU is always yellow
(maintenance request) because no partner CPU was found for redundant operation.
No simulation is possible with PLCSIM Advanced in redundant system operation.
Additional information
The Redundant system S7-1500R/H System Manual
(https://support.industry.siemens.com/cs/de/de/view/109754833/en) describes in detail the
configuration, installation, wiring and commissioning of the redundant S7-1500R/H system.
The STEP 7 online help supports you in the configuration and programming.
The equipment manuals of the R-, H- and HF-CPUs contain a compact description of the
module-specific information, such as properties, wiring diagrams, characteristics and
technical specifications of the CPUs.
S7-PLCSIM Advanced
74 Function Manual, 05/2021, A5E37039512-AD
Virtual time response 6
The virtual controller uses internally two types of clocks for simulation: A virtual clock and a
real clock. The virtual clock is always the basis for the user program. It is used by components
that are relevant for running the STEP 7 user program, such as cyclic OBs, cycle time
monitoring, minimum cycle time, virtual system time and time calculations. Also, the time
between two cycle control points is measured in virtual time.
The virtual time can be accelerated or slowed for test purposes.
The real clock always runs unchanged. It is used by components that are not subject to
control processes, for example, communication with STEP 7.
Note
Difference between system time and local time
• System time: UTC ± 0 with daylight saving / standard time
• Local time: UTC ± time zone with daylight saving time / winter time
API functions
• GetSystemTime() (Page 249)
• SetSystemTime() (Page 250)
• SystemTime { get; set; } (Page 250)
S7-PLCSIM Advanced
75 Function Manual, 05/2021, A5E37039512-AD
Virtual time response
Time offset
Note
Keep in mind that the time information of virtual system time and real local time differs by
the time offset that is formed in addition to the selected scaling factor from the time zone
offset and the daylight saving time/standard time offset.
Scaling factor
Using a scaling factor, you can speed up or slow down the virtual clock of the virtual
controller for simulations.
To set the required scaling factor, enable the grayed out icon on the control panel to the
right of your PLCSIM Advanced instance. The symbol then becomes active and you can
use the scaling function.
• The default is 1, i.e. the course of the virtual time corresponds to the course of real time.
• Fast forward: A scaling factor greater than 1 accelerates the virtual clock.
Example: Scaling factor 2.0 → The virtual time is running twice as fast.
• Slow motion: A scaling factor less than 1 decelerates the virtual clock.
Example: Scaling factor 0.5 → The progress of the virtual time slows down to 50%.
API functions
• GetScaleFactor() (Page 250)
• SetScaleFactor() (Page 251)
• ScaleFactor { get; set; } (Page 252)
See also
Settings for the virtual time (Page 249)
S7-PLCSIM Advanced
76 Function Manual, 05/2021, A5E37039512-AD
Virtual time response
6.1 Speed up and slow down simulation
Note
Performance
The performance depends on the size of your project, among other things.
If the scaling factor is too high and the cycle-time monitoring indicates that the PC was
incapable of calculating the OB1 or cyclic OBs in the specified time, the virtual controller goes
to STOP.
Recommendation: To avoid this, start with a small scaling factor and gradually increase it
step-by-step while keeping the virtual controller in RUN.
If an overflow of events occurs, slow down the speed of the simulation. See Monitoring
overflow (Page 407) and Cycle control (Page 252).
Fast forward
To speed up the virtual time, select a scaling factor greater than 1 in the Control Panel or in
the API.
Slow motion
To slow down the virtual time, select a scaling factor less than 1 in the Control Panel or in the
API.
API functions
• GetScaleFactor() (Page 250)
• SetScaleFactor() (Page 251)
• ScaleFactor { get; set; } (Page 252)
See also
Settings for the virtual time (Page 249)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 77
Virtual time response
6.2 Stop simulation
Note
Freeze state during downloading
To complete a download in freeze state, the virtual controller must pass a cycle control point
at the end of the download.
Note
Freeze-state ≠ operating state
The freeze state is an internal operating state of the virtual controller. It does not correspond
to RUN/STOP mode of a CPU. In the freeze state, the virtual controller maintains the last
operating state.
• The LED display on the Control Panel and on the Web server accordingly shows RUN or
STOP for instance.
• The instance shows the operating state SROS_FREEZE / Freeze, see EOperatingState
(Page 380).
S7-PLCSIM Advanced
78 Function Manual, 05/2021, A5E37039512-AD
Virtual time response
6.2 Stop simulation
Synchronization points
A synchronization point always exists before inputs are read in, for example at the cycle
control point or at the beginning of a cyclic OB.
API functions
• Settings for the cycle control (Page 252)
• GetOperatingMode() (Page 252)
• SetOperatingMode() (Page 253)
• OperatingMode { get; set; } (Page 253)
• EOperatingMode (Page 381)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 79
Virtual time response
6.3 Synchronize simulation partner
S7-PLCSIM Advanced
80 Function Manual, 05/2021, A5E37039512-AD
Virtual time response
6.3 Synchronize simulation partner
Example
The figure schematically shows the sequence in the SingleStep_CP operating mode.
In addition to the OnSyncPointReached event the virtual controller also sends the virtual
time since the last synchronization point of the same process image partition ID or of any
process image partition ID has been reached (TimeSinceSameSyncPoint_ns /
TimeSinceAnySyncPoint_ns).
The RunToNextSyncPoint() function cancels the freeze state.
Note
Selecting triggers for monitoring of tags in the SingleStep operating modes
In TIA Portal the watch table in basic mode shows the values for outputs and bit memories
before the processing.
In order to display the tag values after the processing, select the extended mode for the
watch table and then select "Permanently, at end of scan cycle" in the "Monitor with trigger"
column.
See also
Cycle control (Page 252)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 81
Virtual time response
6.3 Synchronize simulation partner
S7-PLCSIM Advanced
82 Function Manual, 05/2021, A5E37039512-AD
Virtual time response
6.3 Synchronize simulation partner
Example
The figure schematically shows the sequence in the TimespanSynchronized_CP
operating mode.
In addition to the OnSyncPointReached event the virtual controller also sends the runtime
since the last call of the StartProcessing(t) (TimeSinceSameSyncPoint_ns /
TimeSinceAnySyncPoint_ns) function.
The StartProcessing() function cancels the freeze state.
Description
At least two clients are synchronized on the basis of a virtual period for the time-controlled
operating modes. A client can be an instance of a virtual controller or an application that uses
the Runtime API (API client). The synchronization must be performed by a synchronization
master.
The synchronization master instructs a client to run for a specific period. The time period is
specified by the master in nanoseconds. The client then runs for the expected period before
he goes into the freeze state at the next synchronization point. Before switching to the freeze
state, the client sends the master the exact amount of time that he currently needed.
Thereafter, the master signals the next client to catch up.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 83
User interfaces (API) 7
7.1 Introduction
Components Description
• "Siemens.Simatic.Simulation. A Windows process that runs in the background.
Main component of Runtime that manages all other
Runtime.Manager.exe"
Runtime components.
The process is started automatically as soon as an applica-
tion attempts to initialize the Runtime API. It is ended auto-
matically as soon as there is no longer any application
running that initialized the Runtime API.
• "Siemens.Simatic.Simulation. The process of the instance that loads a DLL of a virtual
controller. Each virtual controller generates its own process.
Runtime.Instance.exe"
• "Siemens.Simatic.Simulation. API libraries that must load an application to use the Simula-
tion Runtime. The libraries contain interfaces for native code
Runtime.Api.x86.dll"
and managed code.
• "Siemens.Simatic.Simulation. The "Runtime.Api.x86.dll" is loaded exclusively by 32-bit
Runtime.Api.x64.dll" applications, and the "Runtime.Api.x64.dll" by 64-bit appli-
cations.
• "SimulationRuntimeApi.h" Header file that describes all data types that require a native
C++ application to use the API library.
• "Siemens.Simatic.PlcSim.Vplc1500. ODK client process for a CPU function library (original
Shared Object)
ODKClient.so.exe"
S7-PLCSIM Advanced
84 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 85
User interfaces (API)
7.1 Introduction
API functions
• Table 7-6 Overview of IInstances functions - Native C++ (Page 90)
• Table 7-13 Overview of IInstances functions - .NET (C#) (Page 94)
• Table 7-8 Overview of IRemoteRuntimeManager functions - Native C++ (Page 92)
• Table 7-15 Overview of IRemoteRuntimeManager functions - .NET (C#) (Page 95)
See also
Overview of user interfaces for managed code (Page 93)
S7-PLCSIM Advanced
86 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
① ISimulationRuntimeManager
Interface of the Runtime Manager. It is used to register new Runtime instances, to search
through existing Runtime instances, and to receive an interface of a registered instance. Up to
16 instances can be registered in one Runtime Manager.
② IInstances
Interface of a Runtime instance. It is used to change the operating state of a virtual controller
and to exchange I/O data. Each instance has a unique name and an ID.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 87
User interfaces (API)
7.1 Introduction
Note
The list of tables in this manual gives you direct access to the description of the individual
functions and data types.
Actions Functions
Initialize API InitializeApi (Page 100)
RuntimeApiEntry_Initialize (Page 102)
Shut down API (Page 104) DestroyInterface
RuntimeApiEntry DestroyInterface
Logging off API library FreeApi
(Page 107) ShutdownAndFreeApi
S7-PLCSIM Advanced
88 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
Global functions
Actions Functions
Global functions (Page 109) GetNameOfAreaSection()
GetNameOfCPUType()
GetNameOfCommunicationInterface()
GetNameOfDataType()
GetNameOfLEDMode()
GetNameOfLEDType()
GetNameOfOperatingMode()
GetNameOfOperatingState()
GetNameOfPrimitiveDataType()
GetNameOfTagListDetails()
GetNameOfErrorCode()
GetNameOfRuntimeConfigChanged()
GetNameOfInstanceConfigChanged()
GetNameOfDiagSeverity()
GetNameOfDirection()
GetNameOfRackOrStationFaultType()
GetNameOfProcessEventType()
GetNameOfPullOrPlugEventType()
GetNameOfCycleTimeMonitoringMode()
GetNameOfDiagProperty()
GetNameOfAutodiscoverType()
API ISimulationRuntimeManager
Settings Functions
Interface (Page 114) GetVersion()
IsInitialized()
IsRuntimeManagerAvailable()
Shutdown()
GetStrictMotionTiming()
SetStrictMotionTiming()
Simulation Runtime instances GetRegisteredInstancesCount()
(Page 118) GetRegisteredInstanceInfoAt()
RegisterInstance()
RegisterCustomInstance()
CreateInterface()
Remote connections OpenPort()
(Page 124) ClosePort()
GetPort()
GetRemoteConnectionsCount()
GetRemoteConnectionInfoAt()
RemoteConnect()
RunAutodiscover()
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 89
User interfaces (API)
7.1 Introduction
Events Functions
OnConfigurationChanged RegisterOnConfigurationChangedCallback()
(Page 132) UnregisterOnConfigurationChangedCallback()
RegisterOnConfigurationChangedEvent()
UnregisterOnConfigurationChangedEvent()
WaitForOnConfigurationChangedEvent()
OnRuntimeManagerLost RegisterOnRuntimeManagerLostCallback()
(Page 134) UnregisterOnRuntimeManagerLostCallback()
RegisterOnRuntimeManagerLostEvent()
UnregisterOnRuntimeManagerLostEvent()
WaitForOnRuntimeManagerLostEvent()
OnAutodiscover (Page 137) RegisterOnAutodiscoverCallback()
UnregisterOnAutodiscoverCallback()
API IInstances
Settings Functions
Interface (Page 138) GetID()
GetName()
GetCPUType()
SetCPUType()
GetCommunicationInterface()
SetCommunicationInterface()
GetInfo()
UnregisterInstance()
GetStrictMotionTiming()
SetStrictMotionTiming()
Controller (Page 144) GetControllerName()
GetControllerShortDesignation()
GetControllerIPCount()
GetControllerIP()
GetControllerIPSuite4()
SetIPSuite()
GetStoragePath()
SetStoragePath()
ArchiveStorage()
RetrieveStorage()
CleanupStoragePath()
Operating state (Page 156) PowerOn()
PowerOff()
Run()
Stop()
GetOperatingState()
MemoryReset()
Tag list (Page 167) UpdateTagList()
GetTagListStatus()
GetTagInfoCount()
GetTagInfos()
CreateConfigurationFile()
I/O access via address - Reading GetAreaSize()
(Page 174) ReadBit()
ReadByte()
ReadBytes()
ReadSignals()
S7-PLCSIM Advanced
90 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
Settings Functions
I/O access via address - Writing WriteBit()
(Page 183) WriteByte()
WriteBytes()
WriteSignals()
I/O access via tag name - Read- Read()
ing (Page 189) ReadBool()
ReadChar(), ReadWChar()
ReadDouble()
ReadFloat()
ReadInt8(), ReadInt16(), ReadInt32(), ReadInt64()
ReadUInt8(), ReadUInt16(), ReadUInt32(), Rea-
dUInt64()
ReadSignals()
I/O access via tag name - Writ- Write()
ing (Page 220) WriteBool()
WriteChar(), WriteWChar()
WriteDouble()
WriteFloat()
WriteInt8(), WriteInt16(), WriteInt32(),
WriteInt64(),
WriteUInt8(), WriteUInt16(), WriteUInt32(),
WriteUInt64()
WriteSignals()
Virtual time (Page 249) GetSystemTime()
SetSystemTime()
GetScaleFactor()
SetScaleFactor()
Cycle control (Page 252) GetOperatingMode()
SetOperatingMode()
SetSendSyncEventInDefaultModeEnabled()
IsSendSyncEventInDefaultModeEnabled
GetOverwrittenMinimalCycleTime_ns()
SetOverwrittenMinimalCycleTime_ns()
RunToNextSyncPoint()
StartProcessing()
SetCycleTimeMonitoringMode()
GetCycleTimeMonitoringMode()
Acyclic services (Page 261)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 91
User interfaces (API)
7.1 Introduction
Events Functions
OnOperatingStateChanged RegisterOnOperatingStateChangedCallback()
(Page 281) UnregisterOnOperatingStateChangedCallback()
RegisterOnOperatingStateChangedEvent()
UnregisterOnOperatingStateChangedEvent()
WaitForOnOperatingStateChangedEvent()
OnLedChanged (Page 285) RegisterOnLedChangedCallback()
UnregisterOnLedChangedCallback()
RegisterOnLedChangedEvent()
UnregisterOnLedChangedEvent()
WaitForOnLedChangedEvent()
OnConfigurationChanging RegisterOnConfigurationChangingCallback()
(Page 287) UnregisterOnConfigurationChangingCallback()
RegisterOnConfigurationChangingEvent()
UnregisterOnConfigurationChangingEvent()
WaitForOnConfigurationChangingEvent()
OnConfigurationChanged RegisterOnConfigurationChangedCallback()
(Page 290) UnregisterOnConfigurationChangedCallback()
RegisterOnConfigurationChangedEvent()
UnregisterOnConfigurationChangedEvent()
WaitForOnConfigurationChangedEvent()
OnSyncPointReached RegisterOnSyncPoin-
tReachedCallback()UnregisterOnSyncPointReachedCall
(Page 292) back()RegisterOnSyncPointReachedEvent()UnregisterO
nSyncPoin-
tReachedEvent()WaitForOnSyncPointReachedEvent()
API IRemoteRuntimeManager
Settings Functions
Interface (Page 304) GetVersion()
GetIP()
GetPort()
GetRemoteComputerName()
Disconnect()
GetStrictMotionTiming()
SetStrictMotionTiming()
Simulation Runtime instances GetRegisteredInstancesCount()
(Page 309) GetRegisteredInstanceInfoAt()
RegisterInstance()
RegisterCustomInstance()
CreateInterface()
Events Functions
OnConnectionLost (Page 317) RegisterOnConnectionLostCallback()
UnregisterOnConnectionLostCallback()
RegisterOnConnectionLostEvent()
UnregisterOnConnectionLostEvent()
WaitForOnConnectionLostEvent()
S7-PLCSIM Advanced
92 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
Actions Functions
Initialize API (Page 104) Sie-
mens.Simatic.Simulation.Runtime.SimulationRuntimeM
anager
Shut down API (Page 109)
API ISimulationRuntimeManager
Settings Functions
Interface (Page 114) Version { get; }
IsInitialized { get; }
IsRuntimeManagerAvailable { get; }
Shutdown()
StrictMotionTiming { get; set; }
Simulation Runtime instances RegisterInstanceInfo { get; }
(Page 118) RegisterInstance()
RegisterCustomInstance()
CreateInterface()
Remote connections OpenPort()
(Page 124) ClosePort()
Port { get; }
RemoteConnectionInfo { get; }
RemoteConnect()
RunAutodiscover()
Events Functions
OnConfigurationChanged OnConfigurationChanged
(Page 132) RegisterOnConfigurationChangedEvent()
UnregisterOnConfigurationChangedEvent()
WaitForOnConfigurationChangedEvent()
OnRuntimeManagerLost OnRuntimeManagerLost()
(Page 134) RegisterOnRuntimeManagerLostEvent()
UnregisterOnRuntimeManagerLostEvent()
WaitForOnRuntimeManagerLostEvent()
OnAutodiscover (Page 137) OnAutodiscoverData
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 93
User interfaces (API)
7.1 Introduction
API IInstances
Settings Functions
Interface (Page 138) Dispose ()
ID { get; }
Name { get; }
CPUType { get; set; }
CommunicationInterface { get; }
Info { get; }
UnregisterInstance()
StrictMotionTiming { get; set; }
Controller - Information and ControllerName { get; }
settings (Page 144) ControllerShortDesignation { get; }
ControllerIPSuite4 { get; }
SetIPSuite()
StoragePath { get; set; }
ArchiveStorage()
RetrieveStorage()
CleanupStoragePath()
Operating state (Page 156) PowerOn()
PowerOff()
Run()
Stop()
OperatingState { get; }
MemoryReset()
Tag list (Page 167) UpdateTagList()
GetTagListStatus()
TagInfos { get; }
CreateConfigurationFile()
I/O access via address - Reading InputArea | MarkerArea | OutputArea { get; }
(Page 174) AreaSize { get; }
ReadBit()
ReadByte()
ReadBytes()
ReadSignals()
I/O access via address - Writing WriteBit()
(Page 183) WriteByte()
WriteBytes()
WriteSignals()
I/O access via tag name - Read- Read()
ing (Page 189) ReadBool()
ReadChar(), ReadWChar()
ReadDouble()
ReadFloat()
ReadInt8(), ReadInt16(), ReadInt32(), ReadInt64()
ReadUInt8(), ReadUInt16(), ReadUInt32(), Rea-
dUInt64()
ReadSignals()
I/O access via tag name - Writ- Write()
ing (Page 220) WriteBool()
WriteChar(), WriteWChar()
WriteDouble()
WriteFloat()
WriteInt8(), WriteInt16(), WriteInt32(),
WriteInt64(),
WriteUInt8(), WriteUInt16(), WriteUInt32(),
WriteUInt64()
WriteSignals()
S7-PLCSIM Advanced
94 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
Settings Functions
Virtual time (Page 249) SystemTime { get; set; }
ScaleFactor { get; set; }
Cycle control (Page 252) OperatingMode { get; set; }
IsSendSyncEventInDefaultModeEnabled { get; set; }
OverwrittenMinimalCycleTime_ns { get; set; }
RunToNextSyncPoint
StartProcessing()
SetCycleTimeMonitoringMode()
GetCycleTimeMonitoringMode()
Acyclic services (Page 261)
Events Functions
OnOperatingStateChanged OnOperatingStateChanged
(Page 281) RegisterOnOperatingStateChangedEvent()
UnregisterOnOperatingStateChangedEvent()
WaitForOnOperatingStateChangedEvent()
OnLedChanged (Page 285) OnLedChanged
RegisterOnLedChangedEvent()
UnregisterOnLedChangedEvent()
WaitForOnLedChangedEvent()
OnConfigurationChanging OnConfigurationChanging
(Page 287) RegisterOnConfigurationChangingEvent()
UnregisterOnConfigurationChangingEvent()
WaitForOnConfigurationChangingEvent()
OnConfigurationChanged OnConfigurationChanged
(Page 290) RegisterOnConfigurationChangedEvent()
UnregisterOnConfigurationChangedEvent()
WaitForOnConfigurationChangedEvent()
OnSyncPointReached OnSyncPointReached
(Page 292) RegisterOnSyncPointReachedEvent()
UnregisterOnSyncPointReachedEvent()
WaitForOnSyncPointReachedEvent()
API IRemoteRuntimeManager
Settings Functions
Interface (Page 304) Dispose()
Version { get; }
IP { get; }
Port { get; }
RemoteComputerName { get; }
Disconnect()
StrictMotionTiming { get; set; }
Simulation Runtime instances RegisterInstanceInfo { get; }
(Page 118) RegisterInstance()
RegisterCustomInstance()
CreateInterface()
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 95
User interfaces (API)
7.1 Introduction
Events Functions
OnConnectionLost() OnConnectionLost()
(Page 317) RegisterOnConnectionLostEvent()
UnregisterOnConnectionLostEvent()
WaitForOnConnectionLostEvent()
Data type
DLL import functions ApiEntry_Initialize
(Page 321) ApiEntry_DestroyInterface
Event callback functions EventCallback_VOID
(Page 322) EventCallback_SRCC_UINT32_UINT32_INT32
EventCallback_SRRSI_AD
EventCallback_IRRTM
EventCallback_II_SREC_ST_SROS_SROS
EventCallback_II_SREC_ST_UINT32_INT64_INT64_UINT32
EventCallback_II_SREC_ST
Event-
Callback_II_SREC_ST_SRICC_UINT32_UINT32_UINT32_UINT32
EventCallback_II_SREC_ST_SRLT_SRLM
EventCallback_II_SREC_ST_SDRI
EventCallback_II_SREC_ST_SDRI_BYTE
EventCallback_II_SREC_ST_UINT32_UINT32
EventCallback_II_SREC_ST_UINT32_UINT32_EPET_UINT32
EventCallback_II_SREC_ST_UINT32_EPPET_UINT32
EventCallback_II_SREC_ST_UINT32_ERSFET
EventCallback_II_SREC_ST_UINT32
Definitions and constants (Page 349)
Unions (Page 350) UIP
UDataValue
S7-PLCSIM Advanced
96 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.1 Introduction
Data type
Structures (Page 353) SDataValue
SDVBNI
SDataValueByAddress
SDataValueByName
SConnectionInfo
SInstanceInfo
SDimension
STagInfo
SIP
SIPSuite4
SOnSyncPointReachedResult
SDataValueByAddressWithCheck
SDataValueByNameWithCheck
SDataRecordInfo
SDataRecord
SConfiguredProcessEvents
SDiagExtChannelDescription
SAutodiscoverData
Enumerations (Page 375) ERuntimeErrorCode
EArea
EOperatingState
EOperatingMode
ECPUType
ECommunicationInterface
ELEDType
ELEDMode
EPrimitiveDataTypes
EDataType
ETagListDetails
ERuntimeConfigChanged
EInstanceConfigChanged
EPullOrPlugEventType
EProcessEventType
EDirection
EDiagProperty
EDiagSeverity
ERackOrStationFaultType
ECycleTimeMonitoringMode
EAutodiscoverType
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 97
User interfaces (API)
7.1 Introduction
Data type
Delegate definitions Delegate_Void
(Page 335) Delegate_SRCC_UINT32_UINT32_INT32
- Event handler methods Delegate_SRRSI_AD
Delegate_IRRTM
Delegate_II_EREC_DT_EOS_EOS
Delegate_II_EREC_DT_UINT32_INT64_INT64_UINT32
Delegate_II_EREC_DT
Dele-
gate_II_EREC_DT_SRICC_UINT32_UINT32_UINT32_UINT32
Delegate_II_EREC_DT_ELT_ELM
Delegate_II_EREC_DT_SDRI
Delegate_II_EREC_DT_SDR
Delegate_SREC_ST_UINT32_UINT32
Delegate_SREC_ST_UINT32_UINT32_EPET_UINT32
Delegate_SREC_ST_UINT32_EPPET_UINT32
Delegate_SREC_ST_UINT32_ERSFET
Delegate SREC ST UINT32
Definitions and constants (Page 349)
Structures (Page 353) SDataValue
SDVBNI
SDataValueByAddress
SDataValueByName
SConnectionInfo
SInstanceInfo
SDimension
STagInfo
SIP
SIPSuite4
SOnSyncPointReachedResult
SDataValueByAddressWithCheck
SDataValueByNameWithCheck
SDataRecordInfo
SDataRecord
SConfiguredProcessEvents
SDiagExtChannelDescription
SAutodiscoverData
S7-PLCSIM Advanced
98 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.2 Initialize API
Data type
Enumerations (Page 374) ERuntimeErrorCode
EArea
EOperatingState
EOperatingMode
ECPUType
ECommunicationInterface
ELEDType
ELEDMode
EPrimitiveDataTypes
EDataType
ETagListDetails
ERuntimeConfigChanged
EInstanceConfigChanged
EPullOrPlugEventType
EProcessEventType
EDirection
EDiagProperty
EDiagSeverity
ERackOrStationFaultType
ECycleTimeMonitoringMode
EAutodiscoverType
Description
For PLCSIM Advanced, the interfaces of the API V4.0 are not compatible with the interfaces of
previous API versions. However, the Runtime Manager of PLCSIM Advanced V4.0 is
compatible with the API of previous PLCSIM Advanced versions.
Earlier versions of the API are also installed during the installation of PLCSIM Advanced V4.0.
The default path is:
• C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\1.0
• C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\2.0
• C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\2.1
• C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\3.0
• C:\Program Files (x86)\Common Files\Siemens\PLCSIMADV\API\4.0
The installation path of PLCSIM Advanced is contained in the registry:
• Key: "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Siemens\Shared
Tools\PLCSIMADV_SimRT"
• Value: "Path"
To maintain the path to the API, add the character string of the following subdirectory at the
end: "API\<API version>" (e.g. "API\4.0").
When you use this path the API library (DLL) is loaded directly from the installation directory.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 99
User interfaces (API)
7.2 Initialize API
Reference
Additional information can be found in:
• For Native C++ in section InitializeApi() (Page 100).
• For .NET via the call of the function "System.Reflection.Assembly.LoadFile(string)" in the
online documentation for MSDN.
7.2.2.1 InitializeApi()
Description
The InitializeApi function loads the API library (DLL) and initializes the API. The function
loads the version of the DLL that is compatible with the architecture of your application and
which is also compatible with the header file of the API ("SimulationRuntimeApi.h").
To load the DLL, the function InitializeApi searches in the following directories one after
the other:
• In the directory to which the parameter of the function leads
(in_SimulationRuntimeApiDllPath)
• In the directory of your application that calls this function.
• In the installation directory of PLCSIM Advanced
If no DLL is available, the function accesses the next directory.
S7-PLCSIM Advanced
100 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.2 Initialize API
The function returns an interface to the Simulation Runtime Manager. Use this interface to
create a new instance of the virtual controller or to obtain access to an existing instance.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 101
User interfaces (API)
7.2 Initialize API
Note
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
7.2.2.2 RuntimeApiEntry_Initialize
Description
Use the function RuntimeApiEntry_Initialize only if the API library (DLL) is to be
loaded from a different directory than the directory of your application that calls this
function.
When the API is initialized, the API library is first loaded and the Initialize function is then
imported and called.
The function returns an interface to the Simulation Runtime Manager. Use this interface to
create a new instance of the virtual controller or to obtain access to an existing instance.
Table 7- 20 RuntimeApiEntry_Initialize - Native C++
S7-PLCSIM Advanced
102 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.2 Initialize API
Note
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 103
User interfaces (API)
7.3 Shut down API
7.2.3.1 Initialize
Description
The entry point to the API is the static class
Siemens.Simatic.Simulation.Runtime.SimulationRuntimeManager.
The API is initialized when a function of this class is used the first time.
Exceptions Sie-
mens.Simatic.Simulation.Runtime.SimulationInitializationExcep
tion
Runtime error code Condition
ERuntimeError- Unable to establish a connection to the Runtime
Code.ConnectionError
Manager.
ERuntimeError- The version of the API is not compatible with
Code.WrongVersion
Runtime.
See Compatibility during upgrade (Page 17).
ERuntimeError- No Runtime Manager runs in this Windows user
Code.RuntimeNotAvailabl
e session.
ERuntimeError- Operation regarding the configuration file
Code.ConfigFileError
"UserInterfaceConfiguration.xml" has failed, for
example, create, read, write.
S7-PLCSIM Advanced
104 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.3 Shut down API
7.3.1.1 DestroyInterface()
Description
A function pointer to the RuntimeApiEntry_DestroyInterface function. The function
pointer DestoyInterface() is only valid if the InitializeApi function has been
successfully called.
The function unloads the memory of an ISimulationRuntimeManager,
IRemoteRuntimeManager or IInstance interface.
// The Interfaces
ERuntimeErrorCode result;
ISimulationRuntimeManager* api = NULL;
IInstance* instance = NULL;
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 105
User interfaces (API)
7.3 Shut down API
7.3.1.2 RuntimeApiEntry_DestroyInterface
Description
Use the RuntimeApiEntry_DestroyInterface function only if the API library (DLL) is to
be loaded from a different directory than the Startup directory of the application that calls
this function.
If the API was initialized using the InitializeApi function, you select the
DestroyInterface() (Page 105) function.
The function unloads the memory of an ISimulationRuntimeManager,
IRemoteRuntimeManager or IInstance interface.
S7-PLCSIM Advanced
106 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.3 Shut down API
7.3.1.3 FreeApi()
Description
The FreeApi() function unloads the library of the Runtime API.
This function can only be called after the successful call of the InitializeApi function. If
the InitializeApi function was not called, the library must be unloaded using the
Win32 API function FreeLibrary().
// The Interfaces
ERuntimeErrorCode result;
ISimulationRuntimeManager* api = NULL;
IInstance* instance = NULL;
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 107
User interfaces (API)
7.3 Shut down API
7.3.1.4 ShutdownAndFreeApi()
Description
The ShutdownAndFreeApi() function shuts down the Runtime API, deletes the
IRuntimeManager interface and unloads the library of the Runtime API.
This function can only be called after the successful call of the InitializeApi function. If
the InitializeApi function was not called, the library must be unloaded using the
Win32 API-Funktion FreeLibrary().
// The Interfaces
ERuntimeErrorCode result;
ISimulationRuntimeManager* api = NULL;
IInstance* instance = NULL;
S7-PLCSIM Advanced
108 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfAreaSection()
GetNameOfCPUType()
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 109
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfCommunicationInterface()
GetNameOfDataType()
GetNameOfErrorCode()
GetNameOfLEDMode()
GetNameOfLEDType()
S7-PLCSIM Advanced
110 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfOperatingMode()
GetNameOfErrorCode()
GetNameOfOperatingState
GetNameOfPrimitiveDataType
GetNameOfTagListDetails
ETagListDetails in_TagListDetails
);
Parameters ETagListDetails in_TagListDetails: Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 111
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfRuntimeConfigChanged()
GetNameOfInstanceConfigChanged()
GetNameOfDirection()
GetNameOfDiagSeverity()
GetNameOfRackOrStationFaultType()
S7-PLCSIM Advanced
112 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfProcessEventType()
GetNameOfPullOrPlugEventType()
GetNameOfCycleTimeMonitoringMode()
GetNameOfDiagProperty()
GetNameOfAutodiscoverType()
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 113
User interfaces (API)
7.5 API ISimulationRuntimeManager
See also
EPrimitiveDataType (Page 385)
EDataType (Page 388)
Enumerations (Page 374)
S7-PLCSIM Advanced
114 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 115
User interfaces (API)
7.5 API ISimulationRuntimeManager
Shutdown()
Ends communication with Runtime Manager and clears the interfaces.
Call this function in the following cases:
• Immediately before the API library (DLL) is unregistered (native C++).
• When your application is no longer using Runtime Manager.
S7-PLCSIM Advanced
116 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 117
User interfaces (API)
7.5 API ISimulationRuntimeManager
GetRegisteredInstancesCount()
Returns the number of instances that are registered in Runtime Manager. If the function fails,
the return value is 0.
GetRegisteredInstanceInfoAt()
Returns information about an already registered instance. You can use the ID or name to
create an interface of this instance, see CreateInterface().
Index of the created instance from which you want to receive the information.
The index must be less than the value you receive when you call GetRegis-
teredInstanceCount().
• SInstanceInfo* out_InstanceInfo:
The information with name and ID of the instance. See Data types (Page 349).
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_TIMEOUT The function does not return on time.
SREC_DOES_NOT_EXIST There is no instance information for this
index.
SREC_INDEX OUT_OF_RANGE The index is greater than 15.
RegisteredInstanceInfo { get; }
Returns information about all already registered instances. Use the ID or name of this
instance to create an interface of this instance, see CreateInterface().
S7-PLCSIM Advanced
118 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
RegisterInstance()
Registers a new instance of a virtual controller in Runtime Manager. Creates and returns an
interface of this instance.
Defines which CPU type is simulated at the start of the instance. The default set-
ting is "SRCT_1500_Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual SIMATIC
Memory Card, this CPU type applies.
• WCHAR* in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
• IInstance** out_InstanceInterface:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 119
User interfaces (API)
7.5 API ISimulationRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
Defines which CPU type is simulated at the start of the instance. The default set-
ting is "ECPUType.Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual SIMATIC
Memory Card, this CPU type applies.
• string in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
Return values If the function is successful, an interface of a virtual controller, otherwise a null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name is invalid.
Code.WrongArgument
ERuntimeError- There are already 16 instances registered
Code.LimitReached
in Runtime Manager.
ERuntimeError- An instance with this name already exists.
Code.AlreadyExists
S7-PLCSIM Advanced
120 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
RegisterCustomInstance()
Registers a new instance of a virtual controller in Runtime Manager. Creates and returns an
interface of this instance.
The complete path to the DLL of the virtual controller that "Sie-
mens.Simatic.Simulation.Runtime.Instance.exe" loads at PowerOn.
• WCHAR* in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
• IInstance** out_InstanceInterface:
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 121
User interfaces (API)
7.5 API ISimulationRuntimeManager
The complete path to the DLL of the virtual controller that "Sie-
mens.Simatic.Simulation.Runtime.Instance.exe" loads at PowerOn.
• string in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
Return values If the function is successful, an interface of a virtual controller; otherwise a Null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name or the ID is invalid.
Code.WrongArgument
ERuntimeError- There are already 16 instances registered
Code.LimitReached
in Runtime Manager.
ERuntimeError- An instance with this name already exists.
Code.AlreadyExists
CreateInterface()
Creates and returns an interface of an already registered instance of a virtual controller.
S7-PLCSIM Advanced
122 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
The instance could have been registered via the application or another application that uses
the Simulation Runtime API.
The ID of the registered instance from which you want to receive the interface.
• WCHAR* in_InstanceName:
The name of the registered instance from which you want to receive the inter-
face.
• IInstance** out_InstanceInterface:
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 123
User interfaces (API)
7.5 API ISimulationRuntimeManager
The ID of the registered instance from which you want to receive the interface.
• string in_InstanceName:
The name of the registered instance from which you want to receive the inter-
face.
Return values If the function is successful, an interface of a virtual controller; otherwise a Null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name or the ID is invalid.
Code.WrongArgument
ERuntimeError- The instance is not registered in Runtime
Code.DoesNotExists
Manager.
OpenPort()
Opens a port to which another Runtime Manager can connect.
S7-PLCSIM Advanced
124 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
ClosePort()
Closes an open port and all open connections that another Runtime Manager has created to
this open port.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 125
User interfaces (API)
7.5 API ISimulationRuntimeManager
GetRemoteConnectionsCount()
Supplies the number of open remote connections.
GetRemoteConnectionInfoAt()
Returns information about an open connection.
S7-PLCSIM Advanced
126 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
RemoteConnectionInfo { get; }
Returns an array of information about all open connections.
RemoteConnect()
Creates a new connection to a remote Runtime Manager or uses an existing connection to
create an IRemoteRuntimeManager interface.
UINT8 in_IP0:
Pointer to a remote Runtime Manager interface pointer. The pointer must be in-
itialized with ZERO. The interface is created in the function.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 127
User interfaces (API)
7.5 API ISimulationRuntimeManager
if (result == SREC_OK)
{
result = api->RemoteConnect(192,203,145,144, 4444, &client);
}
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
S7-PLCSIM Advanced
128 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
See also
Tag list (Page 167)
Data types (Page 320)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 129
User interfaces (API)
7.5 API ISimulationRuntimeManager
7.5.3.1 RunAutodiscover()
Description
This function identifies all Runtime Managers that are on the network and that are ready to
establish a remote connection.
Note
The function identifies Runtime Managers as of PLCSIM Advanced V4.0.
Requirements
• The Runtime Manager must be running and allowing remote connections.
• The firewall of the remote PC must not block traffic on the selected UDP port.
• Devices in the local network (such as routers, switches, firewalls) must not block multicast
packets of the selected class.
RunAutodiscover()
The function starts the identification of the Runtime Manager in the network.
A timeout value in milliseconds that defines how long the local Runtime Man-
ager waits for responses from the Remote Manager.
S7-PLCSIM Advanced
130 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
A timeout value in milliseconds that defines how long the local Runtime Man-
ager waits for responses from the Remote Manager.
Event Cause
OnConfigurationChanged The Runtime Manager configuration has changed:
(Page 132)
• A new instance is registered.
• An instance is removed.
• A connection to a client is established.
The Control Panel uses such an event to update the list of available
instances.
OnRuntimeManagerLost The connection to the Runtime Manager is interrupted.
(Page 134)
RunAutodiscover (Page 137) The network searches for Runtime Managers which are ready to estab-
lish a remote connection.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 131
User interfaces (API)
7.5 API ISimulationRuntimeManager
OnConfigurationChanged
Registers or unregisters an event handler method.
RegisterOnConfigurationChangedCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. The registration of a new callback function causes the
previous callback function to be deleted.
RegisterOnConfigurationChangedEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registration of a new event object causes the
previous event object to be deleted.
S7-PLCSIM Advanced
132 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
UnregisterOnConfigurationChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
UnregisterOnConfigurationChangedEvent()
Unregisters the event object.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 133
User interfaces (API)
7.5 API ISimulationRuntimeManager
WaitForOnConfigurationChangedEvent()
The function blocks the program until the registered event object is set to the signaled state
or the timeout interval is exceeded.
OnRuntimeManagerLost
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
134 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
RegisterOnRuntimeManagerLostCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. The registration of a new callback function causes the
previous callback function to be deleted.
RegisterOnRuntimeManagerLostEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registration of a new event object causes the
previous event object to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 135
User interfaces (API)
7.5 API ISimulationRuntimeManager
UnregisterOnRuntimeManagerLostCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
UnregisterOnRuntimeManagerLostEvent()
Unregisters the event object.
WaitForOnRuntimeManagerLostEvent()
The function will block the program until the registered event object is set to the signaled
state or the timeout interval is exceeded.
S7-PLCSIM Advanced
136 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.5 API ISimulationRuntimeManager
OnAutodiscoverData
Registers or unregisters an event handler method.
RegisterOnAutodiscoverCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. The registration of a new callback function causes the
previous callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 137
User interfaces (API)
7.6 API IInstances
UnregisterOnAutodiscoverCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Dispose()
Deletes the managed interface and unloads the native components of the user interfaces.
GetID() / ID { get; }
Returns the instance ID. The ID is assigned by Runtime Manager when the instance is
registered.
S7-PLCSIM Advanced
138 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
A user-allocated storage for the name of the instance. The field length should
be at least as long as DINSTANCE_NAME_MAX_LENGTH.
See Definitions and constants (Page 349).
• UINT32 in_ArrayLength:
WCHAR name[DINSTANCE_NAME_MAX_LENGTH];
if (result == SREC_OK)
{
result = psa->GetName(name, DINSTANCE_NAME_MAX_LENGTH);
}
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 139
User interfaces (API)
7.6 API IInstances
GetCPUType()
Returns the CPU type of the virtual controller.
SetCPUType()
Sets the CPU type of the virtual controller. A change of CPU type occurs only when the
controller is restarted.
When a different CPU type is loaded via STEP 7 or from the Virtual Memory
Card, this CPU type applies.
Return values None
S7-PLCSIM Advanced
140 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
GetCommunicationInterface()
Returns the communication interface of the virtual controller: Local communication (Softbus)
or TCPIP. A change of communication interface occurs only when the controller is restarted.
All instances that are started must use the same communication interface.
PowerOn is prevented if a communication interface that is not used by the started instances
is selected.
SetCommunicationInterface()
Sets the communication interface of the virtual controller: Local communication (Softbus) or
TCPIP. A change of communication interface occurs only when the controller is restarted. All
instances that are started must use the same communication interface.
PowerOn is prevented if a communication interface that is not used by the started instances
is selected.
Cannot be selected.
• SRCI_SOFTBUS
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 141
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
142 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterInstance()
Unregisters this instance from Runtime Manager.
Note
Loss of the interfaces
Other applications that are connected to this instance will lose their interface to this instance.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 143
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
144 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
GetControllerIPCount()
Returns the number of configured IP addresses of the virtual controller. If the function fails,
the return value is 0.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 145
User interfaces (API)
7.6 API IInstances
The index of the IP address you want to receive. The index must be less than
the value you receive from GetControllerIPCount(). The default setting
is 0.
Return values UIP: IP address of the virtual controller. If the function fails, the return value is
0.
The index of the IP address you want to receive. The index must be less than
the value you receive from GetControllerIPCount(). The default setting is
0.
Return values SIPSuite4: The IP suite of the virtual controller. If the function fails, the return
values are 0.
S7-PLCSIM Advanced
146 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
SetIPSuite()
Sets the IP suite of the network interface of a virtual controller.
The IP suite that is to be assigned to the network interface. The IP suite contains
the IP address, the subnet mask and the standard gateway.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 147
User interfaces (API)
7.6 API IInstances
GetStoragePath()
Returns the full directory in which the instance stores its data.
A user-allocated storage for the storage path. The length of the array should be
at least as long as DSTORAGE_PATH_MAX_LENGTH. See Data types (Page 320).
• UINT32 in_ArrayLength:
S7-PLCSIM Advanced
148 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
SetStoragePath()
Sets the full path of the directory in which the instance stores its data. This can also be a
network share.
Set the path before you start the instance. A change to the path takes effect only when the
controller is restarted.
If no path is set, the default setting:
<My Documents>\Siemens\Simatic\Simulation\Runtime\Persistence\<Instance Name> is used.
Full name of the storage path. The length of the name must be less than
DSTORAGE_PATH_MAX_LENGTH. See Data types (Page 320).
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INDEX_OUT_OF_RANGE The length of the path exceeds the limit.
SREC_WRONG_ARGUMENT The path contains invalid characters.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 149
User interfaces (API)
7.6 API IInstances
ArchiveStorage()
The user program, the hardware configuration and the retentive data is stored in a file, the
Virtual SIMATIC Memory Card. ArchiveStorage() stores this file as a ZIP file. The instance
of the virtual controller must be in OFF operating state for this.
The full path to the ZIP file. The path relates to directories of the computer
where the API is being called.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INVALID_OPERATING_STATE The instance is not in OFF operating
state.
SREC_INVALID_ARCHIVE_PATH The archive path is invalid.
SREC_CREATE_DIRECTORIES_FAILE The directory for the ZIP file could not be
D
created.
SREC_ARCHIVE_STORAGE_FAILED The ZIP file could not be created.
SREC_STORAGE_TRANSFER_ERROR Error during network data transfer.
Memory data between client and server
computers do not match.
SREC_NO_STORAGE_PATH_SET No storage path is set. The user has to
execute the SetStoragePath() function
beforehand.
S7-PLCSIM Advanced
150 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The full path to the ZIP file. The path relates to directories of the computer
where the API is being called.
Return values Runtime error code Condition
SREC_NO_STORAGE_PATH_SET No storage path is set. The user has to
execute the SetStoragePath() function
beforehand.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The instance is not in OFF operating
Code.InvalidOperatingState
state.
ERuntimeError- The archive path is invalid.
Code.InvalidArchivePath
ERuntimeError- The directory for the ZIP file could not be
Code.CreateDirectoriesFailed
created.
ERuntimeError- The ZIP file could not be created.
Code.ArchiveStorageNotCreated
ERuntimeError- Error during network data transfer.
Code.StorageTransferError
Memory data between client and server
computers do not match.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 151
User interfaces (API)
7.6 API IInstances
RetrieveStorage()
RetrieveStorage() creates a Virtual SIMATIC Memory Card from the archived ZIP file. The
virtual controller must be in OFF operating state for this.
The full path to the ZIP file. The path relates to directories of the computer
where the API is being called.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INVALID_OPERATING_STATE The instance is not in OFF operating
state.
SREC_INVALID_ARCHIVE_PATH The archive path is invalid.
SREC_DELETE_EXISTING_STORAGE_ The old storage cannot be deleted.
FAILED
SREC_RETRIEVE_STORAGE_FAILURE The ZIP file cannot be unzipped.
SREC_STORAGE_TRANSFER_ERROR Error during network data transfer.
Memory data between client and server
computers do not match.
SREC_NO_STORAGE_PATH_SET No storage path is set. The user has to
execute the SetStoragePath() function
beforehand.
S7-PLCSIM Advanced
152 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The full path to the ZIP file. The path relates to directories of the computer
where the API is being called.
Return values Runtime error code Condition
SREC_NO_STORAGE_PATH_SET No storage path is set. The user has to
execute the SetStoragePath() function
beforehand.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The instance is not in OFF operating
Code.InvalidOperatingState
state.
ERuntimeError- The archive path is invalid.
Code.InvalidArchivePath
ERuntimeError- The old storage cannot be deleted.
Code.DeleteExistingStorageFai
led
ERuntimeError- The ZIP file cannot be unzipped.
Code.RetrieveStorageFailure
ERuntimeError- Error during network data transfer.
Code.StorageTransferError
Memory data between client and server
computers do not match.
CleanupStoragePath()
The function deletes the directory with the Virtual SIMATIC Memory Card of a local instance
or a remote instance. To do this, the function checks whether required and invalid files are
available. Even if the directory is missing, the function is considered successful.
To make sure that the correct directory is deleted, the function checks if there are any files
that need to be present in the Virtual SIMATIC Memory Card:
• ".\sim_hwdb.ini"
• ".\SIMATIC_MC\SIMATIC.S7S\"
• ".\SIMATIC_MC\RData\"
To permanently delete the directory, only the following directories with files are also allowed:
• ".\CrashDump\"
• ".\Traces\"
• ".\retain.pms"
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 153
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
154 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 155
User interfaces (API)
7.6 API IInstances
PowerOn()
The function creates the process for the Simulation Runtime instance and starts the firmware
of the virtual controller.
S7-PLCSIM Advanced
156 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 157
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
158 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 159
User interfaces (API)
7.6 API IInstances
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The expected operating state does not
occur on time.
ERuntimeError- The "Siemens.Simatic.Simulation.
Code.ErrorLoadingDll
Runtime.Instance.exe" cannot load the
"Siemens.Simatic.PlcSim.Vplc1500.dll".
ERuntimeError- The selected path for this instance is
Code.StoragePathAlreadyInUse
already being used by another instance.
ERuntimeError- The path could not be created. The length
Code.NoStoragePathSet
of the DSTORAGE_PATH_MAX_LENGTH
characters might be exceeded.
ERuntimeError- The virtual switch is configured incorrect-
Code.VirtualSwitchMisconfigur
ed ly.
ERuntimeError- The process of the virtual controller is no
Code.InstanceNotRunning
longer running.
PowerOff()
Shuts down the Simulation Runtime and closes its process.
S7-PLCSIM Advanced
160 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Run()
Calls on the virtual controller to change to RUN operating state.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 161
User interfaces (API)
7.6 API IInstances
Stop()
Calls on the virtual controller to change to STOP operating state.
S7-PLCSIM Advanced
162 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 163
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
164 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 165
User interfaces (API)
7.6 API IInstances
MemoryReset()
Shuts down the virtual controller, closes its processes and performs a restart.
S7-PLCSIM Advanced
166 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Note
Elements with data types not known to the API (EDataType.Unknown) are not included in
the tag list.
UpdateTagList()
The function reads the tags from the virtual controller and writes them to the shared storage
arranged by name.
If the tag is an array or a structure, there are multiple entries.
In the case of a structure, there is an entry for the structure itself and an additional entry for
each structure element.
Entry_1: "StructName"
Entry_2: "StructName.ElementName_1"
..
Entry_N: "StructName.ElementName_n"
In the case of an array, in this example a two-dimensional array, there is an entry for the array
itself and an additional entry for each array element.
Entry_1: "ArrayName"
Entry_2: "ArrayName[a,b]", {a} and {b} correspond to the first index of the respective
dimension)
..
Entry_N: "ArrayName[x,y]", {x} and {y} correspond to the last index of the respective
dimension)
Memory for up to 500000 entries (not PLC tags) is reserved for the list. If the list becomes too
large, the function returns the error/exception "NOT_ENOUGH_MEMORY".
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 167
User interfaces (API)
7.6 API IInstances
If there are problems with the maximum number of entries and not all tags are needed, two
filters can be used when refreshing the tag table.
Example: IOM reads only the tags from the area Inputs / Outputs and Bit
memory.
• bool in_IsHMIVisibleOnly:
If true, only tags marked with "HMI Visible" are read. The default setting is
true.
• WCHAR* in_DataBlockFilterList:
A string that includes the name of all data blocks that are supposed to be avail-
able in the tag table. The string must be in quotation marks.
All characters within the quotation marks are interpreted as a DB name. If the
data block does not exist in the PLC program, it is not added to the tag table
memory. No error is triggered in the process.
S7-PLCSIM Advanced
168 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 169
User interfaces (API)
7.6 API IInstances
Example: IOM reads only the tags from the area Inputs / Outputs and Bit
memory.
• bool in_IsHMIVisibleOnly:
If true, only tags marked with "HMI Visible" are read. The default setting is
true.
• string in_DataBlockFilterList:
A string that includes the name of all data blocks that are supposed to be avail-
able in the tag table. The string must be in quotation marks.
All characters within the quotation marks are interpreted as a DB name. If the
data block does not exist in the PLC program, it is not added to the tag table
memory. No error is triggered in the process.
S7-PLCSIM Advanced
170 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
GetTagListStatus()
Returns the current update status of the tag list storage.
"inout_TagListDetails" is NONE, if the list needs to be updated.
Status of the tag list details. SRTLD_NONE when an update of the list is re-
quired.
• bool out_IsHMIVisibleOnly:
If true, only tags marked with "HMI Visible" are available in the list.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
If true, only tags marked with "HMI Visible" are available in the list.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
GetTagInfoCount()
Returns the number of entries in the tag list storage. If the function fails, the return value is 0.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 171
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
172 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
CreateConfigurationFile()
Writes all entries from the tag list to an XML file.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 173
User interfaces (API)
7.6 API IInstances
Description
In PLCSIM Advanced the complete scope of the input and output area is used (see
GetAreaSize/AreaSize (Page 174)). This is also possible when no IO module is configured.
Inputs and outputs that are defined via configured IO modules are synchronized to the
defined update of the process image partition (PIP).
Inputs and outputs that are not assigned to an IO module are synchronized in the cycle
control point.
Note the following when synchronizing these inputs and outputs:
• Inputs can only be used as inputs.
You can write the values via the API, but values which are written via the user program
(TIA Portal) are not visible in the API.
• Outputs can be used as output and as input.
You can write the values via the API and via the CPU / the user program (TIA Portal). If API
and user program write to the same area, the values from the API will overwrite the values
from the user program.
Table 7- 164 InputArea { get; } MarkerArea { get; } OutputArea { get; } - .NET (C#)
S7-PLCSIM Advanced
174 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
ReadBit()
Reads an individual bit from the area.
Note
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name (Page 189) and not via the address areas.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 175
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• UINT8 in_Bit:
The bit offset within the byte. The value must be between 0 and 7.
• bool* out_Value:
Returns the bit value.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE Offset or bits are invaid.
SREC_WRONG_ARGUMENT The area is invalid.
S7-PLCSIM Advanced
176 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
• Byte in_Bit:
The bit offset within the byte. The value must be between 0 and 7.
Return values bool: Bit value
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- Offset or bits are invaid.
Code.IndexOutOfRange
ReadByte()
Reads an individual bit from the area.
Note
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name and not via the address areas.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 177
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• BYTE* out_Value:
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
Return values Byte: Byte value.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- Offset is invalid.
Code.IndexOutOfRange
S7-PLCSIM Advanced
178 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
ReadBytes()
Reads a byte array from the area.
Note
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name and not via the address areas.
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• UINT32 in_BytesToRead:
Returns the number of bytes that were just written to the value storage.
• BYTE inout_Values[]:
The storage for the bytes that are read from the area.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE The offset is outside the area size. No
byte could be read.
SREC_WRONG_ARGUMENT The area is invalid.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 179
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
• UInt32 in_BytesToRead:
ReadSignals()
Structures and fields can be emulated through signal lists and be read by using the
ReadSignals() function.
The function also takes into consideration the byte order (Endianness).
Only primitive data type signals are supported, but the function is not type-safe.
Note
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name (Page 189) and not via the address areas.
S7-PLCSIM Advanced
180 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The signal list that is read. The result is stored in the structure. "Value-
HasChanged" is set to true if the value of the signal has changed since the
preceding call.
• UINT32 in_SignalCount:
Returns true if the value of at least one signal has changed since the preced-
ing call.
Signal error Error code Condition
SREC_OK The signal operation is successful.
SREC_DOES_NOT_EXIST The entry does not exist in the stored tag
table.
SREC_NOT_SUPPORTED Access to entire structures or arrays is not
supported.
SREC_TYPE_MISMATCH The expected type does not match the stored
type. See Compatible primitive data types
(Page 385).
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_WRONG_ARGUMENT The area is invalid.
SREC_SIGNAL_CONFIGURATION At least one signal error is in the list.
ERROR
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 181
User interfaces (API)
7.6 API IInstances
The signal list that is read. The result is stored in the structure. "Value-
HasChanged" is set to true if the value of the signal has changed since the
preceding call.
• out bool out_SignalsHaveChanged:
Returns true if the value of at least one signal has changed since the preceding
call.
Return values None
Signal error Runtime error code Condition
ERuntimeErrorCode.OK The signal operation is successful.
ERuntimeError- Offset or bits are invalid.
Code.IndexOutOfRange
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- At least one signal error is in the list.
Code.SignalConfigurationError
S7-PLCSIM Advanced
182 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
WriteBit()
Writes an individual bit to the area.
Note
Data can be overwritten
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name (Page 220) and not via the address areas.
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• UINT8 in_Bit:
The bit offset within the byte. The value must be between 0 and 7.
• bool in_Value:
Bit value.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE Offset or bits are invaid.
SREC_WRONG_ARGUMENT Area is invalid.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 183
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
• Byte in_Bit:
The bit offset within the byte. The value must be between 0 and 7.
• bool in_Value:
Bit value.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- Offset or bits are invaid.
Code.IndexOutOfRange
WriteByte()
Writes an individual byte to the area.
Note
Data can be overwritten
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name (Page 220) and not via the address areas.
S7-PLCSIM Advanced
184 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• BYTE in_Value:
Byte value.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE Offset is invalid.
SREC_WRONG_ARGUMENT Area is invalid.
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
• BYTE in_Value:
Byte value.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- Offset is invalid.
Code.IndexOutOfRange
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 185
User interfaces (API)
7.6 API IInstances
WriteBytes()
Writes a byte array to the area.
Note
Data can be overwritten
The function allows access to the entire storage area of the virtual controller.
In particular, do not write to bytes that belong to other applications or contain internal data,
for example, qualifier bits for fail-safe I/O modules.
Therefore, use access via the tag name (Page 220) and not via the address areas.
The byte offset within the area. The value must be between 0 and the value
that GetAreaSize() returns.
• UINT32 in_BytesToWrite:
S7-PLCSIM Advanced
186 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
The byte offset within the area. The value must be between 0 and the value
that AreaSize returns.
• UInt32 in_BytesToWrite:
Contains the number of bytes to be written. The value must be between 1 and
the size of the array value.
• BYTE in_Value:
Byte value.
Return values Uint32: Contains the number of bytes that were just written.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- The offset is outside the area size. No
Code.IndexOutOfRange
byte could be written.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 187
User interfaces (API)
7.6 API IInstances
WriteSignals()
Writes multiple signals within an API call. The function also takes into consideration the byte
order (Endianness).
The function supports only primitive data type signals, but it is not typical.
Note
Data can be overwritten
The function allows access to the entire storage area of the virtual controller.
Therefore, use access via the tag name (Page 220) and not via the address areas.
S7-PLCSIM Advanced
188 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Note
To simulate a regular exchange of signals, create a signal list for each set of signals. Use this
signal list for all further accesses. Create a new list as soon as the set of signals changes.
For the signal lists use the functions ReadSignals() and WriteSignals().
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 189
User interfaces (API)
7.6 API IInstances
Read()
Reads the value of a PLC tag.
Contains the value and the expected type of the PLC tag. If the expected type is
UNSPECIFIC, it is set to the stored type when the function was successful. The
STRUCT type is not supported.
Structures and fields can be emulated through signal lists and be read by using
the ReadSignals() function.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE The offset lies outside the area range. No
value could be read.
SREC_DOES_NOT_EXIST The entry does not exist in the stored tag
list.
SREC_NOT_SUPPORTED Access to entire structures or arrays is not
supported.
SREC_TYPE_MISMATCH The expected type does not match the
stored type. See Compatible primitive
data types (Page 385).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
S7-PLCSIM Advanced
190 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 191
User interfaces (API)
7.6 API IInstances
ReadBool()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
192 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 193
User interfaces (API)
7.6 API IInstances
ReadInt8()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
194 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 195
User interfaces (API)
7.6 API IInstances
ReadInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
196 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 197
User interfaces (API)
7.6 API IInstances
ReadInt32()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
198 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 199
User interfaces (API)
7.6 API IInstances
ReadInt64()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
200 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 201
User interfaces (API)
7.6 API IInstances
ReadUInt8()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
202 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 203
User interfaces (API)
7.6 API IInstances
ReadUInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
204 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 205
User interfaces (API)
7.6 API IInstances
ReadUInt32()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
206 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 207
User interfaces (API)
7.6 API IInstances
ReadUInt64()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
208 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 209
User interfaces (API)
7.6 API IInstances
ReadFloat()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
210 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 211
User interfaces (API)
7.6 API IInstances
ReadDouble()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
212 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 213
User interfaces (API)
7.6 API IInstances
ReadChar()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
214 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 215
User interfaces (API)
7.6 API IInstances
ReadWChar()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
216 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
ReadSignals()
Reads multiple signals within an API call. When the function is called for the first time, it
stores internal information in the structures SDataValueByName* to improve the
performance of the subsequent calls.
Note
To simulate a regular exchange of signals, create a signal list for each set of signals. Use this
signal list for all further accesses. Create a new list as soon as the set of signals changes.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 217
User interfaces (API)
7.6 API IInstances
Contains the name, the value and the expected type of the PLC tag. If the ex-
pected type is UNSPECIFIC, it is set to the stored type when the function was
successful. The STRUCT type is not supported.
• SDataValueByNameWithCheck* inout_Signals:
Contains the name, the value and the expected type of the PLC tag. If the ex-
pected type is UNSPECIFIC, it is set to the stored type when the function was
successful. The STRUCT type is not supported. "ValueHasChanged" is set to
true if the value of the signal has changed since the preceding call.
• UINT32 in_SignalCount:
Returns true if the value of at least one signal has changed since the preceding
call.
Signal error Runtime error code Condition
SREC_OK The signal operation is successful.
SREC_DOES_NOT_EXIST The entry does not exist in the stored tag
list.
SREC_NOT_SUPPORTED Access to entire structures or arrays is not
supported.
SREC_TYPE_MISMATCH The expected type does not match the
stored type. See Compatible primitive
data types (Page 385).
SREC_INDEX_OUT_OF_RANGE Offset or bits are invalid.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
SREC_SIGNAL_CONFIGURATION_ERR At least one signal error is in the list.
OR
S7-PLCSIM Advanced
218 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Contains the name, the value and the expected type of the PLC tag. If the ex-
pected type is UNSPECIFIC, it is set to the stored type when the function was
successful. The STRUCT type is not supported.
• ref SDataValueByNameWithCheck[] inout_Signals:
Contains the name, the value and the expected type of the PLC tag. If the ex-
pected type is UNSPECIFIC, it is set to the stored type when the function was
successful. The STRUCT type is not supported. "ValueHasChanged" is set to
true if the value of the signal has changed since the preceding call.
• out bool out_SignalsHaveChanged:
Returns true if the value of at least one signal has changed since the preceding
call.
Return values SDataValue: Contains the value and the type of the PLC tag.
Signal error Runtime error code Condition
ERuntimeErrorCode.OK The signal operation is successful.
ERuntimeError- The entry does not exist in the stored tag
Code.DoesNotExist
list.
ERuntimeError- Access to entire structures or arrays is not
Code.NotSupported
supported.
ERuntimeError- The expected type does not match the
Code.TypeMismatch
stored type. See Compatible primitive
data types (Page 385).
ERuntimeError- Offset or bits are invalid.
Code.IndexOutOfRange
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 219
User interfaces (API)
7.6 API IInstances
Note
To simulate a regular exchange of signals, create a signal list for each set of signals. Use this
signal list for all further accesses. Create a new list as soon as the set of signals changes.
For the signal lists use the functions ReadSignals() and WriteSignals().
Write()
Writes the value of a PLC tag.
Contains the value and the expected type of the PLC tag. The UNSPECIFIC and
STRUCT types are not supported.
Structures and fields can be emulated through signal lists and then be read by
using the ReadSignals() function and written by using the WriteSig-
nals() function.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_INDEX_OUT_OF_RANGE The offset lies outside the area range. No
value could be written.
SREC_DOES_NOT_EXIST The entry does not exist in the stored tag
list.
SREC_NOT_SUPPORTED Access to entire structures or arrays is not
supported.
SREC_TYPE_MISMATCH The expected type does not match the
stored type. See Compatible primitive
data types (Page 385).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
SREC_WRONG_ARGUMENT The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
220 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Contains the value and the expected type of the PLC tag. The UNSPECIFIC and
STRUCT types are not supported.
Structures and fields can be emulated through signal lists and then be written
by using the WriteSignals() function.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- The offset lies outside the area range. No
Code.IndexOutOfRange
value could be written.
ERuntimeError- The entry does not exist in the stored tag
Code.DoesNotExist
list.
ERuntimeError- Access to entire structures or arrays is not
Code.NotSupported
supported.
ERuntimeError- The expected type does not match the
Code.TypeMismatch
stored type. See Compatible primitive
data types (Page 385).
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
ERuntimeError- The expected type is UNSPECIFIC.
Code.WrongArgument
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 221
User interfaces (API)
7.6 API IInstances
WriteBool()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
222 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 223
User interfaces (API)
7.6 API IInstances
WriteInt8()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
224 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 225
User interfaces (API)
7.6 API IInstances
WriteInt16()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
226 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 227
User interfaces (API)
7.6 API IInstances
WriteInt32()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
228 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 229
User interfaces (API)
7.6 API IInstances
WriteInt64()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
230 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 231
User interfaces (API)
7.6 API IInstances
WriteInt8()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
232 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 233
User interfaces (API)
7.6 API IInstances
WriteUInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
234 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 235
User interfaces (API)
7.6 API IInstances
WriteUInt32()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
236 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 237
User interfaces (API)
7.6 API IInstances
WriteUInt64()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
238 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 239
User interfaces (API)
7.6 API IInstances
WriteFloat()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
240 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 241
User interfaces (API)
7.6 API IInstances
WriteDouble()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
242 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 243
User interfaces (API)
7.6 API IInstances
WriteChar()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
244 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 245
User interfaces (API)
7.6 API IInstances
WriteWChar()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
246 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
WriteSignals()
Writes multiple signals within an API call. When the function is called for the first time, it
stores internal information in the structures SDataValueByName* to improve the
performance of the subsequent calls.
Note
To simulate a regular exchange of signals, create a signal list for each set of signals. Use this
signal list for all further accesses. Create a new list as soon as the set of signals changes.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 247
User interfaces (API)
7.6 API IInstances
Contains the name, the value and the expected type of the PLC tag. The
UNSPECIFIC and STRUCT types are not supported.
• UINT32 in_SignalCount:
Number of signals.
Signal error Error code Condition
SREC_INDEX_OUT_OF_RANGE Offset or bits are invalid.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_DOES_NOT_EXIST The entry does not exist in the stored tag
list.
SREC_NOT_SUPPORTED Access to entire structures or arrays is not
supported.
SREC_TYPE_MISMATCH The expected type does not match the
stored type. See Compatible primitive
data types (Page 385).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
SREC_WRONG_ARGUMENT The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
248 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Contains the name, the value and the expected type of the PLC tag. The
UNSPECIFIC and STRUCT types are not supported.
Return values None
Signal error Error code Condition
ERuntimeError- Offset or bits are invalid.
Code.IndexOutOfRange
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- The entry does not exist in the stored tag
Code.DoesNotExist
list.
ERuntimeError- Access to entire structures or arrays is not
Code.NotSupported
supported.
ERuntimeError- The expected type does not match the
Code.TypeMismatch
stored type. See Compatible primitive
data types (Page 387).
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
ERuntimeError- The expected type is UNSPECIFIC.
Code.WrongArgument
GetSystemTime()
Returns the virtual system time of the virtual controller. Returns an empty structure when the
function fails.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 249
User interfaces (API)
7.6 API IInstances
SetSystemTime()
Sets the virtual system time of the virtual controller. A system time between
"Jan 1 1970 00:00:00:000" and "Dec 31 2200 23:59:59:999" is valid.
GetScaleFactor()
Returns the scaling factor with which the virtual time advances.
S7-PLCSIM Advanced
250 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
SetScaleFactor()
Sets the scaling factor with which the virtual time advances.
Start with a small scaling factor and incrementally approach a scaling factor at which the
virtual controller remains in RUN.
A value between 0.01 and 100 is valid. The default setting is 1.
• If the value is less than 1, the virtual time of the virtual controller runs X-times slower than
the real time.
• If the value is greater than 1, the virtual time of the virtual controller runs X-times faster
than the real time.
A change in the value during runtime only takes effect at the cycle control point.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 251
User interfaces (API)
7.6 API IInstances
GetOperatingMode()
Returns the operating mode (Page 381) of the virtual controller.
SetOperatingMode()
Sets the operating mode of the virtual controller.
S7-PLCSIM Advanced
252 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
A change in the value during runtime only takes effect at the synchronization point.
SetSendSyncEventInDefaultModeEnabled()
Sets the SendSyncEventInDefault mode. In this mode the OnSyncPointReached
event is triggered after each cycle end in the Default operating mode. See
OnSyncPointReached (Page 292).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 253
User interfaces (API)
7.6 API IInstances
IsSendSyncEventInDefaultModeEnabled()
Returns the SendSyncEventInDefaultMode mode. When the function fails, the return
value is false.
GetOverwrittenMinimalCycleTime_ns()
Returns the overwritten minimum cycle time (in nanoseconds) that is used in the
SingleStep_CT and SingleStep_CPT operating modes.
S7-PLCSIM Advanced
254 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
SetOverwrittenMinimalCycleTime_ns()
Sets the overwritten minimum cycle time (in nanoseconds) that is used in the
SingleStep_CT and SingleStep_CPT operating modes.
A value between 0 and 6000000000 is valid. The default setting is 100 ms.
A change in the value during runtime only takes effect at the cycle control point.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 255
User interfaces (API)
7.6 API IInstances
RunToNextSyncPoint()
If the virtual controller is running in a SingleStep operating mode, it is stopped at the
synchronization point (Freeze state). The RunToNextSyncPoint() function cancels the
freeze state. The virtual controller continues to run until the next synchronization point.
S7-PLCSIM Advanced
256 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
StartProcessing()
If the virtual controller is running in a TimespanSynchronized operating mode, it is stopped at
the synchronization point (Freeze state). The StartProcessing() function cancels the
freeze state. The virtual controller will now run for at least the requested time before it
changes to Freeze state at the next synchronization point.
The minimum virtual time (in nanoseconds) that the virtual controller runs be-
fore it changes to Freeze state.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
SREC_INSTANCE_NOT_RUNNING The process of the virtual controller is not
running.
SREC_WRONG_ARGUMENT The value is less than 0.
The minimum virtual time (in nanoseconds) that the virtual controller runs be-
fore it changes to Freeze state.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The process of the virtual controller is not
Code.InstanceNotRunning
running.
ERuntimeError- The value is less than 0.
Code.WrongArgument
Additional information
For further information, see sections Virtual time response (Page 75), Stop simulation
(Page 78).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 257
User interfaces (API)
7.6 API IInstances
SetCycleTimeMonitoringMode()
With this function the source of the timer for the maximum cycle time monitoring can be
changed.
Select one of the following options for the maximum cycle time monitoring:
– SRCTMM_DOWNLOADED:
The maximum cycle time from the project that was downloaded from
STEP 7 is used as maximum cycle time monitoring.
– SRCTMM_IGNORED (default):
A timer value of one minute is used as maximum cycle time monitoring to
prevent a potential error in case of an overflow of cyclic events.
See Monitoring overflow (Page 407).
– SRCTMM_SPECIFIED:
A value that is specified with the in_MaxCycleTime_ns parameter is used
as maximum cycle time monitoring.
S7-PLCSIM Advanced
258 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
void SetCycleTimeMonitoringMode(
ECycleTimeMonitoringMode in_CycleTimeMonitoringMode,
Int64 in_MaxCycleTime_ns
)
Parameters • ECycleTimeMonitoringMode in_CycleTimeMonitoringMode:
Select one of the following options for the maximum cycle time monitoring:
– ECycleTimeMonitoringMode.Downloaded:
The maximum cycle time from the project that was downloaded from
STEP 7 is used as maximum cycle time monitoring.
– ECycleTimeMonitoringMode.Ignored (default):
A timer value of one minute is used as maximum cycle time monitoring to
prevent a potential error in case of an overflow of cyclic events.
See Monitoring overflow (Page 407).
– ECycleTimeMonitoringMode.Specified:
A value that is specified with the in_MaxCycleTime_ns parameter is used
as maximum cycle time monitoring.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 259
User interfaces (API)
7.6 API IInstances
GetCycleTimeMonitoringMode()
This function returns information on the source of the timer for the maximum cycle time
monitoring.
The configured mode for cycle time monitoring. The default setting is
SRCTM_IGNORED.
• INT64 in_MaxCycleTime_ns:
The user-specific value for the maximum cycle time monitoring. If no value is
specified in the API, the default value of 150 ms is returned.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_TIMEOUT The function does not return on time.
The configured mode for cycle time monitoring. The default setting is ECy-
cleTimeMonitoringMode.Ignored.
• Int64 in_MaxCycleTime_ns:
The user-specific value for the maximum cycle time monitoring. If no value is
specified in the API, the default value of 150 ms is returned.
Return values None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
S7-PLCSIM Advanced
260 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.1 Overview
The acyclic services of PLCSIM Advanced include:
• Read and write processes of parameter and status data from the user program of the PLC
to the I/O modules
• Interrupt and event information which the I/O modules send to the CPU.
SFB Name API method (alarm) API event for triggering the SFB
52 RDREC ReadRecordDone (Page 263) OnDataRecordRead (Page 295)
53 WRREC WriteRecordDone (Page 263) OnDataRecordWrite (Page 295)
Flowchart
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 261
User interfaces (API)
7.6 API IInstances
OB Name API methods for triggering the API event after OB execution
OB (query) (alarm)
82 Diagnostic error Inter- AlarmNotification (Page 266) OnAlarmNotificationDone
rupt (Page 297)
4x Hardware Interrupt ProcessEvent (Page 269) OnProcessEventDone (Page 298)
83 Pull or Plug of module PullOrPlugEvent (Page 271) OnPullOrPlugEventDone
(Page 299)
55 Status StatusEvent (Page 273) OnStatusEventDone (Page 300)
57 Profile ProfileEvent (Page 275) OnProfileEventDone (Page 301)
56 Update UpdateEvent (Page 277) OnUpdateEventDone (Page 302)
86 Rack or station failure RackOrStationFaultEvent OnRackOrStationFaultEventDone
(Page 279) (Page 303)
Flowchart
Flowchart for the simulation of events which are triggered by the I/O modules.
S7-PLCSIM Advanced
262 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
ReadRecordDone()
With this API method, the simulation of an I/O module signals to the CPU that the
asynchronous reading of a data record has been completed. The simulation hereby makes the
read information available.
Byte array of the read data record with the length defined by DataSize in the
structure SDataRecordInfo.
• UINT32 in_Status:
Status of the job execution
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The instance is not registered in Runtime
Manager.
SREC_DOES_NOT_EXIST No hardware identifier of the module.
SREC_INDEX_OUT_OF_RANGE The byte array of the read data record
exceeds the length
DDATARECORD_MAX_SIZE = 64000.
SREC_TIMEOUT The function does not return on time.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 263
User interfaces (API)
7.6 API IInstances
Byte array of the read data record with the length defined by DataSize in the
structure SDataRecordInfo.
• UInt32 in_Status:
WriteRecordDone()
With this API method, the simulation of an I/O module signals to the CPU that the
asynchronous writing of a data record has been completed.
S7-PLCSIM Advanced
264 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 265
User interfaces (API)
7.6 API IInstances
7.6.8.3 AlarmNotification
AlarmNotification()
This function triggers diagnostic alarms according to the PROFINET standard.
Each call of this function calls the OB 82 once, regardless of the number and the severity level
of the transferred diagnostic entries.
The hardware identifier of the module or submodule which sends the diagnos-
tics entry.
DMODULE_STATE_OK = 0,
DMODULE_STATE_ERROR = 1,
DMODULE_STATE_MAINT_DEMANDED = 2,
DMODULE_STATE_MAINT_REQUIRED = 4
The in_ModuleState parameter is derived from the sum (ORed) of the severi-
ty level in the SDiagExtChannelDescription field. If a diagnostic interrupt
should be generated for both "Maintenance demanded" as well as "Mainte-
nance required", select "6" as the module status.
• UINT16 in_NumberOfDiagnosisEvents:
Multiple diagnostic entries can be sent to the CPU with a single API call.
Valid range: 0 to 16. 0 means that no diagnostics entry should appear for the
submodule or the channel.
• SDiagExtChannelDescription* in_ArrayOfDiagnosisEvents:
Pointer to a field with diagnostic entries. The field must match the number of
diagnostic entries. It can also be a zero pointer. For definitions, see SDi-
agExtChannelDescription (Page 371).
• UINT16* out_SequenceNumber:
S7-PLCSIM Advanced
266 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 267
User interfaces (API)
7.6 API IInstances
The hardware identifier of the module or submodule which sends the diagnos-
tics entry.
ModuleState.Ok = 0,
ModuleState.Error = 1,
ModuleState.MaintenanceDemanded = 2,
ModuleState.MaintenanceRequired = 4
The in_ModuleState parameter is derived from the sum (ORed) of the severi-
ty level in the SDiagExtChannelDescription field.
Multiple diagnostic entries can be sent to the CPU with a single API call.
Valid range: 0 to 16. 0 means that no diagnostics entry should appear for the
submodule or the channel.
• SDiagExtChannelDescription [] in_ArrayOfDiagnosisEvents:
Pointer to a field with diagnostic entries. The field must match the number of
diagnostic entries. It can also be a zero pointer. For definitions, see SDi-
agExtChannelDescription (Page 371).
• Out ushort out_SequenceNumber:
S7-PLCSIM Advanced
268 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Instance.AlarmNotification(269, 7, 3,
In_ArrayOfDiagnosisEvent, out seqNumber);
//ModuleState parameter is sum of the severities in the SDi-
agExtChannelDescription array above: 4+2+1
7.6.8.4 ProcessEvent
ProcessEvent()
Process events from central and distributed input modules can be simulated with this
function.
The hardware identifier of the module or submodule which sends the process
event.
A value from the list of predefined types of events for S7 modules, see EProces-
sEventType (Page 394).
• UINT16* out_SequenceNumber:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 269
User interfaces (API)
7.6 API IInstances
The hardware identifier of the module or submodule which generates the pro-
cess event.
A value from the list of predefined types of events for S7 modules, see EProces-
sEventType (Page 394).
• Out ushort out_SequenceNumber:
S7-PLCSIM Advanced
270 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.5 PullOrPlugEvent
PullOrPlugEvent()
This function triggers pull/plug events. The interrupt OB (OB 83) "Pull or plug of modules" is
executed for these events.
A value from the list of predefined types of pull/plug events, see EPullOr-
PlugEventType (Page 394).
• UINT16* out_SequenceNumber:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 271
User interfaces (API)
7.6 API IInstances
A value from the list of predefined types of pull/plug events, see EPullOr-
PlugEventType (Page 394).
• Out ushort out_SequenceNumber
S7-PLCSIM Advanced
272 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.6 StatusEvent
StatusEvent()
This function is used to trigger the status event OB (OB 55). Status events are only supported
for modules in a distributed IO system.
The hardware identifier of the module that generates the status event.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 273
User interfaces (API)
7.6 API IInstances
The hardware identifier of the module that generates the status event.
S7-PLCSIM Advanced
274 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.7 ProfileEvent
ProfileEvent()
This function is used to trigger the Profile event OB (OB 57). Profile events are only supported
for modules in a distributed IO system.
The hardware identifier of the module that generates the profile event.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 275
User interfaces (API)
7.6 API IInstances
The hardware identifier of the module that generates the profile event.
S7-PLCSIM Advanced
276 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.8 UpdateEvent
UpdateEvent()
This function is used to trigger the Update event OB (OB 56). Update events are only
supported for modules in a distributed IO system.
The hardware identifier of the module that triggers the update event.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 277
User interfaces (API)
7.6 API IInstances
The hardware identifier of the module that triggers the update event.
7.6.8.9 GetConfiguredProcessEvent
GetConfiguredProcessEvents()
With this API method, the process events configured in the TIA Portal can be read out during
runtime.
If no process events are present, SREC_OK is returned. The value for EventsCount is then 0.
Pointer or reference to a user-defined memory which contains the field with the
downloaded configured process events. The structure SConfiguredProcessEv-
ents (Page 369) contains information about these process events.
• UINT16* out_EventsCount:
S7-PLCSIM Advanced
278 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
7.6.8.10 RackOrStationFaultEvent
Description
This function is used to trigger the RackOrStationFault event OB (OB 86). These events are
only supported for distributed devices.
The hardware identifier of the device that sends the event. Use the hardware
identifier of the Hw_Device type.
• ERackOrStationFaultType in_EventType:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 279
User interfaces (API)
7.6 API IInstances
ERackOrStationFaultType in_EventType
);
Parameter • ushort in_HardwareIdentifier:
The hardware identifier of the device that sends the event. Use the hardware
identifier of the Hw_Device type.
• ERackOrStationFaultType in_EventType:
Additional information
You can find additional information on the HW identifier in the STEP 7 online help.
S7-PLCSIM Advanced
280 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
Event Cause
OnOperatingStateChanged The operating state of the virtual controller has changed.
(Page 281)
OnLedChanged (Page 285) The LED display of the virtual controller has changed.
OnConfigurationChanging The configuration of the virtual controller changes:
(Page 287)
• During power up from the Virtual SIMATIC Memory Card
• At the start of a download
When this event is triggered, the stored tag list is reset.
OnConfigurationChanged The configuration of the virtual controller has changed:
(Page 290)
• After power up from the Virtual SIMATIC Memory Card
• At the end of a download
• When the IP address changes
OnSyncPointReached The virtual controller has reached a synchronization point.
(Page 292) If the virtual controller is being operated in Default mode, the
SendSyncEventInDefaultMode flag must be set to receive the
event. See SendSyncEventInDefaultMode (Page 252).
OnOperatingStateChanged events
OnOperatingStateChanged
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 281
User interfaces (API)
7.6 API IInstances
RegisterOnOperatingStateChangedCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
RegisterOnOperatingStateChangedEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registering a new event object causes the
previous event object to be deleted.
S7-PLCSIM Advanced
282 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
// Do Something
…
// Clean up the handle
CloseHandle(eventHandle);
// Thread 2 -----------------------------------------------
---
while (condition)
{
// Wait for the event to be set //OR:
WaitForSingleObject(eventHandle, INFINITE); //psa-
>WaitForOnOperatingStateChangedEvent();
// Do Something
…
}
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 283
User interfaces (API)
7.6 API IInstances
UnregisterOnOperatingStateChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
UnregisterOnOperatingStateChangedEvent()
Unregisters the event object.
WaitForOnOperatingStateChangedEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
S7-PLCSIM Advanced
284 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
OnLedChanged events
OnLedChanged
Registers or unregisters an event handler method.
RegisterOnLedChangedCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 285
User interfaces (API)
7.6 API IInstances
RegisterOnLedChangedEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registering a new event object causes the
previous event object to be deleted.
UnregisterOnLedChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
UnregisterOnLedChangedEvent()
Unregisters the event object.
S7-PLCSIM Advanced
286 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
WaitForOnLedChangedEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
OnConfigurationChanging events
OnConfigurationChanging
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 287
User interfaces (API)
7.6 API IInstances
RegisterOnConfigurationChangingCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
RegisterOnConfigurationChangingEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registration of a new event object causes the
previous event object to be deleted.
UnregisterOnConfigurationChangingCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
S7-PLCSIM Advanced
288 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterOnConfigurationChangingEvent()
Unregisters the event object.
WaitForOnConfigurationChangingEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 289
User interfaces (API)
7.6 API IInstances
OnConfigurationChanged events
OnConfigurationChanged
Registers or unregisters an event handler method.
RegisterOnConfigurationChangedCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
290 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
RegisterOnConfigurationChangedEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registering a new event object causes the
previous event object to be deleted.
UnregisterOnConfigurationChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
UnregisterOnConfigurationChangedEvent()
Unregisters the event object.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 291
User interfaces (API)
7.6 API IInstances
WaitForOnConfigurationChangedEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
OnSyncPointReached events
OnSyncPointReached
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
292 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
RegisterOnSyncPointReachedCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
RegisterOnSyncPointReachedEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registering a new event object causes the
previous event object to be deleted.
UnregisterOnSyncPointReachedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 293
User interfaces (API)
7.6 API IInstances
UnregisterOnSyncPointReachedEvent()
Unregisters the event object.
WaitForOnSyncPointReachedEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
S7-PLCSIM Advanced
294 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
OnDataRecordRead
Registers or unregisters an event handler method.
OnDataRecordWrite
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 295
User interfaces (API)
7.6 API IInstances
RegisterOnDataRecordReadCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
UnregisterOnDataRecordReadCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
RegisterOnDataRecordWriteCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
296 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterOnDataRecordWriteCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnAlarmNotification events
OnAlarmNotificationDone()
Registers or unregisters an event handler method.
RegisterOnAlarmNotificationDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 297
User interfaces (API)
7.6 API IInstances
UnregisterOnAlarmNotificationDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnProcessEvent events
OnProcessEventDone()
Registers or unregisters an event handler method.
RegisterOnProcessEventDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
298 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterOnProcessEventDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnPullOrPlugEvent events
OnPullOrPlugEventDone()
Registers or unregisters an event handler method.
RegisterOnPullOrPlugEventDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 299
User interfaces (API)
7.6 API IInstances
UnregisterOnPullOrPlugEventDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnStatusEvent events
OnStatusEventDone()
Registers or unregisters an event handler method.
RegisterOnStatusEventDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
300 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterOnStatusEventDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnProfileEvent events
OnProfileEventDone()
Registers or unregisters an event handler method.
RegisterOnProfileEventDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 301
User interfaces (API)
7.6 API IInstances
UnregisterOnProfileEventDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
OnUpdateEvent events
OnUpdateEventDone()
Registers or unregisters an event handler method.
RegisterOnUpdateEventDoneCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
302 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.6 API IInstances
UnregisterOnUpdateEventDoneCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
RackOrStationFault events
OnRackOrStationFaultEvent
Registers or unregisters an event handler method.
RegisterOnRackOrStationFaultEventCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be deleted.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 303
User interfaces (API)
7.7 API IRemoteRuntimeManager
UnregisterOnRackOrStationFaultEventCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Dispose()
Deletes the managed interface and unloads the native components of the user interfaces.
Note
When the interface of the Remote Runtime Manager is deleted, no IInstance interface which
was generated by the IRemoteRuntimeManager interface can be used.
The .NET Garbage Collector clears its IRemoteRuntimeManager interface when no active
references are present.
S7-PLCSIM Advanced
304 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
GetVersion()
Returns the version of the remote Runtime Manager. If the function fails, version 0.0 is
returned.
GetIP() / IP { get; }
Returns the IP address of the PC on which the remote Runtime Manager is running. If the
function fails, the return value is 0.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 305
User interfaces (API)
7.7 API IRemoteRuntimeManager
S7-PLCSIM Advanced
306 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
Disconnect()
Closes the connection to the remote Runtime Manager.
Note
All applications that are connected to the remote Runtime Manager lose this connection.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 307
User interfaces (API)
7.7 API IRemoteRuntimeManager
S7-PLCSIM Advanced
308 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
GetRegisteredInstancesCount()
Returns the number of instances that are registered in Runtime Manager. If the function fails,
the return value is 0.
GetRegisteredInstanceInfoAt()
Returns information about an already registered instance.
You can use the ID or name to create an interface of this instance (see
CreateInterface()).
Index of the created instance from which you want to receive the information.
The index must be less than the value you receive when you call GetRegis-
teredInstanceCount().
• SInstanceInfo* out_InstanceInfo:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 309
User interfaces (API)
7.7 API IRemoteRuntimeManager
RegisteredInstanceInfo { get; }
Returns information about an already registered instance. You can use the ID or name of this
instance to create an interface of this instance, see CreateInterface().
RegisterInstance()
Registers a new instance of a virtual controller in Runtime Manager. Creates and returns an
interface of this instance.
Defines which CPU type is simulated at the start of the instance. The default set-
ting is "SRCT_1500_Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual SIMATIC
Memory Card, this CPU type applies.
• WCHAR* in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
• IInstance** out_InstanceInterface:
S7-PLCSIM Advanced
310 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 311
User interfaces (API)
7.7 API IRemoteRuntimeManager
Defines which CPU type is simulated at the start of the instance. The default set-
ting is "ECPUType.Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual SIMATIC
Memory Card, this CPU type applies.
• string in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
Return values If the function is successful, an interface of a virtual controller. Otherwise, a Null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The interface is disconnected from the
Code.InterfaceRemoved
remote Runtime Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name is invalid.
Code.WrongArgument
ERuntimeError- There are already 16 instances registered
Code.LimitReached
in Runtime Manager.
ERuntimeError- An instance with this name already exists.
Code.AlreadyExists
S7-PLCSIM Advanced
312 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
RegisterCustomInstance()
Registers a new instance of a virtual controller in Runtime Manager. Creates and returns an
interface of this instance.
The complete path to the DLL of the virtual controller that Sie-
mens.Simatic.Simulation.Runtime.Instance.exe loads at PowerOn.
• WCHAR* in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
• IInstance** out_InstanceInterface:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 313
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105).
The complete path to the DLL of the virtual controller that Sie-
mens.Simatic.Simulation.Runtime.Instance.exe loads at PowerOn.
• string in_InstanceName:
Name to be assigned to the instance. Every instance must have a unique name.
If no name is assigned when registering a new instance, the instance is given
the name "Instance_#" (# is the ID of the instance). If this name already ex-
ists, the name "Instance_#.#" is used, in which the second # is a counter
that is incremented until the name is unique. The length of the name must be
less than DINSTANCE_NAME_LENGTH. See Data types (Page 349).
Return values If the function is successful, an interface of a virtual controller; otherwise a Null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The interface is disconnected from the
Code.InterfaceRemoved
remote Runtime Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name or the ID is invalid.
Code.WrongArgument
ERuntimeError- There are already 16 instances registered
Code.LimitReached
in Runtime Manager.
ERuntimeError- An instance with this name already exists.
Code.AlreadyExists
S7-PLCSIM Advanced
314 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
CreateInterface()
Creates and returns an interface of an already registered instance of a virtual controller.
The instance could have been registered via the application or another application that uses
the Simulation Runtime API.
The ID of the registered instance from which you want to receive the interface.
• WCHAR* in_InstanceName:
The name of the registered instance from which you want to receive the inter-
face.
• IInstance** out_InstanceInterface:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 315
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 105)
The ID of the registered instance from which you want to receive the interface.
• string in_InstanceName:
The name of the registered instance from which you want to receive the inter-
face.
Return values If the function is successful, an interface of a virtual controller; otherwise a Null
pointer.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The interface is disconnected from the
Code.InterfaceRemoved
remote Runtime Manager.
ERuntimeErrorCode.Timeout The function does not return on time.
ERuntimeError- The name or the ID is invalid.
Code.WrongArgument
ERuntimeError- The instance is not registered in Runtime
Code.DoesNotExists
Manager.
S7-PLCSIM Advanced
316 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
Description
The event is triggered when the connection to the Remote Runtime Manager has been
terminated.
OnConnectionLost
Registers or unregisters an event handler method.
RegisterOnConnectionLostCallback()
When the event occurs, the registered callback function is called. Only one callback function
can be registered for the event. Registering a new callback function causes the previous
callback function to be unregistered.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 317
User interfaces (API)
7.7 API IRemoteRuntimeManager
RegisterOnConnectionLostEvent()
When the event occurs, the registered event object is set to the signaled state. Only one
event object can be registered for the event. Registration of a new event object causes the
previous event object to be deleted.
UnregisterOnConnectionLostCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
S7-PLCSIM Advanced
318 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.7 API IRemoteRuntimeManager
UnregisterOnConnectionLostEvent()
Unregisters the event object.
WaitForOnConnectionLostEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 319
User interfaces (API)
7.8 Data types
Note
Unsupported data types
The Runtime API does not support the STRING and WSTRING data types.
Example:
If the value 999 is transferred to the API as 2457H, then Write modifies the value 2457H to
999. Without BCD conversion, there is no UInt16 value and Write writes no value at all.
Additional information
For information on data types and conversion, refer to section "Data types" in the SIMATIC
STEP 7 Basic/Professional (https://support.industry.siemens.com/cs/ww/en/view/109755202)
System Manual.
S7-PLCSIM Advanced
320 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.1.1 ApiEntry_Initialize
Description
Type of the central entry point for the API library (DLL).
7.8.1.2 ApiEntry_DestroyInterface
Description
Type of the entry point for DestroyInterface (Page 105).
Table 7- 390 ApiEntry_DestroyInterface - Native C++
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 321
User interfaces (API)
7.8 Data types
7.8.2.1 EventCallback_VOID
Description
7.8.2.2 EventCallback_SRCC_UINT32_UINT32_INT32
Description
S7-PLCSIM Advanced
322 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.3 EventCallback_SRRSI_AD
Description
Data from the Remote Runtime Manager. The parameter contains valid data
only if in_AutodiscoverMsg = SRRSI_DISCOVER_DATA. Otherwise it is
initialized with 0. See SAutodiscoverData (Page 398).
Return values None
7.8.2.4 EventCallback_IRRTM
Description
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 323
User interfaces (API)
7.8 Data types
7.8.2.5 EventCallback_II_SREC_ST_SROS_SROS
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• EOperatingState in_PrevState:
S7-PLCSIM Advanced
324 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.6 EventCallback_II_SREC_ST_UINT32_INT64_INT64_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_PipId:
The ID of the process image partition (PIP) that triggers this event.
The virtual time (in nanoseconds) since the last synchronization point of the
same process image partition ID was reached.
The virtual time (in nanoseconds) since the last synchronization point of any
process image partition ID was reached.
The number of synchronization points since the last event. If the events are
triggered faster than they are received, multiple events are combined into
one event. In this case, this value contains the number of cycles since the last
event was received.
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 325
User interfaces (API)
7.8 Data types
7.8.2.7 EventCallback_II_SREC_ST
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
Return values None
S7-PLCSIM Advanced
326 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.8 EventCallback_II_SREC_ST_SRICC_UINT32_UINT32_UINT32_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
EIn- UINT32 UINT32 UINT32 UINT32
stanceCon- in_Param1 in_Param2 in_Param3 in_Param4
figChanged
in_Instanc
eCon-
figChanged
SRICC_HARD - - - -
WARE_SOFTW
ARE_CHANGE
D
SRICC_IP_C The ID of the The new IP The new sub- The new
HANGED
interface net mask standard
gateway
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 327
User interfaces (API)
7.8 Data types
7.8.2.9 EventCallback_II_SREC_ST_SRLT_SRLM
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• ELEDType in_LEDType:
S7-PLCSIM Advanced
328 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.10 EventCallback_II_SREC_ST_SDRI
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• SDataRecordInfo in_DataRecordInfo:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 329
User interfaces (API)
7.8 Data types
7.8.2.11 EventCallback_II_SREC_ST_SDRI_BYTE
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• SDataRecordInfo in_DataRecordInfo:
The data record. This pointer becomes invalid after the callback function has
returned.
Return values None
S7-PLCSIM Advanced
330 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.12 EventCallback_II_SREC_ST_UINT32_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_HardwareIdentifier:
The hardware identifier of the module or submodule which sends the diag-
nostics event.
• UINT32 in_SequenceNumber:
Note
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 331
User interfaces (API)
7.8 Data types
7.8.2.13 EventCallback_II_SREC_ST_UINT32_UINT32_EPET_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_HardwareIdentifier:
The hardware identifier of the IO module that sends the process event.
• UINT32 in_Channel:
A value from the list of predefined types of events for S7 modules, see EPro-
cessEventType (Page 394).
• UINT32 in_SequenceNumber:
During the simulation, the sequence number creates the relation between in-
terrupt request and the associated acyclic alarm.
Return values None
S7-PLCSIM Advanced
332 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.14 EventCallback_II_SREC_ST_UINT32_EPPET_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_HardwareIdentifier:
A value from the list of predefined types of events for S7 modules, see EPul-
lOrPlugEventType (Page 394).
• UINT32 in_SequenceNumber:
Note
During the simulation, the sequence number creates the relation between in-
terrupt request and the associated acyclic alarm.
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 333
User interfaces (API)
7.8 Data types
7.8.2.15 EventCallback_II_SREC_ST_UINT32_ERSFET
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_HardwareIdentifier:
The hardware identifier of the module or submodule which sends the diag-
nostics event.
• ERackOrStationFaultType in_EventType:
S7-PLCSIM Advanced
334 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.2.16 EventCallback_II_SREC_ST_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 in_HardwareIdentifier:
The hardware identifier of the module or submodule which generates the sta-
tus, update or Profile event.
7.8.3.1 Delegate_Void
Description
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 335
User interfaces (API)
7.8 Data types
7.8.3.2 Delegate_SRCC_UINT32_UINT32_INT32
Description
S7-PLCSIM Advanced
336 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.3 Delegate_SRRSI_AD
Description
Data from the Remote Runtime Manager. The parameter contains valid data
only if in_AutodiscoverType = AutodiscoverData. Otherwise it is ini-
tialized with 0. See SAutodiscoverData (Page 373).
Return values None
7.8.3.4 Delegate_II_EREC_DT
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 337
User interfaces (API)
7.8 Data types
7.8.3.5 Delegate_II_EREC_DT_EOS_EOS
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• EOperatingState in_PrevState:
S7-PLCSIM Advanced
338 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.6 Delegate_II_EREC_DT_ELT_ELM
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• ELEDType in_LEDType:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 339
User interfaces (API)
7.8 Data types
7.8.3.7 Delegate_II_EREC_DT_UINT32_INT64_INT64_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_PipId:
The ID of the process image partition (PIP) that triggers this event.
0 for the cycle control point (End of cycle).
• Int64 in_TimeSinceSameSyncPoint_ns:
The virtual time (in nanoseconds) since the last synchronization point of the
same process image partition ID was reached.
Or the process time for the time-controlled operating modes (Page 82).
• Int64 in_TimeSinceAnySyncPoint_ns:
The virtual time (in nanoseconds) since the last synchronization point of any
process image partition ID was reached.
Or the process time for the time-controlled operating modes (Page 82).
• UInt32 in_SyncPointCount:
The number of synchronization points since the last event. If the events are
triggered faster than they are received, multiple events are combined into
one event. In this case, this value contains the number of cycles since the last
event was received.
Return values None
S7-PLCSIM Advanced
340 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.8 Delegate_IRRTM
Description
7.8.3.9 Delegate_II_EREC_DT_SRICC_UINT32_UINT32_UINT32_UINT32
Description
The virtual system time of the virtual controller at the time when this
event was triggered.
EIn- UInt32 UInt32 UInt32 UInt32
stanceCon- in_Param1 in_Param2 in_Param3 in_Param4
figChanged
in_Instanc
eCon-
figChanged
Hard- - - - -
wareSoft-
wareChange
d
IPChanged The ID of the The new IP The new The new
interface subnet mask standard
gateway
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 341
User interfaces (API)
7.8 Data types
7.8.3.10 Delegate_II_EREC_DT_SDRI
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• SDataRecordInfo in_DataRecordInfo:
S7-PLCSIM Advanced
342 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.11 Delegate_II_EREC_DT_SDR
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• SDataRecord in_DataRecord:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 343
User interfaces (API)
7.8 Data types
7.8.3.12 Delegate_SREC_ST_UINT32_EPPET_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_HardwareIdentifier:
A value from the list of predefined types of events for S7 modules, see EPul-
lOrPlugEventType (Page 394).
• UInt32 in_SequenceNumber:
Note
During the simulation, the sequence number creates the relation between in-
terrupt request and the associated acyclic alarm.
Return values None
S7-PLCSIM Advanced
344 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.13 Delegate_SREC_ST_UINT32_UINT32_EPET_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_HardwareIdentifier:
The hardware identifier of the module or submodule that sends the process
event.
• UInt32 in_Channel:
A value from the list of predefined types of events for S7 modules, see EPro-
cessEventType (Page 394).
• UInt32 in_SequenceNumber:
During the simulation, the sequence number creates the relation between in-
terrupt request and the associated acyclic alarm.
Return values None
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 345
User interfaces (API)
7.8 Data types
7.8.3.14 Delegate_SREC_ST_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_HardwareIdentifier:
The ID of the module which generates the status event, update event or pro-
file event.
Return values None
S7-PLCSIM Advanced
346 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.3.15 Delegate_SREC_ST_UINT32_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_HardwareIdentifier:
The hardware identifier of the module or submodule which sends the diag-
nostics entry.
• UInt32 in_SequenceNumber:
Note
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 347
User interfaces (API)
7.8 Data types
7.8.3.16 Delegate_SREC_ST_UINT32_ERSFET
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 in_HardwareIdentifier:
The hardware identifier of the module or submodule which sends the diag-
nostics entry.
• ERackOrStationFaultType in_EventType:
S7-PLCSIM Advanced
348 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 349
User interfaces (API)
7.8 Data types
7.8.5.1 UIP
Description
Contains an IPv4 address.
S7-PLCSIM Advanced
350 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.5.2 UDataValue
Description
Contains the value of a PLC tag.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 351
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
352 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6 Structures
The following structures are available:
• SDataValue (Page 353)
• SDVBNI (Page 356)
• SDataValueByAddress (Page 356)
• SDataValueByAddressWithCheck (Page 357)
• SDataValueByName (Page 358)
• SDataValueByNameWithCheck (Page 359)
• SConnectionInfo (Page 359)
• SInstanceInfo (Page 360)
• SDimension (Page 360)
• STagInfo (Page 361)
• SIP (Page 364)
• SIPSuite4 (Page 364)
• SOnSyncPointReachedResult (Page 366)
• SDataRecordInfo (Page 368)
• SDataRecord (Page 369)
• SConfiguredProcessEvents (Page 369)
• SDiagExtChannelDescription (Page 371)
• SAutodiscoverData (Page 373)
7.8.6.1 SDataValue
Description
The structure contains the value and type of a PLC tag.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 353
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
354 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 355
User interfaces (API)
7.8 Data types
7.8.6.2 SDVBNI
Description
This structure is for internal use only. Do not change this structure.
7.8.6.3 SDataValueByAddress
Description
This structure represents a PLC tag that is accessed via its address.
S7-PLCSIM Advanced
356 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.4 SDataValueByAddressWithCheck
Description
This structure represents a PLC tag that is accessed via its address.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 357
User interfaces (API)
7.8 Data types
7.8.6.5 SDataValueByName
Description
This structure represents a PLC tag that is called by its name.
S7-PLCSIM Advanced
358 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.6 SDataValueByNameWithCheck
Description
This structure represents a PLC tag that is called by its name.
7.8.6.7 SConnectionInfo
Description
This structure contains the IP address and port of a TCP/IP connection.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 359
User interfaces (API)
7.8 Data types
7.8.6.8 SInstanceInfo
Description
This structure contains an IPv4 address.
7.8.6.9 SDimension
Description
This structure contains information about the dimension of a field.
Table 7- 443 SDimension - Native C++
S7-PLCSIM Advanced
360 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.10 STagInfo
Description
This structure contains information about a PLC tag.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 361
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
362 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 363
User interfaces (API)
7.8 Data types
7.8.6.11 SIP
Description
This structure contains an IPv4 address.
7.8.6.12 SIPSuite4
Description
This structure contains an IPv4 suite.
The IP address
• UIP SubnetMask:
S7-PLCSIM Advanced
364 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
The IP address
• SIP SubnetMask:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 365
User interfaces (API)
7.8 Data types
7.8.6.13 SOnSyncPointReachedResult
Description
This structure contains the results of the OnSyncPointReached event.
The virtual system time of the virtual controller at the time when this event
was triggered.
• UINT32 PipId:
The ID of the process image partition (PIP) that triggers this event.
The virtual time (in nanoseconds) since the last synchronization point of the
same process image partition ID was reached.
The virtual time (in nanoseconds) since the last synchronization point of any
process image partition ID was reached.
The number of synchronization points since the last event. If the events are
triggered faster than they are received, multiple events are combined into
one event. In this case, this value contains the number of cycles since the last
event was received.
S7-PLCSIM Advanced
366 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
The virtual system time of the virtual controller at the time when this event
was triggered.
• UInt32 PipId:
The ID of the process image partition (PIP) that triggers this event.
The virtual time (in nanoseconds) since the last synchronization point of the
same process image partition ID was reached.
The virtual time (in nanoseconds) since the last synchronization point of any
process image partition ID was reached.
The number of synchronization points since the last event. If the events are
triggered faster than they are received, multiple events are combined into
one event. In this case, this value contains the number of cycles since the last
event was received.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 367
User interfaces (API)
7.8 Data types
7.8.6.14 SDataRecordInfo
Description
This structure contains read/write data record information.
S7-PLCSIM Advanced
368 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.15 SDataRecord
Description
This structure contains read/write data record information and data records.
7.8.6.16 SConfiguredProcessEvents
Description
This structure contains information about the configured process events.
The HW identifier
• UINT16 Channel:
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 369
User interfaces (API)
7.8 Data types
The HW identifier
• ushort Channel:
S7-PLCSIM Advanced
370 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.17 SDiagExtChannelDescription
Description
This structure contains read/write data record information and data records.
If the interrupt relates to a specific channel of the IO device (e.g. short circuit),
this parameter must contain the number of the faulty channel.
The parameter defines error types according to PROFINET standard, see "Error
types" section.
• EDiagSeverity Severity:
The value of the severity for the diagnostics, see EDiagSeverity (Page 396).
• EDiagProperty Direction:
This parameter provides the option of defining more details for the diagnostic
interrupt. This is helpful in combination with PDEV error types which are gener-
ated for CPU-internal modules. Should be 0 by default.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 371
User interfaces (API)
7.8 Data types
If the interrupt relates to a specific channel of the IO device (e.g. short circuit),
this parameter must contain the number of the faulty channel.
The parameter defines error types according to PROFINET standard, see "Error
types" section.
• EDiagSeverity Severity:
The value of the severity for the diagnostics, see EDiagSeverity (Page 396).
• EDiagProperty Direction:
This parameter provides the option of defining more details for the diagnostic
interrupt. This is helpful in combination with PDEV error types which are gener-
ated for CPU-internal modules. Should be 0 by default.
Error types
The following table contains important error types (ErrorType) according to PROFINET
standard:
Value Meaning
0x0000 Reserved / unknown error
0x0001 Short-circuit
0x0002 Undervoltage
0x0003 Overvoltage
0x0004 Overload
0x0005 Overtemperature
0x0006 Wire break
0x0007 High limit violated
0x0008: Low limit violated
0x0009 Error
S7-PLCSIM Advanced
372 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.6.18 SAutodiscoverData
Description
This structure contains the IP address, the port, the Runtime version, and the name of the
computer that has a Runtime Manager ready to make a remote connection.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 373
User interfaces (API)
7.8 Data types
7.8.7 Enumerations
The following enumerations are available:
• ERuntimeErrorCode (Page 375)
• EArea (Page 379)
• EOperatingState (Page 380)
• EOperatingMode (Page 381)
• ECPUType (Page 382)
• ECommunicationInterface (Page 384)
• ELEDType (Page 384)
• ELEDMode (Page 385)
• EPrimitiveDataType (Page 385)
• EDataType (Page 388)
• ETagListDetails (Page 392)
• ERuntimeConfigChanged (Page 393)
• EInstanceConfigChanged (Page 393)
• EPullOrPlugEventType (Page 394)
• EProcessEventType (Page 394)
• EDirection (Page 395)
• EDiagProperty (Page 396)
• EDiagSeverity (Page 396)
• ERackOrStationFaultType (Page 397)
• ECycleTimeMonitoringMode (Page 397)
• EAutodiscoverType (Page 398)
See also
Global functions (Native C++) (Page 109)
S7-PLCSIM Advanced
374 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.1 ERuntimeErrorCode
Description
This enumeration contains all error codes that are used by the Simulation Runtime API. Most
API functions return one of these error codes. If the function is successful, the return value is
always SREC_OK / OK. Errors are returned with negative values, warnings with positive
values.
Table 7- 463 ERuntimeErrorCode - Native C++
Syntax enum ERuntimeErrorCode
{
SREC_OK = 0,
SREC_INVALID_ERROR_CODE = -1,
SREC_NOT_IMPLEMENTED = -2,
SREC_INDEX_OUT_OF_RANGE = -3,
SREC_DOES_NOT_EXIST = -4,
SREC_ALREADY_EXISTS = -5,
SREC_UNKNOWN_MESSAGE_TYPE = -6,
SREC_INVALID_MESSAGE_ID = -7,
SREC_WRONG_ARGUMENT = -8,
SREC_WRONG_PIPE = -9,
SREC_CONNECTION_ERROR = -10,
SREC_TIMEOUT = -11,
SREC_MESSAGE_CORRUPT = -12,
SREC_WRONG_VERSION = -13,
SREC_INSTANCE_NOT_RUNNING = -14,
SREC_INTERFACE_REMOVED = -15,
SREC_SHARED_MEMORY_NOT_INITIALIZED = -16,
SREC_API_NOT_INITIALIZED = -17,
SREC_WARNING_ALREADY_EXISTS = 18,
SREC_NOT_SUPPORTED = -19,
SREC_WARNING_INVALID_CALL = 20,
SREC_ERROR_LOADING_DLL = -21,
SREC_SIGNAL_NAME_DOES_NOT_EXIST = -22,
SREC_SIGNAL_TYPE_MISMATCH = -23,
SREC_SIGNAL_CONFIGURATION_ERROR = -24,
SREC_NO_SIGNAL_CONFIGURATION_LOADED = -25,
SREC_CONFIGURED_CONNECTION_NOT_FOUND = -26,
SREC_CONFIGURED_DEVICE_NOT_FOUND = -27,
SREC_INVALID_CONFIGURATION = -28,
SREC_TYPE_MISMATCH = -29,
SREC_LICENSE_NOT_FOUND = -30,
SREC_NO_LICENSE_AVAILABLE = -31,
SREC_WRONG_COMMUNICATION_INTERFACE = -32,
SREC_LIMIT_REACHED = -33,
SREC_NO_STORAGE_PATH_SET = -34,
SREC_STORAGE_PATH_ALREADY_IN_USE = -35,
SREC_MESSAGE_INCOMPLETE = -36,
SREC_ARCHIVE_STORAGE_NOT_CREATED = -37,
SREC_RETRIEVE_STORAGE_FAILURE = -38,
SREC_INVALID_OPERATING_STATE = -39,
SREC_INVALID_ARCHIVE_PATH = -40,
SREC_DELETE_EXISTING_STORAGE_FAILED = -41,
SREC_CREATE_DIRECTORIES_FAILED = -42,
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 375
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
376 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 377
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
378 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.2 EArea
Description
This enumeration contains all PLC areas that contain the available PLC tags.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 379
User interfaces (API)
7.8 Data types
7.8.7.3 EOperatingState
Description
This enumeration contains all the operating states of a virtual controller.
SROS_ENUMERATION_SIZE = 9
};
S7-PLCSIM Advanced
380 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.4 EOperatingMode
Description
This enumeration contains all the operating modes of a virtual controller.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 381
User interfaces (API)
7.8 Data types
7.8.7.5 ECPUType
Description
This enumeration contains all CPU types that can be loaded in a virtual controller.
S7-PLCSIM Advanced
382 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 383
User interfaces (API)
7.8 Data types
7.8.7.6 ECommunicationInterface
Description
This enumeration contains the available communication interfaces of a virtual controller.
7.8.7.7 ELEDType
Description
This list includes all types of LEDs of a virtual controller.
Table 7- 475 ELEDType - Native C++
S7-PLCSIM Advanced
384 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.8 ELEDMode
Description
This list contains all the LED states of a virtual controller.
7.8.7.9 EPrimitiveDataType
Description
This list contains all the primitive data types that are used by the I/O access functions.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 385
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
386 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 387
User interfaces (API)
7.8 Data types
7.8.7.10 EDataType
Description
This enumeration contains all the PLC data types (STEP 7).
S7-PLCSIM Advanced
388 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 389
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
390 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 391
User interfaces (API)
7.8 Data types
7.8.7.11 ETagListDetails
Description
This list contains all PLC areas that can be used as a filter to update the tag table.
S7-PLCSIM Advanced
392 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.12 ERuntimeConfigChanged
Description
This list contains all possible causes of a OnConfigurationChanged event that the Runtime
Manager sends.
7.8.7.13 EInstanceConfigChanged
Description
This list contains all possible causes for a OnConfigurationChanged event that the virtual
controller sends.
Table 7- 489 EInstanceConfigChanged - Native C++
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 393
User interfaces (API)
7.8 Data types
7.8.7.14 EPullOrPlugEventType
Description
This enumeration contains predefined types of pull/plug events for S7 modules.
7.8.7.15 EProcessEventType
Description
This enumeration contains predefined types of process events for S7 modules.
S7-PLCSIM Advanced
394 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.16 EDirection
Description
This enumeration contains properties of the diagnostic alarm.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 395
User interfaces (API)
7.8 Data types
7.8.7.17 EDiagProperty
Description
This enumeration contains the incoming/outgoing information of the diagnostic alarm.
7.8.7.18 EDiagSeverity
Description
This enumeration contains the severity of the diagnostic alarm (error, maintenance
demanded, maintenance required).
S7-PLCSIM Advanced
396 Function Manual, 05/2021, A5E37039512-AD
User interfaces (API)
7.8 Data types
7.8.7.19 ERackOrStationFaultType
Description
This enumeration contains the types of the RackOrStationFault event.
7.8.7.20 ECycleTimeMonitoringMode
Description
This enumeration contains the sources of the timer for the maximum cycle time monitoring.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 397
User interfaces (API)
7.8 Data types
7.8.7.21 EAutodiscoverType
Description
This enumeration is used in the Autodiscover Callback function.
S7-PLCSIM Advanced
398 Function Manual, 05/2021, A5E37039512-AD
Restrictions, messages and solution 8
8.1 Overview
Certain actions or events can lead to behavior in PLCSIM Advanced or in STEP 7 which
deviates from that of a hardware CPU. Messages and possible solutions can be found in the
following sections:
• OPC UA server (Page 400)
• Web server (Page 400)
• Backing up and restoring the configuration of a PLCSIM Advanced instance (Page 401)
• Restrictions for file paths (Page 402)
• Restrictions for communications services (Page 402)
• Restrictions for instructions (Page 402)
• Restrictions to local communication via Softbus (Page 403)
• Messages for communication via TCP/IP (Page 404)
• Restrictions of security with VMware vSphere Hypervisor (ESXi) (Page 405)
• Restrictions for Hyper-V (Page 407)
• Monitoring overflow (Page 407)
• Deviating I/O values in the STEP 7 user program (Page 408)
• Multiple simulations and possible collision of IP addresses (Page 408)
• Lacking access to an IP address (Page 408)
• Simulation in standby mode (Page 408)
• ET 200SP CPUs: Use of BusAdapters with fiber-optic interface (Page 409)
• Installing SIMATIC NET (Page 409)
S7-PLCSIM Advanced
399 Function Manual, 05/2021, A5E37039512-AD
8.2 OPC UA server
With OPC UA, data exchange is performed through an open, standardized and manufacturer-
independent communication protocol. The CPU as OPC UA server can communicate with OPC
UA clients, for example, with HMI panels and SCADA systems.
S7 PLCSIM Advanced
Start the instances via the communication interface "PLCSIM Virtual Ethernet Adapter"
(TCP/IP) to use the Web server.
The Web server functionality is not available if the communication is performed via the
Softbus.
STEP 7
Configure the Web server in STEP 7 in the CPU properties.
S7-PLCSIM Advanced
400 Function Manual, 05/2021, A5E37039512-AD
Restricted Web server functionality
• The information may not be fully displayed on some websites due to different data
handling.
• There is no topology information.
• "Online Backup&Restore" is not available.
• FW updates are not supported.
Requirements
• The configuration of a PLCSIM Advanced instance is backed up and restored over the
TCP/IP protocol, Softbus is not supported.
• It is only possible to restore the configuration of a PLCSIM Advanced instance with the
corresponding backup from PLCSIM Advanced.
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 401
8.5 Restrictions for file paths
The following restrictions apply for user interfaces which expect a path or a complete file
name as the transfer parameter:
Restrictions for local Write permissions to system-critical directories such as the Windows directo-
paths ry (%Windows%) or the program directories (%Program Files%, %Program
Files (x86)%) are not allowed.
In this case the C++ user interface returns the error code
SREC_WRONG_ARGUMENT. In this case the managed user interface returns
an exception with the error code RuntimeErrorCode.WrongArgument.
Restrictions for net- In order to be able to use network paths, you must incorporate them as a
work paths network drive.
Otherwise, the C++ user interface returns the error code
SREC_WRONG_ARGUMENT. The managed user interface returns an exception
with the error code RuntimeErrorCode.WrongArgument.
TUSEND / TURCV
When you run the UDP blocks TUSEND and TURCV via the "PLCSIM" communication interface
(Softbus), you get error code 0x80C4 at the transmission end and receiving end:
Temporary communications error. The specified connection is temporarily down.
Solution
Set "PLCSIM Virtual Ethernet Adapter" (TCP/IP) as the communication interface in PLCSIM
Advanced.
S7-PLCSIM Advanced
402 Function Manual, 05/2021, A5E37039512-AD
8.8 Restrictions to local communication via Softbus
Solution
Use the API function SetIPSuite() to assign a unique address for each instance, then all
instances are displayed in STEP 7 with their IP addresses.
API function
• SetIPSuite() (Page 147)
1. Start only one instance with the symbol in the Control Panel.
2. In TIA Portal, download the program to this instance.
3. Repeat the steps until you have created all instances and downloaded all projects.
See also
Controller - Information and settings (Page 144)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 403
8.9 Messages for communication via TCP/IP
Error codes
If an ID with error designation appears in the taskbar, you will find the description in section 7
User interfaces (API) (Page 84).
Message
"Siemens PLCSIM Virtual Ethernet Adapter was not found. Please reinstall PLCSIM Advanced."
Remedy
The PLCSIM Virtual Ethernet Adapter cannot be found on the system.
Run PLCSIM Advanced Setup again:
1. Double-click the download package or insert the installation medium into the drive. The
setup program starts up automatically, provided you have not disabled the Autostart
function on the computer. If the setup program does not start up automatically, start it
manually by double-clicking the "Start.exe" file.
2. Follow the prompts until you reach the "Configuration" window. Select the "Repair" check
box.
3. Follow the remaining prompts to repair your installation.
4. Complete the repair operation by restarting your computer.
Message
"Siemens PLCSIM Virtual Ethernet Adapter is disabled. Please enable it."
Remedy
The PLCSIM Virtual Ethernet Adapter is deactivated on the system. In the Control Panel, under
"Network and Sharing Center" > "Change Adapter Settings" and activate the network adapter.
S7-PLCSIM Advanced
404 Function Manual, 05/2021, A5E37039512-AD
Message
"Npcap service is not running. When installed start it from elevated command prompt with
'net start npcap'."
Remedy
The Npcap is not active on the system. Open a command line in administrator mode and
enter the command "net start npcap".
Message
"You have to set a valid IP address for the Siemens PLCSIM Virtual Ethernet Adapter."
Remedy
Assign a static IP address to the Siemens PLCSIM Virtual Ethernet Adapter or obtain an IP
address via DHCP (default setting).
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 405
Promiscuous Mode
In Promiscuous mode, the network adapter reads all incoming telegrams, including those
that are not intended for the network adapter, and forwards the data to the operating system
for processing.
The Promiscuous mode is necessary for the simulation with PLCSIM Advanced so that
telegrams can be forwarded by the Ethernet adapter to the PC or the VM for processing, for
example, data for additional PLCSIM Advanced instances in the network.
NOTICE
Restrictions of security
For security reasons, Promiscuous mode is disabled by default.
If you accept the Promiscuousmode, the real Ethernet adapter even receives telegrams that
are not addressed to it.
S7-PLCSIM Advanced
406 Function Manual, 05/2021, A5E37039512-AD
8.11 Restrictions for Hyper-V
The following information is only important if you want to communicate with the "outside
world". This means when you access from a visualization platform on which an instance is
being executed to another VM on which the TIA Portal is being executed. When you are using
TCP/IP on the local PC, the following settings are not necessary.
When you use the virtualization platform Hyper-V, you must change the following setting to
be able to use the communication over TCP/IP.
1. In the Hyper-V Manager, select the Hyper-V server.
2. Select the VM and its settings via "Settings...".
3. In the "Extended Functions", select "MAC Address Spoofing".
This setting is necessary for the simulation with PLCSIM Advanced so that telegrams can be
forwarded by the Ethernet adapter to the PC or the VM for processing, for example, data for
additional PLCSIM Advanced instances in the network.
NOTICE
Restrictions of security
For security reasons, Promiscuous mode is disabled by default.
If you accept the Promiscuousmode, the real Ethernet adapter even receives telegrams that
are not addressed to it.
See also
Speed up and slow down simulation (Page 77)
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 407
8.13 Deviating I/O values in the STEP 7 user program
Updated values
Each value change made by a STEP 7 user program in the I/O address areas is overwritten in
the cycle control point with the updated value that was written via the API functions
Write...(). The API functions Read...() only return this updated value and not the
value from STEP 7 for the input range.
Non-updated values
If the value was not updated via the API functions Write...(), the API functions
Read...() return the value from STEP 7 for the output range.
See also
Simulate peripheral I/O (Page 59)
Remedy
Repeat your requests or enter "arp -d <IP address>" in the command line editor of Windows.
S7-PLCSIM Advanced
408 Function Manual, 05/2021, A5E37039512-AD
8.17 ET 200SP CPUs: Use of BusAdapters with fiber-optic interface
Remedy
Use the communication interface "PLCSIM" (Softbus) in PLCSIM Advanced.
Remedy
Update the operating system on your PC:
• Windows 10, Version ≥ 1903 or
• Windows Server version > 2019
S7-PLCSIM Advanced
Function Manual, 05/2021, A5E37039512-AD 409
List of abbreviations A
Abbreviation Term
ALM Automation License Manager
Tool for managing license keys in STEP 7
API Application Programming Interface user interface
arp Address resolution protocol
BCD Binary Coded Decimal
CPU Central Processing Unit (Synonym for PLC)
DLL Dynamic Link Library
HMI Human Machine Interface user interface
I-device Intelligent IO device
IE Industrial Ethernet
GUI Graphical User Interface
LAN Local Area Network
Computer network that is limited to a local area.
MFP Multifunctional platform
OB Organization Block
ODK Open Development Kit
OPC UA Open Platform Communications Unified Architecture
PA Process image output (PIQ)
PE Process image input (PII)
PG Programming device
PLC Programmable Logic Controller
PN PROFINET
RAM Random Access Memory
RT Runtime
SO Shared Object
TCP/IP Transmission Control Protocol/Internet Protocol
TIA Totally Integrated Automation
PIP Process Image Partition
UTC Coordinated Universal Time
VM Virtual Machine
VPLC Virtual Programmable Logic Controller
WinCC Windows Control Center
S7-PLCSIM Advanced
410 Function Manual, 05/2021, A5E37039512-AD