Industrial program file processing method and device

By analyzing the variable and address index data of the target program file before compilation, the address offset is directly obtained, which solves the problem of space and time-consuming macro definition constants in the compilation process of binary file, and realizes a more efficient compilation process.

CN119536738APending Publication Date: 2025-02-28HANGZHOU HOLLYSYS AUTOMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411587579.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In the prior art, during the compilation process of binary files, macro definition constants occupy a large amount of code segment space, which is relatively low in efficiency, affecting product release efficiency.

Method used

Before compiling, analyze the target program file, determine the address index data of variables and variables, and directly obtain the address offset of the address index data during compilation, and then determine the address of the variables, and generate runnable program files.

Benefits of technology

It reduces the use of macro definition constants, reduces the space usage of code segments and compilation time, and significantly improves compilation efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536738A_ABST
    Figure CN119536738A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of industrial programming, and provides an industrial program file processing method and device. The method comprises the following steps: analyzing a to-be-compiled target program file, and determining all variables in the target program file and address index data of each variable; the target program file is compiled, address offsets corresponding to the address index data in the target program file are determined, the address of each variable is determined based on the address offsets, a runnable program file corresponding to the target program file is obtained, and the runnable program file runs based on the addresses. According to the method, the target program file is analyzed before compiling to determine the variable and the address index data of the variable, the address offset of the variable corresponding to the address index data can be directly obtained in the compiling process, and then the address is determined. The address offset determined based on the address index data does not occupy the code segment space, so that the time consumption related to the macro definition constant is reduced, the code segment space occupation is reduced, and the compiling efficiency is obviously improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial programming technology, and in particular to a method and device for processing industrial program files. Background Art

[0002] In the field of industrial automation, in order to protect the security of the algorithm library, the program that runs on-site and implements the algorithm logic is usually a compiled binary file. In order to better reuse the algorithm library, the binary file usually contains the function block corresponding to the logic algorithm and the variable information of the function block. The host computer on the site obtains the variable address corresponding to the variable information of the function block in the binary file after configuration, implements the instantiation of the function block, obtains the corresponding data according to the variable address, and calls the instantiated function block.

[0003] At present, the process of determining the variable address based on variable information is implemented in the stage of compiling and generating binary files. Usually, when compiling binary files, the address offset of the corresponding variable is represented by a macro-defined constant, and then the specific variable address is determined based on the address offset and the base address. This method will generate a large number of macro-defined constants when the number of variables is large, resulting in a large amount of code segment space being occupied. At the same time, the actions of allocating addresses and generating address offset information of macro-defined constants during the compilation process are very time-consuming, which greatly affects the efficiency of product release.

[0004] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve. Summary of the invention

[0005] In view of this, an embodiment of the present application provides a method and device for processing industrial program files to solve the problem in the prior art that macro-defined constants in the compilation process of binary files occupy a large amount of code segment space and have low efficiency.

[0006] A first aspect of an embodiment of the present application provides a method for processing an industrial program file, comprising:

[0007] Analyze the target program file to be compiled, determine all variables in the target program file and the address index data of each variable;

[0008] Compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain the executable program file corresponding to the target program file. The executable program file is used to run based on the address.

[0009] A second aspect of an embodiment of the present application provides an industrial program file processing device, including:

[0010] The variable analysis module is used to analyze the target program file to be compiled, determine all variables in the target program file and the address index data of each variable;

[0011] The compiling module is used to compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain the executable program file corresponding to the target program file. The executable program file is used to run based on the address.

[0012] 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.

[0013] 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.

[0014] Compared with the prior art, the embodiments of the present application have at least the following beneficial effects: the embodiments of the present application analyze the target program file before compilation to determine the variables and address index data of the variables therein, and the address offset of the variable corresponding to the address index data can be directly obtained during the compilation process, thereby determining the corresponding address, and obtaining the compiled executable program file at the same time, and the executable program file can be run based on the address. It is no longer necessary to use macro-defined constants to represent the address offset during compilation, and the address offset determined based on the address index data will not occupy the code segment space, so the time consumption related to the macro-defined constants is reduced, the code segment space occupancy is reduced, and the compilation efficiency is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] 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.

[0016] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present application;

[0017] Figure 2 It is a flowchart of a method for processing industrial program files provided in an embodiment of the present application;

[0018] Figure 3 It is a structural schematic diagram of an industrial program file processing device provided in an embodiment of the present application;

[0019] Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0020] 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.

[0021] In the field of industrial automation, when the host computer on the field side instantiates a function block, it needs a binary file and the variable addresses of the corresponding variables in the binary file. The variable addresses serve as the basis for calling the instantiated function block. At present, the determination of the variable address occurs at the stage of compiling and generating the binary file. The macro-defined constant represents the corresponding address offset and then determines the variable address. When there are many variables, there are many macro-defined constants, which will cause a large amount of code segment space to be occupied. At the same time, the actions of allocating addresses and generating macro-defined constants are very time-consuming, which greatly affects the efficiency of product release.

[0022] This embodiment obtains the address index data of each variable before the compilation action. Therefore, during the compilation process, the corresponding address offset and address are determined based on the address index data. The representation of the address offset no longer requires macro-defined constants and does not occupy code segment space. Therefore, the related time consumption and code segment space occupation of the macro-defined constants corresponding to the original address offset are reduced, and the compilation efficiency is significantly improved.

[0023] A method and device for processing industrial program files according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.

[0024] Figure 1 1 is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a server 104 and a network 105.

[0025] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be hardware or software. When the first terminal device 101, the second terminal device 102, and the third terminal device 103 are hardware, they can be various electronic devices with display screens and support communication with the server 104, including but not limited to vehicle systems, smart phones, tablet computers, laptop portable computers, and desktop computers; when the first terminal device 101, the second terminal device 102, and the third terminal device 103 are software, they can be installed in the above electronic devices. The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be implemented as multiple software or software modules, or as a single software or software module, which is not limited in the embodiment of the present application. Further, various applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.

[0026] The server 104 may be a server that provides various services, for example, a background server that receives a request sent by a terminal device that establishes a communication connection with the server, and the background server may receive and analyze the request sent by the terminal device, and generate a processing result. The server 104 may be a single server, or a server cluster composed of several servers, or a cloud computing service center, which is not limited in the present embodiment of the application.

[0027] It should be noted that the server 104 can be hardware or software. When the server 104 is hardware, it can be various electronic devices that provide various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103. When the server 104 is software, it can be multiple software or software modules that provide various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103, or it can be a single software or software module that provides various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103, and the embodiment of the present application does not limit this.

[0028] The network 105 can be a wired network connected by coaxial cable, twisted pair and optical fiber, or it can be a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., which is not limited in the embodiments of the present application.

[0029] It should be noted that the specific types, quantities and combinations of the first terminal device 101, the second terminal device 102, the third terminal device 103, the server 104 and the network 105 can be adjusted according to the actual needs of the application scenario, and the embodiments of the present application do not limit this.

[0030] Figure 2 It is a flowchart of a method for processing industrial program files provided in an embodiment of the present application. Figure 2 The processing method can be Figure 1 The first terminal device, the second terminal device, the third terminal device or the server executes. Figure 2 As shown, the processing method includes:

[0031] S201: Analyze the target program file to be compiled, and determine all variables in the target program file and address index data of each variable;

[0032] S202: Compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain an executable program file corresponding to the target program file, the executable program file is used to run based on the address.

[0033] It is understandable that the specific program content of the target program file is analyzed to determine the variables and corresponding address index data appearing in the target program file. The analysis means include at least one of lexical analysis, syntax analysis, and semantic analysis. The information of each variable is recorded through analysis, and then the address index data of each variable is created. Therefore, the process of analyzing the target program file to be compiled and determining all variables in the target program file and the address index data of each variable may include:

[0034] The target program file to be compiled is analyzed through lexical analysis, and / or syntax analysis, and / or semantic analysis to determine all variables in the target program file and address index data of each variable.

[0035] It can be understood that the target program file to be compiled is compiled to obtain an executable file. The compilation process of the target program file can obtain the address offset corresponding to each variable. In this embodiment, the address offset is associated with the address index data, and the address offset corresponding to each address index data is actually determined and recorded. Since the address offset is associated with the address index data, the address offset does not need to be represented by a macro definition constant, and the address corresponding to each variable can be directly determined based on the association relationship, so that the compiled executable file can call the relevant variable based on the address at runtime.

[0036] Specifically, the association between address index data and address offset is essentially a variable address index table. The variable address index table can be represented as an array, a linked list or other data storage form that can store associations, which is not limited here. The variable address index table replaces the original macro-defined constant to record the address offset, reducing the large amount of code segment space that the original macro-defined constant will occupy. Since all address index data have been obtained in the early stage, it is necessary to establish a relationship between the address offset obtained in the compilation process and the address index data. In fact, the variable address index table has been created in the early stage. It is only necessary to fill the address offset obtained in the compilation process as a value into the corresponding position of the variable address index table, saving the time corresponding to the creation of the macro-defined constant when the original macro-defined constant represents the address offset. When the macro-defined constant is used to represent the address offset, a large number of string replacement operations are required in the pre-compilation stage of the compilation process. At this time, it is not necessary to perform, which saves operation time and improves compilation efficiency.

[0037] Therefore, after determining all variables in the target program file and the address index data of each variable, it can also include:

[0038] Create a variable address index table based on all address index data;

[0039] Accordingly, the process of determining the address offset corresponding to each address index data in the target program file and determining the address of each variable based on the address offset includes:

[0040] Determine the address offset corresponding to each address index data in the target program file, and update the variable address index table based on the address index data and the corresponding address offset;

[0041] Based on the variable address index table, the address of each variable is determined.

[0042] Furthermore, compiling the target program file will obtain an executable program file and variable information, the variable information including address index data, address offset and address of each variable, the variable information is stored in the memory in the form of a variable address index table, and can be modified and adjusted at any stage, even during the running of the executable program, the address offset in the variable address index table can be adjusted by assigning or modifying a value, so the method of this embodiment can also include:

[0043] According to the address modification instruction, modify the corresponding address offset in the variable address index table;

[0044] and / or, assigning a value to a corresponding address offset in a variable address index table according to an address assignment instruction;

[0045] Executes an action based on the variable address index table to determine the address of each variable.

[0046] It can be understood that at this time, the variables of the executable program file have the characteristic of dynamically assigning addresses, allowing the addresses of variables to be assigned or modified during the running of the executable program, eliminating the restrictions that addresses must be assigned to variables when program files are released and that the released program files can only be compiled executable program files. The target program file before compilation can be directly released as a product, and the address offset assignment and address determination can be achieved later through address allocation instructions.

[0047] It can be understood that the compilation of the target program file in the method of this embodiment is usually to compile the target program file in the form of C language or other programming languages ​​into a binary executable program file, and the target index data will usually also be written into the target program file before compilation.

[0048] Specifically, the target program file before compilation can also be written in other programming languages ​​and then converted into a programming language form that can be compiled. For example, the commonly used programming language in the field of industrial automation is the IEC language used by the IEC (International Electrotechnical Commission) for industrial automation programming in accordance with the standards specified by the IEC. Therefore, in some embodiments, the target program file is a program file programmed in the IEC language. After analyzing the target program file to be compiled and determining all variables in the target program file and the address index data of each variable, the following may also be included:

[0049] Convert the target program file into C language;

[0050] Write the address index data into the target program file converted into C language.

[0051] It can be understood that for each variable, determining the corresponding address based on the address offset actually means offsetting the first address of the partition where the variable is located to obtain the address of the variable, and the offset corresponding to the offset is the address offset of the variable. It can also be understood that the address offset of each variable is the offset between the address of the variable and the first address of the partition where the variable is located. Therefore, the process of determining the address of each variable based on the address offset can include:

[0052] For each variable, the address of the corresponding variable is obtained based on the address offset corresponding to the partition first address offset of the partition where the variable is located.

[0053] Further, the partition first address is the preset first address of the partition where the variable is located, which can be predetermined, usually a fixed address, or an address determined according to the position of the partition in the entire storage area. The partition first address is specifically determined by the area first address of the storage area and the partition offset of each partition in the storage area. It can be understood that a storage area includes multiple partitions. For a specific partition, its partition first address is obtained by offsetting the area first address of the storage area by a certain offset. Here, the offset is specifically determined based on the partition offset of each partition in the storage area. The partition offset of each partition is determined when the entire storage area is divided into multiple partitions. For example, the data area is used as a storage area, and its area first address is pDataAreaAddr. Assuming that the partition offset of area G in the data area is 8M, the partition first address of area G is: pDataAreaAddr+0x800000; further, assuming that variable P1 is in area G of the data area, and the address offset of variable P1 in area G is recorded as: H_FB_1_VarIndex[0], the address of variable P1 can be obtained as:

[0054] pDataSectionAddr+0x800000+H_FB_1_VarIndex[0].

[0055] In a specific embodiment, it is assumed that the target program file is a function block FB_1, which can implement the function of adding two input variables and assigning the value to the output variable. Therefore, the function block can be defined as follows:

[0056] FUNCTION_BLOCK FB_1

[0057] VAR_INPUT

[0058] P1: INT;

[0059] P2: INT;

[0060] END VAR

[0061] VAR_OUTPUT

[0062] OUT: DINT;

[0063] END VAR

[0064] VAR

[0065] END VAR

[0066] Based on the target program file defined above, the compiler front end analyzes the target program file to determine all variables in the target program file and the address index data of each variable. The analysis results are as follows:

[0067] / / Address index data

[0068] According to certain rules, such as the order of variable declaration, the correspondence between the elements in the array and the IEC variables is determined;

[0069] extern int32_t H_FB_1_VarIndex[];

[0070] H_FB_1_VarIndex[0] / *Address of input variable P1* /

[0071] H_FB_1_VarIndex[1] / *Address of input variable P2* /

[0072] H_FB_1_VarIndex[2] / *Address of output variable OUT* /

[0073] Furthermore, after converting the target program file into C language, the function block is implemented as follows:

[0074]

[0075] During the compilation of the target program file, addresses are assigned to each variable. Assume that the data area is used as the storage area and its first address is pDataAreaAddr. The partition where variables P1, P2, and OUT are located is the G area. The partition offset of the G area in the data area is 8M. The address offsets of variables P1, P2, and OUT in the G area are 1, 2, and 3, respectively, which are recorded as:

[0076] H_FB_1_VarIndex[0]=1;

[0077] H_FB_1_VarIndex[1]=2;

[0078] H_FB_1_VarIndex[2]=3;

[0079] Based on the region first address, partition offset and address offset, the address of each variable can be determined as follows:

[0080] P1: pDataSectionAddr+0x800000+H_FB_1_VarIndex[0];

[0081] P2: pDataSectionAddr+0x800000+H_FB_1_VarIndex[1];

[0082] OUT: pDataSectionAddr+0x800000+H_FB_1_VarIndex[2];

[0083] At this time, the code logic of adding the two input variables and assigning them to the output variable can be transformed into the following calculation process:

[0084] *(int32_t*)(pDataAreaAddr+0x800000+H_FB_1_VarIndex[3])=

[0085] (*(int16_t*)(pDataSectionAddr+0x800000+H_FB_1_VarIndex[0])

[0086] +(*(int16_t*)(pDataSectionAddr+0x800000+H_FB_1_VarIndex[1]);

[0087] The calculation process can be realized by executing the corresponding executable program file.

[0088] It can be understood that when the program is running, the address offset of each variable can be modified or assigned through an address modification instruction or an address assignment instruction, thereby completing the change of the address of the variable. For example, the address offset of variables P1, P2 and OUT can be modified as follows:

[0089] H_FB_1_VarIndex[0]=4;

[0090] H_FB_1_VarIndex[1]=5;

[0091] H_FB_1_VarIndex[2]=6;

[0092] The specific address modification instruction or address allocation instruction can be set according to the actual situation and user needs, but it is necessary to meet the specific address constraints of the storage area and the partition where the variable is located, and there are no other restrictions.

[0093] The method of the embodiment of the present application determines the variables and address index data of the variables by analyzing the target program file before compiling. During the compilation process, the address offset of the variable corresponding to the address index data can be directly obtained, and then the corresponding address can be determined, and the compiled executable program file can be obtained at the same time. The executable program file can be run based on the address. It is no longer necessary to use macro-defined constants to represent the address offset during compilation. The address offset determined based on the address index data will not occupy the code segment space. Therefore, the time consumption related to the macro-defined constant is reduced, the code segment space occupancy is reduced, and the compilation efficiency is significantly improved.

[0094] All the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here. It should be understood that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0095] 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.

[0096] Figure 3 Schematic diagram of an industrial program file processing device provided in an embodiment of the present application. Figure 3 As shown, the processing device includes:

[0097] The variable analysis module 301 is used to analyze the target program file to be compiled, and determine all variables in the target program file and the address index data of each variable;

[0098] The compiling module 302 is used to compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain the executable program file corresponding to the target program file. The executable program file is used to run based on the address.

[0099] The device of the embodiment of the present application determines the variables and address index data of the variables by analyzing the target program file before compiling. During the compilation process, the address offset of the variable corresponding to the address index data can be directly obtained, and then the corresponding address can be determined, and the compiled executable program file can be obtained at the same time. The executable program file can be run based on the address. It is no longer necessary to use macro-defined constants to represent the address offset during compilation. The address offset determined based on the address index data will not occupy the code segment space. Therefore, the time consumption related to the macro-defined constant is reduced, the code segment space occupancy is reduced, and the compilation efficiency is significantly improved.

[0100] In an exemplary embodiment, the compiling module is specifically used for:

[0101] For each variable, the address of the corresponding variable is obtained based on the address offset corresponding to the partition first address offset of the partition where the variable is located.

[0102] In an exemplary embodiment, the partition head address is specifically determined by the region head address of the storage area and the partition offset of each partition in the storage area.

[0103] In an exemplary embodiment, the variable analysis module is further used to:

[0104] Create a variable address index table based on all address index data;

[0105] Accordingly, the compilation module is also used to:

[0106] Determine the address offset corresponding to each address index data in the target program file, and update the variable address index table based on the address index data and the corresponding address offset;

[0107] Based on the variable address index table, the address of each variable is determined.

[0108] In an exemplary embodiment, the compiling module is further configured to:

[0109] According to the address modification instruction, modify the corresponding address offset in the variable address index table;

[0110] and / or, assigning a value to a corresponding address offset in a variable address index table according to an address assignment instruction;

[0111] Executes an action based on the variable address index table to determine the address of each variable.

[0112] In an exemplary embodiment, the variable analysis module is further used to:

[0113] Convert the target program file into C language;

[0114] Write the address index data into the target program file converted into C language.

[0115] In an exemplary embodiment, the variable analysis module is specifically used to:

[0116] The target program file to be compiled is analyzed through lexical analysis, and / or syntax analysis, and / or semantic analysis to determine all variables in the target program file and address index data of each variable.

[0117] Figure 4 Schematic diagram of an electronic device 4 provided in an embodiment of the present application. Figure 4 As shown, the electronic device 4 of this embodiment includes: a processor 401, a memory 402, and a computer program 403 stored in the memory 402 and executable on the processor 401. When the processor 401 executes the computer program 403, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 401 executes the computer program 403, the functions of the modules / units in the above-mentioned device embodiments are implemented.

[0118] The electronic device 4 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that Figure 4The electronic device 4 is merely an example and does not limit the electronic device 4 , and may include more or less components than those shown in the figure, or different components.

[0119] The processor 401 may 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.

[0120] The memory 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 4. The memory 402 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 402 is used to store computer programs and other programs and data required by the electronic device.

[0121] 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 assigned to different functional units and modules as needed, that is, the internal structure of the device can be 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.

[0122] 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, which may be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0123] 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 processing industrial program files, characterized in that: include: Analyze the target program file to be compiled, and determine all variables in the target program file and address index data of each variable; Compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain an executable program file corresponding to the target program file, wherein the executable program file is used to run based on the address.

2. The method according to claim 1, characterized in that The process of determining the address of each of the variables based on the address offset comprises: For each of the variables, based on the address offset corresponding to the partition first address offset of the partition where the variable is located, the address corresponding to the variable is obtained.

3. The method according to claim 2, characterized in that The partition head address is specifically determined by the region head address of the storage area and the partition offset of each partition in the storage area.

4. The method according to claim 1, characterized in that: After determining all variables in the target program file and the address index data of each variable, the method further includes: Establishing a variable address index table according to all the address index data; The process of determining the address offset corresponding to each of the address index data in the target program file, and determining the address of each of the variables based on the address offset includes: Determine the address offset corresponding to each address index data in the target program file, and update the variable address index table based on the address index data and the corresponding address offset; Based on the variable address index table, the address of each of the variables is determined.

5. The method according to claim 4, characterized in that Also includes: According to the address modification instruction, modify the corresponding address offset in the variable address index table; and / or, assigning a value to the corresponding address offset in the variable address index table according to the address allocation instruction; An action of determining the address of each of the variables based on the variable address index table is performed.

6. The method according to claim 1, characterized in that The target program file is a program file programmed in IEC language. After analyzing the target program file to be compiled and determining all variables in the target program file and address index data of each variable, the method further includes: Convert the target program file into C language; The address index data is written into the target program file converted into C language.

7. The method according to any one of claims 1 to 6, characterized in that The process of analyzing the target program file to be compiled and determining all variables in the target program file and address index data of each variable includes: The target program file to be compiled is analyzed through lexical analysis, and / or syntax analysis, and / or semantic analysis to determine all variables in the target program file and address index data of each variable.

8. An industrial program file processing device, characterized in that: include: A variable analysis module, used for analyzing the target program file to be compiled, and determining all variables in the target program file and address index data of each variable; A compiling module is used to compile the target program file, determine the address offset corresponding to each address index data in the target program file, determine the address of each variable based on the address offset, and obtain an executable program file corresponding to the target program file, wherein the executable program file is used to run based on the address.

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 7 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 7 are implemented.