A short summary of how to set up the HSL 2.0 framework and get first results.
1.Python version
For information and download see the following link.
Note
By clicking on one of the following links you leave this documentation!
Attention
The framework was developed and tested with Python versions 2.6.6 and 2.7.9 and is only released for use with these versions!
2.Requirements
- You have installed a Python version (v2.6.x or v2.7.x) and set it up so that you can access the python.exe file from anywhere. You can find instructions on how to do this on the Internet help pages of python.org.
- You have installed at least version 4.5 of the Expert and the firmware.
- For Expert/FW version 4.5 only Python version 2.6.x is supported!
- For Expert/FW version 4.6 and higher only Python version 2.7.x is supported!
- You have an editor at your disposal with which files in ".py" (Python script) and ".xml" format can be edited.
3.Creation of a building block
This document explains how to set up the HSL 2.0 framework by creating a block using the example of the binary trigger already known from HS/FS.
Note
The finished building block is enclosed with the examples.
3.1.Setup of the framework
You have a copy of the HSL 2.0 framework.
It consists of several files and 3 subdirectories:
The directory
The two files directly in the directory (the tools) are available in a version compatible with Python 2.7.x.
It consists of several files and 3 subdirectories:
generator.pyc |
The directory
projects
is empty, the directory hsl20
contains the source files of the framework.The two files directly in the directory (the tools) are available in a version compatible with Python 2.7.x.
Attention
If you are using Expert / FW 4.5 or 4.6, please replace these files with the versions from the
python26
directory before proceeding.Now call up the setup script with the parameter "-auto".
A new directory
In this directory again some subdirectories have been created and a new file has been created:
Directories:
File:
The file config.xml is the definition file for your module.
The descriptions of the individual parameters and values of the config.xml file can be found in the documentation of the XML definition file.
python create_project.pyc -auto
A new directory
projects
was my project
created in the directory.In this directory again some subdirectories have been created and a new file has been created:
Directories:
debug |
File:
config.xml |
The file config.xml is the definition file for your module.
The descriptions of the individual parameters and values of the config.xml file can be found in the documentation of the XML definition file.
3.2.Definition
Enter the following data for the block in the config.xml file:
category="hsl20\fw_examples"
Menu structure in the GLE.context="hsl20_fw_examples"
Context of the module.id="10700"
5-digit block ID.name="Binary_Trigger"
Name in GLE and part of the file name.version="1.0"
Version number of the module.
The binary trigger has only one input. Enter the following attributes for it:
type="number"
Data type. Is always either "number" or "string".const_name="input"
Name of the input as it should be used in the Python script.init_value="0"
Value with which the input should be preset.- The content of the input element is the label of the input in the block and is set to "
I1
".
Proceed in the same way for the two outputs:
Output 1:
Output 1:
type="number"
const_name="not_equal_to_zero"
init_value="0"
- The content of the output element is the label of the 1st output in the block and is set to "
O1 (I1<>0)
".
Output 2:
type="number"
const_name="equal_to_zero"
init_value="0"
- The content of the output element is the label of the 2nd output in the block and is set to "
O2 (I1=0)
".
The result should now look like this:
|
This completes the definition of your building block.
3.3.Generation
Save the config.xml file and call the HSL 2.0 generator.
The HSL 2.0 generator creates some files in the test directory of the project structure for each module defined in the config.xml file when it is first called.
python generator.pyc "my project" UTF-8
The HSL 2.0 generator creates some files in the test directory of the project structure for each module defined in the config.xml file when it is first called.
- A file
[id]_[Name].py
in the directorysrc
- A file
[id]_[Name].py
in the directorydebug
- A file
[id]_[Name].hsl
in the directoryrelease
For our binary trigger these are:
- 10700_Binary_Trigger.py in the directory
src
- 10700_Binary_Trigger.py in the directory
debug
- 10700_Binary_Trigger.hsl in directory
release
With all further calls of the generator, the files in the directories
debug
and release
completely, the file(s) in the src
-directory are partially regenerated.Attention
If there are errors in the code, it can happen that
generator.pyc
an empty file (0 bytes large) is generated in the src
-directory. In this case please delete this file.Since the device is neither remanent nor fires when the logic is initialised, the whole Python code to be programmed by yourself consists of the following lines:
|
Attention
After completion of the programming work, the module must be regenerated one last time!
An HSL 2.0 module always has the class BaseModule as its basis. The method _get_framework() gives access to the rest of the framework.
4.Test of a module
4.1.Carrying out a test
4.1.1.Test of the example module
After successful generation of the block, proceed as follows:
- If the HS/FS Expert is running
- Copy the created block
projects\my project\release\10700_Binary_Trigger.hsl
into the "logic" directory of your expert installation. - Restart the HS/FS Expert!
- In the GLE you now have access to the new module under
hsl20\fw_examples\Binary_Trigger
". You can use it in the same way as any other module.
- In the GLE you now have access to the new module under
- Transfer the project to the HS/FS
4.1.2.General information on device tests
The recommended method for testing modules still in development is to use the ".iso" file included in the Expert Setup, which allows you to simulate an HS in a virtual machine, as the retransmission of the Expert project necessary after each change only takes a few seconds.
If the module is basically ready, more intensive tests can be carried out using a "normal" HS/FS by using the GLE debugger.
You can find more details about "HS as VM" and the "GLE Debugger" in the HTML Help of the HS/FS Expert.
If the module is basically ready, more intensive tests can be carried out using a "normal" HS/FS by using the GLE debugger.
You can find more details about "HS as VM" and the "GLE Debugger" in the HTML Help of the HS/FS Expert.