A method and system for comparing SCL files
By establishing a standard SCL model and using multi-threaded processing, the differences between nodes and child nodes in SCL files can be quickly identified, solving the problem of low efficiency in SCL file comparison in existing technologies and achieving efficient difference judgment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XUCHANG XJ SOFTWARE TECHNOLOGIES LTD
- Filing Date
- 2022-11-16
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies still require extensive comparisons even when only minor changes are made to the SCL file, resulting in low comparison efficiency.
A standard SCL model is established. By initially extracting nodes and comparing formatted text, the differences between nodes and child nodes can be quickly determined. Multi-threading is used to process IED nodes, simplifying the comparison process.
It improves the efficiency of SCL file comparison, reduces traversal time, and saves comparison time, especially for IED node comparison.
Smart Images

Figure CN115878744B_ABST
Abstract
Description
Technical Field
[0001] This invention pertains to communication configuration in the field of substations, specifically relating to an SCL file comparison method and system. Background Technology
[0002] SCL stands for Substation Configuration Description Language, an XML extension language specified in the IEC 61850-6 standard for describing the communication configuration between IEDs (Integrated Devices) within a smart substation. There are generally four types of SCL files: SSD files describing the substation specifications, ICD files describing IED capabilities, SCD files describing the complete substation configuration, and CID files describing the configuration of a single IED. The SCL file model is as follows: Figure 1 As shown.
[0003] As substations grow larger and collect more information, their configuration files become increasingly larger. Currently, a substation's configuration file can typically reach over 200 megabytes. Furthermore, each substation renovation or expansion requires modifications to the SCL file. Substation technical specifications stipulate that each modification must be archived and compared with historical versions to generate a difference report.
[0004] The current common practice for comparing SCL files is to use conventional XML file text comparison algorithms. This involves traversing both files from the root node, obtaining all node attributes and child nodes, and then recursively comparing them one by one. The advantage of this approach is its comprehensiveness, showing any modification. However, its disadvantage is that it is overly cumbersome, using too many traversals and comparison operations, resulting in low efficiency. Substation technical specifications require that the comparison results of SCL files only concern key information, such as IED descriptions, virtual terminal connection information, and communication information. Modifications to private node attributes, disconnector positions, and IED order are not important and do not need to be reflected in the difference report. Therefore, a faster SCL file comparison method that can identify differences in key information is needed.
[0005] Chinese invention patent application CN109145167A discloses a method for comparing the content differences between an ICD file and the corresponding IED in an SCD. It mentions a file comparison method that matches the nodes to be compared based on the key attributes of the nodes, and then compares the non-key attributes and descendant nodes. However, this method is cumbersome. In scenarios such as substation renovation and expansion where only a few changes are made to the SCL file, a large number of comparisons are still required, which is time-consuming and has low comparison efficiency. Summary of the Invention
[0006] The purpose of this invention is to provide an SCL file comparison method and system to solve the problem of low comparison efficiency in the prior art when only a few changes are made to the SCL file, which still requires a large number of comparisons.
[0007] To achieve the above objectives, the present invention provides an SCL file comparison method, comprising the following steps:
[0008] 1) Read the two SCL files respectively, and then use the root SCL nodes of the two files to be compared as the first pair of matching nodes to be obtained;
[0009] 2) Compare matching nodes according to the SCL standard model; the standard model includes the node model corresponding to each node, and the content of each node model includes the node's label name, attributes and child nodes contained in the node; the attributes include non-critical attributes, which refer to the node attributes that are of interest when comparing nodes.
[0010] The comparison process is as follows: the content of the node model corresponding to a pair of matching nodes is initially extracted, and the initially extracted content of the pair of matching nodes is formatted into text. The text corresponding to the pair of matching nodes is directly compared. If the text is the same, the pair of matching nodes is determined to be the same and the comparison ends; otherwise, the pair of matching nodes is determined to be different. Then, the non-key attributes of the pair of matching nodes and the child nodes they contain are extracted and compared, and the comparison results are recorded.
[0011] The beneficial effects of the above technical solution are as follows: A corresponding node model containing node attributes and child node information is established for each node in the SCL file, avoiding traversal during comparison and saving traversal time; and when comparing nodes, the content of the corresponding node model is first formatted as text for text comparison; when comparing text, only the text content is compared for similarity, without concern for specific differences. This comparison method can intuitively and quickly determine whether there are differences in the content of matching nodes. If there are no differences, the process of comparing the specific content of the nodes can be directly eliminated, saving comparison time.
[0012] Furthermore, the content of each node model also includes whether the node cares about the specific differences of its child nodes and details of the child nodes contained in the node;
[0013] In step 2), when comparing the child nodes contained in a pair of matching nodes, if the pair of matching nodes does not care about the specific differences of the child nodes, the text content of the child nodes of the pair of matching nodes is compared, the comparison result is recorded and the comparison ends; the text content of the child nodes of the node refers to the content of the node in the SCL file, which is formatted as text and the content of the root node corresponding to the current matching node is removed.
[0014] If the key differences between the child nodes of this pair of matching nodes are not critical attributes, then only the text content of the child nodes of this pair of matching nodes is compared. If they are the same, the comparison ends and the result is recorded; otherwise, the comparison of the child node details of this pair of matching nodes continues.
[0015] If the node is concerned with the specific differences between its child nodes and the non-critical attributes are the same, then it can directly continue to compare the child node details of this pair of matching nodes.
[0016] The beneficial effects of the above technical solution are as follows: when comparing the child nodes of a node, the content of the corresponding node model is first formatted into text and then compared. When comparing text, only the text content is compared to see if they are the same. At this time, the specific differences are not considered. This comparison method can intuitively and quickly determine whether there are differences between the child nodes of the matching node. If there are no differences, the process of comparing the specific content of the child nodes can be directly omitted.
[0017] Furthermore, when comparing child node details, if a child node in a pair of matching nodes is a single-node child node, then based on the label name of that child node, find the child node that matches that child node in the child nodes of the other node in the pair of matching nodes, and take these two matching child nodes as a new pair of matching nodes, and compare this new pair of matching nodes according to the comparison process in step 2).
[0018] If the label name of a child node in a node corresponds to only this one child node, then the child node is recorded as a single-node child node.
[0019] The beneficial effects of the above technical solution are as follows: based on the characteristics of single-node child nodes, directly using the tag name to match child nodes can quickly and accurately identify each matching single-node child node, thereby improving the overall comparison efficiency.
[0020] Furthermore, in step 2), the attribute also includes a key attribute; the content extracted during the initial extraction of the content of the node model corresponding to the node includes at least the key attribute of the node, and after the initial extraction, the key attribute is concatenated and a hash value is calculated as the hash value of the node.
[0021] When comparing child node details, if a child node of a matching node in one of the files to be compared is a multi-node child node, then one of the files to be compared is set as the old file and the other is set as the new file. All child nodes in the new file with the same tag name as the child node are initially extracted and stored as a linked list in the manner of step 2). Each entry in the linked list corresponds to a child node and its hash value. All child nodes in the old file with the same tag name as the child node are initially extracted and stored as a hash table in the manner of step 2). Then, the hash table of the old file and the linked list of the new file are compared: the linked list of the new file is traversed, and based on the hash value of each entry, it is searched in the hash table of the old file to see if there is a child node with the same hash value. If there is, the two child nodes corresponding to the hash value are taken as a new pair of matching nodes, and the comparison process in step 2) is used to compare this pair of new matching nodes.
[0022] If the label name of a child node in a node corresponds to multiple child nodes, then the child node is recorded as a multi-node child node.
[0023] The beneficial effects of the above technical solution are as follows: When there are multiple child nodes of a certain type, i.e., the child node is a multi-node child node, the comparison of its details is performed by matching the child nodes through unique key attributes, and the key attributes of each child node corresponding to the child node of this type in one of the files to be compared are stored in a linked list in order, thus ensuring the result order of the multi-node child nodes; the key attributes of each child node corresponding to the child node of this type in another file to be compared are directly stored as a hash table, and then the hash table of the old file and the linked list of the new file are compared, which can ensure the retrieval speed.
[0024] Furthermore, if there is no child node in the hash table of the old file that has the same hash value as a certain entry in the linked list, then the child node corresponding to that entry is set as a new node; after traversing the linked list of the new file, the hash table of the old file is traversed again. If there is a child node in the hash table of the old file that has not been compared, then the child node is set as a deleted node. The comparison results, the occurrence of new nodes and deleted nodes, and their key attribute information are recorded.
[0025] The beneficial effects of the above technical solution are: it can more comprehensively reflect the differences between two files to be compared, and avoid the omission of comparison results caused by the deletion or addition of the entire node, which results in the absence of a comparison object.
[0026] Furthermore, when establishing the SCL standard model, only all nodes that need to be compared are modeled, and the attributes of each node only include those that need to be considered when performing node comparisons.
[0027] The beneficial effects of the above technical solution are as follows: when establishing a node model, only the attribute information and child node information that the node is concerned with when comparing are modeled, and when the node does not need to know the details of the differences between its child nodes, the specific child nodes of the node are not modeled, thus saving the comparison of these nodes and attributes.
[0028] Furthermore, in step 2), the method for comparing the text corresponding to a pair of matching nodes is as follows:
[0029] First, compare the lengths of the texts corresponding to each pair of matching nodes. If the lengths are different, it is determined that the pair of matching nodes are different. If the lengths are the same, calculate and compare the hash values of the whole text, the first half of the text, and the second half of the text corresponding to each pair of matching nodes. If they are all the same, it is determined that the texts corresponding to the pair of matching nodes are the same; otherwise, it is determined that the pair of matching nodes are different.
[0030] The beneficial effects of the above technical solution are as follows: First, compare the length of the text. If the lengths are different, it can be directly determined that the pair of matching nodes are different, thus saving the need to compare the specific content of the text. If the lengths are the same, then compare the hash values of the whole text, the first half of the text, and the second half of the text respectively. Using hash values to represent the text content for comparison can simplify the comparison objects, and using three hash values to participate in the comparison can minimize hash collisions.
[0031] Furthermore, the initial content extracted for a node only includes the node's tag name and attributes.
[0032] The beneficial effects of the above technical solution are: it can simplify the content of the text when performing subsequent text comparison, and further reduce the amount of data to be compared.
[0033] Furthermore, when comparing IED nodes in the SCL file, a multi-threaded approach is used.
[0034] The beneficial effect of the above technical solution is that it uses multi-threading to compare the IED data with the largest data volume and the longest comparison time in the SCL file, which can further compress the comparison time.
[0035] The present invention also provides an SCL file comparison system, including a processor for executing program instructions to implement the SCL file comparison method described above. This SCL file comparison system can achieve the same beneficial effects as the SCL file comparison method described above. Attached Figure Description
[0036] Figure 1 This is a schematic diagram of the SCL file model in a smart substation in the background art of this invention;
[0037] Figure 2 This is a flowchart of the SCL file comparison method in an embodiment of the present invention.
[0038] Figure 3 This is a flowchart illustrating the node comparison method in an embodiment of the SCL file comparison method of the present invention. Detailed Implementation
[0039] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0040] Example of SCL file comparison method:
[0041] This embodiment provides a technical solution for an SCL file comparison method, the steps of which are as follows:
[0042] 1) Establish an SCL standard model template as the basis for creating SCL file models. This serves as an information extraction library for node comparison. The standard model includes node models corresponding to each node. The content of each node model includes the node's label name, attributes, and child nodes contained in the node. The attributes here include key attribute values and non-key attribute values. Non-key attributes refer to the attributes that need to be considered when comparing nodes. The content of the node model also includes whether the node cares about the specific differences of child nodes and the details of the child nodes contained in the node.
[0043] Since the SCL model is fixed and the node types are limited, a standard SCL model is built directly. Each type of node corresponds to a different node model, such as what types of attributes each node has (including key and non-key attributes), which child nodes it contains, and the details of these child nodes. This avoids traversing during comparisons, saving traversal time. The following are some key points for modeling:
[0044] ① During comparison, some child nodes and attributes are not relevant and therefore do not need to be modeled. For example, the Services node of the IED node does not need to be compared, so there is no need to create a Services child node when modeling the IED node. The Desc attribute of the AccessPoint node is not relevant during comparison, so there is no need to read this attribute when modeling the AccessPoint node. That is, the content of the node model corresponding to the AccessPoint node does not need to include the Desc attribute, which saves some comparison of nodes and attributes.
[0045] ② Some nodes do not need to know the details of the differences between their child nodes. For example, DOI nodes only care whether the content of the node has been modified, and do not care about the specific changes. Therefore, when modeling DOI nodes, it is not necessary to model its specific child nodes as well. That is, the node model corresponding to the DOI node only needs to record whether the node content (including attributes and child nodes) has changed, and there is no need to record the details of the child nodes.
[0046] Therefore, in this embodiment, only all nodes that need to be compared in the SCL model are modeled, and the attributes of each node only include those that need to be considered when comparing nodes; the content typically included in each node model is shown in Table 1 (if the relevant information is not of interest, the node model does not include content related to that information):
[0047] Table 1
[0048]
[0049] 2) such as Figure 2 As shown, before the comparison begins, two SCL files are read separately, meaning the contents of both files are parsed and loaded into memory in the format of raw XML files. Then, based on the SCL standard model template, node information is extracted from the XML files starting from the root SCL node to create an SCL model (node model). The node models are then compared. The principle for extracting node information from the XML file is to avoid reading it if possible, to read as little as possible, and to read it as late as possible. This principle is reflected in the following comparison method:
[0050] At the start of the comparison, the root SCL nodes of the two files to be compared are taken as the first pair of matching nodes. Following the standard model template in step 1), the content of the node models corresponding to each pair of matching nodes is initially extracted. In this embodiment, to reduce the amount of data extracted, the initial extraction only extracts the node's label and key attribute information, obtaining the initial SCL model corresponding to the node. Then, the two models are compared. Figure 3 During the initial extraction of each node model, the key attributes of the node are first read according to the SCL model. All key attributes of the node are concatenated, and a corresponding hash value is calculated as the node's hash value (non-key attributes and child node information are not read at this stage). The hash value of the node is its unique identifier. By comparing the hash values of two nodes, it can be determined whether two nodes are a matching pair. Therefore, the specific comparison process for a pair of matching nodes in two files to be compared is as follows:
[0051] The initial extracted content corresponding to a pair of matching nodes is formatted into text. The text corresponding to the pair of matching nodes is directly compared. If the text is the same, the pair of matching nodes is considered to be the same, and the comparison ends. Otherwise, the pair of matching nodes is considered to be different. The non-critical attributes of the pair of matching nodes and their child nodes are read and compared, and the comparison result is recorded.
[0052] In this text comparison, only the text content is compared for similarity; specific differences are not considered. To simplify the comparison, only the tag names and attributes (including both critical and non-critical attribute values) from the node model's content are used when formatting the text. For example, when formatting the content of an IED node model, its tag names and attribute information are as follows:<IED name=”E1Q1SB22”type=”PCS931”> The formatted text will then contain the format IED E1Q1SB22 PCS931.
[0053] In this embodiment, to further simplify the comparison steps, when comparing the text corresponding to a pair of matching nodes, the lengths of the texts corresponding to each pair of matching nodes are first compared. If the lengths are different, it is directly determined that the pair of matching nodes are different. If the lengths are the same, the hash values of the whole text, the first half of the text, and the second half of the text corresponding to the pair of matching nodes are calculated and compared respectively. If they are all the same, it is determined that the texts corresponding to the pair of matching nodes are the same; otherwise, it is determined that the pair of matching nodes are different. Since comparing only one pair of hash values may result in hash collisions, that is, the hash values of the two texts are exactly the same, this embodiment compares the hash values of the whole text, the first half of the text, and the second half of the text simultaneously, which can minimize hash collisions. In other embodiments, if the efficiency requirements are not particularly strict but accuracy is pursued, the text can also be compared character by character directly.
[0054] Once a pair of matching nodes is identified as differing, the non-critical attributes and child nodes of this pair are extracted and compared. During the initial extraction, only the label name and critical attributes are read from the node model content. The critical attributes serve as unique identifiers for the nodes, used to find paired nodes in the models of the two files for comparison. Non-critical attributes and child node information are extracted as needed after finding paired nodes in the two comparison files. For example, when reading an IED node, only the IED's label name "IED" and the critical attribute "name" are read; other data is not read. When comparing two IEDs with the same name, if the text is identical, the entire IED model is not read, and the IEDs are simply recorded as identical. If they are different, non-critical attributes and child node information are read according to the flowchart above. Thus, by using an unconditional initial extraction and a conditional subsequent extraction method for node information extraction, the overall concept of minimizing or eliminating unnecessary reading is achieved, significantly reducing comparison time.
[0055] For comparisons of non-critical attributes, only the comparison results need to be recorded. When comparing the child nodes contained in a pair of matching nodes, if the specific differences between the child nodes are not important to this pair of matching nodes, the text content of the child nodes of this pair of matching nodes is compared. The text comparison here can also adopt the method of comparing text based on text length and hash value as described above to simplify the comparison steps. After obtaining the comparison results, the comparison is recorded and the comparison ends. The text content of the child nodes of a node here refers to the content remaining after the content of the XML memory structure of the SCL file corresponding to the node is formatted as text and the root node content is removed. The root node content here refers to the root node content corresponding to the current matching node when the current matching node is the root node. This content does not include the child node information of the node. That is, the child node text content only includes the child node details of sequence number 5 in Table 1 corresponding to the current matching node and the information of sequence numbers 1-5 in Table 1 corresponding to these child nodes, but does not include the information of sequence numbers 1-4 in Table 1 corresponding to the current matching node.
[0056] If the matching nodes are concerned with the specific differences in their child nodes and the non-critical attributes are different, then only the text content of the child nodes of the matching nodes are compared first. If they are the same, the comparison ends and the comparison result is recorded; otherwise, the comparison of the child node details of the matching nodes continues. If the node is concerned with the specific differences in its child nodes and the non-critical attributes are the same, it means that the difference between the currently compared matching nodes must be caused by the child nodes, so the comparison of the child node details of the matching nodes can continue directly.
[0057] Since it has already been determined that there is a difference between the matching nodes, but it is unclear whether the difference is a difference in non-critical attributes, a difference in child nodes, or a difference in both non-critical attributes and child nodes, the difference is first determined by comparing the text of the child nodes. Only when a difference is found in the child nodes and the specific content of the difference is of interest, will the comparison of the details of the child nodes continue. Otherwise, the text comparison result is recorded directly and the comparison ends. Therefore, a lot of redundant comparison processes can be saved and the comparison efficiency can be improved.
[0058] When comparing child node details, if one of the child nodes in a pair of matching nodes is a single-node child node, then based on the label name of that child node, find the child node that matches that child node in the other child node of the pair of matching nodes, take these two matching child nodes as a new pair of matching nodes, and compare this new pair of matching nodes according to the extraction and comparison process in step 2).
[0059] If the label name of a child node in a node corresponds to only one child node, then the child node is called a single-node child node; for example, the Communication child node in the SCL node model. In an SCL node model, there is only one child node with the label name Communication, so this child node is a single-node child node relative to the SCL node model.
[0060] If a child node of a matching node in one of the files to be compared is a multi-node child node, then one of the files to be compared is set as the old file, and the other is set as the new file. Since the key attributes of nodes are unique, if all key attribute values of two nodes are the same, then these two nodes must be a pair of matching nodes. Therefore, the hash value of the node, calculated by concatenating all key attributes during the initial SCL model initialization obtained in the initial extraction, is used for matching between child nodes. To ensure the order of multi-node child node results, all child nodes in the new file with the same label name (node type) as the multi-node child node are extracted according to the initial extraction method in step 2) and their corresponding SCL initial models are stored as a linked list. Each entry in the linked list corresponds to a child node and its hash value, allowing the child nodes to be arranged in order. To ensure retrieval speed, all child nodes in the old file with the same label name as the multi-node child node are extracted according to the initial extraction method in step 2) and their corresponding SCL initial models are stored as a linked list. First, the hash table of the old file and the linked list of the new file are compared. Since the linked list guarantees the order of comparison results, and the hash table facilitates comparison and search, the linked list of the new file is traversed. Based on the hash value of each entry, the old file's hash table is searched for child nodes with the same hash value. If they exist, the two child nodes corresponding to that hash value are treated as a new pair of matching nodes, and this pair of matching nodes is compared according to the comparison process in step 2). During the comparison, if there is no child node in the old file's hash table with the same hash value as an entry in the new file's linked list, the child node corresponding to that entry is set as a new node. After traversing the linked list of the new file, the old file's hash table is traversed again. If there is a child node in the old file's hash table that has not been compared, the child node is set as a deleted node. The comparison results are recorded accordingly, and the occurrence of new and deleted nodes and their key attribute information are recorded, such as: adding a () node, deleting a () node, etc. The key attribute information of the node is recorded in parentheses.
[0061] In this context, if the label name of a child node in a node corresponds to multiple child nodes, then that child node is called a multi-node child node; for example, in the DataTypeTemplates node model, the DOType child node has multiple child nodes with the label name DOType in a DataTypeTemplates node model, so this child node is a multi-node child node relative to the DataTypeTemplates node model.
[0062] After starting step 2), as long as there are unmatched matching nodes that require comparison of child node details, continue to compare them using the same method as in step 2), nesting the extraction and comparison process, until there are no more unmatched matching nodes that require comparison of child node details. The comparison ends, the comparison result is output, and the comparison of the two SCL files to be compared is completed.
[0063] Furthermore, the IED child nodes of the root SCL node are multi-node child nodes, and the amount of data that needs to be compared is very large. In the comparison methods described above, if the data processing methods are the same, the comparison time of the IED node exceeds 90% of the overall comparison time. Therefore, in this embodiment, considering that the IED data has the largest amount of data and the longest comparison time in the SCL file, multi-threading is used when comparing IED nodes, which can further compress the comparison time.
[0064] SCL file comparison system implementation example:
[0065] This embodiment provides a technical solution for an SCL file comparison system. The comparison system includes a processor that executes program instructions to implement the comparison method as described in the above SCL file comparison method embodiment. Since the specific principles and implementation of this comparison system have been described in detail in the above SCL file comparison method embodiment, they will not be repeated here.
[0066] This invention has the following characteristics:
[0067] 1) Create a corresponding node model for each node in the SCL file, which includes node attributes and child node information, to avoid traversing during comparison and save traversal time.
[0068] 2) When building the node model, only the attribute information and child node information that the node is concerned with when comparing are modeled. When the node does not need to know the details of the differences between its child nodes, the specific child nodes of the node are not modeled. Therefore, the comparison of these nodes and attributes can be eliminated.
[0069] 3) When comparing nodes or their child nodes, the content of the corresponding node models is first formatted as text and then compared. When comparing text, only the text content is compared to see if they are the same. At this time, the specific differences are not considered. This comparison method can intuitively and quickly determine whether there are differences in the content of the matching nodes. If there are no differences, the process of comparing the specific content of the nodes can be skipped.
[0070] 4) When comparing texts, first compare the lengths of the texts. If the lengths are different, it can be directly determined that the pair of matching nodes are different, which can save the comparison of the specific content of the text. If the lengths are the same, then compare the hash values of the whole text, the first half of the text, and the second half of the text respectively. Using hash values to represent the text content for comparison can simplify the comparison objects, while using three hash values to participate in the comparison can minimize hash collisions.
[0071] 5) When there are multiple child nodes of a certain type (multi-node child nodes), the comparison of their details is performed by matching the child nodes with unique key attributes. The key attributes of each child node of this type in one of the files to be compared are stored in a linked list in order, thus ensuring the result order of multi-node child nodes. The key attributes of each child node of this type in another file to be compared are directly stored in a hash table. Then, the hash table of the old file and the linked list of the new file are compared, which can ensure the retrieval speed.
[0072] 6) When comparing IED nodes, using multi-threading can further reduce the comparison time.
[0073] It should be understood that the specific embodiments described above are merely illustrative or explanatory of the principles of the invention and do not constitute a limitation thereof. Therefore, any modifications, equivalent substitutions, improvements, etc., made without departing from the spirit and scope of the invention should be included within the protection scope of the invention. Furthermore, the appended claims are intended to cover all variations and modifications falling within the scope and boundaries of the appended claims, or equivalent forms of such scope and boundaries.
Claims
1. A method for comparing SCL files, characterized in that, The steps are as follows: 1) Read the two SCL files respectively, and then use the root SCL nodes of the two files to be compared as the first pair of matching nodes to be obtained; 2) Compare matching nodes according to the SCL standard model; the standard model includes the node model corresponding to each node, and the content of each node model includes the label name, attributes and child nodes contained in the node; the attributes include non-critical attributes and critical attributes, and the non-critical attributes refer to the node attributes that are of interest when comparing nodes. The process of comparing matching nodes is as follows: When the node model corresponding to the node is initially extracted, the key attributes of the node are read according to the SCL standard model and the key attributes are concatenated to calculate the hash value as the hash value of the node. By comparing the hash values of two nodes, it is determined whether the two nodes are a pair of matching nodes. The initially extracted content corresponding to a pair of matching nodes is formatted into text, and the text corresponding to this pair of matching nodes is directly compared. If the text is the same, it is determined that this pair of matching nodes is the same, and the comparison ends; otherwise, it is determined that this pair of matching nodes is different, and the non-critical attributes of this pair of matching nodes and the child nodes they contain are extracted and compared, and the comparison results are recorded.
2. The SCL file comparison method according to claim 1, characterized in that, The content of each node model also includes whether the node cares about the specific differences of its child nodes and details of the child nodes contained in the node; In step 2), when comparing the child nodes contained in a pair of matching nodes, if the pair of matching nodes does not care about the specific differences of the child nodes, the text content of the child nodes of the pair of matching nodes is compared, the comparison result is recorded and the comparison ends; the text content of the child nodes of the node refers to the content of the node in the SCL file, which is formatted as text and the content of the root node corresponding to the current matching node is removed. If the key differences between the child nodes of this pair of matching nodes are not critical attributes, then only the text content of the child nodes of this pair of matching nodes is compared. If they are the same, the comparison ends and the result is recorded; otherwise, the comparison of the child node details of this pair of matching nodes continues. If the node is concerned with the specific differences between its child nodes and the non-critical attributes are the same, then it can directly continue to compare the child node details of this pair of matching nodes.
3. The SCL file comparison method according to claim 2, characterized in that, When comparing child node details, if one of the child nodes in a pair of matching nodes is a single-node child node, then based on the label name of that child node, find the child node that matches that child node in the child nodes of the other node in the pair of matching nodes, take these two matching child nodes as a new pair of matching nodes, and compare this new pair of matching nodes according to the comparison process in step 2). If the label name of a child node in a node corresponds to only this one child node, then the child node is recorded as a single-node child node.
4. The SCL file comparison method according to claim 2, characterized in that, In step 2), when comparing the details of child nodes, if a child node of a matching node in one of the files to be compared is a multi-node child node, then one of the files to be compared is set as the old file and the other file to be compared is set as the new file. All child nodes in the new file with the same tag name as the child node are initially extracted in the manner of step 2) and stored as a linked list. Each entry in the linked list corresponds to a child node and its hash value. Then, all child nodes in the old file with the same tag name as the child node are initially extracted and stored in a hash table in the manner of step 2). Then, the hash table of the old file and the linked list of the new file are compared: the linked list of the new file is traversed, and according to the hash value of each entry, it is searched in the hash table of the old file to see if there is a child node with the same hash value. If there is, the two child nodes corresponding to the hash value are regarded as a new pair of matching nodes, and the comparison process in step 2) is followed to compare this pair of new matching nodes. If the label name of a child node in a node corresponds to multiple child nodes, then the child node is recorded as a multi-node child node.
5. The SCL file comparison method according to claim 4, characterized in that, If there is no child node in the hash table of the old file that has the same hash value as a certain entry in the linked list, then the child node corresponding to that entry is set as a new node; after traversing the linked list of the new file, the hash table of the old file is traversed again. If there is a child node in the hash table of the old file that has not been compared, then the child node is set as a deleted node. The comparison results, the occurrence of new nodes and deleted nodes, and their key attribute information are recorded.
6. The SCL file comparison method according to any one of claims 1-5, characterized in that, When building the SCL standard model, only all nodes that need to be compared are modeled, and the attributes of each node only include those that need to be considered when comparing nodes.
7. The SCL file comparison method according to any one of claims 1-5, characterized in that, In step 2), the method for comparing the text corresponding to a pair of matching nodes is as follows: First, compare the lengths of the texts corresponding to each pair of matching nodes. If the lengths are different, it is determined that the pair of matching nodes are different. If the lengths are the same, calculate and compare the hash values of the whole text, the first half of the text, and the second half of the text corresponding to each pair of matching nodes. If they are all the same, it is determined that the texts corresponding to the pair of matching nodes are the same; otherwise, it is determined that the pair of matching nodes are different.
8. The SCL file comparison method according to claim 4, characterized in that, The initial content extracted for a node only includes the node's tag name and key attributes.
9. The SCL file comparison method according to any one of claims 1-5, characterized in that, When comparing IED nodes in the SCL file, a multi-threaded approach is used.
10. An SCL file comparison system, characterized in that, Includes a processor for executing program instructions to implement the SCL file comparison method as described in any one of claims 1-9.