Data synchronization method and device, equipment, storage medium and program product
By analyzing engineering files to identify key variables and synchronizing data through associated relationships, the method addresses inefficiencies in soft PLC data synchronization, ensuring accurate simulation results.
Patent Information
- Application Number
- CN202510466826.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-07-15
AI Technical Summary
In the prior art, there is poor timeliness in synchronization with the intermediate process data of soft PLC simulation calculation and field PLC, which affects the accuracy of simulation operations, and it takes time to obtain data through polling.
By analyzing the project files of the target controller, obtaining leaf node variables, collecting actual running data, and calculating the simulation running data of the associated controller variables based on the simulation control program, and synchronizing it to the simulation control program to participate in the operation.
Quickly realize the synchronization of intermediate data between soft PLC and field PLC, shorten the data acquisition time period, and ensure the accuracy of simulation calculations.
Smart Images

Figure CN120315364A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data processing, and in particular, to a data synchronization method, apparatus, electronic device, storage medium, and program product. Background Art
[0002] A programmable logic controller (PLC) is a digital operation electronic system that controls various devices through digital or analog inputs and outputs. The historical data of controllers such as PLCs, especially the intermediate process data, can record important information during equipment anomalies or failures, and can help engineers troubleshoot faults and quickly and accurately locate the cause of the faults. Due to the complexity and large volume of the intermediate process data, the current acquisition of the intermediate process data is mainly carried out by polling or listening. Affected by the industrial field network bandwidth and the maximum communication load of the PLC, etc., it is impossible to obtain all the data within the controller scan cycle in a timely manner. In this regard, using a soft PLC to simulate the operation logic of the on-site PLC in order to simulate and calculate all the data within the on-site PLC scan cycle is an important implementation method for obtaining all the data of the controller.
[0003] A soft PLC is an executable program generated by transplanting the on-site PLC project to a common PC for compilation, and its program operation logic is the same as that of the on-site PLC. However, since the on-site PLC has actually been running for a period of time at the start-up moment of the soft PLC, a large amount of intermediate process data has been generated during this period, and this intermediate process data will affect the logical operation of the intermediate program of the on-site PLC, and ultimately affect the operation result output by the on-site PLC. At the start-up moment of the soft PLC, there is almost no intermediate process data. At this time, even if the input data and program operation logic of the soft PLC are the same as those of the on-site PLC, there will still be a large gap between the operation result output by the soft PLC and the operation result output by the on-site PLC, affecting the accuracy of the soft PLC simulation calculation.
[0004] Since the data volume of the intermediate process data of controllers such as PLCs is very large, obtaining all of them by polling will take a long time, resulting in poor timeliness of the obtained data and unable to guarantee the accuracy of the soft PLC simulation calculation after synchronization.
[0005] Therefore, how to quickly synchronize the intermediate data between the soft PLC and the on-site PLC to ensure the accuracy of the soft PLC simulation calculation is a technical problem that needs to be solved urgently. Summary of the Invention
[0006] In order to solve the above technical problems, the present disclosure provides a data synchronization method, apparatus, device, storage medium, and program product.
[0007] The first aspect of the embodiments of the present disclosure provides a data synchronization method, including: Parse the engineering file corresponding to the target control program of the target controller to obtain the leaf node variables of the target control program; Collect the actual operation data corresponding to the leaf node variables, where the actual operation data includes the data generated during the operation of the target control program; Based on the simulation control program, calculate the simulated operation data of the controller variables associated with the leaf node variables, where the simulated operation data includes the simulated intermediate process data generated during the operation of the simulation control program; Synchronize the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program.
[0008] The second aspect of the embodiments of the present disclosure provides a data synchronization device, including: A parsing module for parsing the engineering file corresponding to the target control program of the target controller to obtain the leaf node variables of the target control program; A collection module for collecting the actual operation data corresponding to the leaf node variables, where the actual operation data includes the data generated during the operation of the target control program; A calculation module for calculating the simulated operation data of the controller variables associated with the leaf node variables based on the simulation control program, where the simulated operation data includes the simulated intermediate process data generated during the operation of the simulation control program; A synchronization module for synchronizing the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program.
[0009] The third aspect of the embodiments of the present disclosure provides an electronic device, including: A processor; A memory; and A computer program; wherein, the computer program is stored in the memory and is configured to be executed by the processor to implement the data synchronization method provided in the first aspect above.
[0010] The fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, enables the processor to implement the data synchronization method provided in the first aspect above.
[0011] The fifth aspect of the embodiments of the present disclosure provides a computer-readable program product, which includes a computer program or instruction, and when the computer program or instruction is executed by a processor, enables the processor to implement the data synchronization method provided in the first aspect above.
[0012] The technical solutions provided by the embodiments of the present disclosure have the following advantages compared with the prior art: The data synchronization method, device, equipment, storage medium and program product provided by the embodiments of the present disclosure obtain the leaf node variables of the target control program by parsing the engineering file corresponding to the target control program of the target controller; collect the actual operation data corresponding to the leaf node variables, and the actual operation data includes the data generated by the operation of the target control program; based on the simulation control program, calculate the simulation operation data of the controller variables associated with the leaf node variables, and the simulation operation data includes the simulation intermediate process data generated by the operation of the simulation control program; synchronize the actual operation data corresponding to the leaf node variables and the simulation operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program. Thereby, it is possible to obtain a large amount of intermediate process data through rapid calculation only by collecting the actual operation data corresponding to a small number of leaf node variables, greatly shortening the time period for obtaining the intermediate process data, thus quickly realizing the intermediate data synchronization between the soft PLC and the field PLC, and further ensuring the accuracy of the soft PLC simulation calculation. Description of the Drawings
[0013] The drawings here are incorporated into the specification and form a part of this specification, showing the embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0015] Figure 1 is a flowchart of a data synchronization method provided by an embodiment of the present disclosure; Figure 2 is a flowchart of another data synchronization method provided by an embodiment of the present disclosure; Figure 3 is a schematic diagram of a variable association map provided by an embodiment of the present disclosure; Figure 4 is a schematic structural diagram of a data synchronization device provided by an embodiment of the present disclosure; Figure 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. Detailed Embodiments
[0016] To better understand the above objects, features, and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that, without conflict, the embodiments of the present disclosure and the features in the embodiments may be combined with each other.
[0017] In the following description, numerous specific details are set forth to facilitate a thorough understanding of the present disclosure, but the present disclosure may be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of the present disclosure, rather than all of the embodiments.
[0018] It should be understood that the steps recited in the method embodiments of the present disclosure may be executed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.
[0019] It should be noted that, in this document, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variation thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0020] It should be noted that the modifiers "a" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise clearly specified in the context, it should be construed as "one or more".
[0021] Under normal circumstances, when simulating the operation of the on-site PLC, since the on-site PLC has actually been running for a period of time at the moment when the soft PLC starts, a large amount of intermediate process data is generated during this period, and this intermediate process data will affect the operation of the on-site PLC, and ultimately affect the operation result output by the on-site PLC. At the moment when the soft PLC starts, there is almost no intermediate process data. At this time, even if the input data and program operation logic of the soft PLC are the same as those of the on-site PLC, there will still be a large gap between the operation result output by the soft PLC and the operation result output by the on-site PLC, affecting the accuracy of the soft PLC simulation operation. If all the intermediate process data is obtained through the acquisition method, it will take a long time, resulting in poor timeliness of the obtained data and unable to guarantee the accuracy of the soft PLC simulation operation after synchronization. To solve this problem, the embodiments of the present disclosure provide a data synchronization method, which will be introduced below in combination with specific embodiments.
[0022] Figure 1 FIG. is a flowchart of a data synchronization method provided by an embodiment of the present disclosure. This method can be executed by a data synchronization device, which can be implemented in software and / or hardware, and the data synchronization device can be configured in an electronic device, such as a server or a terminal.
[0023] As Figure 1 shown, the data synchronization method provided in this embodiment includes the following steps.
[0024] S110. Analyze the engineering file corresponding to the target control program of the target controller, and obtain the leaf node variables of the target control program.
[0025] In the embodiments of the present disclosure, the target controller 21 is an entity controller, in which a target control program runs. The target control program controls various types of configuration devices in the field by digital or analog input and output data. The target controller can be any controller capable of device control, including but not limited to: Programmable Logic Controller (PLC), Distributed Control System (DCS), and robot special controllers, etc. Different types of controllers have different control methods and application scenarios.
[0026] The devices connected to and controlled by the target controller here include but are not limited to automation devices such as sensors, cameras, motors, frequency converters, and robots in the industrial field. These devices are controlled by the target controller and execute in an orderly manner according to a predetermined program.
[0027] The project file corresponding to the control program of the controller refers to the files created and used during the controller development process, which contains all the information required to implement specific automation control tasks, such as configuration files for describing the hardware configuration, communication configuration, parameter configuration, etc. of the controller, as well as program files for describing the control logic of the controller, etc.
[0028] Optionally, the format of the controller can be XML format, or JSON format or other formats.
[0029] Optionally, depending on the different configurations and settings of the controller, the number of project files can be one or more.
[0030] In some embodiments of the present disclosure, the corresponding project file is exported from the controller by calling a dedicated export tool, thereby obtaining the project file corresponding to the controller. The project file can also be obtained through other means, which will not be further limited here. For example, taking Siemens PLC1500 as an example, the project file of the PLC controller can be directly exported through the openness tool.
[0031] By parsing the obtained project file of the controller, the leaf node variables of the target control program can be obtained. Here, a node refers to the syntax element corresponding to the controller program in the project file, and these syntax elements can be the basic components of the controller program (such as variables, constants, operators), or more complex structures (such as expressions, statements, functions or modules). The hierarchical relationship between nodes reflects the logical relationship of the program code.
[0032] Optionally, the node types can include root nodes, leaf nodes and intermediate nodes. Among them, the root node refers to the node without a parent node. The root node is generally the top-level node, and it may contain multiple child nodes below. The leaf node refers to the node without child nodes, and it is generally the bottom-level node. The intermediate node refers to the node other than the root node and the leaf node.
[0033] Each node usually contains the corresponding variable information. Here, the variable information refers to the variable name, variable type, variable address, and the location information of the DB block or program block where the variable is located, etc. of at least one variable contained in the node.
[0034] Optionally, the root node contains root node variables, the leaf node contains leaf node variables, and the intermediate node contains intermediate node variables. The leaf node variables include controller variables without child nodes, the root node variables contain controller variables without parent nodes, and the intermediate node variables include controller variables with both parent nodes and child nodes.
[0035] By parsing the engineering file of the control program and analyzing the node information of the controller program corresponding to the engineering file, the variable information contained in each node can be obtained. Furthermore, the leaf node variables contained in the leaf nodes can be obtained, that is, the variable information of the leaf node variables contained in the leaf nodes can be obtained. The variable information includes at least the variable names of the leaf node variables.
[0036] S120. Collect the actual operation data corresponding to the leaf node variables. The actual operation data includes the data generated by the operation of the target control program.
[0037] In the embodiments of the present disclosure, for the leaf node variables of the target control program obtained by parsing, collect the actual operation data corresponding to the leaf node variables. Among them, the collection methods include but are not limited to: active collection or listening collection.
[0038] Optionally, the actual operation data corresponding to the leaf node variables obtained by collection refers to the data generated by the operation of the target control program of the target controller, including the actual input data. For example, it includes the actual operation data of the I variable.
[0039] The actual operation data here refers to the data actually generated by the industrial field equipment. The actually generated actual operation data is real-time data. If the actually generated actual operation data is stored, it constitutes historical data. The actual operation data includes real-time operation data and / or historical operation data.
[0040] Optionally, after collecting the actual operation data corresponding to the leaf node variables and before sending it to the simulation control program, store these data. The storage method is not specifically limited.
[0041] S130. Based on the simulation control program, calculate the simulation operation data of the controller variables associated with the leaf node variables. The simulation operation data includes the simulation intermediate process data generated by the operation of the simulation control program.
[0042] In the embodiments of the present disclosure, based on the simulation control program, calculate the simulation operation data of the controller variables associated with the leaf node variables from the actual operation data corresponding to the leaf node variables obtained in the above steps. Among them, the simulation operation data includes the simulation intermediate process data generated by the operation of the simulation control program.
[0043] Optionally, the controller variables associated with the leaf node variables include root node variables and intermediate node variables. Whether it is a root node variable or an intermediate node variable, it is a variable associated with the leaf node variable. The association relationship here refers to the dependency relationship between the variables contained in each node. By analyzing the logical relationship of the control program code, the hierarchical relationship between the nodes can be obtained, and then the dependency relationship between the variables contained in each node can be obtained, so as to determine the association relationship of the variables contained in each node.
[0044] The simulation control program is a program that can simulate the operation of the target control program of the target controller, that is, the simulation control program has the same or similar operation logic as the target control program.
[0045] Optionally, the simulation control program can run on a hardware redundant controller (such as a redundant PLC device, a redundant DCS device, etc.), can also run on a data acquisition module integrated in the hardware controller, and can also run on any electronic device capable of running the simulation control program. The simulation control program can be a soft PLC, which is not limited here.
[0046] Based on the actual operation data corresponding to the leaf node variables obtained by acquisition, the simulation control program can calculate and obtain the simulation operation data of the controller variables associated with the leaf node variables by running the same or similar program as the target control program. The simulation operation data includes the simulation intermediate process data generated by the operation of the simulation control program.
[0047] Among them, the intermediate process data refers to the data generated during the controller scan cycle or operation cycle except for the input data and output data. The simulation intermediate process data refers to the data generated during the simulation control program scan cycle or operation cycle of the simulation controller except for the input data and output data.
[0048] Optionally, the simulation intermediate process data includes but is not limited to: DB data, C data, T data, M data, temporary data (temp data), etc. Among them, DB data refers to the data located in the D area of the controller, which is used to store the relevant data of the background data block; C data refers to the data located in the C area of the controller, which is used to store the relevant data of the calculator; T data refers to the data located in the T area of the controller, which is used to store the relevant data of the timer.
[0049] Optionally, the simulation operation data also includes simulation input data and simulation output data. Among them, the simulation input data is the data sent by the device to the target controller, for example, it is I-type data. Generally, the simulation input data is the same as the actual input data. The simulation output data is the output data generated by the simulation control program after simulation operation. The simulation output data is not sent to the device for device control, while the actual output data will be sent by the target controller to the corresponding device.
[0050] Optionally, the simulated intermediate process data and the simulated output data are not sent to the device for device control, but are used for statistical analysis of industrial big data to determine the root cause of on-site device failures or optimize the operation and maintenance of on-site devices, etc.
[0051] Optionally, the simulated intermediate process data and / or the simulated output data are stored, and the storage method is not further defined herein.
[0052] S140. Synchronize the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program.
[0053] In the embodiments of the present disclosure, synchronizing both the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program can enable data from different sources to participate in the operation of the simulation control program and obtain simulated output data through running calculations.
[0054] Among them, the actual operation data corresponding to the leaf node variables obtained by the acquisition method and the simulated operation data of the controller variables associated with the leaf node variables obtained by the calculation method can both constitute the simulated intermediate process data to be synchronized in the simulation control program. These data can make up for the lack of intermediate process data at the initial stage of the simulation control program startup, thereby improving the calculation accuracy of the simulation control program.
[0055] In the embodiments of the present disclosure, by parsing the engineering file corresponding to the target control program of the target controller, the leaf node variables of the target control program are obtained; the actual operation data corresponding to the leaf node variables is collected, and the actual operation data includes the data generated during the operation of the target control program; based on the simulation control program, the simulated operation data of the controller variables associated with the leaf node variables is calculated, and the simulated operation data includes the simulated intermediate process data generated during the operation of the simulation control program; the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables are synchronized to the simulation control program to participate in the operation of the simulation control program. Thus, it is only necessary to collect a small amount of operation data corresponding to the leaf node variables, and then quickly calculate most of the intermediate process data through the simulation control program, and synchronize the data obtained by the combination of collection + calculation to the simulation control program to make up for the lack of intermediate process data at the initial stage of the simulation control program startup. Compared with the method of collecting all intermediate process data, it can greatly shorten the time cycle for obtaining intermediate process data, effectively improve the efficiency of intermediate process data synchronization, and further improve the simulation calculation accuracy of the simulation control program.
[0056] Based on the above embodiments, Figure 2 is a flowchart of another data synchronization method provided by an embodiment of the present disclosure. As Figure 2 shown, the specific steps are as follows: S210. Analyze the engineering file corresponding to the target control program of the target controller to obtain the leaf node variables of the target control program, including: analyze the engineering file of the target controller to obtain the program text and variable table; analyze the program text and variable table to obtain the abstract syntax tree; extract the node information of the abstract syntax tree, and determine the leaf node variables of the target control program based on the node information.
[0057] In an embodiment of the present disclosure, after obtaining the engineering file, the program text and variable table can be obtained by analyzing the engineering file. The program text records all relevant information of the program code, and the variable table records all relevant information of the controller variables included in the program text.
[0058] Optionally, the analysis here includes at least one or more of operations such as decompressing the engineering file, format processing, and information reading.
[0059] Optionally, format processing refers to converting the program text of different programming languages into the program text of a unified language. For example, the program text of Structured Text (ST) language. The language types of the program text of different programming languages include, but are not limited to, languages such as Sequential Function Chart (SFC), Function Block Diagram (FBD), Ladder Diagram (LD), Instruction List (IL), and Structured Text (ST) language. The program texts of other languages can all be converted into the program text in ST format. As for the technology of converting the program text of different languages, no further limitation is made here as long as the language conversion function can be realized.
[0060] Optionally, the variable table includes the variable information of all controller variables corresponding to the controller program. The variable information includes one or more of information such as the variable name, variable type, block type, and block number of the variable.
[0061] Analyze the program text and variable table to obtain the abstract syntax tree. Specifically, it means to obtain the abstract syntax tree corresponding to the program code by performing lexical analysis and syntactic analysis on the obtained program text. Here, the abstract syntax tree (abbreviated as AST) or syntax tree (abbreviated as ST) is a tree-like representation of the abstract syntactic structure of the program code, which expresses the syntactic structure of the program code in the program text in a tree-like form, and each node on the tree represents a syntactic element of the program code. The syntactic elements here can be the basic components of the controller program (such as variables, constants, operators), or more complex structures (such as expressions, statements, functions, or modules). The hierarchical relationship between nodes reflects the logical relationship of the program code.
[0062] Among them, lexical analysis means to sequentially identify keywords, variables, constants, identifiers, operators, etc. according to the lexical definition of the source program, and generate and output a sequence of lexical units. Syntactic analysis is a process of analyzing the input text composed of a sequence of units from top to bottom according to a given formal grammar and determining its syntactic structure. According to the syntactic rules of the source program, various syntactic components are identified from the output of the lexical analysis stage.
[0063] For example, in the syntactic analysis of I3 = I1 + 5, the syntactic components include: variables I1, I3; constant 5; plus sign (+), equal sign (=), and there is a dependency relationship between variables I1 and I3.
[0064] By performing lexical analysis and syntactic analysis on the program text, analyze the dependency relationships of various variables in the program, clarify the execution order of methods in the program, analyze the formal parameters and actual parameters in functions and methods in the program block, represent the structure of the data, clarify the reference relationships between variables, and generate an abstract syntax tree using the reference relationships between variables in the program to be processed. The abstract syntax tree is an abstract representation of the syntactic structure of the source code. It describes the dependency relationships between nodes in the program text in the form of a tree, and each node on the tree represents a dependency relationship in the source code, and different nodes contain different types of variables.
[0065] Each node in the abstract syntax tree includes a preset node name, node hierarchical relationship information, node type, variable information and constant information contained in each node, etc. Among them, the node name is used to name each node, and it is unique. The node position information includes the starting line, starting column, ending line, and ending column where the lexical unit matched by each node is located, and is used for error tracking and position location.
[0066] On this basis, extract the node information of the abstract syntax tree, and determine the leaf node variables of the target control program based on the node information. Specifically, through the node hierarchy relationship information, the position of each node in the syntax tree can be determined, the association relationship between each node can be determined, and then the leaf nodes and the leaf node variables included in the leaf nodes can be determined. Among them, the node types include root nodes, leaf nodes, or parent nodes, child nodes, etc. The parent node is the previous node of the current node. Except for the root node, each node in the abstract syntax tree has and only has one parent node. The root node is the starting node and has no parent node. The variable information includes the variable names, variable addresses, and dependency relationships between variables of one or more variables included in the node.
[0067] Optionally, the root node is the starting node, and the root node variable is a variable without a parent node upward. The root node variable is generally a global variable, and the variable types include but are not limited to: Q variable, DB variable, M variable, T variable, C variable. The intermediate node variable is a variable that has both a parent node and a child node, and the types of intermediate node variables include but are not limited to: M variable, DB variable, C variable, T variable, etc. The leaf node variable is a variable without descendant nodes, and the types of leaf node variables include but are not limited to: I variable, DB variable, M variable, T variable, C variable.
[0068] Optionally, extracting the node information of the abstract syntax tree and determining the leaf node variables of the target control program based on the node information further includes: reading the node information of each node of the abstract syntax tree, where the node information includes at least one variable information included in the node and the dependency relationship between variables; establishing a variable association graph based on the dependency relationship between variables; and identifying leaf node variables based on the variable association graph.
[0069] Specifically, extract all nodes in the abstract syntax tree, and based on a recursive function, traverse all subtrees under each node in a forward or reverse order to obtain the variables under each node and the dependency relationships of the corresponding variables. Determine the dependency relationships between the variables included in each node according to the hierarchical relationship of the nodes, and then based on the dependency relationships between the variables, sort out the variables with dependency relationships, find all the root node variables, intermediate node variables, and leaf node variables in the program text, and establish a variable association graph, see Figure 3 。
[0070] For example, Figure 3 the variable dependency relationship in is: variable Q1 = DB2 + M3, variable DB2 = I4 + m, variable M3 = I5 + x. From this analysis, it can be concluded that the root node variable is Q1, the leaf node variables are I4 and I5, the intermediate node variables are DB2 and M3, and m and x are specific constants.
[0071] Optionally, when extracting the variables of each node from the abstract syntax tree, it is necessary to determine whether all the variables of all the nodes in the syntax tree have been extracted. If all the nodes in the syntax tree have been extracted, then generate a dependency relationship formula using the variables of all the nodes in the syntax tree; if not all the nodes in the syntax tree have been extracted, then extract the child nodes and adjacent nodes of the node in turn. When the extraction of the child nodes and adjacent nodes of the node is completed, jump out of the node. Traverse the other subtrees under each node again until all the nodes in the syntax tree have been extracted. For the above extraction results, based on the recursive function, recursively obtain the parent node of the node as the independent variable of the dependency relationship formula, and generate the dependency relationship formula. Build a variable association map from the root node variable to the intermediate process node variable, and finally to the leaf node variable from top to bottom.
[0072] S220. Collect the actual operation data corresponding to the leaf node variable, and the actual operation data includes the actual input data required for the operation of the target control program; S230. Based on the simulation control program, calculate the simulation operation data of the controller variable associated with the leaf node variable, and the simulation operation data includes the simulation intermediate process data generated by the operation of the simulation control program; Optionally, the controller variables associated with the leaf node variable include the root node variables and / or intermediate node variables that have a dependency relationship with the leaf node variable. The root node variables include the controller variables without a parent node, and the intermediate node variables include the controller variables that have both a parent node and a child node.
[0073] S240. Synchronize the actual operation data corresponding to the leaf node variable and the simulation operation data of the controller variable associated with the leaf node variable to the simulation control program, and participate in the operation of the simulation control program.
[0074] It should be noted that the specific implementation manners of S220 - S240 are similar to the above implementation manners and will not be elaborated here.
[0075] The present disclosure implements obtaining program text and variable tables by parsing the engineering files of the target controller; analyzing the program text and variable tables to obtain an abstract syntax tree; reading the node information of each node of the abstract syntax tree, and based on the dependency relationship between variables, establishing a variable association graph. Based on this variable association graph, leaf node variables are identified, so that it is possible to more efficiently and intuitively determine the leaf node variables that need to be collected. Using the operation data corresponding to the collected leaf node variables and the corresponding soft PLC calculation program for simulation operations, the operation data of the root node variables and intermediate node variables associated with the leaf node variables are obtained. The operation data obtained by the above "collection + calculation" is used as intermediate process data to synchronously overwrite the soft PLC, and the subsequent simulation calculation of the soft PLC is continued based on the overwritten intermediate process data and the collected input data to make up for the lack of intermediate process data in the initial stage of the soft PLC startup, thereby improving the accuracy of the soft PLC simulation calculation. Compared with the method of obtaining all intermediate process data by collection, by using the "collection + calculation" method to obtain intermediate process data, only the operation data corresponding to a small number of leaf node variables needs to be collected, and most of the intermediate process data can be obtained through the fast calculation of the soft PC program, shortening the time cycle for obtaining intermediate process data, thereby improving the efficiency of intermediate data synchronization, and further facilitating the improvement of the accuracy of the soft PLC simulation calculation.
[0076] Optionally, in some embodiments, before synchronizing the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program and participating in the operation of the simulation control program, the method further includes: synchronizing the clock corresponding to the preset operation environment for running the simulation control program, so that the clock corresponding to the simulation control program is synchronized with the clock corresponding to the target control program of the target controller.
[0077] Since there are hardware quality differences between the clock corresponding to the simulation control program and the clock corresponding to the target control program, there may be errors in their timing accuracy. Therefore, it is necessary to synchronize the two to provide the same time reference for the data synchronization process.
[0078] Specifically, a request for obtaining the current time is sent to the clock server used by the target controller, the current time is obtained, and the system time of the preset operation environment of the simulation control program is set to the current time.
[0079] Optionally, the step of clock synchronization is executed once every preset time during the data synchronization process, so as to avoid large time errors caused by the long-term accumulation of errors between the clock corresponding to the simulation control program and the clock corresponding to the target control program.
[0080] Optionally, in some embodiments, after synchronizing the actual operation data corresponding to the leaf node variable and the simulated operation data of the controller variable associated with the leaf node variable to the simulation control program and participating in the operation of the simulation control program, the method further includes: collecting the actual operation data of the target control program, where the actual operation data includes actual intermediate process data and / or actual output data; obtaining the simulated operation data generated by the simulation control program simulating the operation of the target control program, where the simulated operation data includes simulated intermediate process data and / or simulated output data; comparing the actual operation data with the simulated operation data, and when the actual operation data is inconsistent with the simulated operation data, replacing the simulated operation data with the actual operation data.
[0081] After synchronizing the intermediate process data and the synchronized data participating in the operation of the simulation control program, it is necessary to detect and calibrate the accuracy of the simulation control program, and at the same time update the data in the simulation control program to continuously improve its accuracy, and finally achieve full synchronization or be infinitely close to the target control program.
[0082] Specifically, comparing the actual operation data of the target control program with the simulated operation data of the simulation control program, if the two are consistent, it proves that the simulation control program is synchronized with the target control program; if the two are inconsistent, it proves that the simulation control program is not synchronized with the target control program, and the simulation control program needs to be calibrated.
[0083] Based on the above embodiments, after replacing the simulated operation data with the actual operation data, continue to perform multiple rounds of data comparison, and replace the simulated operation data with the actual operation data every time the comparison result is inconsistent; when the number of rounds of data comparison exceeds the preset round threshold, if the simulation control program is still not synchronized with the target control program, a warning message needs to be generated to remind the developer to check.
[0084] In the embodiments of the present disclosure, during the process of the simulation control program performing operations based on the collected actual operation data, the actual operation data and the simulated operation data are compared in real time to determine whether the simulation control program is synchronized with the target control program, and when the two are not synchronized, the simulated operation data is replaced with the actual operation data, so that the simulated operation data gradually approaches the target operation data, continuously improves the accuracy of the simulation control program, and finally is synchronized with the target control program.
[0085] Figure 4 It is a schematic structural diagram of a data synchronization device provided by an embodiment of the present disclosure. The data synchronization device provided by the embodiments of the present disclosure can execute the processing flow provided by the data synchronization method embodiments, as Figure 4 shown, the data synchronization device 40 includes: a parsing module 41, a collection module 42, a calculation module 43, and a synchronization module 44.
[0086] Among them, the parsing module 41 can be used to parse the project file corresponding to the target control program of the target controller and obtain the leaf node variables of the target control program.
[0087] The acquisition module 42 can be used to acquire the actual operation data corresponding to the leaf node variables, and the actual operation data includes the data generated during the operation of the target control program.
[0088] The calculation module 43 can be used to calculate the simulated operation data of the controller variables associated with the leaf node variables based on the simulated control program, and the simulated operation data includes the simulated intermediate process data generated during the operation of the simulated control program.
[0089] The synchronization module 44 can be used to synchronize the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulated control program and participate in the operation of the simulated control program.
[0090] In the embodiments of the present disclosure, it is possible to obtain the leaf node variables of the target control program by parsing the project file corresponding to the target control program of the target controller; acquire the actual operation data corresponding to the leaf node variables, and the actual operation data includes the data generated during the operation of the target control program; calculate the simulated operation data of the controller variables associated with the leaf node variables based on the simulated control program, and the simulated operation data includes the simulated intermediate process data generated during the operation of the simulated control program; synchronize the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulated control program and participate in the operation of the simulated control program. Thus, it is possible to quickly obtain a large amount of intermediate process data through rapid calculation by only acquiring the actual operation data corresponding to a small number of leaf node variables, thereby quickly realizing the intermediate data synchronization between the soft PLC and the field PLC and ensuring the accuracy of the soft PLC simulation calculation.
[0091] In some embodiments of the present disclosure, the parsing module 41 further includes a leaf node variable acquisition sub-module, which is used to parse the project file of the target controller to obtain the program text and variable table; analyze the program text and variable table to obtain the abstract syntax tree; extract the node information of the abstract syntax tree, and determine the leaf node variables of the target control program based on the node information.
[0092] In some embodiments of the present disclosure, the parsing module 41 further includes a variable association graph construction sub-module, which is used to read the node information of each node of the abstract syntax tree, and the node information includes at least one variable information contained in the node and the dependency relationship between variables; establish a variable association graph based on the dependency relationship between variables; and then identify the leaf node variables of the variable association graph based on the variable association graph, and the leaf node variables are controller variables without child nodes.
[0093] In some embodiments of the present disclosure, the data synchronization device further includes a verification module 45, which can be used to collect the actual operation data of the target control program. The actual operation data includes actual intermediate process data and / or actual output data; obtain the simulated operation data generated by the simulated control program simulating the operation of the target control program. The simulated operation data includes simulated intermediate process data and / or simulated output data; compare the actual operation data with the simulated operation data, and when the actual operation data is inconsistent with the simulated operation data, replace the simulated operation data with the actual operation data.
[0094] In some embodiments of the present disclosure, the data synchronization device further includes a clock synchronization module 46, which can be used to synchronize the clock corresponding to the preset operation environment for running the simulated control program, so that the clock corresponding to the simulated control program is synchronized with the clock corresponding to the target control program of the target controller.
[0095] Figure 4 The data synchronization device of the embodiment can be used to execute the technical solutions of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here.
[0096] Figure 5 It is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. The electronic device provided by the embodiment of the present disclosure can execute the processing flow provided by the data synchronization method embodiment, as Figure 5 shown, the electronic device 5 includes: a processor 51, a memory 52, and a computer program 53; wherein, the computer program is stored in the memory 52 and is configured to read the computer program 53 from the memory 52 and execute the computer program 53 to implement the data synchronization method provided by the embodiment of the present disclosure Figures 1 to 3 provided.
[0097] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium, which can store a computer program. When the computer program is executed by a processor, the processor implements the data synchronization method provided by the embodiment of the present disclosure Figures 1 to 3 provided.
[0098] The above storage medium can, for example, include a memory of a computer program. The above computer program can be executed by a processor of the data synchronization device to complete the data synchronization method provided by the embodiment of the present disclosure Figures 1 to 3 provided. Optionally, the storage medium can be a non-transitory computer-readable storage medium. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (Random Access Memory, RAM), a compact disc read-only memory (Compact Disc ROM, CD-ROM), a magnetic tape, a floppy disk, and an optical data storage configuration device, etc.
[0099] In addition, an embodiment of the present disclosure also provides a computer program product, which includes a computer program or instruction. When the computer program or instruction is executed by a processor, the above data synchronization method is implemented.
[0100] The above are only specific implementation manners of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be obvious to those skilled in the art. The general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data synchronization method, characterized in that, Including: Analyze the project file corresponding to the target control program of the target controller to obtain the leaf node variables of the target control program; Collect the actual operation data corresponding to the leaf node variables, where the actual operation data includes the data generated during the operation of the target control program; Based on the simulation control program, calculate the simulated operation data of the controller variables associated with the leaf node variables, where the simulated operation data includes the simulated intermediate process data generated during the operation of the simulation control program; Synchronize the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program.
2. The method according to claim 1, characterized in that The step of analyzing the project file corresponding to the target control program of the target controller to obtain the leaf node variables of the target control program further includes: Analyze the project file of the target controller to obtain the program text and the variable table; Analyze the program text and the variable table to obtain the abstract syntax tree; Extract the node information of the abstract syntax tree, and determine the leaf node variables of the target control program based on the node information.
3. The method according to claim 2, characterized in that The step of extracting the node information of the abstract syntax tree and determining the leaf node variables of the target control program based on the node information further includes: Read the node information of each node of the abstract syntax tree, where the node information includes at least one variable included in the node and the dependency relationship between the variables; Based on the dependency relationship between the variables, establish a variable association graph; Based on the variable association graph, identify the leaf node variables.
4. The method according to claim 1, wherein The step of calculating the simulated operation data of the controller variables associated with the leaf node variables based on the simulation control program, where the simulated operation data includes the simulated intermediate process data generated during the operation of the simulation control program further includes: The controller variables associated with the leaf node variables include root node variables and / or intermediate node variables associated with the leaf node variables. The leaf node variables include controller variables without child nodes. The root node variables include controller variables without parent nodes. The intermediate node variables include controller variables with both parent nodes and child nodes.
5. The method according to claim 1, characterized in that After synchronizing the actual operation data corresponding to the leaf node variables and the simulated operation data of the controller variables associated with the leaf node variables to the simulation control program to participate in the operation of the simulation control program, the method further includes: Collect the actual operation data of the target control program, where the actual operation data includes actual intermediate process data and / or actual output data; Obtain the simulated operation data generated by the simulation control program simulating the operation of the target control program, where the simulated operation data includes simulated intermediate process data and / or simulated output data; Compare the actual operation data with the simulated operation data. When the actual operation data is inconsistent with the simulated operation data, replace the simulated operation data with the actual operation data.
6. The method according to claim 1, characterized in that Before synchronizing the actual operation data corresponding to the leaf node variable and the simulated operation data of the controller variable associated with the leaf node variable to the simulation control program and participating in the operation of the simulation control program, the method further includes: Performing synchronization processing on the clock corresponding to the preset operation environment for running the simulation control program, so that the clock corresponding to the simulation control program is synchronized with the clock corresponding to the target control program of the target controller.
7. A data synchronization device, characterized in that, Including: A parsing module, configured to parse the engineering file corresponding to the target control program of the target controller and obtain the leaf node variables of the target control program; An acquisition module, configured to acquire the actual operation data corresponding to the leaf node variable, where the actual operation data includes the data generated by the operation of the target control program; A calculation module, configured to calculate, based on the simulation control program, the simulated operation data of the controller variable associated with the leaf node variable, where the simulated operation data includes the simulated intermediate process data generated by the operation of the simulation control program; A synchronization module, configured to synchronize the actual operation data corresponding to the leaf node variable and the simulated operation data of the controller variable associated with the leaf node variable to the simulation control program and participate in the operation of the simulation control program.
8. An electronic device, characterized in that, Including: A processor; A memory; And A computer program; Wherein, the computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by the processor, the processor is enabled to implement the method according to any one of claims 1-6 above.
10. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instruction is executed by the processor, the method according to any one of claims 1-6 is implemented.