Script Editor

This section describes Script Editor

With the Script Editor, the user can write, open and execute various automated testing scripts written in Python, using appropriate Typhoon API libraries.

Note: For more information about Typhoon API refer to HTML API Documentation.
Note: For more information about the Python programming language visit http://www.python.org/.
Important: Before executing a script in the Script Editor, if you opened the Script Editor through Typhoon HIL Control Center, please close the HIL SCADA tool.

The Script Editor consists of three main parts marked on (Figure 1 Script editor main ).

Figure 1: Script editor main window



  • API Wizard pane – this pane allows the user to easily and quickly insert appropriate HIL API functions. The API Wizard pane interface is dynamically generated based on the loaded Model.
  • Script editor pane – a minimalistic text editor for writing and editing Python scripts.
  • Console pane – a simple console that displays outputs from the user’s Python scripts.

To open a Python script (file) click on the icon (or File->Load in the menu). The content of the file will be shown in the Script Editor pane.

To execute the opened script, click on the icon in the tool bar (or Run->Run in the menu). When the script has been started, all outputs will be shown in the Console pane. To stop a script, click on the icon, and the script will be forcibly terminated.

Figure 2: Python interpreter selection combo box



Additionally, you will find the Python interpreter selection combo box in the same toolbar (Figure 2 ). It lets you select which Python interpreter you want to use for running an opened script. The options are:

  1. Embedded (Python 3) – use the embedded (portable) Python interpreter (with all the necessary dependencies included) that comes with the Typhoon HIL Software installation.
  2. System – use the system Python installed on the user’s PC.

API Wizard

Figure 3: Automatically insert an API command



To automatically insert a new API command, you first need to open the HIL SCADA model you are writing the script for. To do that, click on the icon in the toolbar (or API Wizard->Open API Wizard in the menu). Once the model is opened, the API Wizard pane will be automatically shown. To insert a new command, configure the appropriate section in the API Wizard pane, and click on the Insert button (Figure 3).

If you need some help about a specific API function, pressing the icon in the toolbar will show the Typhoon API Help Documentation window. Also, if you select a function name inside an opened script and press F1, the API Help Documentation window will be shown (in case it is not already open) and it will show the search results for the selected function name.

Important considerations

Note: To run Python scripts written using Typhoon API, you do not need to install any Python libraries. All necessary dependency libraries are provided with the Typhoon HIL Software installation (including a Python 3 installation with preinstalled Typhoon API). You only need to select the appropriate Embedded Python interpreter before running the script.
Note: By selecting the System interpreter for running an opened script you can easily integrate Typhoon API with your Python environment.

Starting from the 2017.4 software version, Typhoon API is distributed as a precompiled wheel files available both from PyPI (https://pypi.python.org/pypi/Typhoon-HIL-API/ and https://pypi.python.org/pypi/TyphoonTest/) and from Typhoon HIL Software installation (inside api_install subfolder).

APIs included in the Typhoon API wheel file (together with Typhoon API documentations) are:

  1. Schematic Editor API
  2. HIL API
  3. Modbus API
  4. PV Generator API
  5. Test Executor API

New Typhoon API is compatible with both Python 2 and Python 3, supports both 32-bit and 64-bit Python versions, and requires fewer dependencies.

The recommended way to install the new Typhoon API is to use the Python package management system (pip, https://en.wikipedia.org/wiki/Pip_(package_manager) ) by executing one of the following commands in the command prompt:
  1. By using a wheel file shipped together with Typhoon HIL Software installation:

    pip install C:\Typhoon HIL Control Center\api_install\[typhoon_api_wheel_file_name]

All necessary dependencies (listed below) are going to be installed automatically.

Important: In both Python interpreter use cases (system or embedded) you must run a script from the Script Editor
Important: If you want to run scripts entirely outside of the Script Editor, you only need to install Typhoon API inside your Python environment as described above.

Earlier versions of Typhoon API (prior to the 2017.4 software version) required you to extend PATH and to create a PYTHONHOME system variable in order to setup and use API correctly.

The new version of Typhoon API does not require these interventions. If you have used Typhoon API in earlier versions (2017.3 or older), you should remove Typhoon Software installation root (default: C:\Typhoon HIL Control Center\) from the PATH and PYTHONHOME system variable in order to use the new API correctly.

Important: Typhoon API requires Typhoon HIL Control Center (with an appropriate license) to be installed.

With the new Typhoon API you can freely mix different Python versions (32-bit or 64-bit) with different Typhoon HIL Control Center versions (32-bit or 64-bit). There is no longer the version matching restriction that, for example, a 64-bit system Python version should only be used with a 64-bit Typhoon HIL Control Center version.