Packet management-based call library system and method in PLC (Programmable Logic Controller) compiler
By introducing a package management-based call library system in the PLC compiler, the problems of insufficient flexibility in library file calling and performance bottlenecks in the existing technology are solved, efficient management and reuse of library files are realized, and compilation and operation efficiency is improved.
Patent Information
- Application Number
- CN202411460470.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-25
AI Technical Summary
The lack of effective package management mechanisms in existing PLC compilers leads to insufficient flexibility in calling library files and large performance bottlenecks, making it difficult to achieve efficient reuse and modularity of code.
The PLC compiler introduces a calling library system based on package management. Through the system library module and user library module, it is managed and distributed in the form of library packages to achieve orderly management and version control of the library.
The organizational structure of the library file is optimized, the flexibility and compilation efficiency of the calling library are improved, the runtime efficiency optimization is achieved, and the user can share and encapsulate algorithms and functions.
Smart Images

Figure CN119512558A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of code library management, and in particular to a calling library system and method based on package management in a PLC compiler. Background Art
[0002] Programmable logic controller (hereinafter referred to as PLC) is a digital logic controller used for automation control. It receives and sends various types of digital or analog signals in industrial production environments to complete process control and servo control. The PLC software compilation system consists of a running system and a development system. Using library modules in the running system can greatly improve the user's development efficiency and improve the reusability of the code. There are two major types of libraries: system libraries and user libraries, which are described in detail below.
[0003] System library, the PLC operating system provides users with packaged system library files, which are merged with the user program into an executable file during the linking stage of compilation. Any user can directly call the system library standard functions and function blocks, which together constitute the PLC built-in instruction system. When the program is compiled, the implementation code of these libraries is not included in the project program file; instead, it waits until the linking stage, when the runtime system loads the user program, to link the function functions and function blocks in the library, and the system library is copied to the user program for calling.
[0004] The user library is actually a package of user-defined algorithms or functions, presented in the form of a compressed package; when using it, first import the library package, the system will parse the file, and provide the functional interface for user use. The system library is provided to all users who use this version of PLC, and the circulation of the user library is limited to the release and sharing of the creator.
[0005] In the field of PLC applications, no patents or public knowledge related to the technology have been found. In other computer technology fields, there are the following two existing patents and one paper related to the present invention:
[0006] Patent document CN117270952A discloses a new code base management method in a smart medical scenario, including the following steps: using turbo plug-in to create turborepo environment, selecting pnpm as the package manager, and waiting for turborepo environment to be created. The invention implements the package management function, organizes the code base into a specific structure, and the user uses the function of the corresponding code package by configuring the entry file. However, the application scenario of the invention is the smart medical project code, not the industrial control PLC; the invention uses the turbo plug-in to configure the environment by executing script commands; instead of completing the generation and reading of the configuration entry file at compile time in the environment of the PLC compiler; the patent configuration file structure includes: ".json", ".yaml" files, various public tables, forms, pop-up boxes and other public component parts under the overall project, etc.; instead of using ".l ibrary", ".func", etc. The difference in configuration files also shows that the internal design and architecture of the package management function are very different.
[0007] Patent document CN117270896A discloses a method, system, device and storage medium for automatic identification and installation of applications, which belongs to the field of computer technology. The method includes: uploading an installation package of an installation boot, an application installation package and a communication configuration file; accessing the installation package management interface of the server, identifying the architecture information of the current terminal, and determining the installation boot download link according to the architecture information; using the installation boot download link to download the installation boot package and the corresponding communication configuration file, and running the installation boot; obtaining the operating system information of the current terminal, using the communication configuration file to download the application installation package corresponding to the current terminal; monitoring the installation process of the application installation package; after the installation is completed, establishing communication with the business server. The patent combines the configuration file to obtain the corresponding installation package, realizes the identification, downloading and installation of the program, and has the function of installation package management. However, the source of the application program that needs to be managed and installed in the patent is not explained or limited; the invention is based on the client / server architecture, obtains information such as CPU architecture, operating system, storage medium, etc. through the installation boot, accesses the installation package management interface of the server through the browser according to the specific URL, and the server parses the access request parameters; but does not distinguish between multiple versions of underlying hardware and libraries in configuration. The invention is closely integrated with the business, realizing automatic identification, downloading and installation of applications in different terminal environments, and has the function of monitoring the installation process of the application installation package; but it does not encapsulate the user's algorithm or function, and cannot be used out of the box in PLC programming projects.
[0008] Zhu Peilin. Design and Implementation of App Package Management and Monitoring System [D]. Nanjing University, 2020. DOI: 10.27235 / d.cnki.gnj iu.2020.002938. This paper is an offline resource management tool that can realize version management, resource monitoring, resource package file packaging, uploading, and deployment processes. This paper designs a complete system from the front end to the back end, obtains user data from the front end, and the back end implements package access and data exchange through the Node.js platform. Instead of only targeting the package management module, a package management method related to back-end compilation is designed. This paper displays package management and data information on the front end of the web page, and realizes data visualization through various components; instead of providing services to users through the library manager and the system library instruction table in the sidebar, the compilation result represents the call result of the package. Summary of the invention
[0009] In view of the defects in the prior art, the object of the present invention is to provide a calling library system and method based on package management in a PLC compiler.
[0010] A calling library system based on package management in a PLC compiler provided by the present invention comprises:
[0011] System library module: It is a system built-in library function. When a user references a system built-in library function, the PLC system copies the library package of the system built-in library function to the project directory, distributes the system library, and provides underlying support for the user library.
[0012] User library module: implements functions according to the interface provided by the system library, customizes library functions for users, and after successful compilation and release, other users can import and use them.
[0013] Preferably, both the system library and the user library are in the form of library packages:
[0014] For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, a new library package is added to distribute new system libraries to users;
[0015] For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
[0016] Preferably, in the system library module:
[0017] During the PLC system development phase, developers package commonly used instructions into library files. Common instructions refer to the national standard IEC 61131 instruction list, including logic operation instructions, data processing instructions, timer and counter instructions;
[0018] When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory;
[0019] Select library file: Open the PLC program and select the library function to be imported in the sidebar;
[0020] Load library file: drag the selected library function to the programming area to copy from an existing project to the library;
[0021] When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted;
[0022] During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure.
[0023] When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
[0024] Preferably, in the user library module:
[0025] Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation;
[0026] Library packaging: add user libraries, automatically install them locally after successful compilation, and install them on the remote project server after publishing;
[0027] Use user library: other users install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module, and the user calls the function or function block in the user library;
[0028] During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out;
[0029] During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
[0030] Preferably, the system library and user library are managed in the following manner:
[0031] The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project.
[0032] Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents:
[0033] Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version;
[0034] The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function;
[0035] Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information;
[0036] Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
[0037] A calling library method based on package management in a PLC compiler provided by the present invention includes:
[0038] Step S1: The system library module is a system built-in library function. When a user references a library function, the PLC system copies the library package of the function to the project directory, distributes the system library, and provides underlying support for the user library.
[0039] Step S2: The user library module implements functions according to the interface provided by the system library. The user defines the library function and writes the program. After successful compilation and release, other users can import and use it.
[0040] Preferably, both the system library and the user library are in the form of library packages:
[0041] For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, a new library package is added to distribute new system libraries to users;
[0042] For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
[0043] Preferably, in the system library module:
[0044] During the PLC system development phase, developers package commonly used instructions into library files. Common instructions refer to the national standard IEC 61131 instruction list, including logic operation instructions, data processing instructions, timer and counter instructions;
[0045] When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory;
[0046] Select library file: Open the PLC program and select the library function to be imported in the sidebar;
[0047] Load library file: drag the selected library function to the programming area to copy from an existing project to the library;
[0048] When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted;
[0049] During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure.
[0050] When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
[0051] Preferably, in the user library module:
[0052] Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation;
[0053] Library packaging: add user libraries, automatically install them locally after successful compilation, and install them on the remote project server after publishing;
[0054] Use user library: other users install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module, and the user calls the function or function block in the user library;
[0055] During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out;
[0056] During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
[0057] Preferably, the system library and user library are managed in the following manner:
[0058] The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project.
[0059] Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents:
[0060] Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version;
[0061] The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function;
[0062] Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information;
[0063] Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
[0064] Compared with the prior art, the present invention has the following beneficial effects:
[0065] 1. The present invention optimizes the organizational structure of the call library file and provides a reasonable organizational mode for the call library with various implementation methods to achieve the best compilation effect and optimize the runtime efficiency;
[0066] 2. The present invention distributes and circulates the package in the PLC compiler, and users can flexibly share the realization of algorithms and functions, which is an important usage requirement;
[0067] 3. The present invention improves the convenience of user code reuse, is conducive to program modularization, and helps the development of application programs to achieve free assembly and iteration.
[0068] 4. For PLC products, the present invention uses a calling library method based on package management, which can help provide system basic function functions and function blocks, while facilitating management and version control; it also provides convenience for users to share and encapsulate the realization of algorithms and functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0070] Figure 1 It is the call library flow chart of package management in PLC compiler;
[0071] Figure 2 To create a flow chart for implementing library functions in code;
[0072] Figure 3 This is a structural design diagram for package management in the PLC compiler. DETAILED DESCRIPTION
[0073] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0074] Embodiment 1:
[0075] With reference to package management technologies and methods in other fields, the present invention has made improvements in the distribution and circulation of library packages, adopted original system design and ideas, solved the problems of insufficient flexibility and performance bottleneck in calling libraries in previous designs, and has strong practicality and reliability.
[0076] The purpose of the present invention is to provide a library calling method based on package management in a PLC compiler, so as to improve the user programming efficiency through orderly management and version distribution of the library. In some scenarios, the user wants to customize the library function, or customize the library file, and use the library generator module of the present invention to generate a library package for distribution and circulation; the free sharing of the library package can be achieved by using storage media, network transmission, etc. When using the library package of the system and the user, the library parser module of the present invention is used to realize unpacking, identify the method interface, and provide direct calling for the user. The specific implementation of the invention spans the four stages of the compiler: preprocessing, compilation, assembly, and linking, and combines the advantages of static compilation and dynamic compilation, and is innovative.
[0077] A library calling method based on package management in a PLC compiler provided by the present invention includes:
[0078] Step S1: The system library module is a system built-in library function. When a user references a library function, the PLC system copies the library package of the function to the project directory, distributes the system library, and provides underlying support for the user library.
[0079] Step S2: The user library module implements functions according to the interface provided by the system library. The user defines the library function and writes the program. After successful compilation and release, other users can import and use it.
[0080] Specifically, system libraries and user libraries are in the form of library packages:
[0081] For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, a new library package is added to distribute new system libraries to users;
[0082] For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
[0083] Specifically, in the system library module:
[0084] During the PLC system development phase, developers package commonly used instructions into library files. Common instructions refer to the national standard IEC61131 instruction list, including logic operation instructions, data processing instructions, timer and counter instructions;
[0085] When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory;
[0086] Select library file: Open the PLC program and select the library function to be imported in the sidebar;
[0087] Load library file: drag the selected library function to the programming area to copy from an existing project to the library;
[0088] When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted;
[0089] During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure.
[0090] When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
[0091] Specifically, in the user library module:
[0092] Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation;
[0093] Library packaging: add user libraries, which will be automatically installed locally after successful compilation and installed on the remote project server after publishing;
[0094] Use user library: other users install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module, and the user calls the function or function block in the user library;
[0095] During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out;
[0096] During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
[0097] Specifically, the management methods used by system libraries and user libraries are:
[0098] The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project.
[0099] Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents:
[0100] Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version;
[0101] The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function;
[0102] Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information;
[0103] Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
[0104] Embodiment 2:
[0105] Embodiment 2 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0106] The present invention also provides a calling library system based on package management in a PLC compiler. The calling library system based on package management in the PLC compiler can be implemented by executing the process steps of the calling library method based on package management in the PLC compiler, that is, those skilled in the art can understand the calling library method based on package management in the PLC compiler as a preferred implementation of the calling library system based on package management in the PLC compiler.
[0107] According to a call library system based on package management in a PLC compiler provided by the present invention, Figure 1-Figure 3 As shown, including:
[0108] System library module: It is a system built-in library function. When a user references a system built-in library function, the PLC system copies the library package of the system built-in library function to the project directory, distributes the system library, and provides underlying support for the user library.
[0109] Specifically, in the system library module:
[0110] During the PLC system development phase, developers package commonly used instructions into library files. Common instructions refer to the national standard IEC 61131 instruction list, including logic operation instructions, data processing instructions, timer and counter instructions;
[0111] When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory;
[0112] Select library file: Open the PLC program and select the library function to be imported in the sidebar;
[0113] Load library file: drag the selected library function to the programming area to copy from an existing project to the library;
[0114] When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted;
[0115] During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure.
[0116] When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
[0117] User library module: implements functions according to the interface provided by the system library, customizes library functions for users, and after successful compilation and release, other users can import and use them.
[0118] Specifically, in the user library module:
[0119] Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation;
[0120] Library packaging: add user libraries, which will be automatically installed locally after successful compilation and installed on the remote project server after publishing;
[0121] Use user library: other users install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module, and the user calls the function or function block in the user library;
[0122] During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out;
[0123] During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
[0124] Specifically, system libraries and user libraries are in the form of library packages:
[0125] For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, a new library package is added to distribute new system libraries to users;
[0126] For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
[0127] Specifically, the management methods used by system libraries and user libraries are:
[0128] The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project.
[0129] Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents:
[0130] Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version;
[0131] The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function;
[0132] Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information;
[0133] Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
[0134] Embodiment 3:
[0135] Embodiment 3 is a preferred example of Embodiment 1, and is used to illustrate the present invention in more detail.
[0136] Both system libraries and user libraries are in the form of library packages:
[0137] 1. For system libraries, whenever a user references a library function, the PLC system will copy the library package of the function to the project directory. This is the distribution of the system library. In addition, as the product is updated, new system libraries may be added, and new library packages need to be distributed to users.
[0138] 2. For user libraries, once the library package is published and exported, it can be used by host users of other different PLC servers. This is the circulation of user libraries.
[0139] A package management-based library calling method in the PLC compiler. Based on the different sources of the packages, the current implementation scheme can be divided into the following two types. The steps are as follows:
[0140] System library functions are built into the PLC system by PLC developers before each product release based on the national standard IEC 61131 or personalized user requirements. Therefore, any user who uses this version of PLC can use the system library functions.
[0141] User library functions are first written by one user. After successful compilation and release, other users can import and use them.
[0142] (1) System library
[0143] Step 1: During the PLC system development phase, developers package some commonly used instructions into library files. Commonly used instructions can be found in the national standard IEC 61131 instruction list, including logic operation instructions, data processing instructions, timer and counter instructions, etc.
[0144] When the user references a library function during the development phase, the three related descriptions or configuration files (organized in a unified directory structure) are compressed and packaged and copied to the project directory.
[0145] Step 2: Select the library file: Open the PLC program and select the library function to be imported in the sidebar.
[0146] Step 3: Load library file: Drag and drop the selected library function to the programming area and copy it from the existing project to the library.
[0147] Step 4: When coding, the user calls the function or function block in the library. The calling process is: follow the prompts to pass in the specified type and number of parameters;
[0148] Step 5: During compilation, the PLC compiler unpacks the user library and generates three interface description files: interface attribute configuration file (with .func as the suffix), interface declaration file (with .itf as the suffix), and interface operation file (with .out as the suffix). Unpacking decompresses the function file in the project directory and restores a unified directory structure to facilitate the system to read file data.
[0149] Step 6: When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inline with the user program into one file or assemble into an executable file set. During the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
[0150] (2) User Library
[0151] Step 1: Library creation: Create a new library project, add program units, and use PLC programming language to write the user library function or function block algorithm implementation according to your needs to complete the package creation;
[0152] Step 2: Library packaging: add user library, which will be automatically installed locally after successful compilation and installed on the remote project server after publishing;
[0153] Step 3: Use the user library: Other users can install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module. At this time, the user can call the function or function block in the user library.
[0154] Step 4: During compilation, the PLC compiler unpacks the user library file and generates the same three description files: interface property configuration file (with .func as the suffix), interface declaration file (with .itf as the suffix), and interface operation file (with .out as the suffix).
[0155] Step 5: During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface run files into an executable file set.
[0156] The system library and the user library are in parallel. The system library is the system's built-in library functions, and the user library is the user-defined library functions. Both are designed to achieve code modularization and reuse, and the organizational structure of the library package is similar; however, there are differences in the generation, management, and calling methods.
[0157] In terms of functions, user libraries implement more advanced functions by calling the interfaces provided by system libraries, which means that user libraries can use or not use system libraries. This also determines their dependency relationship: user libraries rely on the interfaces provided by system libraries to implement their functions, while system libraries provide underlying support for user libraries.
[0158] The system library and user library files together constitute the reference library module of the PLC compiler project.
[0159] The structure of a library is organized through the following modules.
[0160] A.Category: Catalog of library categories
[0161] B.Libraries: library functions and function blocks in a library directory
[0162] C.LibContent: Description of a library element of a library function version
[0163] Package management is implemented through the Libset class and the LibStructManager class. The library configuration information is stored in the Libset class, including the following information:
[0164] A. “Display”: front-end display information;
[0165] B. "EnEno": ENENO mode description;
[0166] C. "Generic": true if this library function has multiple implementations, false otherwise;
[0167] D. "Implementations": Each library function has at least one optional type of implementation;
[0168] E. "Interface": describes the interface information of the library function;
[0169] F. "Selection": Lists all optional types of implementations. If there is only one implementation, it will be empty;
[0170] G. "Name": library name;
[0171] H. "PLC": PLC version;
[0172] I. "Type": FC / FB;
[0173] J. "Language": supported programming languages, such as ST, LD;
[0174] The LibStructManager class can access all Libset objects and provide methods for adding, deleting, and managing versions of libraries.
[0175] System libraries and user libraries are managed in a similar way:
[0176] The library files provided by the system are called through the "Library Manager". The library files can be used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attributes, and version information provided by the library manager and add them to the project. These POUs can be copied from existing projects to the library, or users can define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries will be automatically integrated into the project.
[0177] Each library exists in the form of a compressed file with a ".lib" suffix. Each ".lib" file may include the following:
[0178] A. "library" describes the information of a series of functions or function blocks of the same type of operation, including PLC version, Category library category, library version, serial number, etc.;
[0179] B. "Library function name.func" describes the interface attribute configuration information of a specific function or function block, and is the description file of the Libset object of the function;
[0180] C. "Library function name.out" interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information;
[0181] D. "Library function name.itf" interface declaration file: describes the interface prototype of the library function or function block.
[0182] Take the limit function as an example;
[0183] The "libraries.library" file describes the category of the function, which belongs to the selection function of the basic function library, is the Xth function in this category, and supports all PLC versions;
[0184] "limit+type name+version.itf" describes the prototype of calling this function, including parameter list, return value, namespace, etc., such as STD::bool limit(int, int, int);
[0185] "limit+type name+version.out" is the compiled product that implements the function of limiting the value range of variables of this type and is semi-readable;
[0186] "limit+type name+version.func" records the information of the libset class corresponding to the function and saves the above file name information, which plays an important role in the linking process.
[0187] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.
[0188] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. A call library system based on package management in a PLC compiler, characterized in that: include: System library module: It is a system built-in library function. When a user references a system built-in library function, the PLC system copies the library package of the system built-in library function to the project directory, distributes the system library, and provides underlying support for the user library. User library module: implements functions according to the interface provided by the system library, customizes library functions for users, and after successful compilation and release, other users can import and use them.
2. The calling library system based on package management in the PLC compiler according to claim 1, characterized in that: Both system libraries and user libraries are organized and used in the form of library packages: For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, new system libraries are distributed to users when updates are released; For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
3. The calling library system based on package management in the PLC compiler according to claim 1, characterized in that: In the system library module: During the PLC system development phase, developers package instructions into library files, including logic operation instructions, data processing instructions, timer and counter instructions; When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory; Select library file: Open the PLC program and select the library function to be imported in the sidebar; Load library file: Drag the selected library function to the programming area or directly enter the function name in the programming area, and the library file will be copied from the system directory to the project directory; When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted; During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure. When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
4. The calling library system based on package management in the PLC compiler according to claim 1, characterized in that: In the user library module: Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation; Library packaging: add user libraries, automatically install them locally after successful compilation, and install them on the remote project server after publishing; Use user library: other users can use the import function of the user library management module to install the user library files in the remote directory to the local computer or project server, and then call the function or function block in the user library; During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out; During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
5. The calling library system based on package management in the PLC compiler according to claim 1, characterized in that: Management methods used for system libraries and user libraries: The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project. Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents: Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version; The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function; Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information; Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
6. A calling library method based on package management in a PLC compiler, characterized in that: include: Step S1: The system library module is a system built-in library function. When a user references a library function, the PLC system copies the library package of the function to the project directory, distributes the system library, and provides underlying support for the user library. Step S2: The user library module implements functions according to the interface provided by the system library. The user defines the library function and writes the program. After successful compilation and release, other users can import and use it.
7. The calling library method based on package management in the PLC compiler according to claim 6, characterized in that: Both system libraries and user libraries are in the form of library packages: For system libraries, whenever a user references a library function, the PLC system copies the library package of the function to the project directory. For the distribution of system libraries, a new library package is added to distribute new system libraries to users; For user libraries, library packages are published and exported, and used by host users of other different PLC servers, for the circulation of user libraries.
8. The calling library method based on package management in the PLC compiler according to claim 6, characterized in that: In the system library module: During the PLC system development phase, developers package instructions into library files, including logic operation instructions, data processing instructions, timer and counter instructions; When a user references a library function during the development phase, the three related descriptions or configuration files are compressed and packaged according to a unified directory organization structure and copied to the project directory; Select library file: Open the PLC program and select the library function to be imported in the sidebar; Load library file: drag the selected library function to the programming area to copy from an existing project to the library; When coding, the user calls a function or function block in the library. The calling process is as follows: pass in the specified type and number of parameters as prompted; During compilation, the PLC compiler unpacks the user library and generates three interface description files. The interface attribute configuration file has a .func suffix, the interface declaration file has a .itf suffix, and the interface operation file has a .out suffix. Unpacking decompresses the function file in the project directory and restores a unified directory structure. When linking, the PLC compiler performs inline and assembly operations according to the type of interface, inlining it with the user program into one file or assembling it into an executable file set; in the linking stage, the compiler reads the interface attribute configuration file and selects different linking methods according to the interface type.
9. The calling library method based on package management in the PLC compiler according to claim 6, characterized in that: In the user library module: Library creation: Create a new library project, add program units, and users use PLC programming language to write the user library function or function block algorithm implementation according to their needs to complete the package creation; Library packaging: add user libraries, automatically install them locally after successful compilation, and install them on the remote project server after publishing; Use user library: other users install the user library files in the remote directory to the local machine or project server through the installation function of the user library management module, and the user calls the function or function block in the user library; During compilation, the PLC compiler unpacks the user library file and generates three description files: the interface attribute configuration file has a suffix of .func, the interface declaration file has a suffix of .itf, and the interface operation file has a suffix of .out; During linking, the PLC compiler uses the unpacked files to verify and assemble the user code and interface runtime files into an executable file set.
10. The calling library method based on package management in the PLC compiler according to claim 6, characterized in that: Management methods used for system libraries and user libraries: The library files provided by the system are called through the library manager. The library files are used to store algorithms and logics that will be reused in the program. They are encapsulated in the form of program organization units (POUs), which are actually a series of compressed packages, each with specific functions. Users select the library files they need to call based on the type, attribute and version information provided by the library manager and add them to the project. POUs are copied from existing projects to the library, or users define their own libraries by creating new library projects. If the libraries used in the project depend on other libraries, these referenced libraries are automatically integrated into the project. Each library exists in the form of a compressed file with a .lib suffix. Each .lib file contains the following contents: Library describes the information of a series of functions or function blocks of the same type of operation, including PLC version, library category, serial number and library version; The library function name.func describes the interface attribute configuration information of a specific function or function block and is the description file of the function; Library function name.out interface running file: contains the compiled generated file of the function and algorithm, including function dependencies, parameter members and fingerprint information; Library function name.itf interface declaration file: describes the interface prototype of the library function or function block.
Citation Information
Patent Citations
Application program automatic identification and installation method, system and device and storage medium
CN117270896A
Novel code library management method in smart medical scene
CN117270952A