S7-Plcsim Advanced Function Manual en-US en-US
S7-Plcsim Advanced Function Manual en-US en-US
Preface
1
___________________
Guide
SIMATIC
___________________
Product overview 2
___________________
Installing 3
S7-1500
S7-PLCSIM Advanced
___________________
Communication paths 4
___________________
Simulate CPU 5
Function Manual
___________________
Virtual time response 6
___________________
User interfaces (API) 7
___________________
Restrictions 8
___________________
List of abbreviations A
09/2016
A5E37039512-AA
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-1FA00-0YA5 - S7-PLCSIM Advanced V1.0 DVD
● 6ES7823-1FE00-0YA5 - S7-PLCSIM Advanced V1.0 Download
The articles each contain one license for one instance.
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 use abbreviate SIMATIC S7-PLCSIM Advanced V1.0 as "PLCSIM Advanced".
Please also observe notes marked as follows:
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.
S7-PLCSIM Advanced
4 Function Manual, 09/2016, A5E37039512-AA
Preface
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 only form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems, machines
and networks. Systems, machines and components should only be connected to the
enterprise network or the internet if and to the extent necessary and with appropriate security
measures (e.g. use of firewalls and network segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be taken into
account. For more information about industrial security, please visit
(http://www.siemens.com/industrialsecurity).
Siemens’ products and solutions undergo continuous development to make them more
secure. Siemens strongly recommends to apply product updates as soon as available and to
always use the latest product versions. Use of product versions that are no longer supported,
and failure to apply latest updates may increase customer’s exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS
Feed under (http://www.siemens.com/industrialsecurity).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 5
Table of contents
Preface ................................................................................................................................................... 4
1 Guide .................................................................................................................................................... 22
1.1 Documentation Guide S7 PLCSIM Advanced ....................................................................... 22
1.2 S7 PLCSIM products ............................................................................................................. 24
2 Product overview .................................................................................................................................. 25
2.1 What is PLCSIM Advanced?.................................................................................................. 25
2.2 Security for PLCSIM Advanced ............................................................................................. 26
2.3 Simulations support ........................................................................................................... 27
2.4 Supported CPUs .................................................................................................................... 28
2.5 Differences between a simulated and a real CPU ................................................................. 29
2.5.1 Restrictions for all supported CPUs ....................................................................................... 29
2.6 Simulating Motion Control ...................................................................................................... 31
3 Installing ............................................................................................................................................... 32
3.1 Introduction ............................................................................................................................ 32
3.1.1 System requirements ............................................................................................................. 32
3.1.2 Licenses ................................................................................................................................. 33
3.1.3 Installation log ........................................................................................................................ 34
3.2 Installation medium ................................................................................................................ 35
3.3 Installing PLCSIM Advanced ................................................................................................. 35
3.4 Changing PLCSIM Advanced ................................................................................................ 37
3.5 Repairing PLCSIM Advanced ................................................................................................ 38
3.6 Uninstalling PLCSIM Advanced ............................................................................................. 39
4 Communication paths ........................................................................................................................... 40
4.1 Local communication ............................................................................................................. 41
4.2 Communication via TCP / IP .................................................................................................. 42
4.3 Enable distributed communication ......................................................................................... 43
5 Simulate CPU ....................................................................................................................................... 45
5.1 Basic procedure for the simulation......................................................................................... 45
5.2 User interface ......................................................................................................................... 46
5.2.1 S7 PLCSIM Advanced Symbol .............................................................................................. 46
5.2.2 S7 PLCSIM Advanced Control Panel .................................................................................... 46
5.3 Download ............................................................................................................................... 50
5.4 MAC address of the instances ............................................................................................... 52
5.5 Simulate peripheral I/O .......................................................................................................... 53
5.6 Simulate communication ........................................................................................................ 54
5.6.1 Communication services that can be simulated .................................................................... 54
5.6.2 Communication between instances ....................................................................................... 55
5.7 Provide project data offline for simulation .............................................................................. 56
S7-PLCSIM Advanced
6 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 7
Table of contents
S7-PLCSIM Advanced
8 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 9
Table of contents
Tables
S7-PLCSIM Advanced
10 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 11
Table of contents
S7-PLCSIM Advanced
12 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 13
Table of contents
S7-PLCSIM Advanced
14 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 15
Table of contents
S7-PLCSIM Advanced
16 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 17
Table of contents
S7-PLCSIM Advanced
18 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 19
Table of contents
Figures
S7-PLCSIM Advanced
20 Function Manual, 09/2016, A5E37039512-AA
Table of contents
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 21
Guide 1
1.1 Documentation Guide S7 PLCSIM Advanced
The documentation for the SIMATIC S7-1500 automation system and the SIMATIC
ET 200SP distributed I/O system is arranged into three areas.
Basic information
System manuals and Getting Started describe in detail the configuration, installation, wiring
and commissioning of the SIMATIC S7-1500 and ET 200SP systems. The STEP 7 online
help supports you in configuration and programming.
Device information
Product manuals contain a compact description of the module-specific information, such as
properties, terminal diagrams, characteristics and technical specifications.
General information
The function manuals contain detailed descriptions on general topics such as diagnostics,
communication, Motion Control, Web server, OPC UA.
You can download the documentation free of charge from the Internet
(http://w3.siemens.com/mcms/industrial-automation-systems-simatic/en/manual-
overview/Pages/Default.aspx).
Changes and additions to the manuals are documented in product information sheets.
You will find the product information on the Internet:
● S7-1500 (https://support.industry.siemens.com/cs/us/en/view/68052815)
● ET 200SP (https://support.industry.siemens.com/cs/us/en/view/73021864)
Manual Collections
The Manual Collections contain the complete documentation of the systems put together in
one file.
You will find the Manual Collections on the Internet:
● S7-1500 (https://support.industry.siemens.com/cs/ww/en/view/86140384)
● ET 200SP (https://support.industry.siemens.com/cs/ww/en/view/84133942)
S7-PLCSIM Advanced
22 Function Manual, 09/2016, A5E37039512-AA
Guide
1.1 Documentation Guide S7 PLCSIM Advanced
"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
(http://support.industry.siemens.com/My/ww/en/documentation).
"mySupport" - Documentation
In the Documentation area in "mySupport" you can combine entire manuals or only parts of
these to your own manual.
You can export the manual as PDF file or in a format that can be edited later.
You can find "mySupport" - Documentation 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/sc/ww/en/sc/2054).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 23
Guide
1.2 S7 PLCSIM products
S7 PLCSIM Advanced
The version of S7-PLCSIM Advanced supports the following SIMATIC CPU series:
● S7-1500, S7-1500F, S7-1500C, S7-1500T and S7-1500TF
● ET 200SP and ET 200SP F
Communication
S7-PLCSIM Advanced supports communication via Softbus or TCP/IP.
S7 PLCSIM Advanced enables C++ and C# programs and simulation software to access
SIMATIC CPU series supported by S7-PLCSIM Advanced via the user interface (API).
S7-PLCSIM Advanced and S7-PLCSIM V12 cannot be installed on the same PC or the
same virtual machine. The communication between the two applications cannot be
simulated.
S7-PLCSIM V5.4 SP7 is automatically installed with S7-PLCSIM Advanced. The
communication between the two applications can be simulated.
S7-PLCSIM V14
The version of S7-PLCSIM supports the following SIMATIC CPU series:
● S7-1200 and S7-1200F
● S7-1500, S7-1500F, S7-1500C, S7-1500T and S7-1500TF
● ET 200SP and ET 200SP F
Communication
S7-PLCSIM V14 supports communication via Softbus.
S7-PLCSIM V5.x
S7-PLCSIM V5.x simulates the following SIMATIC CPU series:
● S7-300 and S7-300F
● S7-400 and S7-400F
S7-PLCSIM V5.x cannot be installed on the same PC or the same virtual machine
S7-PLCSIM as of V12.
S7-PLCSIM V5.4 SP7 is automatically installed with S7-PLCSIM Advanced.
Communication
S7 PLCSIM V5.x can communicate via Softbus with instances of S7-PLCSIM as of V12.
S7-PLCSIM V5.4 SP7 can communicate via Softbus with instances of S7-PLCSIM
Advanced.
S7-PLCSIM Advanced
24 Function Manual, 09/2016, A5E37039512-AA
Product overview 2
2.1 What is PLCSIM Advanced?
Simulation systems support the development of programs and the deployment in production
that follows. In the automation world, a simulated test environment shortens commissioning
times. It is possible to test the program after program changes in the virtual controller before
it is loaded into the corresponding real controller and the plant is put into operation.
S7 PLCSIM Advanced
Using S7-PLCSIM Advanced, you can simulate your CPU programs on a virtual controller.
You do not need a real controller for this. You can configure your CPU in STEP 7 V14,
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.
Application areas
● Software in the Loop-Simulation for virtual commissioning of machine tools
● In combination with third-party software:
– Simulation of production machines and plants
– Combined simulation of automation and mechanics
Advantages
The use of S7 PLCSIM Advanced offers numerous advantages:
● Improve quality of automation projects
● Accelerate time to market
● Reduce production times
● Reduce risk for commissioning
● Avoid costs for hardware in simulation environments
● Increase efficiency in maintenance
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 25
Product overview
2.2 Security for 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 WinPCap component 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
If know-how-protected blocks for the simulation support are enabled, the know-how
protection is limited.
S7-PLCSIM Advanced
26 Function Manual, 09/2016, A5E37039512-AA
Product overview
2.3 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 project properties.
Know-how protection
If a know-how-protected block is to be used for the simulation, it must be unlocked by
entering a password, to enable the "Simulation with SIMATIC S7-PLCSIM Advanced" option
to be unlocked in the properties of the block in the tab "General > Compilation".
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, 09/2016, A5E37039512-AA 27
Product overview
2.4 Supported CPUs
Unsupported CPUs
S7-PLCSIM Advanced V1.0 does not support the simulation of the following CPUs:
● S7-1200 CPUs
● ET 200pro, ET 200pro F CPUs
● ET 200SP Open Controller CPU 1515SP PC
● Software Controller
S7-PLCSIM Advanced
28 Function Manual, 09/2016, A5E37039512-AA
Product overview
2.5 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.
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 protected blocks can only be simulated when they are enabled for
simulation. You need the block password for this purpose.
Instructions
Instructions are simulated with a few exceptions, for example, interrupts. Programs that are
based on the instructions behave different than real CPUs in the simulation.
See also
Restrictions for instructions (Page 306)
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.
Bus systems
S7-PLCSIM Advanced does not simulate bus systems (PROFINET IO, PROFIBUS DP,
backplane bus).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 29
Product overview
2.5 Differences between a simulated and a real CPU
Diagnostics
S7-PLCSIM Advanced cannot simulate the complete range of all the possible diagnostic
buffer entries, for example, no entries that affect the real hardware. Most I/O and program
errors are simulated.
Data logging
S7-PLCSIM Advanced does not simulated data logging, because this function writes all
output to the SD memory card and S7-PLCSIM Advanced does not support the use of an SD
memory card.
Recipes
S7-PLCSIM Advanced does not simulate the use of recipes.
Limited support
S7-PLCSIM Advanced simulates some functions to a limited extent. You can find an
overview in the section Restrictions (Page 302).
S7-PLCSIM Advanced
30 Function Manual, 09/2016, A5E37039512-AA
Product overview
2.6 Simulating Motion Control
Restrictions
PLCSIM Advanced supports STEP 7 projects with configurations and functions for motion
control for the CPUs S7-1500, S7-1500F, S7-1500C, S7-1500T, S7-1500T F, ET 200SP and
ET 200SP F.
PLCSIM Advanced provides only limited support for technology objects in some CPUs, see
Restrictions with Motion Control (Page 307).
Additional information
Information on "Setting in the drive and encoder connection" for actual value calculation of a
virtual axis and on the topic "Virtual axis/Simulation" is available in the S7-1500T Motion
Control (https://support.industry.siemens.com/cs/ww/en/view/109481326) function manual.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 31
Installing 3
3.1 Introduction
Note
Make sure that the Windows operating system you are using is up to date.
S7-PLCSIM Advanced
32 Function Manual, 09/2016, A5E37039512-AA
Installing
3.1 Introduction
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.0
● VMware Workstation 12 Pro
● VMware Workstation Player 12
● Microsoft Windows Server 2012 R2 Hyper-V
3.1.2 Licenses
Floating license
S7 PLCSIM Advanced is supplied with a floating type license. These can be stored locally
and shared for a network.
Note
A floating license is valid for one instance of a virtual controller within a PLCSIM Advanced
installation.
Handling licenses
You can learn how to handle the licenses for S7 PLCSIM Advanced instances on the DVD in
the description of the SIMATIC Automation License Manager (ALM).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 33
Installing
3.1 Introduction
Note
A check is made for the presence of a license at power-up and after one hour during which
you can test an instance without restriction (Trial Mode). When you import a license in the
meantime, SREC_WARNING_TRIAL_MODE_ACTIVE is returned nevertheless.
S7-PLCSIM Advanced
34 Function Manual, 09/2016, A5E37039512-AA
Installing
3.2 Installation medium
Installation requirements
Make sure that the following conditions are met before you begin the installation process:
● The hardware and software of the PC or Siemens Field PG meet the system
requirements.
● The person who performs the installation has administrator rights on the respective
computer.
● No other programs are active. This also applies to the Siemens Automation License
Manager and other Siemens applications.
● All S7-PLCSIM versions V12 and higher are uninstalled.
Note
Security settings
For licensing via the ALM, when installing PLCSIM Advanced you must agree that port 4410
for TCP can be entered as an exception in the Windows Firewall (procedure step 7).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 35
Installing
3.3 Installing PLCSIM Advanced
Remedy
Run the setup for S7-PLCSIM V12 or V12 SP1 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/document/65601780).
S7-PLCSIM Advanced
36 Function Manual, 09/2016, A5E37039512-AA
Installing
3.4 Changing PLCSIM Advanced
Note
Target directory
You cannot change the target directory because you are changing an existing installation.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 37
Installing
3.5 Repairing PLCSIM Advanced
S7-PLCSIM Advanced
38 Function Manual, 09/2016, A5E37039512-AA
Installing
3.6 Uninstalling PLCSIM Advanced
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 39
Communication paths 4
Local and distributed communication
The following paths are open for communication between STEP 7 V14 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
40 Function Manual, 09/2016, A5E37039512-AA
Communication paths
4.1 Local communication
See also
Interfaces - Information and settings (Page 113)
S7 PLCSIM Advanced Control Panel (Page 46)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 41
Communication paths
4.2 Communication via TCP / IP
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.
S7-PLCSIM Advanced
42 Function Manual, 09/2016, A5E37039512-AA
Communication paths
4.3 Enable distributed communication
Recommendation
Use to ensure the VMware settings as the network adapter type for the Bridged Mode to
ensure error-free operation.
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, 09/2016, A5E37039512-AA 43
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.
S7-PLCSIM Advanced
44 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU 5
5.1 Basic procedure for the simulation
The following overview shows the basic steps to perform simulation with an instance of a
virtual controller.
Requirements
The following requirements must be met for starting simulation via local communication:
● STEP 7 V14 and S7 PLCSIM V1.0 Advanced 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 also
Simulations support (Page 27)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 45
Simulate CPU
5.2 User interface
After double-clicking the icon, the icon appears in the taskbar of the information area.
You can use Windows functions to permanently display the icon in the information area of
the taskbar.
Control Panel
The Control Panel is optional and is not needed to use PLCSIM Advanced via the API. It is
available in English in version 1.0.
S7-PLCSIM Advanced
46 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.2 User interface
• Standard gateway
⑥ CPU type Here you select the type of CPU to be simulated.
⑦ "Start" button Create with the button and start an instance with the entered name.
⑧ Instance list The list shows the available local instances.
⑨ LED displays The meaning of the LED is displayed when you move the mouse
over it.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 47
Simulate CPU
5.2 User interface
⑩ Runtime Manager Port Here you open a port on the local PC.
⑪ Virtual SIMATIC Memory Open an Explorer window here with the path to the virtual memory
Card card.
⑫ Display messages Here you disable the PLCSIM Advanced messages in the Windows
task bar for the duration of the operation.
⑬ Function manual This is where you open the S7 PLCSIM Advanced Function Manual
in a standard PDF viewer.
⑭ Exit Exit switches all instances off and closes the Control Panel.
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
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 more information, seeVirtual time
response (Page 58).
S7-PLCSIM Advanced
48 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.2 User interface
Instance list
The instance list contains the instances that are started locally on the PC or virtualization
platform. Instances that have already been started on the runtime API are detected and
displayed in the list.
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:
Apply scaling factor for the virtual time, disable virtual time,
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 49
Simulate CPU
5.3 Download
Exit
● The command switches off all local instances on the PC or the VM and logs them off from
the Runtime Manager.
● This command closes the Runtime Manager if there is no remote connections to other
Runtime Managers.
● If the Runtime Manager has remote connections to instances on additional PCs, these
instances and the Runtime Manager continue to run.
5.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
50 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.3 Download
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-4 Example: Download via the "PLCSIM Virtual Ethernet Adapter" (TCP/IP) after naming
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 51
Simulate CPU
5.4 MAC address of the instances
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, a CPU 1518-4 PN/DP
S7-PLCSIM Advanced
52 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.5 Simulate peripheral I/O
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 310)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 53
Simulate CPU
5.6 Simulate communication
Special conditions apply when communicating with TUSEND/TURCV, see Restrictions for
communications services (Page 305).
S7-PLCSIM Advanced
54 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.6 Simulate communication
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 55
Simulate CPU
5.7 Provide project data offline for simulation
S7-PLCSIM Advanced
56 Function Manual, 09/2016, A5E37039512-AA
Simulate CPU
5.7 Provide project data offline for simulation
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 123)
● StoragePath { get; set; } (Page 124)
See also
Controller - Information and settings (Page 119)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 57
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 218)
● SetSystemTime() (Page 218)
● SystemTime { get; set; } (Page 218)
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.
S7-PLCSIM Advanced
58 Function Manual, 09/2016, A5E37039512-AA
Virtual time response
Scaling factor
Using a scaling factor, you can speed up or slow down the virtual clock of the virtual
controller for simulations.
● 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 219)
● SetScaleFactor() (Page 219)
● ScaleFactor { get; set; } (Page 220)
See also
Settings for the virtual time (Page 218)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 59
Virtual time response
6.1 Speed up and slow down simulation
Fast forward
To speed up the virtual time, select a scaling factor greater than 1 in the Control Panel or in
the API.
Note
CPU load of the PC
If the scaling factor is greater than 1, the CPU load of the PC on which the virtual controller is
simulated increases considerably.
Note
Performance
The performance is 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.
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 219)
● SetScaleFactor() (Page 219)
● ScaleFactor { get; set; } (Page 220)
S7-PLCSIM Advanced
60 Function Manual, 09/2016, A5E37039512-AA
Virtual time response
6.2 Stop simulation
See also
Cycle control (Page 221)
Settings for the virtual time (Page 218)
Error with overflow cyclical events (Page 309)
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 SROS_FREEZE / Freeze, see EOperatingState (Page 288).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 61
Virtual time response
6.3 Synchronize simulation partner
API functions
● Settings for the cycle control (Page 221)
● GetOperatingMode() (Page 221)
● SetOperatingMode() (Page 221)
● OperatingMode { get; set; } (Page 221)
Introduction
The virtual controller must be set to the freeze state for synchronization.
The SingleStep and ExtendedSingleStep modes of the virtual controller provides one way to
synchronize several simulation partners (clients).
API functions
● RunNextCycle() (Page 225)
S7-PLCSIM Advanced
62 Function Manual, 09/2016, A5E37039512-AA
Virtual time response
6.3 Synchronize simulation partner
API functions
● GetOverwrittenMinimalCycleTime_ns() (Page 223)
● SetOverwrittenMinimalCycleTime_ns() (Page 223)
● OverwrittenMinimalCycleTime_ns { get; set; } (Page 224)
● RunNextCycle() (Page 225)
See also
Cycle control (Page 221)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 63
Virtual time response
6.3 Synchronize simulation partner
Introduction
The TimespanSynchronized mode of the virtual controller provides one way to synchronize
several simulation partners (clients).
API functions
● Settings for cycle control (Page 221)
● StartProcessing() (Page 226)
● RunNextCycle() (Page 225)
S7-PLCSIM Advanced
64 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API) 7
7.1 Introduction
Description
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 65
User interfaces (API)
7.1 Introduction
S7-PLCSIM Advanced
66 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.1 Introduction
API functions
● Table 7-5 Overview of IRemoteRuntimeManager functions - Native C++ (Page 72)
● Table 7-9 Overview of IRemoteRuntimeManager functions - .NET (C#) (Page 75)
● Table 7-4 Overview of IInstances functions - Native C++ (Page 70)
● Table 7-8 Overview of IInstances functions - .NET (C#) (Page 74)
See also
Overview of user interfaces for managed code (Page 73)
S7 PLCSIM Advanced Control Panel (Page 46)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 67
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
68 Function Manual, 09/2016, A5E37039512-AA
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 78)
RuntimeApiEntry_Initialize (Page 79)
Shut down API (Page 81) DestroyInterface
RuntimeApiEntry DestroyInterface
Unregister DLL API (Page 84) FreeApi
ShutdownAndFreeApi
Global functions
Actions Functions
Global functions (Page 86) GetNameOfAreaSection()
GetNameOfCPUType()
GetNameOfCommunicationInterface()
GetNameOfDataType()
GetNameOfLEDMode()
GetNameOfLEDType()
GetNameOfOperatingMode()
GetNameOfOperatingState()
GetNameOfPrimitiveDataType()
GetNameOfTagListDetails()
GetNameOfErrorCode()
GetNameOfRuntimeConfigChanged()
GetNameOfInstanceConfigChanged()
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 69
User interfaces (API)
7.1 Introduction
API ISimulationRuntimeManager
The following table shows which functions are available for the API
ISimulationRuntimeManager.
API IInstances
The following table shows which functions are available for the API IInstances.
S7-PLCSIM Advanced
70 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.1 Introduction
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 71
User interfaces (API)
7.1 Introduction
API IRemoteRuntimeManager
The following table shows which functions are available for the API
IRemoteRuntimeManager (remote connections):
S7-PLCSIM Advanced
72 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.1 Introduction
Actions Functions
Initialize API (Page 80) Sie-
mens.Simatic.Simulation.Runtime.SimulationRuntimeManager
Shut down API (Page 86)
API ISimulationRuntimeManager
The following table shows which functions are available for the API
ISimulationRuntimeManager.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 73
User interfaces (API)
7.1 Introduction
API IInstances
The following table shows which functions are available for the API IInstances.
S7-PLCSIM Advanced
74 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.1 Introduction
API IRemoteRuntimeManager
The following table shows which functions are available for the API
IRemoteRuntimeManager.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 75
User interfaces (API)
7.1 Introduction
Data type
DLL import functions ApiEntry_Initialize
ApiEntry_DestroyInterface
(Page 258)
Event callback functions EventCallback_VOID
EventCallback_II_SREC_ST
(Page 259)
EventCallback_II_SREC_ST_SROS_SROS
EventCallback_II_SREC_ST_SRLT_SRLM
EventCallback_II_SREC_ST_INT64_UINT32
EventCallback_IRRTM
EventCallback_SRCC_UINT32_UINT32_INT32
EventCallback II SREC ST SRICC UINT32 UINT32 UINT32 UINT32
Definitions and constants (Page 271)
Unions (Page 272) UIP
UDataValue
Structures (Page 274) SDataValue
SDataValueByAddress
SDataValueByName
SConnectionInfo
SInstanceInfo
SDimension
STagInfo
SIP
SIPSuite4
Enumerations (Page 284) ERuntimeErrorCode
EArea
EOperatingState
EOperatingMode
ECPUType
ECommunicationInterface
ELEDType
ELEDMode
EPrimitiveDataTypes
EDataType
ETagListDetails
ERuntimeConfigChanged
EInstanceConfigChanged
S7-PLCSIM Advanced
76 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.1 Introduction
Data type
Delegate definitions Delegate_Void
Delegate_II_EREC_DT
(Page 265)
Delegate_II_EREC_DT_EOS_EOS
- Event handler methods Delegate_II_EREC_DT_ELT_ELM
Delegate_II_EREC_DT_INT64_UINT32
Delegate_IRRTM
Delegate_SRCC_UINT32_UINT32_INT32
Delegate II EREC DT SRICC UINT32 UINT32 UINT32 UINT32
Definitions and constants (Page 271)
Structures (Page 274) SDataValue
SDataValueByAddress
SDataValueByName
SConnectionInfo
SInstanceInfo
SDimension
STagInfo
SIP
SIPSuite4
Enumerations (Page 284) ERuntimeErrorCode
EArea
EOperatingState
EOperatingMode
ECPUType
ECommunicationInterface
ELEDType
ELEDMode
EPrimitiveDataTypes
EDataType
ETagListDetails
ERuntimeConfigChanged
EInstanceConfigChanged
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 77
User interfaces (API)
7.2 Initialize API
7.2.1.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. The
DLL is loaded from the Startup directory of each application that calls this function or from
the directory that provides the path parameter.
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
78 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.2 Initialize API
Note
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
7.2.1.2 RuntimeApiEntry_Initialize
Description
Use the RuntimeApiEntry_Initialize 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.
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 79
User interfaces (API)
7.2 Initialize API
// Load The DLL And Import The "Initialize" Function (using the
Win32 API)
dllHandle = LoadLibrary(DAPI_DLL_NAME_X86);
if ( dllHandle != NULL )
{
Initialize = (ApiEntry_Initialize)GetProcAddress(dllHandle,
DAPI_ENTRY_INITIALIZE);
}
Note
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
7.2.2.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 Siemens.Simatic.Simulation.Runtime.SimulationInitializationException
Runtime error code Condition
ERuntimeError- Unable to establish a connection to the Runtime
Code.ConnectionError
Manager.
S7-PLCSIM Advanced
80 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.3 Shut down API
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 81
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 Interfaces
ERuntimeErrorCode result;
ISimulationRuntimeManager* api = NULL;
IInstance* instance = NULL;
S7-PLCSIM Advanced
82 Function Manual, 09/2016, A5E37039512-AA
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 82) function.
The function unloads the memory of an ISimulationRuntimeManager,
IRemoteRuntimeManager or IInstance interface.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 83
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().
Parameters None
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_API_NOT_INITIALIZED The InitializeApi function was not called
successfully.
Example C++ // Include The Headerfile Of The API
#include "SimulationRuntimeApi.h"
// The Interfaces
ERuntimeErrorCode result;
ISimulationRuntimeManager* api = NULL;
IInstance* instance = NULL;
S7-PLCSIM Advanced
84 Function Manual, 09/2016, A5E37039512-AA
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
Function Manual, 09/2016, A5E37039512-AA 85
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfAreaSection()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfCPUType()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
S7-PLCSIM Advanced
86 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfCommunicationInterface()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfDataType()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfErrorCode()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfLEDMode()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 87
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfLEDType()
Returns the name of the enumeration entry.
Enumeration entry.
Return values const WCHAR*: Name of the enumeration entry
GetNameOfOperatingMode()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfErrorCode()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfOperatingState
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
S7-PLCSIM Advanced
88 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.4 Global functions (Native C++)
GetNameOfPrimitiveDataType
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfTagListDetails
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfRuntimeConfigChanged()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
GetNameOfInstanceConfigChanged()
Returns the name of the enumeration entry.
Enumeration entry
Return values const WCHAR*: Name of the enumeration entry
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 89
User interfaces (API)
7.5 API ISimulationRuntimeManager
See also
EPrimitiveDataType (Page 294)
EDataType (Page 296)
Parameters None
Return values UINT32: Runtime Manager Version (HIWORD = Major, LOWORD = Minor)
Parameters None
Return values Uint32: Runtime Manager Version (HIWORD = Major, LOWORD = Minor)
S7-PLCSIM Advanced
90 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
Parameters None
Return values • false: If the API was not initialized.
• true: If the API was initialized.
Parameters None
Return values • false: If the API was not initialized.
• true: If the API was initialized.
Parameters None
Return values • false: If the connection is interrupted.
• true: If the connection is active.
Parameters None
Return values • false: If the connection is interrupted.
• true: If the connection is active.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 91
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.
Parameters None
Return values Runtime error code Condition
SREC_OK The function is successful.
Parameters None
Return values None
S7-PLCSIM Advanced
92 Function Manual, 09/2016, A5E37039512-AA
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.
Parameters None
Return values UINT32: Number of available instances.
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 271).
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_TIMEOUT The function does not return on time.
SREC_INDEX OUT_OF_RANGE There is no instance information for this
index.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 93
User interfaces (API)
7.5 API ISimulationRuntimeManager
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
94 Function Manual, 09/2016, A5E37039512-AA
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
setting is "SRCT_1500_Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual Memory
Card, this CPU type applies.
• WCHAR* in_InstanceName:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 95
User interfaces (API)
7.5 API ISimulationRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
Defines which CPU type is simulated at the start of the instance. The default
setting is "ECPUType.Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual Memory
Card, this CPU type applies.
• string in_InstanceName:
S7-PLCSIM Advanced
96 Function Manual, 09/2016, A5E37039512-AA
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:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 97
User interfaces (API)
7.5 API ISimulationRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
The complete path to the DLL of the virtual controller that Sie-
mens.Simatic.Simulation.Runtime.Instance.exe loads at PowerOn.
• string in_InstanceName:
S7-PLCSIM Advanced
98 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
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, 09/2016, A5E37039512-AA 99
User interfaces (API)
7.5 API ISimulationRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
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.
ERuntimeErrorCode.WrongArgument The name or the ID is invalid.
ERuntimeErrorCode.DoesNotExists The instance is not registered in Runtime
Manager.
S7-PLCSIM Advanced
100 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
OpenPort()
Opens a port to which another Runtime Manager can connect.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 101
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.
Parameters None
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
SREC_OK The function is successful.
SREC_TIMEOUT The function does not return on time.
SREC_WARNING_INVALID_CALL No port is open.
Parameters None
Return values UINT16: The open port. 0, if no port is open.
Parameters None
Return values UInt16: The open port. 0, if no port is open.
Exceptions None
S7-PLCSIM Advanced
102 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
GetRemoteConnectionsCount()
Supplies the number of open remote connections.
Parameters None
Return values UINT32: Number of open remote connections.
GetRemoteConnectionInfoAt()
Returns information about an open connection.
RemoteConnectionInfo { get; }
Returns an array of information about all open connections.
Parameters None
Return values SConnectionInfo[]: An array of information about all open connections.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeErrorCode.Timeout The function does not return on time.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 103
User interfaces (API)
7.5 API ISimulationRuntimeManager
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.
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_TIMEOUT The function does not return on time.
SREC_CONNECTION_ERROR The connection to the remote Runtime
Manager cannot be established.
SREC_WRONG_ARGUMENT IP, port or IInstance pointer is invalid.
Example C++ ISimulationRuntimeManager* api = ZERO;
ERuntimeErrorCode result = Initialize(&api);
if (result == SREC_OK)
{
result = api->RemoteConnect(192,203,145,144, 4444, &client);
}
S7-PLCSIM Advanced
104 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 105
User interfaces (API)
7.5 API ISimulationRuntimeManager
See also
Data types (Page 257)
Tag list (Page 135)
7.5.4 Events
Event Cause
OnConfigurationChanged This event is triggered at a change of the Runtime Manager configura-
(Page 106) tion. For example, when a new instance is registered, an instance is
removed or a connection to a client is established.
The Control Panel uses such an event to update the list of available
instances.
OnRuntimeManagerLost The event is triggered when the connection to Runtime Manager is
(Page 110) interrupted.
7.5.4.1 OnConfigurationChanged
OnConfigurationChanged
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
106 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
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.
Parameters None
Return values None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 107
User interfaces (API)
7.5 API ISimulationRuntimeManager
UnregisterOnConfigurationChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
UnregisterOnConfigurationChangedEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
S7-PLCSIM Advanced
108 Function Manual, 09/2016, A5E37039512-AA
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 109
User interfaces (API)
7.5 API ISimulationRuntimeManager
7.5.4.2 OnRuntimeManagerLost
OnRuntimeManagerLost
Registers or unregisters an event handler method.
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.
S7-PLCSIM Advanced
110 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.5 API ISimulationRuntimeManager
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.
Parameters None
Return values None
UnregisterOnRuntimeManagerLostCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 111
User interfaces (API)
7.5 API ISimulationRuntimeManager
UnregisterOnRuntimeManagerLostEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
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
112 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Dispose()
Deletes the managed interface and unloads the native components of the user interfaces.
Parameters None
Return values None
GetID() / ID { get; }
Returns the instance ID. The ID is assigned by Runtime Manager when the instance is
registered.
Parameters None
Return values INT32: Instance ID
Parameters None
Return values Uint32: Instance ID
Exceptions None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 113
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 271).
• UINT32 in_ArrayLength:
WCHAR name[DINSTANCE_NAME_MAX_LENGTH];
if (result == SREC_OK)
{
result = psa->GetName(name, DINSTANCE_NAME_MAX_LENGTH);
}
Parameters None
Return values Name of the instance.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The instance is not registered in Runtime
Code.InterfaceRemoved
Manager.
S7-PLCSIM Advanced
114 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
GetCPUType()
Returns the CPU type of the virtual controller.
Parameters None
Return values An enumeration element that defines the CPU type.
See ECPUType (Page 289).
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
Parameters None
Return values An enumeration element that defines the CPU type.
Exceptions None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 115
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.
Parameters None
Return values • SRCI_NONE
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.
Parameters • SRCI_NONE
Cannot be selected.
• SRCI_SOFTBUS
S7-PLCSIM Advanced
116 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Parameters None
Return values • ECommunicationInterface.None
Parameters None
Return values SInstanceInfo: A structure that provides information about the instance. See
SInstanceInfo (Page 278).
Parameters None
Return values SInstanceInfo: A structure that provides information about the instance.
Exceptions None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 117
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.
Parameters None
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.
Parameters None
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
118 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Parameters None
Return values string:
The downloaded name of the virtual controller.
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
Function Manual, 09/2016, A5E37039512-AA 119
User interfaces (API)
7.6 API IInstances
Parameters None
Return values string:
The downloaded short designation of the virtual controller.
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.
GetControllerIPCount()
Returns the number of configured IP addresses of the virtual controller. If the function fails,
the return value is 0.
Parameters None
Return values INT32: Number of configured IP addresses of the virtual controller.
S7-PLCSIM Advanced
120 Function Manual, 09/2016, A5E37039512-AA
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 set-
ting is 0.
Return values UIP: IP address of the virtual controller. If the function fails, the return value is 0.
Parameters None
Return values string: All downloaded IP addresses of the virtual controller. If the function
fails, the field is empty.
Exceptions None
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.
Parameters None
Return values SIPSuite4[]: All downloaded IP suites of the virtual controller. If the function fails,
the field is empty.
Exceptions None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 121
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 con-
tains the IP address, the subnet mask and the standard gateway.
S7-PLCSIM Advanced
122 Function Manual, 09/2016, A5E37039512-AA
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 257).
• UINT32 in_ArrayLength:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 123
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 257).
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.
Parameters None
Return values string: The configured storage path.
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 length of the path exceeds the limit.
Code.IndexOutOfRange
ERuntimeErrorCode.WrongArgument The path contains invalid characters.
S7-PLCSIM Advanced
124 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
ArchiveStorage()
The user program, the hardware configuration and the retentive data are 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 on
which the instance runs.
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 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
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 125
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 on
which the instance runs.
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_FAI The old storage cannot be deleted.
LED
SREC_RETRIEVE_STORAGE_FAILURE The ZIP file cannot be unzipped.
S7-PLCSIM Advanced
126 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Parameters None
Return values • SROS_INVALID_OPERATING_STATE:
If the function fails.
• SROS_OFF:
If the Simulation Runtime instance is not running.
• SROS_BOOTING:
If PowerOn() was called while in this state and the virtual controller is not yet
ready to start the user program.
• SROS_STOP:
If the virtual controller is in STOP state.
• SROS_STARTUP:
If the user program is currently changing from STOP to RUN.
• SROS_RUN:
If the user program is running.
• SROS_FREEZE:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 127
User interfaces (API)
7.6 API IInstances
Parameters None
Return values • EOperatingState.InvalidOperatingState:
If the function fails.
• EOperatingState.Off:
If the Simulation Runtime instance is not running.
• EOperatingState.Booting:
If PowerOn() was called while in this state and the virtual controller is not yet
ready to start the user program.
• EOperatingState.Stop:
If the virtual controller is in STOP state.
• EOperatingState.Startup:
If the user program is currently changing from STOP to RUN.
• EOperatingState.Run:
If the user program is running.
• EOperatingState.Freeze:
If the user program is being stopped (Freeze status).
• EOperatingState.ShuttingDown:
If PowerOff() was called but the virtual controller is still in the Shutdown
phase.
S7-PLCSIM Advanced
128 Function Manual, 09/2016, A5E37039512-AA
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
Function Manual, 09/2016, A5E37039512-AA 129
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
130 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
PowerOff()
Shuts down the Simulation Runtime and closes its process.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 131
User interfaces (API)
7.6 API IInstances
MemoryReset()
Shuts down the virtual controller, closes its processes and performs a restart.
S7-PLCSIM Advanced
132 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Run()
Calls on the virtual controller to change to RUN operating state.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 133
User interfaces (API)
7.6 API IInstances
Stop()
Calls on the virtual controller to change to STOP operating state.
S7-PLCSIM Advanced
134 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
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]", where {a} and {b} correspond to the first index of the
respective dimension
..
Entry_N: "ArrayName[x,y]", where {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".
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 135
User interfaces (API)
7.6 API IInstances
Example: IOM reads only the tags from the area Inputs / Outputs and Bit
memory. The default setting is IOMCTDB.
• bool in_IsHMIVisibleOnly:
If true, only tags marked with "HMI Visible" are read. The default setting is
true.
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_ENOUGH_MEMORY More than 500000 entries are requested.
S7-PLCSIM Advanced
136 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Example: IOM reads only the tags from the area Inputs / Outputs and Bit
memory.
The default setting is IOMCTDB.
• bool in_IsHMIVisibleOnly:
If true, only tags marked with "HMI Visible" are read. The default setting is
true.
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- More than 500000 entries are requested.
Code.NotEnoughMemory
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 137
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 required.
• 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.
Status of the tag list details. ETagListDetails.None when an update of the list
is required.
• out bool out_IsHMIVisibleOnly:
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.
Parameters None
Return values Number of entries in the tag list storage.
S7-PLCSIM Advanced
138 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Parameters None
Return values An array that contains all available entries of the storage.
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 139
User interfaces (API)
7.6 API IInstances
CreateConfigurationFile()
Writes all entries from the tag list to an XML file.
S7-PLCSIM Advanced
140 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
Table 7- 134 InputArea { get; } MarkerArea { get; } OutputArea { get; } - .NET (C#)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 141
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.
Recommendation: 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.
• UINT8 in_Bit:
The bit offset within the byte. The value must be between 0 and 7.
• bool* out_Value:
S7-PLCSIM Advanced
142 Function Manual, 09/2016, A5E37039512-AA
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
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 143
User interfaces (API)
7.6 API IInstances
ReadByte()
Reads an individual bit from the area.
Note
The function allows access to the entire storage area of the virtual controller.
Recommendation: 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.
• BYTE* out_Value:
S7-PLCSIM Advanced
144 Function Manual, 09/2016, A5E37039512-AA
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.
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
Function Manual, 09/2016, A5E37039512-AA 145
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.
Recommendation: 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
146 Function Manual, 09/2016, A5E37039512-AA
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:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 147
User interfaces (API)
7.6 API IInstances
ReadSignals()
Reads a signal list altogether (structures and arrays). The function also takes into
consideration the byte order (Endianness).
Only primitive data type signals are supported, but the function is not typical.
Note
The function allows access to the entire storage area of the virtual controller.
Recommendation: Therefore, use access via the tag name and not via the address areas.
S7-PLCSIM Advanced
148 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 149
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.
Recommendation: 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.
• 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
150 Function Manual, 09/2016, A5E37039512-AA
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
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 151
User interfaces (API)
7.6 API IInstances
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.
Recommendation: 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.
• 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.
S7-PLCSIM Advanced
152 Function Manual, 09/2016, A5E37039512-AA
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_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, 09/2016, A5E37039512-AA 153
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.
Recommendation: 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_BytesToWrite:
S7-PLCSIM Advanced
154 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
);
UInt32 MarkerArea.WriteBytes(
UInt32 in_Offset,
Byte[] in_Values
);
UInt32 MarkerArea.WriteBytes(
UInt32 in_Offset,
UInt32 in_BytesToWrite,
Byte[] in_Values
);
UInt32 OutputArea.WriteBytes(
UInt32 in_Offset,
Byte[] in_Values
);
UInt32 OutputArea.WriteBytes(
UInt32 in_Offset,
UInt32 in_BytesToWrite,
Byte[] in_Values
);
Parameters • UINT32 in_Offset:
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, 09/2016, A5E37039512-AA 155
User interfaces (API)
7.6 API IInstances
WriteSignals()
Writes a signal list altogether (structures and arrays). The function also takes into
consideration the byte order (Endianness).
The function supports only primitive data type signals. The function is not typical, however.
Note
Data can be overwritten
The function allows access to the entire storage area of the virtual controller.
Recommendation: Therefore, use access via the tag name and not via the address areas.
S7-PLCSIM Advanced
156 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 157
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 arrays can be read altogeth-
er with ReadSignals().
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 294).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
S7-PLCSIM Advanced
158 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 159
User interfaces (API)
7.6 API IInstances
ReadBool()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
160 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 161
User interfaces (API)
7.6 API IInstances
ReadInt8()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
162 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 163
User interfaces (API)
7.6 API IInstances
ReadInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
164 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 165
User interfaces (API)
7.6 API IInstances
ReadInt32()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
166 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 167
User interfaces (API)
7.6 API IInstances
ReadInt64()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
168 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 169
User interfaces (API)
7.6 API IInstances
ReadUInt8()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
170 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 171
User interfaces (API)
7.6 API IInstances
ReadUInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
172 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 173
User interfaces (API)
7.6 API IInstances
ReadUInt32()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
174 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 175
User interfaces (API)
7.6 API IInstances
ReadUInt64()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
176 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 177
User interfaces (API)
7.6 API IInstances
ReadFloat()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
178 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 179
User interfaces (API)
7.6 API IInstances
ReadDouble()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
180 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 181
User interfaces (API)
7.6 API IInstances
ReadChar()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
182 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 183
User interfaces (API)
7.6 API IInstances
ReadWChar()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
184 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 185
User interfaces (API)
7.6 API IInstances
ReadSignals()
Reads multiple signals within an API call.
Reads multiple signals within a single API call.
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.
• UINT32 in_SignalCount:
S7-PLCSIM Advanced
186 Function Manual, 09/2016, A5E37039512-AA
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.
Return values SDataValue: Contains the value and the type of the PLC tag.
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.DoesNotExist The entry does not exist in the stored tag
list.
ERuntimeErrorCode.NotSupported Access to entire structures or arrays is
not supported.
ERuntimeErrorCode.TypeMismatch The expected type does not match the
stored type. See Compatible primitive
data types (Page 294).
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 187
User interfaces (API)
7.6 API IInstances
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 arrays
can be written altogether with WriteSignals().
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 294).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
SREC_WRONG_ARGUMENT The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
188 Function Manual, 09/2016, A5E37039512-AA
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 arrays
can be written altogether with WriteSignals().
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.
ERuntimeErrorCode.DoesNotExist The entry does not exist in the stored tag
list.
ERuntimeErrorCode.NotSupported Access to entire structures or arrays is
not supported.
ERuntimeErrorCode.TypeMismatch The expected type does not match the
stored type. See Compatible primitive
data types (Page 294).
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
ERuntimeErrorCode.WrongArgument The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 189
User interfaces (API)
7.6 API IInstances
WriteBool()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
190 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 191
User interfaces (API)
7.6 API IInstances
WriteInt8()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
192 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 193
User interfaces (API)
7.6 API IInstances
WriteInt16()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
194 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 195
User interfaces (API)
7.6 API IInstances
WriteInt32()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
196 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 197
User interfaces (API)
7.6 API IInstances
WriteInt64()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
198 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 199
User interfaces (API)
7.6 API IInstances
WriteInt8()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
200 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 201
User interfaces (API)
7.6 API IInstances
WriteUInt16()
Reads the value of a PLC tag.
S7-PLCSIM Advanced
202 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 203
User interfaces (API)
7.6 API IInstances
WriteUInt32()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
204 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 205
User interfaces (API)
7.6 API IInstances
WriteUInt64()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
206 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 207
User interfaces (API)
7.6 API IInstances
WriteFloat()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
208 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 209
User interfaces (API)
7.6 API IInstances
WriteDouble()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
210 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 211
User interfaces (API)
7.6 API IInstances
WriteChar()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
212 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 213
User interfaces (API)
7.6 API IInstances
WriteWChar()
Writes the value of a PLC tag.
S7-PLCSIM Advanced
214 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 215
User interfaces (API)
7.6 API IInstances
WriteSignals()
Writes multiple signals within an API call.
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.
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 294).
SREC_NOT_UP_TO_DATE The stored tag list must be updated.
SREC_WRONG_ARGUMENT The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
216 Function Manual, 09/2016, A5E37039512-AA
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
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.DoesNotExist The entry does not exist in the stored tag
list.
ERuntimeErrorCode.NotSupported Access to entire structures or arrays is
not supported.
ERuntimeErrorCode.TypeMismatch The expected type does not match the
stored type. See Compatible primitive
data types.
ERuntimeErrorCode.NotUpToData The stored tag list must be updated.
ERuntimeErrorCode.WrongArgument The expected type is UNSPECIFIC.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 217
User interfaces (API)
7.6 API IInstances
GetSystemTime()
Returns the virtual system time of the virtual controller. Returns an empty structure when the
function fails.
Parameters None
Return values SYSTEMTIME: System time of the virtual controller.
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.
Parameters None
Return values 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.
ERuntimeErrorCode.WrongArgument The value is outside the limits.
S7-PLCSIM Advanced
218 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
GetScaleFactor()
Returns the scaling factor with which the virtual time advances.
Parameters None
Return values double: Scaling factor of the virtual time.
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, 09/2016, A5E37039512-AA 219
User interfaces (API)
7.6 API IInstances
Parameters None
Return values double: Scaling factor of the virtual time.
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.
ERuntimeErrorCode.WrongArgument The value is outside the limits.
S7-PLCSIM Advanced
220 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
GetOperatingMode()
Returns the operating mode of the virtual controller.
Parameters None
Return values EOperatingMode: Operating mode of the virtual controller
SetOperatingMode()
Sets the operating mode of the virtual controller.
A change in the value during runtime only takes effect at the cycle control point.
Parameters None
Return values EOperatingMode: Operating mode of the virtual controller
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
Function Manual, 09/2016, A5E37039512-AA 221
User interfaces (API)
7.6 API IInstances
SetAlwaysSendOnEndOfCycleEnabled()
Sets the AlwaysSendOnEndOfCycle mode. If the mode is set, the OnEndOfCycle event is
triggered after every cycle end for each operating mode. If the event is also to be received in
Default operating mode, set the return value to true. See OnEndOfCycle (Page 232).
IsAlwaysSendOnEndOfCycleEnabled()
Returns the AlwaysSendOnEndOfCycle mode. When the function fails, the return value is false.
Parameters None
Return values • false: The event is not triggered (unless the Sync-Freeze mode is active).
• true: The event is triggered after every cycle.
Parameters None
Return values • false: The event is not triggered (unless the Sync-Freeze mode is active).
• true: The event is triggered after every cycle.
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
222 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
GetOverwrittenMinimalCycleTime_ns()
Returns the overwritten minimum cycle time (in nanoseconds) that is used in the
ExtendedSingleStep operating mode.
Parameters None
Return values INT64: The overwritten minimum cycle time in nanoseconds.
SetOverwrittenMinimalCycleTime_ns()
Sets the overwritten minimum cycle time (in nanoseconds) that is used in the
ExtendedSingleStep operating mode.
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, 09/2016, A5E37039512-AA 223
User interfaces (API)
7.6 API IInstances
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.
Parameters None
Return values Int64: The overwritten minimum cycle time in nanoseconds.
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.
ERuntimeErrorCode.WrongArgument The value is outside the limits.
S7-PLCSIM Advanced
224 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
RunNextCycle()
If the virtual controller is being operated in SingleStep or ExtendedSingleStep operating
mode, it is stopped at the cycle control point (Freeze state). The RunNextCycle() function is
used to trigger the next cycle.
Parameters None
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.
Parameters None
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 225
User interfaces (API)
7.6 API IInstances
StartProcessing()
If the virtual controller is running in TimespanSynchronized operating mode, it is stopped at the
cycle control point (Freeze state). The StartProcessing() function wakes up the virtual
controller from the Freeze state. The virtual controller will now run for at least the requested
time before it changes to Freeze state (stops) at the next cycle control 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.
ERuntimeErrorCode.WrongArgument The value is less than 0.
Additional information
For more information, please refer to the section titled Time response (Page 58), Stopping
the simulation (Page 61)
S7-PLCSIM Advanced
226 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
See also
OnOperatingStateChanged (Page 228)
7.6.8 Events
Event Cause
OnOperatingStateChanged This event is always triggered when the operating state of the virtual
(Page 228) controller has changed.
OnEndOfCycle (Page 232) This event is triggered when the virtual controller reaches the end of
the main cycle.
If the virtual controller is being operated in Default operating mode,
the AlwaysSendOnEndOfCycle flag must be set to receive the event.
See AlwaysSendOnEndOfCycle (Page 221).
OnConfigurationChanging This event is triggered when changing of the configuration of the vir-
(Page 234) tual controller starts.
• 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 This event is triggered when the configuration of the virtual controller
(Page 237) has changed:
• After power up from the Virtual SIMATIC Memory Card
• At the end of a download
• When the IP address changes
OnLedChanged (Page 239) This event is triggered when the LED display of the virtual controller
has changed.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 227
User interfaces (API)
7.6 API IInstances
7.6.8.1 OnOperatingStateChanged
OnOperatingStateChanged
Registers or unregisters an event handler method.
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.
S7-PLCSIM Advanced
228 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
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.
// Thread 2 --------------------------------------------------
while (condition)
{
// Wait for the event to be set (timeout after 10s)
bool isEventSet = psa-
>WaitForOnOperatingStateChangedEvent(10000);
if (isEventSet)
{
// Do Something
…
}
}
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 229
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
…
}
UnregisterOnOperatingStateChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
S7-PLCSIM Advanced
230 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
UnregisterOnOperatingStateChangedEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
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
Function Manual, 09/2016, A5E37039512-AA 231
User interfaces (API)
7.6 API IInstances
7.6.8.2 OnEndOfCycle
OnEndOfCycle
Registers or unregisters an event handler method.
RegisterOnEndOfCycleCallback()
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.
RegisterOnEndOfCycleEvent()
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
232 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
UnregisterOnEndOfCycleCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
UnregisterOnEndOfCycleEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 233
User interfaces (API)
7.6 API IInstances
WaitForOnEndOfCycleEvent()
The function blocks the program until the registered event object is in the signaled state or
the timeout interval is exceeded.
7.6.8.3 OnConfigurationChanging
OnConfigurationChanging
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
234 Function Manual, 09/2016, A5E37039512-AA
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.
Parameters None
Return values None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 235
User interfaces (API)
7.6 API IInstances
UnregisterOnConfigurationChangingEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
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
236 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
7.6.8.4 OnConfigurationChanged
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.
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 237
User interfaces (API)
7.6 API IInstances
UnregisterOnConfigurationChangedCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
UnregisterOnConfigurationChangedEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
S7-PLCSIM Advanced
238 Function Manual, 09/2016, A5E37039512-AA
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.
7.6.8.5 OnLedChanged
OnLedChanged
Registers or unregisters an event handler method.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 239
User interfaces (API)
7.6 API IInstances
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.
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.
Parameters None
Return values None
S7-PLCSIM Advanced
240 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.6 API IInstances
UnregisterOnLedChangedEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
WaitForOnLedChangedEvent()
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, 09/2016, A5E37039512-AA 241
User interfaces (API)
7.7 API IRemoteRuntimeManager
Dispose()
Deletes the managed interface and unloads the native components of the user interfaces.
Parameters None
Return values None
GetVersion()
Returns the version of the remote Runtime Manager. If the function fails, version 0.0 is
returned.
Parameters None
Return values UINT32: Remote Runtime Manager Version (HIWORD = Major, LOWORD = Minor)
Parameters None
Return values Uint32: Remote Runtime Manager Version (HIWORD = Major, LOWORD = Minor)
S7-PLCSIM Advanced
242 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.7 API IRemoteRuntimeManager
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.
Parameters None
Return values UIP: Returns the IP address of the PC on which the Runtime Manager is run-
ning.
Parameters None
Return values SIP: Returns the IP address of the PC on which the Runtime Manager is run-
ning.
Parameters None
Return values UINT16: Open port of the PC on which the remote Runtime Manager is running.
Parameters None
Return values UInt16: Open port of the PC on which the remote Runtime Manager is running.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 243
User interfaces (API)
7.7 API IRemoteRuntimeManager
Parameters None
Return values string: Name of the PC on which the remote Runtime Manager is running.
Exceptions Siemens.Simatic.Simulation.Runtime.SimulationRuntimeException
Runtime error code Condition
ERuntimeError- The interface is disconnected from the
Code.InterfaceRemoved
remote Runtime Manager.
ERuntimeError- The array is too small to accommodate
Code.IndexOutOfRange
the computer name.
S7-PLCSIM Advanced
244 Function Manual, 09/2016, A5E37039512-AA
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.
Parameters None
Return values Runtime error code Condition
SREC_OK The function is successful.
SREC_INTERFACE_REMOVED The interface is disconnected from the
remote Runtime Manager.
SREC_TIMEOUT The function does not return on time.
Parameters None
Return values None
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.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 245
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.
Parameters None
Return values UINT32: Number of available instances.
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
246 Function Manual, 09/2016, A5E37039512-AA
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().
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 247
User interfaces (API)
7.7 API IRemoteRuntimeManager
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
setting is "SRCT_1500_Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual Memory
Card, this CPU type applies.
• WCHAR* in_InstanceName:
S7-PLCSIM Advanced
248 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
Defines which CPU type is simulated at the start of the instance. The default
setting is "ECPUType.Unspecified".
When a different CPU type is loaded via STEP 7 or from the Virtual Memory
Card, this CPU type applies.
• string in_InstanceName:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 249
User interfaces (API)
7.7 API IRemoteRuntimeManager
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.
ERuntimeErrorCode.WrongArgument The name is invalid.
ERuntimeErrorCode.LimitReached There are already 16 instances regis-
tered in Runtime Manager.
ERuntimeErrorCode.AlreadyExists An instance with this name already ex-
ists.
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:
S7-PLCSIM Advanced
250 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82).
The complete path to the DLL of the virtual controller that Sie-
mens.Simatic.Simulation.Runtime.Instance.exe loads at PowerOn.
• string in_InstanceName:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 251
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
252 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.7 API IRemoteRuntimeManager
Note
Native C++
If you no longer require the interface, delete it.
See DestroyInterface() (Page 82)
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.
ERuntimeErrorCode.WrongArgument The name or the ID is invalid.
ERuntimeErrorCode.DoesNotExists The instance is not registered in Runtime
Manager.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 253
User interfaces (API)
7.7 API IRemoteRuntimeManager
7.7.3 Events
7.7.3.1 OnConnectionLost
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
254 Function Manual, 09/2016, A5E37039512-AA
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.
Parameters None
Return values None
UnregisterOnConnectionLostCallback()
Unregisters the callback function. When the event occurs, no callback function is called.
Parameters None
Return values None
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 255
User interfaces (API)
7.7 API IRemoteRuntimeManager
UnregisterOnConnectionLostEvent()
Unregisters the event object.
Parameters None
Return values None
Parameters None
Return values None
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
256 Function Manual, 09/2016, A5E37039512-AA
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
STEP 7 V14 System Manual
(https://support.industry.siemens.com/cs/document/109011420/step-7-professional-v13-
1?dti=0&lc=en-WW // XmlEditor.InternalXmlClipboard:d59d29c4-ec28-6b28-3f63-
754735fb2e2a).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 257
User interfaces (API)
7.8 Data types
7.8.1.1 ApiEntry_Initialize
Description
Type of the central entry point for the API DLL.
7.8.1.2 ApiEntry_DestroyInterface
Description
Type of the entry point for DestroyInterface (Page 82).
S7-PLCSIM Advanced
258 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.2.1 EventCallback_VOID
Description
Parameters None
Return values None
7.8.2.2 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
Function Manual, 09/2016, A5E37039512-AA 259
User interfaces (API)
7.8 Data types
7.8.2.3 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
260 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.2.4 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
Function Manual, 09/2016, A5E37039512-AA 261
User interfaces (API)
7.8 Data types
7.8.2.5 EventCallback_II_SREC_ST_INT64_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• INT64 in_CycleTime_ns:
The virtual time (in nanoseconds) since the last cycle control point. If the
events are triggered faster than they are received, multiple events are com-
bined into one event. In this case, the value contains the virtual time (in na-
noseconds) since the last event was received.
• UINT32 in_CycleCount:
The number of cycles since the last cycle control point. If the events are trig-
gered 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
262 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.2.6 EventCallback_IRRTM
Description
7.8.2.7 EventCallback_SRCC_UINT32_UINT32_INT32
Description
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 263
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_Instance
Con-
figChanged
SRICC_HARDW - - - -
ARE_SOFTWAR
E CHANGED
SRICC_IP_CH The ID of the The new IP The new sub- The new
ANGED
interface net mask standard
gateway
Return values None
S7-PLCSIM Advanced
264 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.3.1 Delegate_Void
Description
Parameters None
Return values None
7.8.3.2 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, 09/2016, A5E37039512-AA 265
User interfaces (API)
7.8 Data types
7.8.3.3 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
266 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.3.4 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, 09/2016, A5E37039512-AA 267
User interfaces (API)
7.8 Data types
7.8.3.5 Delegate_II_EREC_DT_INT64_UINT32
Description
The virtual system time of the virtual controller at the time when this event
was triggered.
• Int64 in_CycleTime_ns:
The virtual time (in nanoseconds) since the last cycle control point. If the
events are triggered faster than they are received, multiple events are com-
bined into one event. In this case, the value contains the virtual time (in na-
noseconds) since the last event was received.
• UInt32 in_CycleCount:
The number of cycles since the last cycle control point. If the events are trig-
gered 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
268 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.3.6 Delegate_IRRTM
Description
7.8.3.7 Delegate_SRCC_UINT32_UINT32_INT32
Description
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 269
User interfaces (API)
7.8 Data types
7.8.3.8 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_Instance
Con-
figChanged
Hard- - - - -
wareSoft-
wareChanged
IPChanged The ID of the The new IP The new sub- The new
interface net mask standard
gateway
Return values None
S7-PLCSIM Advanced
270 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 271
User interfaces (API)
7.8 Data types
7.8.5.1 UIP
Description
Contains an IPv4 address.
7.8.5.2 UDataValue
Description
Contains the value of a PLC tag.
S7-PLCSIM Advanced
272 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 273
User interfaces (API)
7.8 Data types
7.8.6 Structures
7.8.6.1 SDataValue
Description
The structure contains the value and type of a PLC tag.
S7-PLCSIM Advanced
274 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 275
User interfaces (API)
7.8 Data types
7.8.6.2 SDataValueByAddress
Description
This structure represents a PLC tag that can be accessed via its address.
7.8.6.3 SDataValueByName
Description
This structure represents a PLC tag that can be called by name.
S7-PLCSIM Advanced
276 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.6.4 SConnectionInfo
Description
This structure contains the IP address and port of a TCP/IP connection.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 277
User interfaces (API)
7.8 Data types
7.8.6.5 SInstanceInfo
Description
This structure contains an IPv4 address.
S7-PLCSIM Advanced
278 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.6.6 SDimension
Description
This structure contains information about the dimension of a field.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 279
User interfaces (API)
7.8 Data types
7.8.6.7 STagInfo
Description
This structure contains information about a PLC tag.
The number of dimensions of the array. 0 if it is not a field for the tag.
• UINT32 index:
S7-PLCSIM Advanced
280 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
Information about each dimension of the field. Empty, if the tag is not an array.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 281
User interfaces (API)
7.8 Data types
7.8.6.8 SIP
Description
This structure contains an IPv4 address.
S7-PLCSIM Advanced
282 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.6.9 SIPSuite4
Description
This structure contains an IPv4 suite.
The IP address
• UIP SubnetMask:
The IP address
• SIP SubnetMask:
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 283
User interfaces (API)
7.8 Data types
7.8.7 Enumerations
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. Errors are returned with negative values, and alarms with positive values.
S7-PLCSIM Advanced
284 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 285
User interfaces (API)
7.8 Data types
7.8.7.2 EArea
Description
This list contains all PLC areas that contain the available PLC tags.
SRA_ENUMERATION_SIZE = 7
};
S7-PLCSIM Advanced
286 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.7.3 EOperatingState
Description
This list contains all the operating states of a virtual controller.
SROS_ENUMERATION_SIZE = 8
};
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 287
User interfaces (API)
7.8 Data types
7.8.7.4 EOperatingMode
Description
This list contains all the operating modes of a virtual controller.
S7-PLCSIM Advanced
288 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.7.5 ECPUType
Description
This list contains all CPU types that can be loaded in a virtual controller.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 289
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
290 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.7.6 ECommunicationInterface
Description
This list shows the available communication interfaces of a virtual controller.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 291
User interfaces (API)
7.8 Data types
7.8.7.7 ELEDType
Description
This list includes all types of LEDs of a virtual controller.
SRLT_ENUMERATION_SIZE = 10
};
S7-PLCSIM Advanced
292 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
7.8.7.8 ELEDMode
Description
This list contains all the LED states of a virtual controller.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 293
User interfaces (API)
7.8 Data types
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
294 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 295
User interfaces (API)
7.8 Data types
7.8.7.10 EDataType
Description
This list contains all the CPU data types (STEP 7).
S7-PLCSIM Advanced
296 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 297
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
298 Function Manual, 09/2016, A5E37039512-AA
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
Function Manual, 09/2016, A5E37039512-AA 299
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.
S7-PLCSIM Advanced
300 Function Manual, 09/2016, A5E37039512-AA
User interfaces (API)
7.8 Data types
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 301
Restrictions 8
8.1 Overview
Certain actions or events may lead to behavior in S7-PLCSIM Advanced or in STEP 7 which
deviates from that of a hardware CPU. Restrictions and possible remedies can be found in
the following sections:
● OPC UA server (Page 302)
● Web server (Page 304)
● Restrictions for communications services (Page 305)
● Restrictions for instructions (Page 306)
● Restrictions with Motion Control (Page 307)
● Restrictions to local communication via Softbus (Page 308)
● Error with overflow cyclical events (Page 309)
● Deviating I/O values in the STEP 7 user program (Page 310)
● Multiple simulations and possible collision of IP addresses (Page 310)
● Simulation in standby mode (Page 310)
● Error installing the antivirus software from Kaspersky (Page 311)
S7-PLCSIM Advanced
302 Function Manual, 09/2016, A5E37039512-AA
Restrictions
8.2 OPC UA server
Certificate
● Server certificate
PLCSIM Advanced uses its own certificate in the firmware and not that of STEP 7. The
certificate need not be changed for simulations. However, it does not have the same
security level as a downloaded server certificate and cannot be used for secure
connections!
● Server Security Endpoints
PLCSIM Advanced only supports Security Endpoint "none".
● Client certificate
PLCSIM Advanced does not evaluate certificates the imported and configured in STEP 7
. PLCSIM Advanced accepts all client certificates automatically. This setting cannot be
changed.
● User authentication
PLCSIM Advanced does not use the user name configured in STEP 7.
Only one logon is possible as "guest" or "anonymous".
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 303
Restrictions
8.3 Web server
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
304 Function Manual, 09/2016, A5E37039512-AA
Restrictions
8.4 Restrictions for communications services
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.
Remedy
Set "PLCSIM Virtual Ethernet Adapter" (TCP/IP) as the communication interface in PLCSIM
Advanced.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 305
Restrictions
8.5 Restrictions for instructions
Instruction Description
DIS_AIRT Delay interrupts with higher priority and asynchronous errors
EN_AIRT Activate interrupts with higher priority and asynchronous errors
DIS_IRT Call new interrupts and disable asynchronous error
RE_TRIGR Start time monitoring
WR_DPARM Transfer data record
GETIO Read process image
SETIO Transfer process image
GETIO_PART Read a part of the outputs of a DP standard slave / PROFINET IO device
SETIO_PART Write a part of the outputs of a DP standard slave / PROFINET IO device
DPRD_DAT Read consistent data of a standard DP slave
DPWR_DAT Write consistent data to a standard DP slave
RD_OBINF Read OB start information
DP_TOPOL DP bus topology
PORT_CFG Safety function
ATTACH Assigning a hardware interrupt to an OB
DETACH Removing the mapping between hardware interrupt and OB
S7-PLCSIM Advanced
306 Function Manual, 09/2016, A5E37039512-AA
Restrictions
8.6 Restrictions with Motion Control
Note
Maximum 5120 Motion Control resources
PLCSIM Advanced supports a maximum of 5120 motion control resources. The simulation of
motion control is therefore restricted for the following CPUs:
Note
A project that uses more than 5120 motion control resources can be downloaded to a virtual
controller. However, there is no message indicating that the quantity structure has been
exceeded.
Only when the user program accesses the technology objects do you recognize by the error
message at the block and the value 0 of the object that motion control objects cannot be
used due to an overrun of the quantity structure.
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 307
Restrictions
8.7 Restrictions to local communication via Softbus
Additional information
For more information on Motion Control, refer to the following manuals:
● Device manuals to support SIMATIC controllers (http://w3.siemens.com/mcms/industrial-
automation-systems-simatic/en/manual-overview/Pages/Default.aspx)
● Function manual S7-1500 Motion Control
(https://support.industry.siemens.com/cs/ww/en/view/109739589)
● Function manual S7-1500T Motion Control
(https://support.industry.siemens.com/cs/ww/en/view/109481326)
Remedy
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 122)
See also
Controller - Information and settings (Page 119)
S7-PLCSIM Advanced
308 Function Manual, 09/2016, A5E37039512-AA
Restrictions
8.8 Restrictions of security with VMware vSphere Hypervisor (ESXi)
Remedy
Accept the "Promiscuous mode and "Forged transmit" options for the Virtual Switch of the
ESXi.
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 60)
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 309
Restrictions
8.10 Deviating I/O values in the STEP 7 user program
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 53)
Remedy
Repeat your requests or enter "arp -d <IP address>" in the command line editor of Windows.
S7-PLCSIM Advanced
310 Function Manual, 09/2016, A5E37039512-AA
Restrictions
8.14 Error installing the antivirus software from Kaspersky
Remedy
Check your network settings as described in the sectionEnable distributed communication
(Page 43).
S7-PLCSIM Advanced
Function Manual, 09/2016, A5E37039512-AA 311
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)
ES Engineering System
HMI Human Machine Interface user interface
IE Industrial Ethernet
GUI Graphical User Interface
LAN Local Area Network
Computer network that is limited to a local area.
OB Organization Block
ODK Open Development Kit
OPC UA Open Platform Communications Unified Architecture
PG Programming device
PLC Programmable Logic Controller
PN PROFINET
RAM Random Access Memory
RT Runtime
TIA Totally Integrated Automation
UTC Coordinated Universal Time
VM Virtual Machine
VPLC Virtual Programmable Logic Controller
WinCC Windows Control Center
S7-PLCSIM Advanced
312 Function Manual, 09/2016, A5E37039512-AA