A method and system for converting CFC format files to XML format

By parsing and encapsulating the data structure of CFC format files and using XML generator to generate XML files, the problem that CFC format files cannot be directly converted into XML format files is solved, automatic conversion is realized, and the construction efficiency and quality of engineering programs are improved.

CN119740550APending Publication Date: 2025-04-01XJ ELECTRIC CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411811867.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-01

AI Technical Summary

Technical Problem

In the existing engineering control protection program, CFC format files cannot be directly converted into XML format files, resulting in artificial rebuilding, which is a lot of work and error-prone.

Method used

By reading the content of the CFC format file, parsing and encapsulating it into the corresponding data structure, establishing the relationship between the data structures, generating a nested data structure with a tree structure, and re-encapsulating it into a data structure that meets the format requirements of the XML generator, and finally using the XML generator to generate an XML file.

Benefits of technology

Automatic conversion of CFC files into XML files is realized, which avoids errors and inefficiency in the artificial rebuilding process, and improves the construction efficiency and quality of engineering programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119740550A_ABST
    Figure CN119740550A_ABST
Patent Text Reader

Abstract

The present invention relates to a method and system for converting a CFC format file into an XML format, and belongs to the technical field of engineering control protection. The present invention parses the contents of a CFC format file in a memory according to the composition order of the CFC file and encapsulates it into a corresponding data structure, and uses the belonging relationship between each CFC data structure to convert the encapsulated data structure into a nested data structure of a tree structure; then the nested data structure is re-encapsulated into a data structure that meets the format requirements of an XML generator, and finally the XML generator is used to process the data structure that meets the format requirements of the XML generator to generate a corresponding XML file. The present invention realizes the conversion of a CFC file into an XML file, avoiding the reconstruction of an engineering program on a domestically produced ViGET, which improves the efficiency of the construction of the domestically produced ViGET engineering program on the one hand, and avoids the problems caused by human factors in the reconstruction process on the other hand, and improves the quality of the domestically produced ViGET engineering program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a method and system for converting a CFC format file into an XML format, and belongs to the technical field of engineering control protection. Background Art

[0002] The control protection program in the existing project uses the CFC graphical programming language to build the control protection logic. The graphical editor that parses the CFC file content and presents the graphical relationship is written and implemented using Microsoft MFC, which cannot be run on the Linux system. According to the relevant localization requirements of the State Grid, the graphical editor that parses the CFC file content and presents the graphical relationship must support cross-platform in the future and be able to run on Linux. In order to meet the cross-platform requirements, a graphical editor based on the Linux system was reconstructed and developed. The editor uses the semi-structured data format XML to implement data storage (intuitive, easy to understand, and most importantly, easy to expand). In order to avoid rebuilding the control protection program and reduce human errors during the construction process, it is urgent to develop a conversion tool to convert the existing engineering version of the control protection program in CFC format into the control protection program in XML format. Therefore, a CFC to XML format conversion method for the control protection program in the field of direct current transmission is proposed.

[0003] Currently, there are no ready-made tools or methods to convert CFC format files into XML format files. The existing CFC format control protection program needs to be manually rebuilt to migrate to the XML format control protection program. On the one hand, the rebuilding process is a huge workload, and on the other hand, the logical correctness cannot be guaranteed, and errors cannot be avoided during the manual construction process. Summary of the invention

[0004] The purpose of the present invention is to provide a method and system for converting CFC format files into XML format, so as to solve the problem that the current control protection program in CFC format needs to be manually rebuilt to migrate the control protection program in XML format, resulting in a large workload and prone to errors.

[0005] In order to solve the above technical problems, the present invention provides a method for converting a CFC format file into an XML format, the method comprising:

[0006] 1) Read all the contents of the CFC format file to be converted into the memory, and parse the contents of the CFC format file in the memory according to the composition order of the CFC file and encapsulate them into the corresponding data structure;

[0007] 2) Establish the relationship between the CFC data structures and generate a tree-shaped nested data structure, which includes the top chart node FunctionChart and the composite function block node CompBlock, function block node Block and margin function block node MarginBlock under the node;

[0008] 3) Re-encapsulating the nested data structure into a data structure that meets the format requirements of the XML generator, the data structure includes a top-level chart node CFCXMLChart and a page node CFCXMLPage under the node, the page node CFCXMLPage contains a function block node CFCXMLBlock and an internal nested chart node CFCXMLChart, the function block node CFCXMLBlock contains an input-output pin node CFCXMLConnector, and the input-output pin node CFCXMLConnector contains a corresponding connection line node CFCXMLConnection;

[0009] 4) Use the XML generator to process the data structure that meets the format requirements of the XML generator to generate a corresponding XML file.

[0010] Furthermore, the composite function block node CompBlock contains the custom input and output pin node Connector of the composite function block, and the custom input and output pin node Connector contains one or more connection information nodes Connection. If the composite function block contains a nested composite function block, it contains the chart node FunctionChat where the nested composite function block is located; the function block node Block contains the function block input and output pin node Conenctor, and the input and output pin node Connector contains one or more connection information nodes Connection; the margin function block node MarginBlock contains input pin nodes and output pin nodes Connector, and the input and output pin node Connector contains one or more connection information nodes Connection.

[0011] Furthermore, the repackaging process in step 3) is as follows:

[0012] Create a CFCXMLChart instance based on the top-level chart node FunctionChart;

[0013] Traversing the function block set in the data structure in step 2), and processing according to the attributes of each function block in the set;

[0014] When the function block is a CompBlock node, obtain the FunctionChart node in the CompBlock node, and create a CFCXMLChart instance according to the FunctionChart node; when the function block is a Block node, obtain the page number information where the Block node is located, if there is a CFCXMLPage instance corresponding to the page number, then obtain the CFCXMLPage instance corresponding to the page number, if not, create the corresponding CFCXMLPage instance, and add the CFCXMLPage instance to the CFCXMLChart instance;

[0015] Create a CFCXMLBlock instance corresponding to the Block node and add it to the CFCXMLPage instance. At the same time, create a corresponding relationship between the function block instance name and the assigned ID number, and create a corresponding relationship between the function block instance name and the page number.

[0016] Traverse the input pins and output pins of the Block node, create corresponding CFCXMLConnector instances according to the input pin information and output pin information, add them to the CFCXMLBlock instance, and create the corresponding relationship between the function block pin name and the function block pin ID;

[0017] Get the connection information of the input pin and the output pin, create CFCXMLConnection instances of the input pin connection and the output pin connection respectively, and add them to the corresponding CFCXMLConnector instance;

[0018] Determine the properties of the connection. If the connection passes through the sidebar function block MarginBar, create a correspondence between the function block pin information and MarginBarNum, and create a correspondence between the function block pin connection information and MarginBarNum; if the connection passes through the custom pin of the compound function block, create a correspondence between the function block pin information and the custom pin information of the compound function block.

[0019] Furthermore, the process of generating an XML file using an XML generator in step 4) includes:

[0020] Use the Chart generator in the XML generator to generate Chart-related XML content, traverse the CFCXMLPage instance collection in the CFCXMLChart instance, and use the Page generator to generate Page-related XML content for each CFCXMLPage instance item;

[0021] Traverse the CFCXMLBlock instance collection in the CFCXMLPage instance, use the Block generator to process each CFCXMLBlock instance item, and generate Block-related XML content;

[0022] Traverse the CFCXMLConnector instance collection in the CFCXMLBlock instance, and use the Connector generator to generate Connector-related XML content for each CFCXMLConnector instance item;

[0023] Traverse the CFCXMLConnection instance collection in the CFCXMLConnector instance, and use the Connection generator to generate Connection-related XML content for each CFCXMLConnection instance item.

[0024] Furthermore, when processing the CFCXMLConnection instance item, the Connection generator determines the properties of the CFCXMLBlock instance to which the CFCXMLConnection instance belongs. If the CFCXMLBlock instance is an ordinary function block, it is processed according to the processing flow of the ordinary function block; if it is a composite function block, it is processed according to the processing flow of the composite function block.

[0025] Further, when the ordinary function block is not an ordinary function block inside a composite function block, it is processed according to the ordinary function block processing flow; when the ordinary function block is an ordinary function block inside a composite function block, it is processed according to the ordinary function block processing flow inside the composite function block; when the ordinary function block is an ordinary function block nested inside a composite function block, it is processed according to the ordinary function block processing flow inside a composite function block; when the composite function block is not a composite function block nested inside a composite function block, it is processed according to the ordinary function block processing flow; when the composite function block is a composite function block nested inside a composite function block, it is processed according to the ordinary function block processing flow inside the composite function block.

[0026] Furthermore, the general function block processing flow is:

[0027] Determine the properties of the function block connected to it based on the CFCXMLConnection instance information;

[0028] When the function block connected to is a common function block, determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If they are on the same page, directly generate Connection-related XML content. If they are on different pages, obtain MarginBar instance information and generate Connection-related XML content based on the MarginBar instance information.

[0029] When the function block connected to is a composite function block, determine whether the current CFCXMLBlock instance is on the same page as the one connected to the composite function block. If they are on the same page, obtain the custom pin instance information connected to the composite function block, and generate Connection-related XML content based on the obtained custom pin instance information of the composite function block; if they are on different pages, obtain the MarginBar instance information and the custom pin instance information connected to the composite function block, and generate Connection-related XML content based on the obtained MarginBar instance information and the custom pin instance information of the composite function block.

[0030] Furthermore, the processing flow of the common function block inside the composite function block is as follows:

[0031] Determine the properties of the function block connected to it based on the CFCXMLConnection instance information;

[0032] When the function block connected to is an internal function block of the same composite function block, determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If they are on the same page, directly generate the Connection-related XML content; if they are on different pages, obtain the MarginBar instance information and generate the Connection-related XML content according to the MarginBar instance information;

[0033] When the connected function block is an external function block of the composite function block, obtain the custom pin instance information and MarginBar instance information of the connected composite function block, and generate Connection related XML content according to the obtained MarginBar instance information and the custom pin instance information of the composite function block.

[0034] Furthermore, the processing flow of the common function block inside the nested composite function block is the same as the processing flow of the common function block inside the composite function block.

[0035] The present invention also provides a conversion system for converting a CFC format file into an XML format, comprising a processor, wherein the processor is used to execute computer program instructions to implement the conversion method for converting a CFC format file into an XML format of the present invention.

[0036] The beneficial effects of the present invention are as follows: as a pioneering invention, the present invention first parses the CFC format file content in the memory according to the CFC file composition order and encapsulates it into a corresponding data structure, and uses the belonging relationship between the CFC data structures to convert the encapsulated data structure into a nested data structure of a tree structure; then re-encapsulates the nested data structure into a data structure that meets the format requirements of the XML generator, and finally uses the XML generator to process the data structure that meets the format requirements of the XML generator to generate a corresponding XML file. The present invention realizes the conversion of CFC files into XML files, avoids rebuilding the engineering program on the domestic ViGET, improves the efficiency of building the domestic ViGET engineering program on the one hand, and avoids the problems caused by human factors in the rebuilding process on the other hand, and improves the quality of the domestic ViGET engineering program. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1a Schematic diagram of a current function block being a common function block connected to a common function block on the same page in an embodiment of the present invention;

[0038] Figure 1b Schematic diagram of connecting ordinary function blocks across pages in which the current function block is an ordinary function block in an embodiment of the present invention;

[0039] Figure 1c This is a schematic diagram of connecting ordinary function blocks across CFCs in an embodiment of the present invention where the current function block is an ordinary function block;

[0040] Figure 1d Schematic diagram of a composite function block connected to the same page as a common function block in an embodiment of the present invention;

[0041] Figure 1e Schematic diagram of a composite function block connected across pages in which the current function block is a common function block in an embodiment of the present invention;

[0042] Figure 1f This is a schematic diagram of a composite function block connected across CFCs in an embodiment of the present invention where the current function block is a common function block;

[0043] Figure 1g It is a schematic diagram of an embodiment of the present invention in which the current function block is a common function block inside a composite function block and is connected to common function blocks on the same page inside the same composite function block;

[0044] Figure 1h It is a schematic diagram of connecting ordinary function blocks on different pages in a composite function block to ordinary function blocks in different pages in the same composite function block in an embodiment of the present invention;

[0045] Figure 1i Schematic diagram of an embodiment of the present invention in which the current function block is a common function block inside a composite function block connected to a common function block on the same page outside the composite function block;

[0046] Figure 2 It is a flow chart of the conversion method of the CFC format file to the XML format of the present invention;

[0047] Figure 3 is a schematic diagram of a nested data structure converted into a tree structure established in an embodiment of the present invention;

[0048] Figure 4 It is a schematic diagram of the data structure and nested relationship that meet the requirements of the XML generator in an embodiment of the present invention;

[0049] Figure 5 is a data structure repackaging flow chart used in an embodiment of the present invention;

[0050] Figure 6 Schematic diagram of the generation principle of the XML generator used in the embodiment of the present invention;

[0051] Figure 7 It is a generation flow chart of a Connection generator corresponding to a common function block to which CFCXMLBlock to which CFCXMLConnection belongs in an embodiment of the present invention;

[0052] Figure 8 It is a generation flow chart of a Connection generator corresponding to a composite function block to which CFCXMLBlock to which CFCXMLConnection belongs in an embodiment of the present invention;

[0053] Fig. 9 is a general function block processing flow chart in an embodiment of the present invention;

[0054] Fig.10 is a flowchart of ordinary function block processing within a composite function block in an embodiment of the present invention;

[0055] Fig.11 It is a processing flow chart of an ordinary function block nested within a composite function block in an embodiment of the present invention. DETAILED DESCRIPTION

[0056] The specific implementation of the present invention will be further described below in conjunction with the accompanying drawings.

[0057] Embodiment of the conversion method of CFC format file to XML format

[0058] The present invention first parses the CFC format file content in the memory according to the CFC file composition sequence and encapsulates it into a corresponding data structure, and uses the belonging relationship between the CFC data structures to convert the encapsulated data structure into a nested data structure with a tree structure; then re-encapsulates the nested data structure into a data structure that meets the format requirements of the XML generator, and finally uses the XML generator to process the data structure that meets the format requirements of the XML generator to generate a corresponding XML file, thereby converting the CFC format file into the XML format. The conversion process of the method is as follows Figure 2 As shown, the detailed description is given below.

[0059] CFC is the abbreviation of Continuous Function Chart, which is an extension of IEC 61131-3 standard and a graphical programming language based on Function Block Diagram (FBD) language. Its file basic logic includes the following 9 situations: 1) The current function block is a common function block. The same page is connected to the common function block, such as Figure 1a 2) The current function block is a common function block. Cross-page connection of common function blocks, such as Figure 1b As shown, the black ellipse is the MarginBar related information (position information). Crossing Page and CFC must pass through MarginBar; 3) The current function block is a common function block. Crossing CFC connects to common function blocks, such as Figure 1c As shown, the black ellipse is MarginBar related information; 4) The current function block is a common function block connected to a composite function block on the same page, such as Figure 1d As shown, the black ellipse is the custom pin of the composite function block; 5) The current function block is a common function block connected to the composite function block across pages, such as Figure 1e 6) The current function block is a common function block that crosses the CFC to connect the composite function block, such as Figure 1f 7) The current function block is a common function block inside a composite function block, and the common function block on the same page inside the same composite function block is connected, such as Figure 1g 8) The current function block is a common function block inside a composite function block, and the common function blocks on different pages of the same composite function block are connected, such as Figure 1h 9) The current function block is a common function block inside a composite function block, and a common function block on the same page outside the composite function block is connected, such as Figure 1i shown.

[0060] 1. Read the CFC file content, parse it, and encapsulate it into the corresponding data structure.

[0061] This embodiment reads the contents of the CFC file to be converted, reads all the contents of the CFC file into the memory at one time, parses the contents of the CFC file in sequence according to the CFC file structure, and encapsulates them into corresponding data structures. The nested relationship between the data structures established in this embodiment is as follows: Figure 3 As shown, the top layer is the chart node FunctionChat (referred to as FunctionChat node), under which there are compound function block node CompBlock (referred to as CompBlock node), function block node Block (referred to as Block node), and sidebar function block node MarginBlock (referred to as MarginBlock node), wherein the compound function block node CompBlock contains the custom pin nodes (InputConnector and OutputConnector) of the compound function block, and the pin node contains one or more connection information nodes Connection. If the compound function block has nested compound function blocks inside, it contains the chart node FunctionChat to which the nested compound function block belongs; the function block node Block contains function block pin nodes InputConnector and OutputConnector, and the pin node contains one or more connection information nodes Connection; the sidebar function block node MarginBlock contains input pin nodes and output pin nodes. The diagram node FunctionChat can be understood as a canvas, on which there can be function blocks, composite function blocks, connections, etc. The composite function block node CompBlock can be understood as a canvas in a canvas, and is also a canvas. Figure 1a-1i Several basic situations are shown, which explain the basic logical situations such as the same page, cross-page, cross-CFC, connected composite function blocks, function blocks within composite function blocks, and function blocks nested within composite function blocks.

[0062] 2. Repackage the CFC file according to the established nesting relationship.

[0063] The repackaging process is as follows Figure 5 As shown, the specific process is as follows:

[0064] 1) Analysis Figure 3 The data structure shown creates a CFCXMLChart instance based on the top-level (uppermost) chart node FunctionChart;

[0065] 2) Traverse such as Figure 3The function block set in the data structure shown (including the Blcok set, the CompBlock set, and the MarginBlcok set) determines the attribute of the item in the set. If it is a CompBlock, execute 3), if it is a Blcok, execute 4), and if it is a MarginBlock, do nothing;

[0066] 3) Get the FunctionChart node in the CompBlock node, create a CFCXMLChart instance based on the FunctionChart node, and execute 2);

[0067] 4) Get the page number information where the Block is located, check from the existing data structure whether the CFCXMLPage instance corresponding to the page number exists, if it exists, get the CFCXMLPag instance corresponding to the page number, if it does not exist, create the corresponding CFCXMLChart instance, and add the CFCXMLPage instance to the CFCXMLChart instance;

[0068] 5) Create a CFCXMLBlock instance corresponding to the Block and add it to the CFCXMLPage instance where it is located. At the same time, create a corresponding relationship between the function block instance name and the assigned ID number, and create a corresponding relationship between the function block instance name and the page number where it is located;

[0069] 6) Traverse the input pins of the Block node, create a corresponding CFCXMLConnector instance according to the input pin information and add it to the CFCXMLBlock instance, and create a corresponding relationship between the function block pin name and the function block pin ID;

[0070] 7) Get the connection information of the input pin (the input pin has only one connection);

[0071] 8) Create a CFCXMLConnection instance for the corresponding connection and add it to the CFCXMLConnector instance, and execute 12;

[0072] 9) Traverse the output pins of the Block node, create a corresponding CFCXMLConnector instance according to the output pin information and add it to the CFCXMLBlock instance, and create a corresponding relationship between the function block pin name and the function block pin ID;

[0073] 10) Get the connection information set of the output pin (the output pin can have multiple connections);

[0074] 11) Create a CFCXMLConnection instance for the corresponding connection and add it to the CFCXMLConnector instance;

[0075] 12) Determine the properties of the connection. If the connection passes through the sidebar function block Marginbar, create a correspondence between the function block pin information and marginbarNum, and create a correspondence between the function block pin connection information and marginbarNum; if the connection passes through the custom pin of the compound function block, create a correspondence between the function block pin information and the custom pin information of the compound function block.

[0076] The repackaged structure can meet the requirements of the XML generator. The specific data structure is as follows Figure 4 shown.

[0077] 3. Use the XML generator to process the data structure that meets the format requirements of the XML generator to generate the corresponding XML file.

[0078] The XML generator processes the data structure that meets the format requirements of the XML generator. Figure 6 As shown, the process is: first, call the Chart generator according to the data structure, and generate the XML content corresponding to the Chart according to the relevant information of the CFCXMLChart instance; traverse the CFCXMLPage instance collection in the CFCXMLChart instance, call the Page generator for each CFCXMLPage instance item, and generate the XML content corresponding to the Page according to the relevant information of the CFCXMLPage instance; traverse the CFCXMLBlock collection in the CFCXMLPage instance, call the Block generator for each CFCXMLBlock instance item, and the Block generator generates the Block-related XML content according to the relevant information of the CFCXMLBlock instance; traverse the CFCXMLConnector instance collection in the CFCXMLBlock instance, call the Connector generator for each CFCXMLConnector instance item, and the Connector generator generates the Connector-related XML content according to the relevant information of the CFCXMLConnector instance; traverse the CFCXMLConnection instance collection in the CFCXMLConnector instance, call the Connection generator for each CFCXMLConnection instance item, and the Connection generator generates the Connection-related XML content. Each generator is part of the conversion method. The main processing logic is in the Connection generator. Other generators only generate relevant xml attributes for the corresponding data.

[0079] The relevant processes used by the Connection generator are as follows Figure 7 and Figure 8 As shown, Figure 7 The CFCXMLBlock instance to which the CFCXMLConnection instance belongs is the process corresponding to the common function block. Figure 8 The CFCXMLBlock instance to which the CFCXMLConnection instance belongs is the process corresponding to the composite function block. The specific process is as follows:

[0080] 1) Obtain the attribute information of the CFCXMLBlock instance to which the CFCXMLConnection instance belongs. If the CFCXMLBlock instance is a common function block, execute 2); if the CFCXMLBlock instance is a composite function block, execute 5);

[0081] 2) If the common function block is not a common function block inside a composite function block, execute Fig. 9 The common functional block processing flow shown;

[0082] 3) If the common function block is a common function block inside a composite function block, execute Fig.10 The common function block processing flow within the composite function block shown;

[0083] 4) If the common function block is a common function block nested inside a compound function block, execute the following Fig.11 The internal nesting of the composite function block shown conforms to the normal function block processing flow within the function block;

[0084] 5) If the composite function block is not a composite function block nested within a composite function block, execute the following steps: Fig. 9 The common functional block processing flow shown;

[0085] 6) If the composite function block is a composite function block nested within a composite function block, then Fig.10 The processing flow of ordinary function blocks within the composite function block is shown.

[0086] The processing flow of common function blocks is as follows:

[0087] 1) Obtain the function block information connected to according to the CFCXMLConnection instance information, and determine the properties of the function block connected to. If the function block is a common function block, execute 2); if it is a composite function block, execute 5);

[0088] 2) Determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If so, execute 3). If not, execute 4).

[0089] 3) Directly generate Connection related XML content;

[0090] 4) Get the MarginBar instance information and generate Connection related XML content according to the MarginBar instance information;

[0091] 5) Determine whether the current CFCXMLBlock instance is on the same page as the compound function block connected to it. If so, execute 6); if not, execute 7);

[0092] 6) Obtain the custom pin instance information connected to the composite function block, and generate Connection related XML content according to the obtained custom pin instance information of the composite function block;

[0093] 7) Obtain the MarginBar instance information and the custom pin instance information connected to the composite function block, and generate Connection related XML content according to the obtained MarginBar instance information and the custom pin instance information of the composite function block.

[0094] The processing flow of common function blocks in composite function blocks is as follows:

[0095] 1) Obtain the function block information connected to according to the CFCXMLConnection instance information, determine the properties of the function block connected to, and if the connected function block is an internal function block of the same composite function block, execute 2); if it is an external function block of the composite function block, execute 5);

[0096] 2) Determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If so, execute 3); if not, execute 4);

[0097] 3) Directly generate Connection related XML content;

[0098] 4) Get the MarginBar instance information and generate Connection related XML content according to the MarginBar instance information;

[0099] 5) Obtain the MarginBar instance information and the custom pin information connected to the composite function block, and generate Connection related XML content according to the obtained MarginBar instance information and the custom pin instance information of the composite function block.

[0100] The nested function blocks in the composite function block conform to the processing flow of the common function blocks in the function block as follows:

[0101] According to the CFCXMLConnection instance information, the connection to the function block information is obtained. The processing logic is the same as the processing logic of the ordinary function block inside the composite function block, that is, Fig.10 The process is shown in , and will not be repeated here.

[0102] According to the above process, the present invention realizes the conversion of CFC files into XML files, avoiding the reconstruction of engineering programs on the domestic ViGET, which improves the efficiency of constructing the domestic ViGET engineering programs on the one hand, and avoids the problems caused by human factors in the reconstruction process on the other hand, thereby improving the quality of the domestic ViGET engineering programs; the existing engineering programs can be directly transplanted to the domestic ViGET tool through the conversion tool, which is convenient for the application and promotion of the domestic ViGET in the later stage.

[0103] Example of a conversion system for converting CFC format files to XML format

[0104] The CFC format file to XML format conversion system of the present invention includes a processor, and the processor is used to execute computer program instructions to implement the CFC format file to XML format conversion method of the present invention. The specific implementation process has been described in the method embodiment and will not be repeated here.

Claims

1. A method for converting a CFC format file into an XML format, characterized in that: The method includes: 1) Read all the contents of the CFC format file to be converted into the memory, and parse the contents of the CFC format file in the memory according to the composition order of the CFC file and encapsulate them into the corresponding data structure; 2) Establish the relationship between the CFC data structures and generate a tree-shaped nested data structure, which includes the top chart node FunctionChart and the composite function block node CompBlock, function block node Block and margin function block node MarginBlock under the node; 3) Re-encapsulating the nested data structure into a data structure that meets the format requirements of the XML generator, the data structure includes a top-level chart node CFCXMLChart and a page node CFCXMLPage under the node, the page node CFCXMLPage contains a function block node CFCXMLBlock and an internal nested chart node CFCXMLChart, the function block node CFCXMLBlock contains an input-output pin node CFCXMLConnector, and the input-output pin node CFCXMLConnector contains a corresponding connection line node CFCXMLConnection; 4) Use the XML generator to process the data structure that meets the format requirements of the XML generator to generate a corresponding XML file.

2. The method for converting a CFC format file to an XML format according to claim 1, characterized in that: The composite function block node CompBlock contains the composite function block custom input and output pin node Connector, and the custom input and output pin node Connector contains one or more connection information nodes Connection. If the composite function block is nested inside the composite function block, it contains the chart node FunctionChart where the nested composite function block is located; the function block node Block contains the function block input and output pin node Conenctor, and the input and output pin node Connector contains one or more connection information nodes Connection; The margin function block node MarginBlock contains input and output pin nodes Connector, and the input and output pin nodes Connector contain one or more connection information nodes Connection.

3. The method for converting a CFC format file to an XML format according to claim 2, characterized in that: The repackaging process in step 3) is as follows: Create a CFCXMLChart instance based on the top-level chart node FunctionChart; Traversing the function block set in the data structure in step 2), and processing according to the attributes of each function block in the set; When the function block is a CompBlock node, obtain the FunctionChart node in the CompBlock node, and create a CFCXMLChart instance according to the FunctionChart node; when the function block is a Block node, obtain the page number information where the Block node is located, if there is a CFCXMLPage instance corresponding to the page number, then obtain the CFCXMLPage instance corresponding to the page number, if not, create the corresponding CFCXMLPage instance, and add the CFCXMLPage instance to the CFCXMLChart instance; Create a CFCXMLBlock instance corresponding to the Block node and add it to the CFCXMLPage instance. At the same time, create a corresponding relationship between the function block instance name and the assigned ID number, and create a corresponding relationship between the function block instance name and the page number. Traverse the input pins and output pins of the Block node, create corresponding CFCXMLConnector instances according to the input pin information and output pin information, add them to the CFCXMLBlock instance, and create the corresponding relationship between the function block pin name and the function block pin ID; Get the connection information of the input pin and the output pin, create CFCXMLConnection instances of the input pin connection and the output pin connection respectively, and add them to the corresponding CFCXMLConnector instance; Determine the properties of the connection. If the connection passes through the sidebar function block MarginBar, create a corresponding relationship between the function block pin information and MarginBarNum, and create a corresponding relationship between the function block pin connection information and MarginBarNum; If the connection passes through a custom pin of a compound function block, a correspondence between the function block pin information and the custom pin information of the compound function block is created.

4. The method for converting a CFC format file to an XML format according to claim 3, characterized in that: The process of generating an XML file using an XML generator in step 4) includes: Use the Chart generator in the XML generator to generate Chart-related XML content, traverse the CFCXMLPage instance collection in the CFCXMLChart instance, and use the Page generator to generate Page-related XML content for each CFCXMLPage instance item; Traverse the CFCXMLBlock instance collection in the CFCXMLPage instance, use the Block generator to process each CFCXMLBlock instance item, and generate Block-related XML content; Traverse the CFCXMLConnector instance collection in the CFCXMLBlock instance, and use the Connector generator to generate Connector-related XML content for each CFCXMLConnector instance item; Traverse the CFCXMLConnection instance collection in the CFCXMLConnector instance, and use the Connection generator to generate Connection-related XML content for each CFCXMLConnection instance item.

5. The method for converting a CFC format file to an XML format according to claim 4, characterized in that: When processing the CFCXMLConnection instance item, the Connection generator determines the properties of the CFCXMLBlock instance to which the CFCXMLConnection instance belongs. If the CFCXMLBlock instance is a common function block, it is processed according to the processing flow of the common function block; if it is a composite function block, it is processed according to the processing flow of the composite function block.

6. The method for converting a CFC format file to an XML format according to claim 5, characterized in that: When the ordinary function block is not an ordinary function block inside a composite function block, it is processed according to the ordinary function block processing flow; when the ordinary function block is an ordinary function block inside a composite function block, it is processed according to the ordinary function block processing flow inside the composite function block; when the ordinary function block is an ordinary function block nested inside a composite function block, it is processed according to the ordinary function block processing flow inside a composite function block; when the composite function block is not a composite function block nested inside a composite function block, it is processed according to the ordinary function block processing flow; when the composite function block is a composite function block nested inside a composite function block, it is processed according to the ordinary function block processing flow inside the composite function block.

7. The method for converting a CFC format file to an XML format according to claim 6, characterized in that: The general function block processing flow is: Determine the properties of the function block connected to it based on the CFCXMLConnection instance information; When the function block connected to is a common function block, determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If they are on the same page, directly generate Connection-related XML content. If they are on different pages, obtain MarginBar instance information and generate Connection-related XML content based on the MarginBar instance information. When the function block connected to is a composite function block, determine whether the current CFCXMLBlock instance is on the same page as the composite function block connected to it. If so, obtain the custom pin instance information connected to the composite function block, and generate the Connection-related XML content according to the obtained custom pin instance information of the composite function block. If they are on different pages, obtain the MarginBar instance information and the custom pin instance information connected to the composite function block, and generate Connection related XML content according to the obtained MarginBar instance information and the custom pin instance information of the composite function block.

8. The method for converting a CFC format file to an XML format according to claim 6, characterized in that: The processing flow of ordinary function blocks inside the composite function block is as follows: Determine the properties of the function block connected to it based on the CFCXMLConnection instance information; When the function block connected to is an internal function block of the same composite function block, determine whether the current CFCXMLBlock instance and the connected function block are on the same page. If they are on the same page, directly generate the Connection-related XML content; If they are on different pages, get the MarginBar instance information and generate Connection related XML content based on the MarginBar instance information; When the connected function block is an external function block of the composite function block, obtain the custom pin instance information and MarginBar instance information of the connected composite function block, and generate Connection related XML content according to the obtained MarginBar instance information and the custom pin instance information of the composite function block.

9. The method for converting a CFC format file to an XML format according to claim 6, characterized in that: The processing flow of ordinary function blocks inside a nested compound function block is the same as that of ordinary function blocks inside a compound function block.

10. A system for converting a CFC format file into an XML format, comprising a processor, characterized in that: The processor is used to execute computer program instructions to implement the method for converting a CFC format file into an XML format as described in any one of claims 1 to 9.