Target program running method and device, electronic equipment and storage medium

By compiling the target program organization unit in the target program and generating the symbol table, the problems of large amount of download data and low efficiency in the existing technology are solved, and efficient compilation and downloading process is achieved.

CN119645537APending Publication Date: 2025-03-18HANGZHOU HOLLYSYS AUTOMATION
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411789466.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-06
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In the prior art, all program organization units in the target program need to be compiled and generated executable programs, and then loaded to the controller, resulting in large amount of download data and low loading efficiency.

Method used

By obtaining at least two program organization units in the target program, at least one target program organization unit is determined, each target program organization unit is compiled, executable files and symbol table files are generated, and these files are then loaded to the controller, so that the controller determines the jump address through the symbol table file to jump and run.

Benefits of technology

It avoids compiling all program organization units, improves compilation speed, realizes the separate operation of each executable file, reduces the amount of download data and improves the efficiency of downloading.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645537A_ABST
    Figure CN119645537A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial control, and provides a target program running method and device, electronic equipment and a storage medium. The method comprises the steps of obtaining a target program comprising at least two program organization units, and determining at least one target program organization unit from the target program; compiling each target program organization unit to obtain an executable file corresponding to each target program organization unit; according to each executable file, generating a symbol table file corresponding to each target program organization unit; the executable file and the symbol table file are downloaded to the controller, so that when the controller executes the executable file, the controller determines the jump address through the symbol table file to jump and run, only the target program organization unit is compiled, compiling of all the program organization units is avoided, the compiling speed is increased, and the compiling efficiency is improved. Subsequently, a symbol file table is generated through the executable file corresponding to each target program organization unit, and then independent operation of each executable file is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial control technology, and in particular to a method, device, electronic device and storage medium for running a target program. Background Art

[0002] The controller in the industrial control system is usually an embedded device, and the configuration software runs on the host computer. Through the host computer configuration software, users can use industrial programming languages ​​(for example, IEC 61131-3 language) to configure and program the control logic. After completing the logic configuration and obtaining the target program, the target program needs to be compiled into an executable program and downloaded to the controller device for execution.

[0003] The target program of each task usually consists of multiple Programming Organization Units (POUs). However, traditional compilation requires all program organization units to be fully compiled and linked to generate a complete executable program. This method requires the entire executable program to be downloaded each time, including all referenced POUs, regardless of whether these POUs have actually changed. This not only increases the complexity of the downloaded data, but also significantly increases the download time, reducing development efficiency and system response speed. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a method, device, electronic device and storage medium for running a target program to solve the problem in the prior art that all program organization units in the target program need to be compiled into an executable program and then downloaded to a controller, resulting in a large amount of downloaded data and low download efficiency.

[0005] According to a first aspect of an embodiment of the present application, a method for running a target program is provided, the method comprising: obtaining a target program including at least two program organization units, and determining at least one target program organization unit from the target program; compiling each target program organization unit to obtain an executable file corresponding to each target program organization unit; generating a symbol table file corresponding to each target program organization unit according to each executable file, the symbol table file containing a jump address corresponding to a symbol in the executable file; downloading the executable file and the symbol table file to a controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run.

[0006] According to a second aspect of an embodiment of the present application, a target program running device is provided, the device comprising: a determination module, used to obtain a target program including at least two program organization units, and determine at least one target program organization unit from the target program; a compilation module, used to compile each target program organization unit to obtain an executable file corresponding to each target program organization unit; a generation module, used to generate a symbol table file corresponding to each target program organization unit according to each executable file, the symbol table file containing a jump address corresponding to the symbol in the executable file; a download module, used to download the executable file and the symbol table file to a controller, so that when the controller executes the executable file, the jump address is determined by the symbol table file to jump and run.

[0007] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0008] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0009] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the method of the embodiments of the present application obtains a target program including at least two program organization units, determines at least one target program organization unit from the target program; compiles each target program organization unit to obtain an executable file corresponding to each target program organization unit; generates a symbol table file corresponding to each target program organization unit according to each executable file, and the symbol table file contains a jump address corresponding to the symbol in the executable file; the executable file and the symbol table file are downloaded to the controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run, the present application only compiles the target program organization unit, avoids compiling all program organization units, and improves the compilation speed, and subsequently generates a symbol file table through the executable file corresponding to each target program organization unit, so that the controller can execute the executable file according to the corresponding symbol file table, thereby realizing the separate operation of each executable file, avoiding the problem in the related art that all program organization units in the target program need to be compiled to generate an executable program, and then downloaded to the controller, resulting in a large amount of downloaded data and low download efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0011] Figure 1 It is a flowchart of a method for running a target program provided in an embodiment of the present application;

[0012] Figure 2 It is a flowchart of another method for running a target program provided in an embodiment of the present application;

[0013] Figure 3 It is a flowchart of a single-point download program organization unit provided in an embodiment of the present application;

[0014] Figure 4 It is a flowchart of another method for running a target program provided in an embodiment of the present application;

[0015] Figure 5 It is a schematic diagram of a flow chart of generating a symbol table file for a target program organization unit provided by an embodiment of the present application;

[0016] Figure 6 It is a flowchart of another method for running a target program provided in an embodiment of the present application;

[0017] Figure 7 It is another flow chart of generating a symbol table file for a target program organization unit provided by an embodiment of the present application;

[0018] Figure 8 It is a schematic diagram of a flow chart of a controller executing an executable file provided in an embodiment of the present application;

[0019] Fig. 9 It is a flowchart of another method for running a target program provided in an embodiment of the present application;

[0020] Fig.10 It is a flowchart of an optional method for running a target program provided in an embodiment of the present application;

[0021] Fig.11 It is a structural schematic diagram of a target program running device provided in an embodiment of the present application;

[0022] Fig.12 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0024] A method and device for running a target program according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0025] Figure 1 This is a method for running a target program provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:

[0026] S101, obtaining a target program including at least two program organization units, and determining at least one target program organization unit from the target program;

[0027] S102, compile each target program organization unit to obtain an executable file corresponding to each target program organization unit;

[0028] S103, generating a symbol table file corresponding to each target program organization unit according to each executable file, wherein the symbol table file contains a jump address corresponding to the symbol in the executable file;

[0029] S104: Download the executable file and the symbol table file to the controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run.

[0030] It can be understood that the target program operation method provided in the present application is applied to a host computer, the configuration software belongs to the host computer, and the host computer configuration software uses an industrial programming language to perform logic configuration programming to obtain the target program.

[0031] It can be understood that the present application does not limit the types of the above-mentioned industrial programming languages. The industrial programming language only needs to conform to the standards of the programming systems of programmable logic controllers (PLC), DCS, IPC, CNC, and SCADA. Exemplarily, the industrial programming language is the IEC61131-1 language. The types of industrial programming languages ​​include ST, SFC, LD, FBD, etc.

[0032] It can be understood that the program organization unit is the basic programming unit in industrial programming languages. POU consists of three types of basic units: program, function block, and function.

[0033] It can be understood that if the target program contains only one program organization unit, then each time it is downloaded, it is necessary to compile and link this program organization unit. There is no problem proposed in the present application that all program organization units in the target program need to be compiled to generate an executable program and then downloaded to the controller, resulting in a large amount of downloaded data and low download efficiency.

[0034] Based on the above reasons, if the target program contains only one program organization unit, the program organization unit can be directly compiled and downloaded; if the target program contains at least two program organization units, then after obtaining the target program, this application will determine at least one target program organization unit from the target program, and the target program organization unit is the program organization unit that needs to be compiled and downloaded to the controller subsequently.

[0035] Exemplarily, if there are three program organization units A, B, and C in the target program, the present application determines at least one target program unit from the three program organization units A, B, and C, and the target program unit can be at least one of the A program organization unit, the B program organization unit, and the C program organization unit.

[0036] In some examples, after determining the target program organization unit, the present application will compile each target program organization unit to obtain the executable file corresponding to each target program organization unit, and the program organization units that are not the target program organization units will not be processed; specifically, if there are three program organization units A, B, and C in the target program, and it is determined that the B and C program organization units are respectively a target program organization unit, then the B program organization unit and the C program organization unit are compiled respectively to obtain the executable file corresponding to the B program organization unit and the executable file corresponding to the C program organization unit, and before the A program organization unit is determined as the target program organization unit, the A program organization unit will not be compiled.

[0037] The above method determines the target program organization unit from the target program, and subsequently only compiles the target program organization unit, thereby improving the compilation speed and avoiding the problem of slowing down the compilation speed caused by directly compiling all program organization units.

[0038] In some examples, after obtaining the executable file corresponding to each target program organization unit, the present application will also generate a symbol table file corresponding to each target program organization unit based on each executable file, and the symbol table file contains the jump address corresponding to the symbol in the executable file (the address where the program is actually loaded + the relative offset address); illustratively, if there are N executable files, N symbol table files are generated; specifically, if there are three program organization units A, B, and C in the target program, and it is determined that the B and C program organization units are respectively a target program organization unit, then the B program organization unit and the C program organization unit are compiled respectively to obtain the B executable file corresponding to the B program organization unit and the C executable file corresponding to the C program organization unit, and subsequently generate the B symbol table file according to the B executable file and the C symbol table file according to the C executable file.

[0039] After generating the symbol table file, the present application downloads the executable file and the symbol table file to the controller, so that the controller executes the executable file by determining the jump address through the symbol table file to jump and run; specifically, taking the target program as an example, in which three program organization units A, B, and C are included, and it is determined that the B and C program organization units are respectively a target program organization unit, then the B program organization unit and the C program organization unit are respectively compiled to obtain the B executable file corresponding to the B program organization unit, and to obtain the C executable file corresponding to the C program organization unit, and then the B symbol table file is generated according to the B executable file, and the C symbol table file is generated according to the C executable file, and then the B executable file, the C executable file, the B symbol table file, and the C symbol table file are respectively downloaded to the controller, and when the controller executes the B executable file, the address corresponding to the symbol in the B executable file is searched through the B symbol table file, so as to jump and run, and when the controller executes the C executable file, the address corresponding to the symbol in the C executable file is searched through the C symbol table file, so as to jump and run.

[0040] According to the technical solution provided in the embodiment of the present application, a target program including at least two program organization units is obtained, and at least one target program organization unit is determined from the target program; each target program organization unit is compiled to obtain an executable file corresponding to each target program organization unit; a symbol table file corresponding to each target program organization unit is generated according to each executable file, and the symbol table file contains a jump address corresponding to the symbol in the executable file; the executable file and the symbol table file are downloaded to a controller, so that when the controller executes the executable file, the jump address is determined by the symbol table file to jump and run. The present application only compiles the target program organization unit, avoids compiling all program organization units, and improves the compilation speed. Subsequently, a symbol file table is generated through the executable file corresponding to each target program organization unit, so that the controller can execute the executable file according to the corresponding symbol file table, thereby realizing the separate operation of each executable file, avoiding the problem in the related art that all program organization units in the target program need to be compiled to generate an executable program and then downloaded to the controller, resulting in a large amount of downloaded data and low download efficiency.

[0041] In some embodiments, Figure 2 As shown, the method also includes:

[0042] S201, if any target program organization unit is updated, generating a new executable file according to the updated target program organization unit;

[0043] S202: Generate a new symbol table file corresponding to the updated target program organization unit according to the new executable file, and download the new symbol table file and the new executable file to the controller.

[0044] It can be understood that when the user modifies a single (or multiple) POUs, only the compiled instructions of the modified POU are downloaded when downloading to the controller, and the unmodified POU program does not need to be downloaded, thereby reducing the downloaded data and improving the download speed. At the same time, it solves the problem that after the user modifies a single POU due to slow compilation and linking, the download of the single POU requires a long compilation process, resulting in the user being unable to submit the modified POU online in real time. This realizes the single-point download of the control logic configuration software based on compilation and execution when the configuration software is online.

[0045] It can be understood that if the user updates any target program organization unit, the present application will generate a new executable file based on the updated target program organization unit; based on the new executable file, a new symbol table file corresponding to the updated target program organization unit is generated, and the new symbol table file and the new executable file are downloaded to the controller.

[0046] For example, taking the target program including three program organization units A, B, and C as an example, and determining that the B and C program organization units are respectively a target program organization unit, the B program organization unit and the C program organization unit are respectively compiled to obtain the B executable file corresponding to the B program organization unit, and the C executable file corresponding to the C program organization unit. Subsequently, a B symbol table file is generated according to the B executable file, and a C symbol table file is generated according to the C executable file. Subsequently, the B executable file, the C executable file, the B symbol table file, and the C symbol table file are respectively downloaded to the controller. When the controller executes the B executable file, the B symbol table file is used to search for the symbol table file in the B executable file. The address corresponding to the symbol is found, so as to jump and run. When the controller executes the C executable file, the address corresponding to the symbol in the C executable file is searched through the C symbol table file, so as to jump and run. If the B program organization unit is updated subsequently, a new B executable file is generated according to the updated B program organization unit, and then a new B symbol table file corresponding to the updated B program organization unit is generated according to the new B executable file, and the new B symbol table file and the new B executable file are downloaded to the controller, thereby realizing single-point downloading, avoiding the need to recompile and link all the program organization units in the target program, resulting in excessive downloading data volume and low downloading efficiency.

[0047] In some examples, if the program organization unit in the target program is adjusted to a target program organization unit, a new executable file is also generated according to the new target program organization unit, and a new symbol table file corresponding to the updated target program organization unit is generated according to the new executable file, and the new symbol table file and the new executable file are downloaded to the controller. Exemplarily, taking the target program as an example, in which three program organization units A, B, and C are included, and it is determined that the B and C program organization units are respectively a target program organization unit, the B program organization unit and the C program organization unit are respectively compiled to obtain the B executable file corresponding to the B program organization unit, and the C executable file corresponding to the C program organization unit. Subsequently, a B symbol table file is generated according to the B executable file, and a C symbol table file is generated according to the C executable file. Subsequently, the B executable file, the C executable file, the B symbol table file, and the C symbol table file are respectively downloaded to the controller. When the controller executes the B executable file, the B symbol table file is searched The address corresponding to the symbol in the B executable file is searched for in the C executable file, thereby jumping to the execution. When the controller executes the C executable file, the address corresponding to the symbol in the C executable file is searched through the C symbol table file, thereby jumping to the execution. If the A program organization unit is subsequently adjusted to the target program organization unit, the A program organization unit is compiled to obtain the A executable file corresponding to the A program organization unit. Subsequently, the A symbol table file is generated according to the A executable file, and then the A executable file and the A symbol table file are respectively downloaded to the controller. When the controller executes the A executable file, the address corresponding to the symbol in the A executable file is searched for through the A symbol table file, thereby jumping to the execution.

[0048] For example, Figure 3 As shown, the user can modify a single POU in the target program. After the modification is completed, the single POU is compiled to obtain an executable file corresponding to the single POU, and then the executable file and the corresponding symbol table file are downloaded to the controller for operation.

[0049] According to the technical solution provided in the embodiment of the present application, if any target program organization unit is updated, a new executable file is generated according to the updated target program organization unit; according to the new executable file, a new symbol table file corresponding to the updated target program organization unit is generated, and the new symbol table file and the new executable file are downloaded to the controller. When the POU is updated, the present application realizes the single-point download of the POU, avoiding the problem of low compilation and downloading efficiency caused by the need to compile, link, and download the entire target program when the POU is updated.

[0050] In some embodiments, Figure 4 As shown, each target program organization unit is compiled to obtain an executable file corresponding to each target program organization unit, including:

[0051] S401, converting the target program organization unit into a programming language file corresponding to a preset programming language;

[0052] S402: Compile the programming language file to obtain an executable file.

[0053] Specifically, the preset programming language includes but is not limited to one of C language and C++ language. The preset programming language being C language is taken as an example below.

[0054] like Figure 5 As shown, the user uses IEC language for configuration, and the configuration unit is POU. After determining the target program organization unit, this application converts the above target program organization unit into a programming language file corresponding to C language, and then compiles the programming language file to obtain a .o executable file.

[0055] It can be understood that those skilled in the art can flexibly select a C language compiler to compile a programming language file corresponding to the C language into a .o executable file.

[0056] According to the technical solution provided in the embodiment of the present application, the target program organization unit is converted into a programming language file corresponding to a preset programming language; the programming language file is compiled to obtain an executable file. The present application realizes immediate compilation of the target program organization unit to obtain an executable file.

[0057] In some embodiments, Figure 6 As shown, according to each executable file, a symbol table file corresponding to each target program organization unit is generated, including:

[0058] S601, parsing the executable file to obtain debugging information;

[0059] S602: Obtain a symbol file corresponding to the programming language file, determine a mapping relationship between symbols in the symbol file and binary instruction addresses according to the debugging information and the symbol file, and generate a symbol table file based on the mapping relationship.

[0060] Specifically, when the target program organization unit is converted into a programming language file corresponding to a preset programming language, the present application will generate a symbol file corresponding to the programming language; for example, Figure 5 As shown, taking the programming language as C language as an example, when the target program organization unit is converted into a C language file, a symbol file in the C code will be generated.

[0061] Then this example generates a symbol table file based on the .o executable file and the symbol file. Specifically, this application will parse the executable file to obtain debugging information; then obtain the symbol file corresponding to the programming language file, determine the mapping relationship between the symbols in the symbol file and the binary instruction address based on the debugging information and the symbol file, and generate a symbol table file based on the mapping relationship.

[0062] For example, Figure 7 As shown, the present application provides a linker, which parses the debugging information of the current file from the .o file, obtains the jump address of the symbol generated when the POU is converted into a C language programming file from the debugging information, and then generates a symbol table file for downloading and running; wherein, the linker directly obtains the code segment from the .o executable file, and does not involve various program instruction sets, wherein there are also various open source tools that can be directly used to copy the code segment; such as Figure 8 As shown, when the executable file is downloaded to the controller and run, the downloaded executable file is loaded and the symbol table file corresponding to the executable file is loaded; when the executable file is executed, the symbols of other executable files are called and generated when other executable files are loaded; the symbol table file of the current executable file can be used to call other executable files and can also be used to call the current executable file itself; when the executable file is running, the address corresponding to the symbol in the executable file is searched through the symbol table file, so as to jump and run.

[0063] It is understandable that C language / C++ language, as a commonly used programming language and embedded language, can run well in embedded controllers with high operating efficiency. EC language is converted to C language, and a variety of free and open source C code compilers can be used to solve the problem of great difficulty in developing and maintaining compilers. The input of the linker provided by the present application is only the .o executable file and the corresponding symbol file to be processed, and does not involve various problems of traditional linkers. It only needs to parse to obtain debugging information and copy code segments, avoiding the need to input all .o executable files during full linking, which leads to the high time-consuming disk seek and IO when searching for many .o executable files. It only needs to process the .o executable file generated by the modified (or updated, specified) POU, and only a single POU is required during downloading. The program can be freely loaded in the free memory space at runtime, and the symbol table file is loaded. When the executable file is running, the corresponding instruction address (the actual loaded address of the program + the relative offset address) is found from the symbol table file to complete the jump. The multi-task of the present application can share the code area, thereby avoiding the process of linking each task during multi-tasking. There is no need to load multiple copies of code for the same POU according to the task during runtime, which greatly reduces the occupation of the code area and saves the occupation of memory space. This solution solves many disadvantages of the existing solutions.

[0064] According to the technical solution provided in the embodiment of the present application, the executable file is parsed to obtain debugging information; the symbol file corresponding to the programming language file is obtained, and the mapping relationship between the symbols in the symbol file and the binary instruction addresses is determined based on the debugging information and the symbol file, and a symbol table file is generated based on the mapping relationship. The present application realizes the generation of a symbol table file for an executable file.

[0065] In some embodiments, Fig. 9 As shown, determining at least one target program organization unit from the target program includes:

[0066] S901, obtaining a target determination instruction;

[0067] S902: Determine a target program organization unit from at least two program organization units of the target program according to the target determination instruction.

[0068] Specifically, when the user needs to debug one or more POUs or needs to use one or more POUs, the user can issue a target determination instruction, which is used to specify a program organization unit from the target program as a target program organization unit.

[0069] For example, taking the target program containing three program organization units A, B, and C as an example, if the user needs to debug program organization unit A, then input a target determination instruction to use program organization unit A as the target organization unit, and the host computer subsequently uses program organization unit A as the target organization unit according to the target determination instruction.

[0070] According to the technical solution provided in the embodiment of the present application, a target determination instruction is obtained; a target program organization unit is determined from at least two program organization units of the target program according to the target determination instruction. The present application realizes accurate determination of the target program organization unit.

[0071] In some embodiments, Fig.10 As shown, before downloading the executable file and the symbol table file to the controller, the method further includes:

[0072] S1001. Obtain industrial control requirements;

[0073] S1002. Perform logic configuration programming according to industrial control requirements to obtain a target program.

[0074] Specifically, the user outputs industrial control requirements according to the actual effect that the industrial control wants to achieve, and performs logic configuration programming according to the industrial control requirements to obtain the target program.

[0075] It can be understood that after the logic configuration programming is performed by the host computer configuration software using the IEC61131-3 language, the configuration software compiles it into an executable file in units of tasks and downloads it to the controller device to run in the controller.

[0076] According to the technical solution provided in the embodiment of the present application, industrial control requirements are obtained; logical configuration programming is performed according to the industrial control requirements to obtain a target program, thereby realizing the construction of the target program.

[0077] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.

[0078] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0079] This embodiment also provides a target program running device, such as Fig.11 As shown, the device comprises:

[0080] A determination module 1101 is used to obtain a target program including at least two program organization units, and determine at least one target program organization unit from the target program;

[0081] A compiling module 1102 is used to compile each target program organization unit to obtain an executable file corresponding to each target program organization unit;

[0082] A generating module 1103 is used to generate a symbol table file corresponding to each target program organization unit according to each executable file, wherein the symbol table file contains jump addresses corresponding to symbols in the executable file;

[0083] The download module 1104 is used to download the executable file and the symbol table file to the controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run.

[0084] In some examples, the compilation module 1102 is also used to generate a new executable file based on the updated target program organization unit when any target program organization unit is updated; the generation module 1103 is also used to generate a new symbol table file corresponding to the updated target program organization unit based on the new executable file, and download the new symbol table file and the new executable file to the controller.

[0085] In some examples, the compiling module 1102 is further used to convert the target program organization unit into a programming language file corresponding to a preset programming language; and compile the programming language file to obtain an executable file.

[0086] In some examples, the generation module 1103 is also used to obtain a symbol file corresponding to a programming language file, parse the executable file, and obtain debugging information; obtain the symbol file corresponding to the programming language file, determine the mapping relationship between symbols in the symbol file and binary instruction addresses based on the debugging information and the symbol file, and generate a symbol table file based on the mapping relationship.

[0087] In some examples, the determination module 1101 is further used to obtain a target determination instruction; and determine a target program organization unit from at least two program organization units of the target program according to the target determination instruction.

[0088] In some examples, the determination module 1101 is also used to obtain industrial control requirements; perform logic configuration programming according to the industrial control requirements to obtain a target program.

[0089] According to the technical solution provided by the embodiment of the present application, the target program running device provided by the present embodiment obtains a target program including at least two program organization units, determines at least one target program organization unit from the target program; compiles each target program organization unit to obtain an executable file corresponding to each target program organization unit; generates a symbol table file corresponding to each target program organization unit according to each executable file, and the symbol table file contains a jump address corresponding to the symbol in the executable file; the executable file and the symbol table file are downloaded to the controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run. The present application only compiles the target program organization unit, avoids compiling all program organization units, and improves the compilation speed. Subsequently, a symbol file table is generated through the executable file corresponding to each target program organization unit, so that the controller can execute the executable file according to the corresponding symbol file table, thereby realizing the separate operation of each executable file, avoiding the problem in the related art that all program organization units in the target program need to be compiled to generate an executable program and then downloaded to the controller, resulting in a large amount of downloaded data and low download efficiency.

[0090] Fig.12 Schematic diagram of an electronic device 12 provided in an embodiment of the present application. Fig.12 As shown, the electronic device 12 of this embodiment includes: a processor 1201, a memory 1202, and a computer program 1203 stored in the memory 1202 and executable on the processor 1201. When the processor 1201 executes the computer program 1203, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1201 executes the computer program 1203, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0091] The electronic device 12 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 12 may include, but is not limited to, a processor 1201 and a memory 1202. Those skilled in the art will appreciate that Fig.12 The electronic device 12 is merely an example and does not limit the electronic device 12 , and may include more or fewer components than those shown in the figure, or different components.

[0092] The processor 1201 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0093] The memory 1202 may be an internal storage unit of the electronic device 12, for example, a hard disk or memory of the electronic device 12. The memory 1202 may also be an external storage device of the electronic device 12, for example, a plug-in hard disk, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 12. The memory 1202 may also include both an internal storage unit of the electronic device 12 and an external storage device. The memory 1202 is used to store computer programs and other programs and data required by the electronic device.

[0094] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0095] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of regional requirements and patent practice. For example, in some areas, according to regional requirements and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.

[0096] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for running a target program, characterized in that: The method comprises: Acquire a target program including at least two program organization units, and determine at least one target program organization unit from the target program; Compiling each of the target program organization units to obtain an executable file corresponding to each of the target program organization units; Generate a symbol table file corresponding to each target program organization unit according to each executable file, wherein the symbol table file contains jump addresses corresponding to symbols in the executable file; The executable file and the symbol table file are downloaded to a controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run.

2. The method according to claim 1, characterized in that The method further comprises: If any of the target program organization units is updated, a new executable file is generated according to the updated target program organization unit; According to the new executable file, a new symbol table file corresponding to the updated target program organization unit is generated, and the new symbol table file and the new executable file are downloaded to the controller.

3. The method according to claim 1, characterized in that Compiling each of the target program organization units to obtain an executable file corresponding to each of the target program organization units includes: Converting the target program organization unit into a programming language file corresponding to a preset programming language; The programming language file is compiled to obtain the executable file.

4. The method according to claim 3, characterized in that Generate a symbol table file corresponding to each target program organization unit according to each of the executable files, including: Obtaining a symbol file corresponding to the programming language file, parsing the executable file, and obtaining debugging information; A symbol file corresponding to the programming language file is obtained, a mapping relationship between symbols in the symbol file and binary instruction addresses is determined according to the debugging information and the symbol file, and the symbol table file is generated based on the mapping relationship.

5. The method according to claim 1, characterized in that Determining at least one target program organization unit from the target program includes: Get target determination instructions; A target program organization unit is determined from at least two program organization units of the target program according to the target determination instruction.

6. The method according to claim 1, characterized in that Before downloading the executable file and the symbol table file to the controller, the method further includes: Obtain industrial control requirements; Logic configuration programming is performed according to the industrial control requirements to obtain the target program.

7. A target program running device, characterized in that: The device comprises: A determination module, configured to obtain a target program including at least two program organization units, and determine at least one target program organization unit from the target program; A compiling module, used for compiling each of the target program organization units to obtain an executable file corresponding to each of the target program organization units; A generating module, for generating a symbol table file corresponding to each target program organization unit according to each executable file, wherein the symbol table file contains a jump address corresponding to a symbol in the executable file; The download module is used to download the executable file and the symbol table file to the controller, so that when the controller executes the executable file, it determines the jump address through the symbol table file to jump and run.

8. The device according to claim 7, characterized in that The compilation module is also used to generate a new executable file according to the updated target program organization unit when any of the target program organization units is updated; the generation module is also used to generate a new symbol table file corresponding to the updated target program organization unit according to the new executable file, and download the new symbol table file and the new executable file to the controller.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Compiling method and device of programmable logic control system and electronic equipment

    CN120832151A