Method for creating IEC61850 protocol library object space
By comparing file information and deserializing the image file during program initialization, the problems of time consumption and excessive memory allocation in the creation process of the IEC61850 protocol library object space are solved, and fast initialization is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- XJ GRP CORP
- Filing Date
- 2023-04-28
- Publication Date
- 2026-07-14
AI Technical Summary
In existing technologies, the creation process of the IEC61850 protocol library object space is time-consuming and involves excessive temporary memory allocation, resulting in slow initialization speed, which is prone to failure, especially in embedded devices with scarce memory resources.
During program initialization, the information in the SCD file and configuration file is compared with the information in the image file. If there are no changes, the image file is directly deserialized into memory to create an object space, avoiding parsing the SCD and its configuration file and reducing temporary memory allocation.
It greatly shortens the object space creation time, reduces memory fragmentation, and improves the application initialization speed.
Smart Images

Figure CN116700742B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent substation technology, specifically relating to a method for creating an IEC61850 protocol library object space. Background Technology
[0002] For the IEC 61850 communication protocol, the common practice is to encapsulate the specific implementation of the IEC 61850 specification and underlying network communication, abstracting a set of interfaces to provide applications with a simple and easy-to-use IEC 61850 protocol dynamic link library or static link library. The IEC 61850 communication protocol library mainly includes two parts: the creation of the SCD model file object space and the underlying network communication.
[0003] Existing technology 1: The traditional method for creating the IEC61850 protocol library object space, with the following steps:
[0004] 1) Creating the data template area in the object space: the data template area for parsing SCD files. <datatypetemplates>A node is a data structure that creates data template information in memory.
[0005] 2) Create the data area in the object space: parse the SCD file <ied>Each node creates its own data structure in memory, including each IED and its LD, LN, DO, DA, report control block, log control block, and dataset.
[0006] 3) Based on the data object's type and initial value, search for data template information and instantiate the data object's value.
[0007] 4) Release the memory occupied by parsing the SCD file, retain the data template area and data area, and complete the creation of the object space.
[0008] As the scale of smart substations continues to expand, SCD files are becoming increasingly large. These excessively large SCD files lead to a very time-consuming parsing process, resulting in longer initialization times for the IEC61850 protocol library in existing technology 1, which in turn slows down the startup speed of IEC61850 applications. Furthermore, existing technology 1 requires a large amount of additional temporary memory allocation during SCD file parsing. If this allocation fails, it can cause IEC61850 protocol library initialization failure, which is particularly problematic in memory-constrained embedded devices where the probability of initialization failure increases significantly.
[0009] Existing technology 2: An optimized method for creating the IEC61850 protocol library object space, the steps of which are as follows:
[0010] 1) Optimize the SCD file and delete unnecessary data templates.
[0011] 2) Optimize the SCD file and delete unnecessary data objects.
[0012] 3) Creating the data template area of the object space: the data template area for parsing SCD files. <datatypetemplates>A node is a data structure that creates data template information in memory.
[0013] 4) Create the data area in the object space: parse the SCD file <ied>Each node creates its own data structure in memory, including each IED and its LD, LN, DO, DA, report control block, log control block, and dataset.
[0014] 5) Based on the data object's type and initial value, search for data template information and instantiate the data object's value.
[0015] 6) Release the memory occupied by parsing the SCD file, retain the data template area and data area, and complete the creation of the object space.
[0016] Prior art 2, based on prior art 1, shortens the parsing time of SCD files and reduces the allocation of temporary memory by optimizing SCD files and reducing their size. It also reduces the memory usage of object space by skipping the loading of data object description information. However, prior art 2 still requires parsing SCD files, and the problems of long parsing time due to excessively large SCD files and memory allocation failures due to excessive temporary memory allocation still exist.
[0017] Prior art 3: Chinese invention patent application CN112416452A discloses a method for fast startup of the IEC61850 protocol library, the steps of which are as follows:
[0018] 1) The SCD configuration tool parses the SCD model file and generates offline basic data files;
[0019] 2) Load the basic data file and the SCD model file;
[0020] 3) Create a portion of the IEC61850 object space based on the aforementioned basic data file;
[0021] 4) Parse the SCD model file, extract the data template portion, and place it into the IEC61850 object space;
[0022] 5) Assign initial values to the instantiated values of the data in the basic data file to complete the startup of the IEC61850 protocol library.
[0023] Existing technology 3 parses the SCD file using a configuration tool, writing the information of the data area to the base data file. The application then completes the object space creation by parsing the base data file and the data template portion of the SCD file. Existing technology 3 transforms the information of the SCD file's data area into a more easily parsed base data file, and the parsing of the SCD file's data area into the parsing of the base data file, thus shortening the object space creation time to some extent. However, to create the object space, existing technology 3 still needs to load and parse the base data file and the SCD file, still requiring additional temporary memory allocation and consuming a certain amount of parsing time, failing to fundamentally solve the problems of long parsing time and excessive temporary memory allocation. Summary of the Invention
[0024] The purpose of this invention is to provide a method for creating the IEC61850 protocol library object space, in order to solve the problems of long processing time and excessive temporary memory allocation in the process of parsing the SCD and its configuration files.
[0025] To address the aforementioned technical problems, this invention provides a method for creating an IEC61850 protocol library object space. The specific process is as follows: During application initialization, the SCD file, configuration file, and relevant information of the current program are read and compared with the SCD file, configuration file, and relevant information of the target program in the stored image file. If the comparison results show that all relevant information is identical, the object space portion of the image file is deserialized into memory to complete the creation of the object space. The image file is the image file of the object space generated during initial initialization or when the previous information comparison results were different, using the SCD file and configuration file.
[0026] Its beneficial effects are as follows: Considering that if the SCD file and configuration file information have not changed during program initialization, the parsing of the SCD file can be skipped. Therefore, the SCD file, configuration file and target program information in the stored image file are compared with the SCD file, configuration file and current program information obtained during this initialization to determine whether the data has changed. If the file information has not changed, the image file is directly deserialized to create the object space. This object space creation method avoids the allocation of a large amount of temporary memory when parsing the SCD and its configuration file, reduces the generation of memory fragmentation, greatly shortens the time required to create the object space, and speeds up the initialization speed of the application.
[0027] Furthermore, the relevant information for the SCD file includes the SCD file checksum, the relevant information for the configuration file includes the configuration file checksum, and the relevant information for both the current program and the target program includes the word length model, memory data endianness, and memory data alignment.
[0028] Its beneficial effects are: determining specific comparison information, ensuring the authenticity of the comparison between the two files, saving comparison time, and shortening the time required to create object space.
[0029] Furthermore, generating an object space image file includes the following steps:
[0030] Calculate the checksum of the SCD file and the checksum of the configuration file, and append them to the binary file respectively;
[0031] Add the target program's word length model, data endianness, and memory alignment to the binary file;
[0032] Obtain the word length model, memory data endianness, and memory data alignment of the currently running program; serialize the root node of the directed acyclic graph that the object space is abstracted from; and complete the generation of the object space image file.
[0033] Its beneficial effects are: setting the sorting order ensures that the order in which information is read from the object space and its image file is consistent, thereby improving the accuracy of the judgment between the two initializations.
[0034] Furthermore, the generated image file must be used in conjunction with the specified operating system.
[0035] Its beneficial effects are: this method is not limited to one operating system, but can select multiple operating systems, giving customers more choices.
[0036] Furthermore, serialization includes the following steps:
[0037] An object without pointer members is defined as a simple object, and an object containing pointer members is defined as a complex object.
[0038] If the object is a simple object, convert the object under the word length model, memory data endianness, and memory data alignment of the current running program into the object under the word length model, memory data endianness, and memory data alignment of the target program, append the converted object to the binary file, and assign its offset address in the binary file to the corresponding pointer member in its predecessor node.
[0039] If the object is a complex object, first serialize the objects pointed to by each pointer member in the object, and then serialize the complex object.
[0040] Its beneficial effects are: simplifying the object space, making it easier and more convenient to create an object space image file, reducing the time required to create the object space, and speeding up the initialization of the application.
[0041] Furthermore, deserialization includes the following steps:
[0042] Calculate the size of the serialized object space content in the object space image file, allocate memory according to its size, and record the starting address of the memory; then subtract the offset address of the serialized object space content in the file from the starting address of the memory to calculate the address offset difference;
[0043] Iterate through all objects in memory, add the address offset difference to all pointer members of each object, and make the pointer members point to the corresponding objects in memory.
[0044] Its beneficial effects are: directly deserializing the image file into memory avoids the large amount of temporary memory allocation when parsing the SCD and its configuration files, reduces the generation of memory fragmentation, greatly shortens the time required to create object space, and speeds up the initialization of the application.
[0045] Furthermore, if the information comparison results are not completely identical, the image file is deleted, the object space is recreated, and a new image file is generated accordingly.
[0046] Its beneficial effect is that when the information comparison results are not completely the same, the object space is directly recreated, avoiding the dead loop of continuous comparison, and thus speeding up the creation of the object space. Attached Figure Description
[0047] Figure 1 This is the object space image file format of the present invention;
[0048] Figure 2 This is a flowchart of the object space creation method of the present invention;
[0049] Figure 3 This is a flowchart of the SCD configuration tool of the present invention generating an object space image file;
[0050] Figure 4 This is a flowchart of the node serialization process of the present invention;
[0051] Figure 5 This is a flowchart of the object space deserialization process of the present invention. Detailed Implementation
[0052] The basic concept of this invention is as follows: if it is found that all information related to the file generated by the SCD configuration tool is identical to that in the generated image file, then the most time-consuming process of parsing the SCD and its configuration files is skipped, and the image file is directly loaded into a whole block of memory. The creation of the object space is completed by simply modifying the values of the object pointer members. The invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0053] Method Implementation Examples:
[0054] An embodiment of the IEC61850 protocol library object space creation method of the present invention is shown in the flowchart below. Figure 2 As shown, the specific process is as follows:
[0055] Step 1: When the application is initialized for the first time, the SCD configuration tool generates the SCD and configuration file, and then adds the traditional IEC61850 protocol library initialization process to create the object space. The object space can be created by choosing one of the existing technical methods introduced in the background.
[0056] Step two, the SCD configuration tool generates an object space image file, the file format of which is as follows: Figure 1 As shown, Figure 3 The specific process for generating an object space image file:
[0057] 1) Calculate the CRC of the SCD file and append it to the binary file;
[0058] 2) Calculate the CRC of the configuration file and append it to the binary file;
[0059] 3) Append the target program's word length model to the binary file;
[0060] 4) Append the target program's endianness to the binary file;
[0061] 5) Append the target program's memory alignment to the binary file;
[0062] 6) Obtain the word length model, memory data endianness, and memory data alignment of the current running environment of the SCD configuration tool;
[0063] 7) The root node in the directed acyclic graph corresponding to the serialized object space, such as... Figure 4 As shown, if the object is a simple object, then the object under the word length model, memory data endianness, and memory data alignment of the current running environment of the SCD configuration tool is converted into an object under the word length model, memory data endianness, and memory data alignment of the target program. The converted object is appended to the binary file, and its offset address in the binary file is assigned to the corresponding pointer member in its predecessor node. If the object is a complex object, then the objects pointed to by each pointer member in the object are serialized in sequence, and then the complex object is serialized.
[0064] Additionally, this step allows you to specify the operating system to generate the image file. The operating system can be Windows, Linux, or XP, etc., so that steps three through seven can be executed on the specified operating system.
[0065] Step 3: When the application initializes for the second time, the SCD configuration tool generates the SCD file and configuration file, and the previously generated object space image file is provided to the application.
[0066] Step 4: The IEC61850 protocol library obtains the CRC information of the SCD file and configuration file, and obtains the word length model (ILP32, LP64, LLP64, etc.), memory data endianness, and memory data alignment of the current program.
[0067] Step 5: The IEC61850 protocol library reads the "SCD file CRC", "configuration file CRC", word length model of the target program, memory data endianness, and memory data alignment from the image file.
[0068] Step Six: Compare the SCD file CRC, configuration file CRC, target program word length model, memory data endianness, and memory alignment in Steps Four and Five using the IEC61850 protocol library.
[0069] Step seven: If all the information is the same, then the IEC61850 protocol library deserializes the object space portion of the image file into memory, such as... Figure 5 As shown, the specific steps of deserialization are as follows:
[0070] 1) Calculate the size of the "serialized object space content" in the object space image file, i.e., the object space size;
[0071] 2) Allocate memory according to the object space size in 1), and record the starting address of the memory;
[0072] 3) Subtract the offset address of the "serialized object space content" in the file from the memory starting address in 2) to calculate the address offset difference;
[0073] 4) Traverse all objects in memory, add the address offset difference from 3) to all pointer members in the objects, and make the pointer members point to the corresponding objects in memory;
[0074] 5) Proceed to step ten.
[0075] Step 8: If they are different, then the IEC61850 protocol library deletes the image file and creates the object space using the traditional method from the SCD and configuration file. The traditional method of creating the object space can be selected from several existing technical methods introduced in the background.
[0076] Step 9: The IEC61850 protocol library writes the object space to a binary file, generating an image file of the object space.
[0077] Step 10: The object space for the IEC61850 protocol library has been created.
[0078] Step 11: If the application initializes again, repeat steps 3 through 10.
[0079] The optimization effect of this invention is as follows: Under an environment with 8GB of memory, a 3.6GHz dual-core processor, and a WIN7 64-bit operating system, the specific application data for a 180MB SCD file containing 300 IEDs is shown in Table 1:
[0080] Table 1
[0081]
[0082] In this embodiment, the IEC61850 protocol library obtains the CRC information of the SCD file and configuration file, and obtains the word length model (ILP32, LP64, LLP64, etc.), memory data endianness, and memory data alignment of the current program, and compares them. This invention is not limited to comparing these information; other information can also be used, but the reading order must be consistent.
[0083] This invention primarily addresses the creation method of object space during the Nth (N>1) initialization of a program. It compares the previously recorded object space image file with the current object space file. If the comparison is the same, it indicates that the SCD data has not changed. Therefore, the most time-consuming parsing process of SCD and its configuration file can be skipped, and the image file can be directly loaded into a whole block of memory. The object space creation is completed by simply modifying the values of the object pointer members. This avoids the large amount of temporary memory allocation required each time SCD and its configuration file are parsed, reduces memory fragmentation, greatly shortens the time required to create object space, and speeds up the initialization of the application.< / ied> < / datatypetemplates> < / ied> < / datatypetemplates>
Claims
1. A method for creating an IEC 61850 protocol library object space, characterized in that, During application initialization, the checksum of the SCD file, the checksum of the configuration file, and the relevant information of the current program are read and compared with the checksum of the SCD file, the checksum of the configuration file, and the relevant information of the target program in the stored image file. If the comparison results are all the same, the object space portion of the image file is deserialized into memory to complete the creation of the object space. The relevant information includes word length model, memory data endianness, and memory data alignment. Deserialization involves: calculating the size of the serialized object space content in the object space image file, allocating memory according to the size, and recording the starting address of the memory; subtracting the offset address of the object space content in the file from the starting address of the memory to obtain the address offset difference; Iterate through all objects in memory, add the address offset difference to all pointer members in the objects, and make the pointer members point to the corresponding objects in memory; The image file is an image file of the object space generated when the object space is created using SCD and configuration file during initial initialization or when the previous comparison result is different. The generation method is as follows: calculate the checksum of SCD and configuration file, and append the calculated checksum and relevant information of the target program to the binary file. Obtain relevant information about the currently running program, and the root node of the directed acyclic graph that the serialization object space is abstracted from; Serialization is performed as follows: If the object is a simple object without pointer members, the object under the relevant information of the currently running program is converted into the object under the relevant information of the target program, the converted object is appended to the binary file, and its offset address in the binary file is assigned to the corresponding pointer member in its predecessor node; if the object is a complex object with pointer members, the object pointed to by each pointer member in the object is serialized first, and then the complex object is serialized.
2. The method for creating the IEC61850 protocol library object space according to claim 1, characterized in that, The checksum for an SCD file is a CRC checksum.
3. The method for creating the IEC61850 protocol library object space according to claim 1, characterized in that, The configuration file uses a CRC checksum.
4. The method for creating the IEC61850 protocol library object space according to claim 1, characterized in that, The specified operating system must be used when generating the image file.
5. The method for creating the IEC 61850 protocol library object space according to claim 4, characterized in that, The operating system is Windows, Linux, or XP.
6. The method for creating the IEC61850 protocol library object space according to claim 1, characterized in that, Word length models include ILP32, LP64, and LLP64.
7. The method for creating the IEC 61850 protocol library object space according to claim 1, characterized in that, If the comparison results are not completely identical, delete the image file, recreate the object space, and generate a new image file accordingly.