Scripting Architecture, Control Flow, and External Automation Capabilities in Siemens SIMIT

Scripting Architecture, Control Flow, and External Automation Capabilities in Siemens SIMIT

In Siemens SIMIT simulation software (V9.x, V10.x, and V11), scripting is implemented via a proprietary domain-specific sequential testing language designed for automated simulation scenarios, test vector execution, and signal stimulation. The native script engine executes commands line-by-line without native high-level procedural control structures like 'FOR' or 'WHILE' loops. However, iterative loops, complex algorithmic control flow, and automated batch test suites are achieved either by utilizing the SIMIT Remote Control / API interface (interfaced via external Python or .NET C# applications) or by developing custom reusable simulation components using the SIMIT Component Type Editor (CTE), which supports full C-style algorithmic modeling with loops and mathematical formulas.

Table of Contents

Executive Summary

Siemens SIMIT provides a real-time simulation platform for virtual commissioning, operator training systems (OTS), and hardware-in-the-loop (HIL) testing of PCS 7 and TIA Portal controllers. When automating simulation runs, engineers often seek to write scripts containing programmatic loops (such as iterating through 100 valve signals or executing cyclic stress tests). Understanding the capabilities and boundaries of SIMIT's native scripting engine versus its external automation interfaces is essential. While SIMIT's native script runner executes sequential action-reaction test commands, advanced algorithmic workflows requiring loops, conditionals, and mathematical data manipulation are properly implemented via external Python scripts leveraging the SIMIT API or custom behavioral blocks in the Component Type Editor.

Architecture and Fundamental Mechanics

The simulation architecture of Siemens SIMIT is divided into distinct execution tiers, each providing tailored mechanisms for logic manipulation and test automation:

  1. Native SIMIT Scripting Engine (Automatic Testing Module):
    * SIMIT includes a built-in scripting editor utilized primarily within the Automatic Control or Test Suite modules.
    * The syntax is a proprietary, declarative command set tailored for sequential test vectors. Core primitives include:
    • SET <signal> = <value> (Assign a direct value to a simulation tag)
    • RAMP <signal> FROM <v1> TO <v2> TIME <t> (Ramp an analog value over time)
    • WAIT <time> / WAIT UNTIL <condition> (Pause execution or synchronize with simulation states)
    • CHECK <signal> == <value> (Assert a condition and log pass/fail status)
    • PRINT <message> (Output text to the simulation log)
    • Because the native engine is designed for deterministic, linear playback of test scenarios, it does not support native FOR, WHILE, or recursive loop control structures.
  2. Component Type Editor (CTE) - Internal Behavioral Loops:
    * If a simulation model requires cyclic algorithms, iterative loops (e.g., thermodynamic calculations, iterative matrix solvers, or array lookups), engineers use the Component Type Editor.
    * CTE uses a structured, C-like behavioral modeling language. Inside the equation and behavior sections of a CTE component, full procedural constructs—including for (int i = 0; i < N; i++), while, and if-else branching—are fully supported and execute deterministically within each simulation time slice (e.g., 50 ms).
  3. External Automation via SIMIT API and Python / .NET:
    * For test automation requiring programmatic loops (e.g., cycling through thousands of I/O points, reading Excel test definitions, or orchestrating automated regression testing), SIMIT exposes an open API (Remote Control Interface).
    * The SIMIT API (accessible via .NET assemblies Simit.Api.dll or Python COM/REST wrappers) enables external programs to connect to a running SIMIT instance.
    * Using standard Python:
    python # Example: Iterating tags in Python via SIMIT API for i in range(1, 101): simit.set_signal(f'Valve_{i}_Feedback', True) time.sleep(0.1)
    * This architecture combines the high-speed real-time simulation engine of SIMIT with the unlimited algorithmic flexibility of modern programming languages.

Step-by-Step Implementation Procedure

Follow these procedures to select and implement the appropriate scripting or automation approach in SIMIT:

  1. Determine the Engineering Requirement:
    * If the requirement is a sequential test procedure (e.g., start pump, wait 5 seconds, verify pressure rises, trip interlock): Use the Native SIMIT Script Editor.
    * If the requirement is dynamic mathematical simulation with internal iterative equations: Use the Component Type Editor (CTE).
    * If the requirement is automated mass testing, parameter sweeps, or batch verification loops: Use Python via the SIMIT API.
  2. Implementing Sequential Scripts in Native SIMIT:
    * In SIMIT, navigate to the Automatic Control task in the project tree.
    * Create a new script. Enter sequential commands, for example:
    text WAIT UNTIL 'Pump101_Run' == 1 RAMP 'FIT_101_PV' FROM 0 TO 150 TIME 5s WAIT 10s CHECK 'PT_101_HighAlarm' == 1 PRINT 'Pressure test passed successfully.'
    * Run the script during simulation; verify step progression in the test runner log.
  3. Implementing Procedural Loops via Component Type Editor (CTE):
    * In SIMIT, launch the Component Type Editor.
    * Define input/output connectors and internal variables.
    * In the Behavior section, implement C-style loops:
    text for (i = 0; i < 10; i = i + 1) { sum = sum + input_array[i]; } output_val = sum / 10.0;
    * Compile the component and drag it into your SIMIT simulation diagram.
  4. Implementing Iterative Loops via External Python Scripting:
    * Ensure SIMIT has the Virtual Controller or Remote Interface enabled.
    * Install Python (3.8+) on the engineering workstation.
    * In your Python script, import the SIMIT API wrapper or COM bridge.
    * Initialize the connection to the active SIMIT project:
    python import simit_api client = simit_api.connect_project('Water_Treatment_Sim') for valve_id in range(1, 51): client.write_value(f'V_{valve_id}_OpenLimit', 1) client.write_value(f'V_{valve_id}_CloseLimit', 0) print('All 50 valves initialized via loop.')
    * Execute the Python script; observe instantaneous batch updates in SIMIT.

Verification

Verify script execution by monitoring SIMIT signal tables during runtime. For native scripts, confirm that assertions log 'Pass' or 'Fail' in the Automatic Control window. For Python API scripts, inspect the SIMIT trend view or signal table to verify that looped variables update in real time according to the loop index and timing parameters.

Limitations and Operational Precautions

Avoid creating infinite while loops inside the Component Type Editor without bounded exit conditions; an infinite loop in a CTE component will hang the real-time simulation calculation cycle. In external API scripting, limit polling frequencies to avoid saturating the IPC/network bridge between Python and SIMIT.

Engineer FAQ

Can I write a FOR loop in the basic SIMIT script editor?

No. The native SIMIT script editor uses a sequential command syntax without native FOR/WHILE loops. Use Python with the SIMIT API or the Component Type Editor for loops.

What programming language does the Component Type Editor use?

The Component Type Editor uses a proprietary C-like behavioral modeling language supporting standard mathematical operations, arrays, and control structures.

Does SIMIT require an extra license for the API?

Basic remote control and API access are typically included in SIMIT Engineering packages (such as SIMIT Standard or SIMIT Professional); verify specific package details in official Siemens licensing manuals.

Can SIMIT scripts be triggered automatically from PCS 7 SFC charts?

Yes. By mapping a PCS 7 handshake signal (e.g., an SFC test flag) through the SIMIT coupling, a SIMIT script can be started automatically via 'WAIT UNTIL' conditions.

Technical References

Related Articles

Related Tags

  • SIMIT
  • SIMIT Scripting
  • Component Type Editor
  • Virtual Commissioning
  • Python API
  • Automation
20 respuestas