This is a Python tool (licensed under Apache 2.0) to integrate high-level code with IEC 61499 standard, specifically with EchoStruxure Automation Expert (Schneider Electric).
The tool is developed by SUPPRESS Research Group, from Universidad de León, and it's also available in our GitHub site.
The tool integrates Python code with Function Blocks (FBs) as follows:
- A REQ event reaches an instance of the Function Block Python_Task
- KWARGS string is updated in the Function Block Python_Task
- The Function Block Python_Task is executed and a dictionary containing KWARGS ,TASK_TYPE and TASK_ID is sent to the Python code.
- A TCP Server listening on ADDR_PORT catches the dictionary and handles the request.
- Once the Python code finishes, the result is sent back to the Function Block Python_Task.
- The output RESULT is updated in the Function Block Python_Task.
- The REQ_O event is triggered in the Function Block Python_Task.
In order to avoid race conditions, every Python_Task instance has a unique TASK_ID. This ID is assigned automatically by the tool, when the INIT event is triggered. User only needs to connect NEW_ID to UPDATE_ID and GIVEN_ID to TASK_ID, in order to configure the Python_Task instance.
With this Function Block, RESULT can only be a number (real). Another Function Block called Python_Task_JSON is also available. With this Function Block, users can configure Python tasks that return dictionaries, bringing much more flexibility.
Once you have cloned the repository, you can run the following command to launch the tool:
cd python_tool/
python main.pyThe tool comes with a toy task configured in python_tool/resoruces/available_tasks/SUM.py:
class SUM:
def execute(self, IN1=None, IN2=None):
return IN1+IN2This task could be tested with the following Function Block:
Users can implement their own tasks by creating a new Python file python_tool/resoruces/available_tasks/TASK_NAME.py containing a class TASK_NAME with an execute method. The method should return a number (real) or a JSON.
In order to make debugging easier, the tool comes with a logger. The logger is configured to write logs in python_tool/resources/error_list.log. This log file is restarted every time the tool is launched.
The repository contains the following folders:
python_tool/: Contains the aforementioned tool.EAE_function_block/: Contains importable libraries for EchoStruxure Automation Expert.SUPPRESS.python61499: Contains the Function Blocks Python_Task and Python_Task_JSON, as well as some auxiliary Function Blocks.SUPPRESS.EventBasedPID: Contains Function Blocks in order to implement an Event-Based PID controller. This is the implmenentation proposed by Karl-Erik Åarzén.
If you think this tool is useful for your research, please consider citing it:
@article{GonzlezMateos2024,
title = {A PID Control Architecture Based on IEC 61499},
volume = {58},
ISSN = {2405-8963},
url = {http://dx.doi.org/10.1016/j.ifacol.2024.08.016},
DOI = {10.1016/j.ifacol.2024.08.016},
number = {7},
journal = {IFAC-PapersOnLine},
publisher = {Elsevier BV},
author = {González-Mateos, Guzmán and Prada, Miguel A. and Morán, Antonio and González-Herbón, Raúl and Domínguez, Manuel},
year = {2024},
pages = {91–96}
}
