Text variable processing method and device and storage medium
By analyzing and verifying text variables in wind power industry, the problem of grammar errors in user-defined text variables is solved, and the accuracy of text variables and the comprehensiveness of verification results are improved.
Patent Information
- Application Number
- CN202411373854.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-14
AI Technical Summary
In industries such as wind power, grammar errors are prone to occur in the process of user-defined text variables, resulting in the inability to guarantee the accuracy of text variables. The existing methods have weak ability to check text variables and cannot detect errors in a timely manner.
By obtaining the text data of the target variable, parsing it based on the variable category, obtaining a character sequence, and performing syntax and attribute verification, generating a syntax tree to ensure the accuracy of text variables.
It improves the accuracy of text variables and the comprehensiveness of verification results, ensures the effectiveness of syntax and attribute verification of text variables, and promptly discovers and corrects errors.
Smart Images

Figure CN119312793A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular, to a text variable processing method, device and storage medium in the field of data processing technology. Background Art
[0002] In industries such as wind power, there are many variable categories and the variable structure is extremely complex. Text variables can be used to flexibly define different types of variables, and are highly readable and easy to understand.
[0003] However, in the process of users defining text variables, syntax errors are very likely to occur, making it impossible to guarantee the accuracy of the text variables.
[0004] Therefore, it is necessary to provide a text variable processing method to improve the accuracy of text variables. Summary of the invention
[0005] In order to solve the above technical problems, the present application provides a text variable processing method, device and storage medium to improve the accuracy of text variables.
[0006] According to a first aspect of an embodiment of the present application, a text variable processing method is provided, comprising:
[0007] Acquire target variable text data, wherein the target variable text data includes at least one text variable, and the text variable is a variable displayed by text;
[0008] When receiving the verification instruction, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, wherein the character sequence corresponds to the text variable one by one;
[0009] Based on each of the character sequences, verification processing is performed on each of the text variables in the target variable text data.
[0010] Optionally, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, including:
[0011] Determine a target parsing model based on the variable category corresponding to the target variable text data and the corresponding relationship between the variable category and the sub-parsing model, wherein the sub-parsing model includes parsing rules for text variables of the corresponding variable category;
[0012] Based on the common parsing model and the target parsing model, the target variable text data is parsed to obtain at least one character sequence, wherein the common parsing model includes common parsing rules for text variables of different variable categories.
[0013] Optionally, the checking process of each of the text variables in the target variable text data based on each of the character sequences includes:
[0014] Based on the grammatical rules corresponding to the variable categories, a grammar check is performed on each of the character sequences, and a grammar tree is generated for the character sequences that pass the grammar check based on the grammar check results;
[0015] When the syntax check results of all the character sequences are passed, obtaining each text variable based on the syntax tree;
[0016] Based on the variable attribute rules corresponding to the variable category, attribute verification is performed on each element in each of the text variables, and the variable attribute rules include attribute rules for each element in the text variable.
[0017] Optionally, it also includes:
[0018] When a grammar check result of at least one of the character sequences fails, generating first error indication information based on the grammar check result;
[0019] and / or,
[0020] When a result of the attribute verification of at least one of the text variables fails, second error indication information is generated based on the attribute verification result.
[0021] Optionally, obtaining target variable text data includes:
[0022] Providing a first variable editing interface, wherein the first variable editing interface is used to edit the text variable;
[0023] In response to an input operation on the first variable editing interface, text variable processing is performed to obtain the target variable text data, and the text variable processing includes at least one of text variable creation, text variable update and text variable deletion.
[0024] Optionally, obtaining target variable text data includes:
[0025] Providing a second variable editing interface, the second variable editing interface is used to edit table variables, the table variables are variables displayed through a table;
[0026] In response to an input operation on the second variable editing interface, table variable processing is performed to obtain target variable table data, wherein the table variable processing includes at least one of table variable creation, table variable update, and table variable deletion;
[0027] When receiving the text switching instruction, updating the historical variable text data based on the target variable table data;
[0028] When the update result of the historical variable text data is not empty, the target variable text data is obtained based on the update result of the historical variable text data.
[0029] Optionally, obtaining target variable text data includes:
[0030] Providing a file import interface, wherein the file import interface is used to import variable files;
[0031] In response to an import operation on the file import interface, an initial variable file is obtained;
[0032] When the initial variable file is valid, the initial variable file is adapted based on the variable category corresponding to the initial variable file, and the target variable text data is obtained based on the adapted initial variable file.
[0033] Optionally, after verifying each of the text variables in the target variable text data based on each of the character sequences, the method further includes:
[0034] When the verification processing results of each of the text variables are passed, the historical variable table data is updated based on the target variable text data;
[0035] and / or,
[0036] When an export instruction is received, the target variable text data is exported based on the export requirement information in the export instruction.
[0037] According to a second aspect of an embodiment of the present application, a text variable processing device is provided, comprising:
[0038] A first processing unit is used to obtain target variable text data, where the target variable text data includes at least one text variable, and the text variable is a variable displayed by text;
[0039] A second processing unit is used for, upon receiving the verification instruction, parsing the target variable text data based on the variable category corresponding to the target variable text data to obtain at least one character sequence, wherein the character sequence corresponds to the text variable one by one;
[0040] The third processing unit is used to perform verification processing on each of the text variables in the target variable text data based on each of the character sequences.
[0041] According to a third aspect of an embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the text variable processing method as described in any one of the above items is implemented.
[0042] According to a fourth aspect of an embodiment of the present application, a computer program product or a computer program is provided, wherein the computer program product comprises a computer program, and the computer program is stored in a computer-readable storage medium; a processor of the computer device reads the computer program from the computer-readable storage medium, and when the processor executes the computer program, a text variable processing method as described in any one of the above items is implemented.
[0043] It can be seen from the above technical scheme that the embodiment of the present application provides a text variable processing method, device and storage medium, wherein the text variable processing method obtains target variable text data, the target variable text data includes at least one text variable, and the text variable is a variable displayed through text. When a verification instruction is received, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, and the character sequence corresponds to the text variable one-to-one, so that the character sequence corresponding to each text variable in the target variable text data can be accurately parsed, and then based on each character sequence, each text variable in the target variable text data can be effectively verified, thereby ensuring the accuracy of the text variable. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0045] Figure 1 A flowchart of a text variable processing method provided for one embodiment of this specification;
[0046] Figure 2 A schematic diagram of the structure of a syntax tree provided for one embodiment of this specification;
[0047] Figure 3 A schematic diagram of a process for verifying target variable text data provided by one embodiment of this specification;
[0048] Figure 4 A schematic diagram of a process for converting variable text data into variable table data is provided for one embodiment of the present specification;
[0049] Figure 5 Another schematic diagram of a process for converting variable text data into variable table data is provided for one embodiment of the present specification;
[0050] Figure 6 A schematic diagram of a process for converting variable table data into variable text data is provided for one embodiment of the present specification;
[0051] Figure 7 A schematic diagram of a process of importing variable text data into third-party software provided for one embodiment of this specification;
[0052] Figure 8 A schematic diagram of the structure of a text variable processing device provided for one embodiment of the present specification. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] Overview
[0055] As described in the background technology, in industries such as wind power, there are many variable categories and the variable structure is extremely complex. Different types of variables can be flexibly defined through text variables, and they are highly readable and easy to understand.
[0056] However, in the process of user-defined text variables, grammatical errors are very likely to occur, and the existing methods have weak inspection capabilities for text variables and are unable to detect errors in text variables in a timely manner, thus failing to ensure the accuracy of text variables.
[0057] Therefore, it is necessary to provide a text variable processing method to improve the accuracy of text variables.
[0058] In order to solve the problem that traditional methods cannot guarantee the accuracy of text variables, in the technical solution of the present application, by obtaining target variable text data, the target variable text data includes at least one text variable, and the text variable is a variable displayed through text. When a verification instruction is received, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, and the character sequence corresponds to the text variable one-to-one, so that the character sequence corresponding to each text variable in the target variable text data can be accurately parsed, and then based on each character sequence, each text variable in the target variable text data can be effectively verified, thereby ensuring the accuracy of the text variable.
[0059] At the same time, in order to quickly and effectively parse the target variable text data, the text variable processing method provided in the implementation manner of this specification also limits the parsing method of the target variable text data.
[0060] In addition, in order to improve the comprehensiveness and effectiveness of the verification results of each text variable, the text variable processing method provided in the implementation mode of this specification also limits the verification method of the text variable.
[0061] In addition, the text variable processing method provided in the implementation mode of this specification also limits the method for obtaining the target variable text data to improve the efficiency and freedom of user-defined variables.
[0062] Based on the above-mentioned inventive concept, the text variable processing method provided in the implementation manner of this specification is exemplarily described below.
[0063] Exemplary Methods
[0064] See also Figure 1 In an exemplary embodiment, a text variable processing method is provided, comprising:
[0065] S101. Obtain target variable text data, where the target variable text data includes at least one text variable, and the text variable is a variable displayed through text.
[0066] Specifically, the target variable text data is the variable text data to be processed, and the target variable text data may include at least one text variable, which is a variable displayed in the form of text.
[0067] In implementation, the target variable text data may include all text variables under one or more variable nodes in the project. A variable node may be a logic module, such as a POU (Program Organization Unit), or a custom structure, such as a structure, an enumeration variable node, etc. In addition, the target variable text data may also be determined according to a selection instruction input by a user. For example, the user may select the target variable text data by operating an input device such as a mouse and / or a keyboard, thereby enabling batch processing of text variables.
[0068] The specific method of obtaining the target variable text data can be set according to actual needs. For example, text variables can be edited in the text variable editing interface to obtain variable text data, variable table data can be switched to obtain variable text data, and variable text data can be imported. The imported variable text data can be variable text data edited by third-party software or variable text data edited by non-third-party software.
[0069] S102. When a verification instruction is received, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, where the character sequence corresponds one-to-one to the text variable.
[0070] Specifically, the verification instruction is used to instruct the verification of the target variable text data. The verification instruction can be input by the user through input devices such as mouse and keyboard. For example, the user can input the verification instruction by clicking the left button of the mouse, or by losing the focus of the mouse, or by clicking the verification control with the mouse, or by pressing Enter on the keyboard; in addition, the user can also input the verification instruction by sending voice including similar language such as "verify" to a computer or other device.
[0071] It is understandable that the verification instruction can also be automatically triggered when a project save or project open instruction is received to verify the variable text data of all variable nodes in the project. In addition, the verification instruction can also be triggered when an open instruction of a target variable node is received to verify the variable text data of the target variable node, and the target variable node can be any variable node in the project.
[0072] The variable category corresponding to the target variable text data may represent the variable category of the text variable included therein, for example, the variable category may include POU, structure, enumeration, and global variable, etc. For text variables of different variable categories, their grammatical rules may be different.
[0073] For example, when the variable category is POU or global variable, the syntax rule of the text variable can be:
[0074] “VAR
[0075] Variable name: Variable type: = initial value
[0076] END_VAR".
[0077] When the variable type is a structure, the syntax rules of the text variable can be:
[0078] "TYPE structure type name STRUCT:
[0079] Member name: variable type: = initial value;
[0080] END_STRUCT; END_TYPE".
[0081] When the variable type is enumeration, the syntax rules of the text variable can be:
[0082] "TYPE enumeration type name ENUM:
[0083] Member name: = initial value,
[0084] END_TYPE".
[0085] During implementation, the target variable text data can be parsed based on the variable category corresponding to the target variable text data. For example, the target variable text data can be parsed based on the grammatical rules of the variable category corresponding to the target variable text data. The target parsing model can also be determined based on the variable category corresponding to the target variable text data. The target variable text data can be parsed through the target parsing model, thereby effectively ensuring the validity of the parsing result of the target variable text data.
[0086] By parsing the target variable text data, at least one character sequence can be obtained, and the character sequence can correspond one-to-one to the text variable in the target variable text data, that is, for each text variable, a character sequence can be parsed.
[0087] S103. Based on each of the character sequences, verify each of the text variables in the target variable text data.
[0088] Specifically, for any text variable in the target variable text data, the corresponding character sequence may include keywords and symbols and the arrangement order of the keywords and symbols, keywords may include variable name, variable type, initial value, symbol, comment, etc., and symbols may include colon, semicolon, etc. The arrangement order of the keywords and symbols is the actual arrangement order of the keywords and symbols in the text variable.
[0089] Therefore, according to the keywords, symbols and the arrangement order of the keywords and symbols in the character sequence corresponding to the text variable, the text variable can be grammatically checked to determine whether the text variable meets the corresponding grammatical rules through grammatical checking. In addition, according to the attributes of each keyword and symbol, the text variable can also be attribute-checked to determine whether the text variable meets the corresponding variable attribute rules through attribute checking. In this way, each text variable in the target variable text data can be comprehensively and effectively checked, thereby ensuring the accuracy of the text variable.
[0090] In order to parse the target variable text data quickly and effectively, in an exemplary embodiment, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, including:
[0091] Determine a target parsing model based on the variable category corresponding to the target variable text data and the corresponding relationship between the variable category and the sub-parsing model, wherein the sub-parsing model includes parsing rules for text variables of the corresponding variable category;
[0092] Based on the common parsing model and the target parsing model, the target variable text data is parsed to obtain at least one character sequence, wherein the common parsing model includes common parsing rules for text variables of different variable categories.
[0093] Specifically, a common parsing model and a plurality of sub-parsing models may be pre-constructed, and the plurality of sub-parsing models may correspond one-to-one to a plurality of variable categories, that is, each variable category may correspond to a sub-parsing model.
[0094] The sub-parsing model may include parsing rules for text variables of the corresponding variable category, and the parsing rules may include grammatical rules of the corresponding variable category, that is, the variable text data of the corresponding variable category may be parsed in a personalized manner through the sub-parsing model.
[0095] The common parsing model may include common parsing rules for text variables of different variable categories, that is, parsing rules common to text variables of different variable categories, such as word segmentation, part-of-speech tagging, and the like.
[0096] Through the common parsing model and the sub-parsing models corresponding to each variable category, the parsing process and common methods can be reused, so that variable text data of different variable categories can be parsed and processed quickly and effectively.
[0097] In the process of parsing the target variable text data, the target parsing model can be determined based on the variable category corresponding to the target variable text data and the correspondence between the variable category and the parsing model, and the target variable text data can be parsed through the common parsing model and the target parsing model.
[0098] The execution order of the public parsing model and the target parsing model can be determined according to the actual setting, and no specific limitation is made here. For example, after the target variable text data is preliminarily parsed by the public parsing model, the preliminary parsing result of the target variable text data can be further parsed by the target parsing model to obtain the character sequence corresponding to each text variable in the target variable text data, so that the target variable text data can be parsed quickly and effectively.
[0099] In order to further improve the comprehensiveness and effectiveness of the verification results of each text variable, in an exemplary embodiment, based on each character sequence, each text variable in the target variable text data is verified, including:
[0100] Based on the grammatical rules corresponding to the variable categories, a grammar check is performed on each of the character sequences, and a grammar tree is generated for the character sequences that pass the grammar check based on the grammar check results;
[0101] When the syntax check results of all the character sequences are passed, obtaining each text variable based on the syntax tree;
[0102] Based on the variable attribute rules corresponding to the variable category, attribute verification is performed on each element in each of the text variables, and the variable attribute rules include attribute rules for each element in the text variable.
[0103] Specifically, in the process of checking each text variable in the target variable text data, the syntax check can be performed on each character sequence obtained by the parsing process based on the syntax rule corresponding to the variable category of the target variable text data. For example, for any character sequence obtained by the parsing process, it can be determined whether each keyword and symbol in the character sequence meets the syntax rule corresponding to the variable category of the target variable text data. If so, it indicates that the syntax check result of the text variable corresponding to the character sequence is passed; if not, it indicates that the syntax check result of the text variable corresponding to the character sequence is failed.
[0104] If the grammatical check result of the text variable corresponding to the character sequence passes, a grammatical tree can be generated based on the grammatical rules corresponding to the character sequence and the variable category of the target variable text data. The grammatical tree may include a root node and a subtree corresponding to each character sequence whose grammatical check result passes. Multiple subtrees may be set in parallel.
[0105] For any character sequence, in the process of generating the corresponding subtree, the parent node of the subtree can be the name of the grammar rule, and the child node under the parent node can include the sub-rules of the grammar rule corresponding to the parent node. The child node can also continue to generate the next level of sub-rules according to the configured sub-rules until reaching the leaf node, which can include keywords and symbols in the character sequence.
[0106] The following uses the target variable text data including a text variable as an example to illustrate the structure of the syntax tree. The variable declaration text is var1:BOOL:=0; where the variable name is var1, the variable type is BOOL, and the initial value of the variable is 0. The generated syntax tree can be as follows: Figure 2 shown. Figure 2 The root node (var_decl) is a variable declaration. The child nodes of the root node include the variable name (variable_name), colon (COLON::), variable initialization (var_decl_init:1) and semicolon (SEMI:;); the child nodes of the variable name (variable_name) are the corresponding sub-rules, that is, the identifier (IDENTIFIER:var1); the child nodes of the variable initialization (var_decl_init:1) are the corresponding sub-rules, that is, the variable data type initialization (base_type_decl_init:1); the child nodes of the variable data type initialization (base_type_decl_init:1) are the corresponding sub-rules, that is, the variable initialized to a numeric type (numeric_decl_init:2). nit); the child nodes of the variable initialized to a numeric type (numeric_decl_init) are the corresponding sub-rules, including: variable type name (base_numeric_type_name), assignment (ASSIGN::=) and numeric constant (numeric_literal:1); the child node of the variable type name (base_numeric_type_name) is the variable type BOOL; the child node of the numeric constant (numeric_literal:1) is the corresponding sub-rule, i.e., integer constant (integer_literal); the child node of the integer constant (integer_literal) is the corresponding sub-rule, i.e., typed integer literal (TYPED_INTEGER_LITERAL:0).
[0107] When the syntax check results of all character sequences are passed, each text variable can be obtained based on the syntax tree. For example, each subtree in the syntax tree can be accessed to obtain the variable statement corresponding to each subtree, that is, the text variable. Each subtree in the syntax tree can be accessed in a depth-first traversal manner, so that the information of the next text variable can be obtained after the information of one text variable is obtained, so that the information of each text variable can be completely and accurately obtained, thereby ensuring the reliability of the verification result.
[0108] The variable attribute rules may include the attribute rules of each element in the text variable. The elements in the text variable may include the variable name, variable type, initial value, comment, colon, semicolon, etc. The attribute rules of the element may include the value range and format of the element.
[0109] After obtaining each text variable in the target variable text data, the attribute check can be performed on each element in each text variable based on the variable attribute rule corresponding to the variable category of the target variable text data to determine whether each text variable meets the variable attribute rule. For example, it can be checked whether the variable name is legal, such as whether the variable name contains illegal symbols, whether there are repeated variable names, etc.; it can also be checked whether the variable type exists, whether the format of the initial value is correct, whether the initial value exceeds the corresponding numerical range, etc.
[0110] Therefore, through syntax checking and attribute checking, the comprehensiveness and effectiveness of the verification results of each text variable can be effectively guaranteed.
[0111] If errors occur during the parsing, syntax checking, and attribute checking of the target variable text data, you can edit the text variable again. Figure 3 shown.
[0112] In an exemplary embodiment, it further includes:
[0113] When a grammar check result of at least one of the character sequences fails, generating first error indication information based on the grammar check result;
[0114] and / or,
[0115] When a result of the attribute verification of at least one of the text variables fails, second error indication information is generated based on the attribute verification result.
[0116] Specifically, the first error indication information may be used to indicate a character sequence that has failed the grammar check result, as well as the location of the grammar error in the character sequence, the cause of the grammar error, etc. When the grammar check result of at least one character sequence fails, the grammar check may be stopped and the first error indication information may be generated, so that the first error indication information may be displayed at a corresponding position by means of a pop-up window, highlighting, annotation, etc., so that the user can edit and modify the text variable in a timely manner.
[0117] The second error indication information can be used to indicate the text variable whose attribute verification result fails, as well as the location of the attribute error in the text variable, the cause of the attribute error, etc. When the attribute verification result of at least one text variable fails, the attribute verification can be stopped and the second error indication information can be generated, and the second error indication information can be displayed at the corresponding position by means of a pop-up window, highlighting, annotation, etc., so that the user can edit and modify the text variable in time.
[0118] In an exemplary embodiment, obtaining target variable text data includes:
[0119] Providing a first variable editing interface, wherein the first variable editing interface is used to edit text variables;
[0120] In response to an input operation on the first variable editing interface, text variable processing is performed to obtain the target variable text data, and the text variable processing includes at least one of text variable creation, text variable update and text variable deletion.
[0121] Specifically, the first variable editing interface is used to edit text variables, wherein the first variable editing interface can be triggered and displayed according to the user's click operation on the corresponding control. Through the first variable editing interface, the user can create, update, and delete text variables according to function customization requirements, variable writing habits, grammar rules, etc., so that the text variables can be edited quickly and flexibly, which improves the efficiency and freedom of user-defined variables.
[0122] In implementation, in response to an input operation on the first variable editing interface, text variable processing may be performed, and the text variable processing may include at least one of creating a text variable, updating a text variable, and deleting a text variable. The input operation may include a data input operation performed by an input device such as a keyboard, and may also include operations such as clicking and selecting a mouse.
[0123] Among them, when the user is editing text variables in the first variable editing interface, he can first create a new variable node in the project or open an existing variable node, such as a POU variable node, a structure, an enumeration variable node, a global variable node, etc., and then edit the text variable according to the corresponding grammatical rules. When receiving a verification instruction, all text variables under the current variable node can be used as target variable text data, and according to the received selection instruction, the selected text variable under the current variable node can be used as the target variable text data.
[0124] During implementation, the text variables can be edited according to the grammatical rules in the IEC61131-3 standard to improve the cross-platform and compatibility of the generated text variables.
[0125] In an exemplary embodiment, obtaining target variable text data includes:
[0126] Providing a second variable editing interface, the second variable editing interface is used to edit table variables, the table variables are variables displayed through a table;
[0127] In response to an input operation on the second variable editing interface, table variable processing is performed to obtain target variable table data, wherein the table variable processing includes at least one of table variable creation, table variable update, and table variable deletion;
[0128] When receiving the text switching instruction, updating the historical variable text data based on the target variable table data;
[0129] When the update result of the historical variable text data is not empty, the target variable text data is obtained based on the update result of the historical variable text data.
[0130] Specifically, the second variable editing interface is used to edit table variables, wherein the second variable editing interface can be triggered and displayed according to the user's click operation on the corresponding control, and the second variable editing interface can be the same as the first variable editing interface, or different from the first variable editing interface, and can be specifically set according to actual needs. Table variables are variables displayed in the form of a table, and users can create, update, and delete table variables through the second variable editing interface, so that they can edit table variables quickly and accurately.
[0131] In implementation, table variable processing may be performed in response to an input operation on the second variable editing interface, and the table variable processing may include at least one of table variable creation, table variable update, and table variable deletion. The input operation may include data input operations performed through input devices such as a keyboard, and may also include operations such as mouse clicks and selections.
[0132] Among them, when editing table variables in the second variable editing interface, the user can first create a new variable node in the project or open an existing variable node, such as a POU variable node, structure, enumeration variable node, global variable node, etc., and then edit the table variables according to the corresponding grammatical rules. When receiving a text switching instruction, all table variables under the current variable node can be used as target variable table data.
[0133] The user can input a text switching instruction through an input device such as a mouse, for example, text switching can be selected in the right-click menu of the mouse. When the text switching instruction is received, the historical variable text data can be updated based on the target variable table data. The historical variable text data is the variable text data under the current variable node. It can be understood that if the current variable node is a newly created variable node, the historical variable text data does not exist, that is, the historical variable text data is empty. If the current variable node is an existing variable node, the historical variable text data can be the variable text data corresponding to the historical variable table data before the table variable processing is performed.
[0134] In the process of updating the historical variable text data based on the target variable table data, the difference between the target variable table data and the historical variable text data can be obtained, and based on the difference between the target variable table data and the historical variable text data, the historical variable text data is updated so that the text variables in the update result of the historical variable text data are synchronized with the table variables in the target variable table data. For example, the following steps may be included:
[0135] Step 1: Determine whether the target variable table data is empty. If the target variable table data is empty, clear the historical variable text data.
[0136] Step 2: If the target variable table data is not empty, traverse each table variable in the target variable table data; wherein, for any table variable, compare the table variable with each text variable in the historical variable text data; if there is a text variable with the same variable name as the table variable in the historical variable text data, and there are elements in the text variable that are different from the table variable, then update each element of the text variable based on the table variable; if there is no text variable with the same variable name as the table variable in the historical variable text data, then add a text variable with the same elements as the table variable in the historical variable text data.
[0137] Step 3: Traverse each text variable in the historical variable text data; for any text variable, compare the text variable with each table variable in the target variable table data. If there is no table variable with the same variable name as the text variable in the target variable table data, delete the text variable.
[0138] If the update result of the historical variable text data is not empty, the target variable text data can be obtained based on the update result of the historical variable text data. For example, the update result of the historical variable text data can be directly used as the target variable text data, or the update result of the historical variable text data can be edited in the first variable editing interface and the edited result can be used as the target variable text data.
[0139] If the update result of the historical variable text data is empty, it means that there is no variable in the current variable node, and there is no need to perform text variable processing.
[0140] When the update result of the historical variable text data is not empty, the display text can also be constructed based on the update result of the historical variable text data, and the variable text view can be refreshed.
[0141] It is understandable that when the variable category corresponding to the target variable tabular data is a global variable, the variable node of the target variable tabular data can be hidden, and the above steps 1, 2 and 3 are performed. Wherein, in step 2, if there is no text variable with the same variable name as the tabular variable in the historical variable text data, a default file is generated, and a text variable with the same elements as the tabular variable is added to the default file, wherein the file name of the default file can be default_text, and if the file name already exists, a suffix can be added after the file name to generate a new file name, such as default_text_1, default_text_2, etc. When the update result of the historical variable text data is not empty, the variable node of the target variable text data can also be displayed and the structure tree can be updated. Wherein, the variable node of the target variable tabular data and the variable node of the target variable text data can be different representations of the same variable node.
[0142] In an exemplary embodiment, obtaining target variable text data includes:
[0143] Providing a file import interface, wherein the file import interface is used to import variable files;
[0144] In response to an import operation on the file import interface, an initial variable file is obtained;
[0145] When the initial variable file is valid, the initial variable file is adapted based on the variable category corresponding to the initial variable file, and the target variable text data is obtained based on the adapted initial variable file.
[0146] Specifically, the file import interface is used to import variable files, and the imported variable files may be variable files generated by third-party software, wherein the display file import interface may be triggered based on a user's click operation on a corresponding control.
[0147] The import operation may include a click operation on an import-related control, an input or selection operation of a variable file location to be imported, a selection operation of a variable file to be imported, etc. An initial variable file may be obtained according to an import operation performed by a user on a file import interface, and the initial variable file is the imported variable file. The imported variable file may be a file in XML (eXtensible Markup Language) format.
[0148] It is understandable that the grammatical rules of the imported variable file can be the same as the grammatical rules used by this software when processing text variables, for example, both are grammatical rules in the IEC61131-3 standard, so that each text variable in the imported variable file can be correctly identified.
[0149] After obtaining the initial variable file, it can be determined whether the initial variable file is valid according to the format of the initial variable file, etc. If it is invalid, the import is terminated. If it is valid, the initial variable file is parsed to determine the variable category corresponding to the initial variable file according to the parsing result, and the initial variable file is adapted according to the variable category corresponding to the initial variable file. For example, the initial variable file can be adapted based on the text format of the variable text data in this software. For example, if the variable category corresponding to the initial variable file is POU, the text format of the initial variable file is adapted to "program". If the variable category corresponding to the initial variable file is a custom category (such as structure, enumeration), the text format of the initial variable file is adapted to "end_struct;", so that the imported variable file can be directly applied through simple adaptation processing, which has good engineering portability and provides great convenience for transferring variable definition information between software with different configurations.
[0150] During implementation, if the variable category corresponding to the initial variable file is not a global variable, a new variable node corresponding to the variable category can be created, and the adapted initial variable file can be added to the variable node to determine the target variable text data based on the variable text data under the variable node. For example, the variable text data under the variable node can be directly used as the target variable text data, and the variable text data under the variable node can also be edited in the first variable editing interface, and the editing result can be used as the target variable text data.
[0151] If the variable category corresponding to the initial variable file is a global variable, determine whether there is a corresponding variable node. If so, update the variable text data under the variable node based on the adapted initial variable file, and determine the target variable text data based on the updated result of the variable text data under the variable node. If not, create a new corresponding variable node, and add the adapted initial variable file to the variable node to determine the target variable text data based on the variable text data under the variable node.
[0152] In an exemplary embodiment, after verifying each text variable in the target variable text data based on each character sequence, the method further includes:
[0153] When the verification processing results of each of the text variables are passed, the historical variable table data is updated based on the target variable text data;
[0154] and / or,
[0155] When an export instruction is received, the target variable text data is exported based on the export requirement information in the export instruction.
[0156] Specifically, when the verification processing results of each text variable are all passed, the historical variable table data can be updated based on the target variable text data to keep the text variable and the table variable synchronized. If the current variable node is a newly created variable node, the historical variable table data does not exist, that is, the historical variable table data is empty. If the current variable node is an existing variable node, the historical variable table data can be the variable table data corresponding to the historical text variable data before the text variable processing is performed.
[0157] In the process of updating the historical variable table data based on the target variable text data, the difference between the target variable text data and the historical variable table data can be obtained, and based on the difference between the target variable text data and the historical variable table data, the historical variable table data can be updated so that the table variables in the update result of the historical variable table data are synchronized with the text variables in the target variable text data. For example, for the text variables deleted in the target variable text data, the corresponding table variables in the historical variable table data can be deleted, for the text variables newly added in the target variable text data, the corresponding table variables can be newly added in the historical variable table data, and for the text variables updated in the target variable text data, the elements of the corresponding table variables in the historical variable table data can be updated based on the text variables. Among them, when the update result of the historical variable table data is not empty, the variable table view can also be refreshed based on the update result of the historical variable table data.
[0158] It can be understood that when the variable category corresponding to the target variable text data is a global variable, the variable node of the target variable text data can also be hidden, and the historical variable table data can be updated based on the target variable text data. After the historical variable table data is updated, the variable node of the updated historical variable table data can also be added and displayed in groups according to the variable category.
[0159] At the same time, when an export instruction is received, the target variable text data can be exported based on the export requirement information in the export instruction. The export instruction can be triggered according to the user's click operation on the corresponding control. The export requirement information may include the export location, export format, etc. After the target variable text data is exported, it can be imported into other software (for example, software using the grammatical rules in the IEC61131-3 standard) for application, which is convenient for project transplantation.
[0160] In addition, when each text variable in the target variable text data is verified, each text variable can be stored, for example, each text variable can be stored in a preset data structure. For any variable, variable information such as variable name, variable type, initial value, etc. can be stored. Wherein, a linked list structure can be used to store the variable information of each text variable, and the sequence of the text variable definition can be maintained by the linked list storage method, and the text variable can be quickly inserted or deleted. In addition, the structure of a red-black tree can also be used to store the variable information of each text variable, and the variable information of the corresponding text variable can be quickly found according to the variable name, wherein the memory address of the variable information of the text variable and the variable name can be used as the key value of the red-black tree, which can not only ensure the order of the text variable, but also efficiently search for the variable information. It is understandable that when each text variable is stored, text variables of different categories with business associations can also be stored together for easy viewing and classification search.
[0161] In actual applications, variables can be defined in text form or in table form. After the variable definition is completed, the text variable data and the table variable data need to be synchronized.
[0162] In the process of defining variables in text form, the variable text data can be converted into variable table data. When the variable category is a non-global variable, the conversion method can refer to Figure 4 , specifically including:
[0163] S401, edit variable text data;
[0164] S402, verify the variable text data, if the verification passes, execute step S403, if the verification fails, execute step S401;
[0165] S403, converting variable text data into variable table data.
[0166] When the variable category is a global variable, the conversion method can refer to Figure 5 , specifically including:
[0167] S501, edit variable text data;
[0168] S502, verify the variable text data, if the verification passes, execute step S503, if the verification fails, execute step S501;
[0169] S503, deleting the variable node corresponding to the variable text data;
[0170] S504, converting variable text data into variable table data;
[0171] S505: Generate variable nodes corresponding to the variable table data.
[0172] When defining variables in a table, you can convert variable table data into variable text data. When the variable category is a non-global variable, you can directly convert the variable table data into variable text data. When the variable category is a global variable, the conversion method can refer to Figure 6 , specifically including:
[0173] S601, edit variable table data;
[0174] S602, deleting the variable node corresponding to the variable table data;
[0175] S603, converting variable table data into variable text data;
[0176] S604: Generate a variable node corresponding to the variable text data.
[0177] When importing variable text data from third-party software, you can refer to Figure 7 , specifically including:
[0178] S701, obtain the imported XML file and check whether the XML file is valid. If not, execute step S702; if valid, execute step S703;
[0179] S702, end the import;
[0180] S703, parsing and adapting the XML file, and saving it as variable text data;
[0181] S704, determine the current variable display state, if the current variable display state is text, execute step S705, if the current variable display state is table, execute step S706;
[0182] S705, displaying each text variable in the variable text data in the form of text;
[0183] S706, verify the variable text data, if the verification passes, execute step S707, if the verification fails, execute step S705;
[0184] S707, converting the variable text data into variable table data, and displaying the variables in the form of a table.
[0185] Exemplary Devices
[0186] Accordingly, the present application embodiment also provides a text variable processing device, referring to Figure 8 , the device comprises:
[0187] The first processing unit 801 is used to obtain target variable text data, where the target variable text data includes at least one text variable, and the text variable is a variable displayed by text;
[0188] The second processing unit 802 is used for parsing the target variable text data based on the variable category corresponding to the target variable text data upon receiving the verification instruction to obtain at least one character sequence, wherein the character sequence corresponds to the text variable one by one;
[0189] The third processing unit 803 is used to perform verification processing on each of the text variables in the target variable text data based on each of the character sequences.
[0190] Exemplarily, the second processing unit 802 is specifically configured to:
[0191] Determine a target parsing model based on the variable category corresponding to the target variable text data and the corresponding relationship between the variable category and the sub-parsing model, wherein the sub-parsing model includes parsing rules for text variables of the corresponding variable category;
[0192] Based on the common parsing model and the target parsing model, the target variable text data is parsed to obtain at least one character sequence, wherein the common parsing model includes common parsing rules for text variables of different variable categories.
[0193] Exemplarily, the third processing unit 803 is specifically configured to:
[0194] Based on the grammatical rules corresponding to the variable categories, a grammar check is performed on each of the character sequences, and a grammar tree is generated for the character sequences that pass the grammar check based on the grammar check results;
[0195] When the syntax check results of all the character sequences are passed, obtaining each text variable based on the syntax tree;
[0196] Based on the variable attribute rules corresponding to the variable category, attribute verification is performed on each element in each of the text variables, and the variable attribute rules include attribute rules for each element in the text variable.
[0197] Exemplarily, a fourth processing unit is further included, wherein the fourth processing unit is configured to:
[0198] When a grammar check result of at least one of the character sequences fails, generating first error indication information based on the grammar check result;
[0199] and / or,
[0200] When a result of the attribute verification of at least one of the text variables fails, second error indication information is generated based on the attribute verification result.
[0201] Exemplarily, a fifth processing unit is further included, wherein the fifth processing unit is configured to:
[0202] Providing a first variable editing interface, wherein the first variable editing interface is used to edit the text variable;
[0203] In response to an input operation on the first variable editing interface, text variable processing is performed to obtain the target variable text data, and the text variable processing includes at least one of text variable creation, text variable update and text variable deletion.
[0204] Exemplarily, a sixth processing unit is further included, wherein the sixth processing unit is configured to:
[0205] Providing a second variable editing interface, the second variable editing interface is used to edit table variables, the table variables are variables displayed through a table;
[0206] In response to an input operation on the second variable editing interface, table variable processing is performed to obtain target variable table data, wherein the table variable processing includes at least one of table variable creation, table variable update, and table variable deletion;
[0207] When receiving the text switching instruction, updating the historical variable text data based on the target variable table data;
[0208] When the update result of the historical variable text data is not empty, the target variable text data is obtained based on the update result of the historical variable text data.
[0209] Exemplarily, a seventh processing unit is further included, wherein the seventh processing unit is configured to:
[0210] Providing a file import interface, wherein the file import interface is used to import variable files;
[0211] In response to an import operation on the file import interface, an initial variable file is obtained;
[0212] When the initial variable file is valid, the initial variable file is adapted based on the variable category corresponding to the initial variable file, and the target variable text data is obtained based on the adapted initial variable file.
[0213] Exemplarily, an eighth processing unit is further included, wherein the eighth processing unit is configured to:
[0214] When the verification processing results of each of the text variables are passed, the historical variable table data is updated based on the target variable text data;
[0215] and / or,
[0216] When an export instruction is received, the target variable text data is exported based on the export requirement information in the export instruction.
[0217] The text variable processing device provided in this embodiment belongs to the same application concept as the text variable processing method provided in the above embodiments of this application, and can execute the text variable processing method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the text variable processing method. For technical details not fully described in this embodiment, please refer to the specific processing content of the text variable processing method provided in the above embodiments of this application, and will not be repeated here.
[0218] The functions implemented by the above-mentioned first processing unit 801, the second processing unit 802 and the third processing unit 803 may be implemented by the same or different processors, respectively, and the embodiment of the present application is not limited thereto.
[0219] It should be understood that the units in the above devices can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or realize the functions of each unit of the device, wherein the processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory in the device or a memory outside the device. Alternatively, the units in the device can be implemented in the form of hardware circuits, and the functions of some or all units can be realized by designing the hardware circuits. The hardware circuit can be understood as one or more processors; for example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are realized by designing the logical relationship of the components in the circuit; for another example, in another implementation, the hardware circuit can be implemented by PLD, taking FPGA as an example, which can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by the configuration file, so as to realize the functions of some or all of the above units. All units of the above devices can be implemented in the form of a processor calling software, or in the form of hardware circuits, or in part by a processor calling software, and the remaining part is implemented in the form of hardware circuits.
[0220] In an embodiment of the present application, a processor is a circuit with the ability to process signals. In one implementation, the processor may be a circuit with the ability to read and run instructions, such as a CPU, a microprocessor, a GPU, or a DSP; in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, DPU, etc.
[0221] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0222] In addition, all or part of the units in the above device can be integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a SOC. The SOC may include at least one processor for implementing any of the above methods or implementing the functions of each unit of the device. The type of the at least one processor may be different, for example, including a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.
[0223] Exemplary computer program products and storage media
[0224] In addition to the above-mentioned methods and devices, the text variable processing method provided in the embodiments of this specification may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the text variable processing method according to various embodiments of this specification described in the above-mentioned "Exemplary Method" section of this specification.
[0225] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the embodiments of the present specification, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0226] In addition, an embodiment of the present specification also provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to execute the steps of the text variable processing method according to various embodiments of the present specification described in the above "Exemplary Method" section of the present specification.
[0227] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this specification can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0228] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0229] The above-mentioned embodiments only express several implementation methods of this specification, and the descriptions are relatively specific and detailed, but they cannot be understood as limiting the scope of the solutions provided by the embodiments of this specification. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of this specification, which all belong to the protection scope of this specification. Therefore, the protection scope of the patent of this specification shall be based on the attached claims.
Claims
1. A text variable processing method, characterized in that: include: Acquire target variable text data, wherein the target variable text data includes at least one text variable, and the text variable is a variable displayed by text; When receiving the verification instruction, the target variable text data is parsed based on the variable category corresponding to the target variable text data to obtain at least one character sequence, wherein the character sequence corresponds to the text variable one by one; Based on each of the character sequences, verification processing is performed on each of the text variables in the target variable text data.
2. The method according to claim 1, characterized in that The step of parsing the target variable text data based on the variable category corresponding to the target variable text data to obtain at least one character sequence includes: Determine a target parsing model based on the variable category corresponding to the target variable text data and the corresponding relationship between the variable category and the sub-parsing model, wherein the sub-parsing model includes parsing rules for text variables of the corresponding variable category; Based on the common parsing model and the target parsing model, the target variable text data is parsed to obtain at least one character sequence, wherein the common parsing model includes common parsing rules for text variables of different variable categories.
3. The method according to claim 1, characterized in that: The checking process of each of the text variables in the target variable text data based on each of the character sequences includes: Based on the grammatical rules corresponding to the variable categories, a grammar check is performed on each of the character sequences, and a grammar tree is generated for the character sequences that pass the grammar check based on the grammar check results; When the syntax check results of all the character sequences are passed, obtaining each text variable based on the syntax tree; Based on the variable attribute rules corresponding to the variable category, attribute verification is performed on each element in each of the text variables, and the variable attribute rules include attribute rules for each element in the text variable.
4. The method according to claim 3, characterized in that: Also includes: When a grammar check result of at least one of the character sequences fails, generating first error indication information based on the grammar check result; and / or, When a result of the attribute verification of at least one of the text variables fails, second error indication information is generated based on the attribute verification result.
5. The method according to claim 1, characterized in that The step of obtaining target variable text data includes: Providing a first variable editing interface, wherein the first variable editing interface is used to edit the text variable; In response to an input operation on the first variable editing interface, text variable processing is performed to obtain the target variable text data, and the text variable processing includes at least one of text variable creation, text variable update and text variable deletion.
6. The method according to claim 1, characterized in that The step of obtaining target variable text data includes: Providing a second variable editing interface, the second variable editing interface is used to edit table variables, the table variables are variables displayed through a table; In response to an input operation on the second variable editing interface, table variable processing is performed to obtain target variable table data, wherein the table variable processing includes at least one of table variable creation, table variable update, and table variable deletion; When receiving the text switching instruction, updating the historical variable text data based on the target variable table data; When the update result of the historical variable text data is not empty, the target variable text data is obtained based on the update result of the historical variable text data.
7. The method according to claim 1, characterized in that The step of obtaining target variable text data includes: Providing a file import interface, wherein the file import interface is used to import variable files; In response to an import operation on the file import interface, an initial variable file is obtained; When the initial variable file is valid, the initial variable file is adapted based on the variable category corresponding to the initial variable file, and the target variable text data is obtained based on the adapted initial variable file.
8. The method according to any one of claims 1 to 7, characterized in that: After verifying each of the text variables in the target variable text data based on each of the character sequences, the method further includes: When the verification processing results of each of the text variables are passed, the historical variable table data is updated based on the target variable text data; and / or, When an export instruction is received, the target variable text data is exported based on the export requirement information in the export instruction.
9. A text variable processing device, characterized in that: include: A first processing unit is used to obtain target variable text data, where the target variable text data includes at least one text variable, and the text variable is a variable displayed by text; A second processing unit is used for, upon receiving the verification instruction, parsing the target variable text data based on the variable category corresponding to the target variable text data to obtain at least one character sequence, wherein the character sequence corresponds to the text variable one by one; The third processing unit is used to perform verification processing on each of the text variables in the target variable text data based on each of the character sequences.
10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the text variable processing method according to any one of claims 1 to 8 is implemented.
