Development method of industrial Python language function block
By developing industrial Python language function blocks, the problem of difficult hardware platform reuse and cross-platform application development in traditional function blocks is solved, cross-platform reuse and performance improvement of function blocks is achieved, and the confidentiality of user core assets is ensured.
Patent Information
- Application Number
- CN202311127752.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-11
AI Technical Summary
Traditional functional block development is difficult to reuse the hardware platform, cannot meet the application needs of complex industrial fields, and cannot perform cross-platform applications and confidentiality guarantees.
By developing industrial Python language function blocks, using Python function blocks to develop standard interface frameworks, combining algorithms to develop Python function block libraries, and importing, compiling and downloading them to the intelligent control engine through the upper-level configuration software, realizing the reuse and cross-platform application of different hardware platforms, and at the same time solving the confidentiality problem by compiling into binary library files.
Cross-platform reuse of functional blocks is realized, the development threshold for algorithm engineers is reduced, performance is improved, and the confidentiality of user core assets is ensured.
Smart Images

Figure CN119597269A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial automation intelligent control, and in particular to a method for developing industrial Python language function blocks. Background Art
[0002] In the field of industrial control, the intelligent optimization control of a factory, a workshop or a core device generally requires expert knowledge from multiple parties such as factory operation experts, research institute experts, core device manufacturers, DCS manufacturers, etc., and the expert knowledge is converted into software functions through coding and other means to achieve optimal intelligent control. The function blocks in the function block diagram language are developed according to the functions of the corresponding hardware, and each function block is closely related to the hardware.
[0003] It is difficult for traditional function block development to apply the developed function blocks to other hardware programming development, and the implemented function blocks are difficult to reuse for different hardware. At the same time, they cannot meet the application requirements in some complex industrial fields. For example, traditional function blocks cannot be used for analysis, modeling and reasoning of massive historical data in some industries. In addition, traditional function blocks cannot be applied across platforms. In the context of intelligent manufacturing, to achieve intelligent control, multiple algorithms need to be deployed on multiple host machines and support multiple operating systems, such as Windows, Linux, etc. In addition, expert knowledge in the industrial field is the core asset of users, so confidentiality issues also need to be resolved.
[0004] At present, intelligent optimization control generally provides C / C++ high-level language to write optimization algorithms, but there are the following disadvantages: With the development of AI and data analysis technology, C++ language support for big data and AI technology is limited, and the functional blocks developed using C / C++ language have high development complexity and are subject to scarce C++ algorithm developers and technical difficulties. The Python language with a rich ecology is increasingly showing its value, but the Python source code is confidential. At present, the industry generally uses encryption and obfuscation to provide Python code files. Summary of the invention
[0005] The purpose of the present invention is to solve the shortcomings of the prior art and provide an industrial Python language function block development method, which uses the high-level programming language Python to develop a complex function block library, realizes reuse on different hardware platforms, ensures the confidentiality of the user's core assets, and can meet cross-platform compilation and use, including the following steps:
[0006] Step S1: Develop a Python function block library by using a Python function block development standard interface framework and matching the algorithm, and then package and provide the Python function block library;
[0007] Step S2: importing the corresponding Python function block library file through the host computer configuration software;
[0008] Step S3: dragging each function block in the host computer configuration software through graphical programming, and connecting the parameter pins corresponding to the function blocks in parallel through wiring to compile a mixed user program;
[0009] Step S4: establishing a communication connection between the host computer configuration software and the intelligent control engine, the host computer configuration software compiles the hybrid user program and downloads it to the intelligent control engine, and the intelligent control engine performs a legality check on the configuration of the compiled user program;
[0010] Step S5: the intelligent control engine starts the user program process to parse the mixed user program and schedule it to run, and perform periodic real-time control.
[0011] Furthermore, in step S1, the core standard interface of the Python function block development standard interface framework includes interfaces including initialization, data preparation, calculation and termination.
[0012] Furthermore, in step S1, the packaged file of the Python function block library includes a packaged file including a binary dynamic library file, a standard algorithm function block library description file ending in a json file format, and a standard function block description file ending in a json file format.
[0013] Preferably, the binary dynamic library file is compiled according to rules based on the Python function block, and the binary dynamic library file is the same as C++, realizing mixed scheduling and confidentiality functions with the C++ function block.
[0014] More preferably, a description file ending in a unified standard json file format is provided for the Python function block to achieve multi-language display of the Python function block.
[0015] Furthermore, in step S2, the host computer is a computer that can directly issue control commands and display various signal changes. The host computer configuration software is used to import conventional industrial algorithm function blocks and compile algorithm programs.
[0016] Furthermore, in step S3, the hybrid user program is a user program composed of function blocks PyFBD function blocks compiled using Python language and function blocks CppFBD function blocks compiled using C++ language.
[0017] Preferably, the PyFBD function block and the CppFBD function block are imported through the host computer configuration software and then mixed to compile an algorithm program.
[0018] Furthermore, in step S4, the intelligent control engine is an engine system for parsing the user program composed of the PyFBD function block and the CppFBD function block and executing program scheduling control.
[0019] Furthermore, in step S5, one of the Python function block libraries supports multiple algorithm functions simultaneously, and the intelligent control engine creates multiple instances for use.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] (1) Function blocks written in the high-level language Python are introduced, and a rich third-party ecosystem is also available. For example, some big data analysis frameworks and some third-party libraries for deep learning can be introduced. In addition, the function blocks developed can be compiled and packaged into binary dynamic libraries according to the rules of the intelligent control engine platform to improve performance and make up for the original Python performance weakness.
[0022] (2) Python function blocks can be combined with traditional C++ function blocks to form hybrid custom programs, which can introduce the advantages of both at the same time, such as: Python has a rich third-party ecosystem and C++ has high performance, thereby making up for their respective shortcomings, such as: PyFBD has rich third-party extensions but weaker performance than CppFBD, CppFBD has high performance but its third-party extensions are obviously insufficient compared to PyFBD;
[0023] (3) Solve the confidentiality problem of function blocks developed based on Python language. According to certain rules and requirements of the intelligent control engine platform, compile them into binary library files that are the same as C++, thereby supporting mixed scheduling with C++ function blocks. At the same time, the binary files can also solve the confidentiality problem of user function block libraries to ensure the security of core assets.
[0024] (4) In the industrial field, very few algorithm engineers have C++ development capabilities, but most have Python development capabilities. Therefore, the introduction of Python language development function blocks greatly reduces the development threshold for algorithm engineers. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0026] Figure 1 A development and operation scheduling sequence diagram of an industrial Python language function block of the present invention;
[0027] Figure 2This is an example diagram of a user program composed of PyFBD and CppFBD of the present invention. DETAILED DESCRIPTION
[0028] To make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0029] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present invention refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0030] It is difficult for traditional function block development to apply the developed function blocks to other hardware programming development, and the implemented function blocks are difficult to reuse for different hardware. At the same time, they cannot meet the application requirements in some complex industrial fields. For example, traditional function blocks cannot be used for analysis, modeling and reasoning of massive historical data in some industries. In addition, traditional function blocks cannot be applied across platforms. In the context of intelligent manufacturing, to achieve intelligent control, multiple algorithms need to be deployed on multiple host machines and support multiple operating systems, such as Windows, Linux, etc. In addition, expert knowledge in the industrial field is the core asset of users, so confidentiality issues also need to be resolved.
[0031] Intelligent optimization control generally provides C / C++ high-level language to write optimization algorithms, but there are the following disadvantages: With the development of AI and data analysis technology, C++ language support for big data and AI technology is limited, and the functional blocks developed using C / C++ language have high development complexity and are subject to scarce C++ algorithm developers and technical difficulties. The Python language with a rich ecosystem is increasingly showing its value, but the Python source code is confidential. Currently, the industry generally uses encryption and obfuscation to provide Python code files.
[0032] This method introduces function blocks written in the high-level language Python, and also has a rich third-party ecosystem. For example, some big data analysis frameworks and some third-party libraries for deep learning can be introduced. In addition, the function blocks developed can be compiled and packaged into binary dynamic libraries according to the rules of the intelligent control engine platform to improve performance and make up for the original Python performance weakness.
[0033] Python function blocks can be combined with traditional C++ function blocks to form hybrid custom programs, which can introduce the advantages of both at the same time, such as: Python has a rich third-party ecosystem and C++ has high performance, thereby making up for their respective shortcomings, such as: PyFBD has rich third-party extensions but weaker performance than CppFBD, CppFBD has high performance but its third-party extensions are obviously insufficient compared to PyFBD.
[0034] This method compiles into a binary library file that is the same as C++ according to certain rules and the requirements of the intelligent control engine platform, thereby supporting mixed scheduling with C++ function blocks. At the same time, the binary file can also solve the confidentiality problem of the user function block library to ensure the security of core assets.
[0035] In the industrial field, very few algorithm engineers have C++ development capabilities, but most have Python development capabilities. Therefore, the introduction of Python language development function blocks has greatly lowered the development threshold for algorithm engineers.
[0036] The high-level programming language Python is used to develop complex function block libraries to solve problems encountered in complex industrial fields and reuse them on different hardware platforms, ensuring the confidentiality of users' core assets. At the same time, one code can be compiled and used across platforms.
[0037] The following is described by specific examples:
[0038] First embodiment
[0039] like Figure 1 As shown, the present embodiment provides a method for developing an industrial Python language function block, comprising the following steps:
[0040] Step S1: Develop a Python function block library by using a Python function block development standard interface framework and matching the algorithm, and then package and provide the Python function block library;
[0041] Step S2: importing the corresponding Python function block library file through the host computer configuration software;
[0042] Step S3: dragging each function block in the host computer configuration software through graphical programming, and connecting the parameter pins corresponding to the function blocks in parallel through wiring to compile a mixed user program;
[0043] Step S4: establishing a communication connection between the host computer configuration software and the intelligent control engine, the host computer configuration software compiles the hybrid user program and downloads it to the intelligent control engine, and the intelligent control engine performs a legality check on the configuration of the compiled user program;
[0044] Step S5: the intelligent control engine starts the user program process to parse the mixed user program and schedule it to run, and perform periodic real-time control.
[0045] Among them, in step S1, the core standard interface of the Python function block development standard interface framework includes interfaces including initialization, data preparation, calculation and termination. The Python function block library is developed and packaged by algorithm development engineers, and function blocks written in the high-level language Python are introduced. At the same time, it also has a rich third-party ecosystem. For example, some big data analysis frameworks and some third-party libraries for deep learning can be introduced, and the function blocks developed by it can be compiled and packaged into binary dynamic libraries according to the rules of the intelligent control engine platform to improve performance to make up for the original Python performance weaknesses. At the same time, it solves the problems encountered in complex industrial fields and reuses on different hardware platforms, so as to meet the requirements of one code and cross-platform compilation and use.
[0046] Specifically, in this embodiment, the packaged file of the Python function block library includes a packaged file including a binary dynamic library file, a standard algorithm function block library description file ending in the json file format, and a standard function block description file ending in the json file format.
[0047] Among them, the binary dynamic library file is compiled according to the rules based on the Python function block. The binary dynamic library file is the same as C++, realizing mixed scheduling with the C++ function block, and solving the confidentiality problem to ensure the security of core assets; in addition, a description file ending with a unified standard json file format for the Python function block is provided to realize multi-language display of the Python function block.
[0048] Further, in step S2, the host computer is a computer that can directly issue control commands and display various signal changes. The host computer configuration software is used to import conventional industrial algorithm function blocks and compile algorithm programs. Specifically, in this embodiment, the host computer is a PC / host computer / master computer / upper computer; the on-site engineering personnel import the corresponding Python function block library file through the host computer configuration software.
[0049] Further, specifically, in step S3, the hybrid user program is a user program composed of a function block PyFBD function block compiled using Python language and a function block CppFBD function block compiled using C++ language, such as Figure 2 As shown in the figure, it is a user program based on PyFBD and CppFBD function blocks, which simply shows two input pin parameters and one output pin parameter. The function block pin parameters for actual algorithm development will be much more complicated.
[0050] Among them, Python has a rich third-party ecosystem and C++ has high performance. At the same time, PyFBD has rich third-party extensions but its performance is weaker than CppFBD. CppFBD has high performance but its third-party extensions are obviously insufficient compared to PyFBD. This makes up for their respective shortcomings and introduces the advantages of both.
[0051] Specifically, in this embodiment, the PyFBD function block and the CppFBD function block are imported through the host computer configuration software and then mixed to compile an algorithm program.
[0052] Preferably, in step S4, the intelligent control engine is an engine system for parsing the user program composed of the PyFBD function block and the CppFBD function block and executing program scheduling control.
[0053] Furthermore, in step S4, the host computer configuration software establishes a communication connection with the intelligent control engine, and downloads the compiled user program configuration to the intelligent control engine for legality verification.
[0054] Furthermore, in step S5, one of the Python function block libraries supports multiple algorithm functions simultaneously, and the intelligent control engine creates multiple instances for use.
[0055] In addition, very few algorithm engineers in the industrial field have C++ development capabilities, but most have Python development capabilities. Therefore, the introduction of Python language development function blocks has greatly lowered the development threshold for algorithm engineers.
[0056] This method shows the complete process of Python function block library from development -> reference -> use -> download -> run. The specific sequence is as follows Figure 1 shown.
[0057] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
[0058] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for developing industrial Python language function blocks, characterized in that: The steps include: Step S1: Develop a Python function block library by using a Python function block development standard interface framework and matching the algorithm, and then package and provide the Python function block library; Step S2: importing the corresponding Python function block library file through the host computer configuration software; Step S3: dragging each function block in the host computer configuration software through graphical programming, and connecting the parameter pins corresponding to the function blocks in parallel through wiring to compile a mixed user program; Step S4: establishing a communication connection between the host computer configuration software and the intelligent control engine, the host computer configuration software compiles the hybrid user program and downloads it to the intelligent control engine, and the intelligent control engine performs a legality check on the configuration of the compiled user program; Step S5: the intelligent control engine starts the user program process to parse the mixed user program and schedule it to run, and perform periodic real-time control.
2. The method for developing industrial Python language function blocks according to claim 1, characterized in that: In step S1, the core standard interface of the Python function block development standard interface framework includes interfaces including initialization, data preparation, calculation and termination.
3. The method for developing industrial Python language function blocks according to claim 1, characterized in that: In step S1, the packaged file of the Python function block library includes a packaged file including a binary dynamic library file, a standard algorithm function block library description file ending in a json file format, and a standard function block description file ending in a json file format.
4. The method for developing industrial Python language function blocks according to claim 3, characterized in that: The binary dynamic library file is compiled according to rules based on the Python function block, and the binary dynamic library file is the same as C++, realizing mixed scheduling and confidentiality functions with the C++ function block.
5. The method for developing industrial Python language function blocks according to claim 3, characterized in that: A description file ending in a unified standard json file format is provided for the Python function block to realize multi-language display of the Python function block.
6. The method for developing industrial Python language function blocks according to claim 1, characterized in that: In step S2, the host computer is a computer that can directly issue control commands and display various signal changes. The host computer configuration software is used to import conventional industrial algorithm function blocks and compile algorithm programs.
7. The method for developing industrial Python language function blocks according to claim 1, characterized in that: In step S3, the hybrid user program is a user program composed of function blocks PyFBD function blocks compiled using Python language and function blocks CppFBD function blocks compiled using C++ language.
8. The method for developing industrial Python language function blocks according to claim 7, characterized in that: The PyFBD function block and the CppFBD function block are imported into the host computer configuration software and then mixed to compile an algorithm program.
9. The method for developing industrial Python language function blocks according to claim 7, characterized in that: In step S4, the intelligent control engine is an engine system for parsing the user program composed of the PyFBD function block and the CppFBD function block and executing program scheduling control.
10. The method for developing industrial Python language function blocks according to claim 1, characterized in that: In step S5, one of the Python function block libraries supports multiple algorithm functions simultaneously, and the intelligent control engine creates multiple instances for use.