Industrial control language processing method and device, electronic equipment and storage medium
By analyzing and building wrapping functions, the mutual calls of industrial control language and target programming language are realized, which solves the problem that industrial control language and other programming languages cannot be mixed programming, and improves programming flexibility and functional expansion capabilities.
Patent Information
- Application Number
- CN202411219931.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-06
AI Technical Summary
In the prior art, industrial control languages and other programming languages cannot perform hybrid programming, limiting the programming flexibility and functional expansion of industrial automation systems.
By obtaining the functions built by the target programming language, analyzing the function names and parameters, building the wrapping function in the industrial control language, and generating the function names according to the preset naming rules, establishing a function association relationship, and calling the wrapping function in the industrial control language program, and then calling it Functions of the target programming language.
It realizes hybrid programming of industrial control language and target programming language, avoids language isolation, and enhances programming flexibility and functional expansion capabilities.
Smart Images

Figure CN119087865A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a method, device, electronic device and storage medium for processing an industrial control language. Background Art
[0002] In the field of industrial control, the widespread application of programmable logic controllers (PLC) has become indispensable. It occupies an important position in the automation control systems of many industries. PLC control technology has the characteristics of powerful functions, high flexibility of use and strong practicality, making it one of the three major technical pillars of modern industrial automation. At present, in the development process of PLC configuration software, industrial control languages are usually used for program development; with the development of the times and the improvement of the overall quality of developers, programming languages such as C and C++ are favored by configuration personnel, but industrial control languages are still the most widely used programming languages in industrial automation configuration. In order to realize the simultaneous use of industrial automation languages and programming languages such as C and C++ in the configuration process, it is inevitable to solve the problem of mixed programming of industrial control languages and other languages. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a method, device, electronic device and storage medium for processing an industrial control language to solve the problem in the prior art that industrial control languages and other programming languages cannot be mixed for programming.
[0004] According to a first aspect of an embodiment of the present application, a method for processing an industrial control language is provided, the method comprising: obtaining a first target function constructed in a target programming language, parsing the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter; constructing a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, generating a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and constructing an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name; in a program constructed in the industrial control language, calling the wrapper function through the first function name.
[0005] According to a second aspect of an embodiment of the present application, a device for processing an industrial control language is provided, the device comprising: a parsing module, for obtaining a first target function constructed in a target programming language, parsing the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter; a generating module, for constructing a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, generating a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and constructing an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name; and a calling module, for calling the wrapper function through the first function name in a program constructed in the industrial control language.
[0006] 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.
[0007] 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.
[0008] Compared with the prior art, the embodiments of the present application have the following beneficial effects: in the embodiments of the present application, a first target function constructed in a target programming language is obtained, the first target function is parsed to obtain a first function name, a first parameter, and a function corresponding to the first parameter; a wrapper function corresponding to the industrial control language is constructed according to the first parameter and the function corresponding to the first parameter, and a function name of the wrapper function is generated according to a preset industrial control language naming rule and the first function name; in a program constructed in the industrial control language, the wrapper function is called by the first function name, wherein the wrapper function is generated by the first target function of the target programming language, and then the first target function of the target programming language is implemented by the wrapper function, and the subsequent program constructed in the industrial control language accurately calls the wrapper function corresponding to the first target function by calling the first function name, and the wrapper function can implement the method corresponding to the first target function, thereby realizing mixed programming of the industrial control language and the target programming language, avoiding the problem in the related art that the industrial control language and other programming languages cannot be mixed. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] 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.
[0010] Figure 1 It is a flowchart of a method for processing an industrial control language provided in an embodiment of the present application;
[0011] Figure 2 It is a schematic diagram of a program constructed in an industrial control language calling a function of a target programming language provided by an embodiment of the present application;
[0012] Figure 3 It is a flowchart of another method for processing an industrial control language provided in an embodiment of the present application;
[0013] Figure 4 It is a flowchart of another method for processing an industrial control language provided in an embodiment of the present application;
[0014] Figure 5 It is a flowchart of another method for processing an industrial control language provided in an embodiment of the present application;
[0015] Figure 6 This is a basic schematic diagram of converting an IEC language function to a C language function provided by an embodiment of the present application;
[0016] Figure 7 It is a flowchart of another method for processing an industrial control language provided in an embodiment of the present application;
[0017] Figure 8 It is a schematic diagram of converting an IEC variable into a C language variable provided in an embodiment of the present application;
[0018] Fig. 9 It is a flowchart of another optional industrial control language processing method provided in an embodiment of the present application;
[0019] Fig.10 It is a structural schematic diagram of an industrial control language processing device provided in an embodiment of the present application;
[0020] Fig.11 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] 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.
[0022] A method and device for processing an industrial control language according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0023] Figure 1 This is a method for processing an industrial control language provided by an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0024] S101, obtaining a first target function constructed in a target programming language, parsing the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter;
[0025] S102: construct a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, generate a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and construct an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name;
[0026] S103: In a program constructed in an industrial control language, calling a wrapper function by using a first function name.
[0027] It can be understood that the above-mentioned industrial control language is a programming language used for industrial automation and control systems, wherein the above-mentioned industrial control language complies with the IEC 61131-3 standard, and the above-mentioned industrial control language includes but is not limited to: Ladder Diagram (LD) language, Structured Text (ST) language, Function Block Diagram (FBD) language, Sequential Function Chart (SFC) language, and Instruction List (IL) language.
[0028] It can be understood that configuration development is performed based on the above industrial control language to obtain the program corresponding to the industrial control language, wherein configuration development refers to the configuration and programming of the control system using the industrial control language to meet specific automation and control requirements. The specific steps are as follows.
[0029] 1. Project planning: define the requirements, objectives and scope of the project, and determine the industrial control languages to be used (such as one or more of LD, ST, FBD, SFC, IL). Different industrial control languages are used according to different control tasks.
[0030] 2. Create a project: Use a programming tool that supports industrial control language (such as PLC programming software) to create a new project.
[0031] 3. Write code: Write the code of the control system in the selected industrial control language to form a configuration project. For example, use LD for logic diagram design, ST for structured text programming, FBD for graphical programming, SFC for state machine design, and IL for instruction list programming.
[0032] It can be understood that the above-mentioned target programming language includes high-level languages such as C and C++. In order to realize mixed programming of industrial control language and target programming language, the program constructed by industrial control language needs to call the function of target programming language. Among them, by converting the function of target programming language into the function of industrial control language, the program constructed by industrial control language can call the function of target programming language.
[0033] In some examples, in order to convert a function in a target programming language into a function in an industrial control language, the present example further obtains a first target function constructed in the target programming language, wherein the function in the target programming language called by the program in the industrial control language is used as the above-mentioned first target function; illustratively, there are N functions in the target programming language, wherein functions A, B...D in the target programming language are called by the program constructed in the industrial control language, then functions A, B...D in the target programming language are respectively used as the first target functions.
[0034] Continuing with the above example, after determining the first target function, this example further parses the first target function to obtain the first function name, the first parameter, and the function corresponding to the first parameter; specifically, by performing lexical analysis, grammatical analysis, and semantic analysis on the first target function of the target programming language, the first parameter contained in the first target function and the function corresponding to the first parameter are determined.
[0035] Continuing from the above example, after determining the first parameter contained in the first target function and the function corresponding to the first parameter, this example further constructs a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, and generates a function name of the wrapper function according to the preset industrial control language naming rule and the first function name, and constructs an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name, thereby making the wrapper function correspond to the first target function. Specifically, this example constructs a wrapper function corresponding to the industrial control language according to the preset wrapper function construction rule, the first parameter, and the function corresponding to the first parameter. The wrapper function construction rule is as follows: 1. The first parameter in the first target function is used as a structure pointer; 2. The structure contains all the first parameters and return value type pointers of the target programming language function; 3. The function name of the generated wrapper function is the target programming language function with the prefix H_ added. It can be understood that the method of constructing the wrapper function according to the first parameter and the function corresponding to the first parameter is the same as the method of the first target function.
[0036] Finally, in the program constructed in the industrial control language, the wrapped function is called through the first function name. Specifically, since the function name of the wrapped function is constructed based on the first function name, the corresponding wrapped function is accurately called by the first function name, and the wrapped function can implement the method corresponding to the first target function, thereby enabling the program constructed in the industrial control language to call the function of the target programming language, thereby achieving the effect of mixed programming.
[0037] In order to better illustrate the above method, a more specific example is provided for illustration. Figure 2 As shown, Figure 2 The figure shows a schematic diagram of a program constructed in an industrial control language calling a function in a target programming language, wherein the industrial control language is the IEC language and the target programming language is the C language. Figure 2 As shown, the program No. 1 is a function constructed in C language, and the first parameter and the function corresponding to the first parameter are obtained through lexical analysis, grammatical analysis and semantic analysis, and then the package function No. 2 is generated based on the preset package function construction rule; Figure 2 The IEC language ST call numbered 3 directly calls the C language function. During the calling process, the IEC language program will be parsed as a function call numbered 4. The function numbered 4 calls the wrapped function numbered 2. The wrapped function numbered 2 calls the function numbered 1, thereby realizing the call of the C language built function numbered 1 in the program built in the IEC language.
[0038] According to the technical solution provided in the embodiment of the present application, a first target function constructed in a target programming language is obtained, and the first target function is parsed to obtain a first function name, a first parameter, and a function corresponding to the first parameter; a wrapper function corresponding to the industrial control language is constructed according to the first parameter and the function corresponding to the first parameter, and a function name of the wrapper function is generated according to a preset industrial control language naming rule and the first function name; in a program constructed in the industrial control language, the wrapper function is called by the first function name, wherein the wrapper function is generated by the first target function of the target programming language, and then the first target function of the target programming language is implemented by the wrapper function, and the subsequent program constructed in the industrial control language accurately calls the wrapper function corresponding to the first target function by calling the first function name, and the wrapper function can implement the method corresponding to the first target function, thereby realizing mixed programming of the industrial control language and the target programming language, avoiding the problem in the related art that the industrial control language and other programming languages cannot be mixed.
[0039] In some embodiments, Figure 3 As shown, the method also includes:
[0040] S201, obtaining a first global variable corresponding to a program constructed in a target programming language, and determining a preset target programming language program and industrial control language variable type conversion table;
[0041] S202: Perform industrial control language conversion on the first global variable according to the target programming language program, the industrial control language variable type conversion table, and the type of the first global variable to obtain a first converted global variable corresponding to the industrial control language.
[0042] Specifically, during mixed programming of the industrial control language and the target programming language, the program constructed in the industrial control language also needs to obtain a first global variable corresponding to the target programming language and convert the first global variable into a first conversion global variable corresponding to the industrial control language.
[0043] After acquiring the first global variable, a preset target programming language program and an industrial control language variable type conversion table are determined, and the target programming language program and the industrial control language variable type conversion table are used to determine the correspondence between the variable type of the target programming language and the variable type of the industrial control language. Then, according to the above correspondence and the type of the first global variable, the first global variable is converted into the industrial control language to obtain the first converted global variable corresponding to the industrial control language.
[0044] Exemplarily, taking the industrial control language as IEC language and the target programming language as C language as an example, the preset target programming language program and industrial control language variable type conversion table is shown in Table 1 below.
[0045]
[0046]
[0047] Table 1
[0048] For example, there is a global variable extern int temp1 in C language. According to the above Table 1 and the type of extern int temp1, this example performs industrial control language conversion on extern int temp1 to obtain a first converted global variable corresponding to the industrial control language.
[0049] VAR
[0050] TEMP1: I NT16_t;
[0051] END VAR.
[0052] It can be understood that in the program built in the IEC language, addresses will be assigned to IEC variables during the compilation process. For example, the offset of TEMP1 in the G area is 8. After the program is linked, this example will further query the offset of all function symbols in the symbol table in the data segment. For example, if the offset of int temp1 in the data segment is 80, the auxiliary function CtoI ec(void*pDataAreaAddr,void pDataSect ionAddr) will be generated. The implementation of the auxiliary function is voidCto I ec(void*pDataAreaAddr,void*pDataSect ionAddr){*(i nt*)(pDataAreaAddr+0x800000 / *If the offset of G area in the data area is 8M* / +8)=(*(i nt*)(pDataSect i onAddr+8);}.
[0053] The purpose of the above function is to synchronize the calculation result of the first global variable of C language to the data area of IEC, where pDataAreaAddr is the first address of the data area, and pDataSect i onAddr is the first address of the C program data segment (.data). This function is called once by the controller program after each task cycle is completed, which can ensure the synchronization of the first global variable of C language to the first global conversion variable data of IEC, thereby achieving the purpose of the program constructed by IEC language to reference the first global variable of C language.
[0054] According to the technical solution provided in the embodiment of the present application, a first global variable corresponding to the target programming language program is obtained, and a preset target programming language program and industrial control language variable type conversion table is determined; according to the target programming language program and the industrial control language variable type conversion table and the type of the first global variable, the first global variable is converted into an industrial control language to obtain a first converted global variable corresponding to the industrial control language, thereby achieving the purpose of the program constructed in the industrial control language referencing the first global variable of the target programming language, and further achieving the effect of mixed programming of the industrial control language and the target programming language.
[0055] In some embodiments, Figure 4 As shown, obtaining the first global variable corresponding to the program constructed in the target programming language includes:
[0056] S301, identifying variables in a program constructed in a target programming language through preset keywords;
[0057] S302: Determine a first global variable according to the recognition result.
[0058] Specifically, in the target programming language, keywords are usually set to declare global variables. For example, when the target programming language is C language, the "extern" keyword is usually used to describe global variables, and the variable declared as a global variable is used as the first global variable.
[0059] For example, the following code is shown:
[0060]
[0061]
[0062] As shown in the above code, the keyword "extern" is set before the variable globalVar i ab le, and the variable globalVar i ab le is used as the first global variable corresponding to the target programming language program.
[0063] It can be understood that this example is not limited to determining the first global variable only by keywords, and whether it is the first global variable can also be determined by the definition position of the variable in the target programming language. It can be understood that global variables are usually defined outside all functions, so the variables defined outside the function can be used as the first global variable of the target programming language. In some examples, it can also be determined whether the variable is the first global variable based on the scope of the variable. It can be understood that the scope of the global variable is the entire program. This means that they can be accessed anywhere in the program, not just in the file or function in which they are defined, so the variables in the target programming language with a scope in the entire program can be used as the first global variable.
[0064] According to the technical solution provided in the embodiment of the present application, variables in the target programming language program are identified through preset keywords; the first global variable is determined based on the identification result, thereby achieving accurate determination of the first global variable.
[0065] In some embodiments, Figure 5 As shown, the method also includes:
[0066] S401, obtaining a second objective function constructed by an industrial control language, parsing the second objective function to obtain a second function name, a second parameter, and a type corresponding to the second parameter;
[0067] S402, constructing a package function corresponding to the target programming language according to the types corresponding to the second parameter and the first parameter, and generating a function name of the package function according to a preset naming rule of the target programming language and the second function name;
[0068] S403: In a program constructed in the target programming language, the encapsulated function is called by the function name of the encapsulated function.
[0069] Specifically, in order to realize mixed programming of industrial control language and target programming language, the program constructed in the target programming language needs to call the functions, function blocks, programs, etc. of the industrial control language. Among them, by converting the functions, function blocks, and programs of the target programming language into the functions of the industrial control language, the program constructed in the target programming language can call the functions, function blocks, and programs of the industrial control language.
[0070] Continuing with the above example, taking the case where a program built in the target programming language calls a function in the industrial control language, this example first obtains the second target function constructed in the industrial control language, wherein the function in the industrial control language called by the program in the target programming language is used as the above-mentioned second target function; illustratively, there are N functions in the program built in the industrial programming language, wherein functions A, B...D in the industrial programming language are called by the program built in the target programming language, then functions A, B...D in the industrial programming language are respectively used as the second target functions.
[0071] Continuing with the above example, after determining the second objective function, this example further parses the second objective function to obtain the second function name, the second parameter, and the type corresponding to the second parameter; specifically, by performing lexical parsing, grammatical parsing, and semantic parsing on the second objective function of the industrial control language, the second function name, the second parameter, and the type corresponding to the second parameter are determined.
[0072] Continuing with the above example, the second function name, the second parameter and the type corresponding to the second parameter contained in the second target function are determined. This example further constructs a wrapper function corresponding to the target programming language according to the second function name, the second parameter and the type corresponding to the second parameter, and generates the function name of the wrapper function according to the preset target programming language naming rule and the second function name; in the program constructed in the target programming language, the wrapper function is called by the function name of the wrapper function. Specifically, this example constructs the wrapper function according to the preset wrapper function construction rule, the second parameter and the type corresponding to the second parameter. The wrapper function construction rule is as follows: 1. The second parameter and return value in the second target function are encapsulated in a structure of the target programming language with "st_function name_Params". Taking the target programming language as C language and the industrial control language as C language as an example, the correspondence between the type of the second parameter in the second target function corresponding to IEC and the type of the parameter in C language is shown in Table 2 below:
[0073]
[0074]
[0075] Table 2
[0076] 2. All parameters in the second objective function are converted into pointer types of the corresponding types in the target programming language. 3. The return value of the function is uniformly named pResu lt, and the correspondence between the return value type and the parameter type is consistent. 4. The name of the second objective function in the industrial control language is converted into the target programming language function of H_function.
[0077] Among them, after conversion through this rule, the IEC language is converted into a function that fully complies with the C language function syntax. The C language only needs to include the header file and call the C language function according to the function declaration in the header file.
[0078] For example, Figure 6 For example, Figure 6 This is a basic schematic diagram of converting IEC language functions to C language functions. The IEC function in the figure above is called by C language coding example:
[0079] #include "H_FUN1.h"
[0080] int a=1;
[0081] i nt b=1;
[0082] i nt resu lt;
[0083] stFun1 Params param={&a,&b,&resu lt};
[0084] H_FUN1(¶m);
[0085] pr i ntf("%d+%d=%d\n",*param->pParam1,*param->pParam2,*param->pResult).
[0086] According to the technical solution provided in the embodiment of the present application, a second objective function constructed by an industrial control language is obtained, and the second objective function is parsed to obtain a second function name, a second parameter, and a type corresponding to the second parameter; a wrapper function corresponding to the target programming language is constructed according to the second parameter and the type corresponding to the first parameter, and a function name of the wrapper function is generated according to a preset naming rule of the target programming language and the second function name; in a program constructed by the target programming language, the wrapper function is called by the function name of the wrapper function, wherein the wrapper function is generated by the second objective function of the industrial control language, and then the second objective function of the industrial control language is implemented by the wrapper function, and a subsequent program constructed by the target programming language implements the calling of the second objective function of the industrial control language by calling the wrapper function, thereby implementing mixed programming of the industrial control language and the target programming language, avoiding the problem in the related art that mixed programming of the industrial control language and other programming languages cannot be performed.
[0087] In some embodiments, Figure 7 As shown, the method also includes:
[0088] S501, obtaining a second global variable in the industrial control language;
[0089] S502: Convert the second global variable in the industrial control language into a pointer to a variable in the target programming language.
[0090] Specifically, obtain the second global variable in the industrial control language; convert the second global variable in the industrial control language into a pointer to a variable in the target programming language. For example, the industrial control language is IEC language and the target programming language is C language. Figure 8 As shown, the IEC variable can be used by C++ logic by converting it into a pointer to a C language variable.
[0091] According to the technical solution provided in the embodiment of the present application, the second global variable in the industrial control language is obtained; the second global variable in the industrial control language is converted into a pointer to a target programming language variable, thereby realizing the calling of the second global variable of the industrial control language in the target programming language.
[0092] In some examples, such as Fig. 9 As shown, in a program constructed in the target programming language, after calling the encapsulated function by the function name of the encapsulated function, the method further includes:
[0093] S601, compile a program constructed in the target programming language using a compiler corresponding to the target programming language to obtain binary instructions;
[0094] S602: Transmit the binary instruction to the lower computer to control the lower computer to run according to the binary instruction.
[0095] Specifically, the above method is used to convert the functions of the industrial control language into the functions of the target programming language, and the functions of the target programming language into the functions of the industrial control language, so as to realize the mutual calling of functions between the target programming language and the industrial control language, and then realize the mixed programming between the target programming language and the industrial control language. In some examples, this example will convert all the functions of the industrial control language into the function form of the target programming language, and convert all the variables of the industrial control language into the variable type of the target programming language, so as to realize the conversion of the program constructed by the industrial control language into the target programming language. This example further compiles the program constructed by the target programming language through the compiler corresponding to the target programming language to obtain binary instructions, wherein the program constructed by the target programming language is compiled by the compiler of the target programming language to obtain binary instructions, which can not only realize the cross-compilation of the industrial control language and the target programming language, but also ensure the consistency of the tool chain, version, etc. selected by the compiler of the target programming language.
[0096] Finally, the binary instructions are transmitted to the lower computer to control the lower computer to run according to the binary instructions, realizing the mixed programming of industrial control language and target programming language to realize the automation control system.
[0097] According to the technical solution provided in the embodiment of the present application, the program constructed in the target programming language is compiled by the compiler corresponding to the target programming language to obtain binary instructions; the binary instructions are transmitted to the lower computer to control the lower computer to run according to the binary instructions, thereby realizing cross-compilation of the industrial control language and the target programming language, while ensuring the consistency of the tool chain, version, etc. selected by the target programming language compiler, and the binary instructions are transmitted to the lower computer to control the lower computer to run according to the binary instructions, thereby realizing mixed programming of the industrial control language and the target programming language to realize the automated control system.
[0098] 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.
[0099] 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.
[0100] This embodiment also provides an industrial control language processing device, such as Fig.10 As shown, the device comprises:
[0101] A parsing module 701 is used to obtain a first target function constructed in a target programming language, and parse the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter;
[0102] A generating module 702 is used to construct a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, generate a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and construct an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name;
[0103] The calling module 703 is used to call the wrapped function through the first function name in the program constructed by the industrial control language.
[0104] In some examples, the device also includes: a variable module, which is used to obtain a first global variable corresponding to a program constructed in a target programming language, and determine a preset target programming language program and industrial control language variable type conversion table; according to the target programming language program and the industrial control language variable type conversion table and the type of the first global variable, the first global variable is converted into an industrial control language to obtain a first converted global variable corresponding to the industrial control language.
[0105] In some examples, the variable module is further used to identify variables in the target programming language program through preset keywords; and determine the first global variable according to the identification result.
[0106] In some examples, the acquisition module 701 is also used to acquire a second target function constructed in an industrial control language, parse the second target function to obtain a second function name, a second parameter, and a type corresponding to the second parameter; the generation module 702 is also used to construct an encapsulation function corresponding to the target programming language according to the second parameter and the type corresponding to the first parameter, and generate a function name of the encapsulation function according to a preset target programming language naming rule and the second function name; the calling module 703 is also used to call the encapsulation function through the function name of the encapsulation function in a program constructed in the target programming language.
[0107] In some examples, the variable module is further used to obtain a second global variable in the industrial control language; and convert the second global variable in the industrial control language into a pointer to a variable in the target programming language.
[0108] In some examples, the variable module is also used to compile a program constructed in the target programming language through a compiler corresponding to the target programming language to obtain binary instructions; the binary instructions are transmitted to a lower computer to control the lower computer to run according to the binary instructions.
[0109] According to the technical solution provided by the embodiment of the present application, the processing device of the industrial control language provided by the embodiment obtains the first target function constructed by the target programming language, parses the first target function to obtain the first function name, the first parameter and the function corresponding to the first parameter; constructs a wrapper function corresponding to the industrial control language according to the first parameter and the function corresponding to the first parameter, and generates the function name of the wrapper function according to the preset industrial control language naming rule and the first function name; in the program constructed by the industrial control language, the wrapper function is called by the first function name, wherein the wrapper function is generated by the first target function of the target programming language, and then the first target function of the target programming language is implemented by the wrapper function, and the subsequent program constructed by the industrial control language accurately calls the wrapper function corresponding to the first target function by calling the first function name, and the wrapper function can implement the method corresponding to the first target function, thereby realizing mixed programming of the industrial control language and the target programming language, avoiding the problem in the related art that the industrial control language and other programming languages cannot be mixed.
[0110] Fig.11 Schematic diagram of an electronic device 11 provided in an embodiment of the present application. Fig.11 As shown, the electronic device 11 of this embodiment includes: a processor 1101, a memory 1102, and a computer program 1103 stored in the memory 1102 and executable on the processor 1101. When the processor 1101 executes the computer program 1103, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1101 executes the computer program 1103, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0111] The electronic device 11 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 11 may include, but is not limited to, a processor 1101 and a memory 1102. Those skilled in the art will appreciate that Fig.11 The electronic device 11 is merely an example and does not limit the electronic device 11 , and may include more or less components than those shown in the figure, or different components.
[0112] The processor 1101 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.
[0113] The memory 1102 may be an internal storage unit of the electronic device 11, for example, a hard disk or memory of the electronic device 11. The memory 1102 may also be an external storage device of the electronic device 11, 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 11. The memory 1102 may also include both an internal storage unit of the electronic device 11 and an external storage device. The memory 1102 is used to store computer programs and other programs and data required by the electronic device.
[0114] 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.
[0115] 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.
[0116] 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 control language, characterized in that: The method comprises: Obtain a first target function constructed in a target programming language, and parse the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter; Constructing a wrapper function corresponding to an industrial control language according to the first parameter and the function corresponding to the first parameter, generating a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and constructing an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name; In a program constructed in the industrial control language, the wrapper function is called by the first function name.
2. The method according to claim 1, characterized in that The method further comprises: Acquire a first global variable corresponding to the program constructed in the target programming language, and determine a preset target programming language program and industrial control language variable type conversion table; According to the target programming language program, the industrial control language variable type conversion table and the type of the first global variable, the first global variable is converted into an industrial control language to obtain a first converted global variable corresponding to the industrial control language.
3. The method according to claim 2, characterized in that Obtaining a first global variable corresponding to a program constructed in the target programming language includes: Identifying variables in a program constructed in the target programming language by using preset keywords; The first global variable is determined according to the recognition result.
4. The method according to claim 1, characterized in that The method further comprises: Acquire a second objective function constructed by the industrial control language, and parse the second objective function to obtain a second function name, a second parameter, and a type corresponding to the second parameter; Constructing a wrapper function corresponding to the target programming language according to the types corresponding to the second parameter and the first parameter, and generating a function name of the wrapper function according to a preset naming rule of the target programming language and the second function name; In a program constructed in the target programming language, the encapsulated function is called by the function name of the encapsulated function.
5. The method according to claim 4, characterized in that The method further comprises: Acquire a second global variable in the industrial control language; The second global variable in the industrial control language is converted into a pointer to the variable in the target programming language.
6. The method according to claim 4, characterized in that In the program constructed in the target programming language, after calling the encapsulation function by the function name of the encapsulation function, the method further includes: Compiling the program constructed in the target programming language by using a compiler corresponding to the target programming language to obtain binary instructions; The binary instruction is transmitted to a lower computer to control the lower computer to operate according to the binary instruction.
7. A device for processing industrial control language, characterized in that: The device comprises: A parsing module, used for obtaining a first target function constructed in a target programming language, parsing the first target function to obtain a first function name, a first parameter, and a function corresponding to the first parameter; a generating module, configured to construct a wrapper function corresponding to an industrial control language according to the first parameter and the function corresponding to the first parameter, generate a function name of the wrapper function according to a preset industrial control language naming rule and the first function name, and construct an association relationship between the wrapper function and the first target function according to the function name of the wrapper function and the first function name; A calling module is used to call the wrapped function through the first function name in a program constructed in the industrial control language.
8. The device according to claim 7, characterized in that The device also includes: a variable module, which is used to obtain a first global variable corresponding to a program constructed in the target programming language, and determine a preset target programming language program and industrial control language variable type conversion table; according to the target programming language program and the industrial control language variable type conversion table and the type of the first global variable, the first global variable is converted into an industrial control language to obtain a first converted global variable corresponding to the industrial control language.
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.
