Configuration file processing method and device, computer equipment and storage medium

By automatically parsing switch configuration files and generating tag files, the problems of inefficiency and error-prone traditional switch configuration file management are solved, efficient and reliable configuration file management is achieved, and the overall performance and security of the smart grid are improved.

CN120091059APending Publication Date: 2025-06-03LIJIANG POWER SUPPLY BUREAU OF YUNNAN POWER GRID CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510031386.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

The management of traditional switch configuration files is inefficient and prone to errors, affecting the performance and security of the smart grid.

Method used

By automatically parsing switch configuration files and generating tag files, the operation and maintenance personnel can reduce the operation and maintenance operations of manually processing configuration files, and improve the management efficiency and accuracy of configuration files.

Benefits of technology

It reduces the error rate during the configuration process, improves the efficiency of operation and maintenance work, can quickly respond to network changes, and enhances the overall reliability of the smart grid.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120091059A_ABST
    Figure CN120091059A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of smart power grids, and provides a configuration file processing method and device, computer equipment and a storage medium. Storing the configuration information in a target array, wherein each element of the target array is an object containing the configuration information; traversing each element in the target array and generating corresponding label content based on the traversed elements; performing formatting processing on the label content; and generating a label file based on the formatted label content. The label file is automatically generated through the configuration file, so that the error rate in the configuration process is reduced; meanwhile, the automatic process reduces the time and workload of manually generating labels by operation and maintenance personnel, so that the operation and maintenance work is more efficient, and network changes can be quickly responded; in addition, the accuracy and consistency of the labels can be ensured through the automatic process, the configuration reliability is improved, and therefore the overall reliability of the intelligent power grid is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of smart grids, and particularly to a method, device, computer device, and storage medium for processing switch configuration files in a smart substation. Background Art

[0002] With the continuous innovation and development of smart grid technology, as a key node in the power system, the safety and efficiency of a smart substation are crucial for the stable operation of the entire power grid. A large number of switch devices inside the smart substation undertake the important task of data transmission and exchange, and the precise management of switch configuration files is the basis for ensuring the stability and efficiency of data transmission.

[0003] However, the management of traditional switch configuration files mostly relies on manual configuration. Operation and maintenance personnel need to view the configuration files one by one, manually identify and extract key information, and then make configuration adjustments or troubleshoot faults based on this information. This method is not only inefficient but also prone to human errors, resulting in incorrect configuration of the configuration files, which in turn affects the overall performance and security of the smart grid. Summary of the Invention

[0004] Based on this, a method, device, computer device, and storage medium for processing configuration files are proposed, aiming to solve the technical problems of low configuration efficiency and easy error-prone of traditional switch configuration files.

[0005] The first aspect of this application provides a method for processing configuration files, and the method for processing configuration files includes:

[0006] Obtain the configuration file of the switch;

[0007] Parse the configuration information based on the configuration file;

[0008] Store the configuration information in a target array, and each element of the target array is an object containing the configuration information;

[0009] Traverse each element in the target array and generate corresponding tag content based on the traversed element;

[0010] Format the tag content;

[0011] Generate a tag file based on the formatted tag content.

[0012] Optionally, the parsing the configuration information based on the configuration file includes:

[0013] Use a FileReader object to read the worksheet in the configuration file;

[0014] Convert the data format of the worksheet to a target format;

[0015] Traverse each row of the worksheet in the target format through the `parseXlsx` function, and extract the target information related to the switch in each row;

[0016] Obtain the configuration information based on the target information.

[0017] Optionally, the obtaining the configuration information based on the target information includes:

[0018] Perform duplicate removal processing on the target information;

[0019] Obtain the configuration information based on the target information after duplicate removal processing.

[0020] Optionally, the generating the label file based on the formatted label content includes:

[0021] Create a document object using the `Document` class;

[0022] Generate table rows in the document object using the `generateTableRowsForCenterSwitch` function and set the cell styles;

[0023] Fill the formatted label content into the cells to obtain the label file.

[0024] Optionally, the configuration file processing method further includes:

[0025] Associate the configuration file with the label file to obtain an associated file;

[0026] Convert the associated file into a Blob object;

[0027] Create a download link pointing to the Blob object using `URL.createObjectURL`;

[0028] Simulate clicking the download link to automatically download the associated file.

[0029] Optionally, the configuration file processing method further includes:

[0030] Associate and store the version of the label file with the configuration file.

[0031] Optionally, the configuration file processing method further includes:

[0032] Obtain the file type of the configuration file;

[0033] Determine whether the file type is a preset file type;

[0034] When the file type is the preset file type, execute the configuration information parsed based on the configuration file;

[0035] When the file type is not the preset file type, display a preset prompt message.

[0036] The second aspect of the present application provides a configuration file processing device, and the configuration file processing device includes:

[0037] An acquisition module, configured to acquire a configuration file of a switch;

[0038] An analysis module, configured to analyze and obtain configuration information based on the configuration file;

[0039] A storage module, configured to store the configuration information in a target array, and each element of the target array is an object containing the configuration information;

[0040] A creation module, configured to create a document object;

[0041] A traversal module, configured to traverse each element in the target array and generate corresponding tag content based on the traversed element;

[0042] A processing module, configured to perform formatting processing on the tag content;

[0043] A generation module, configured to generate a tag file based on the tag content after formatting processing.

[0044] The third aspect of the present application provides a computer device, and the computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the configuration file processing method are implemented.

[0045] The fourth aspect of the present application provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the configuration file processing method are implemented.

[0046] The present application automatically analyzes the switch configuration file and generates a tag file based on the analysis result, reducing the operation of maintenance personnel manually processing the configuration file, thereby reducing the error rate during the configuration process; at the same time, the automated process reduces the time and workload of maintenance personnel manually generating tags, making the maintenance work more efficient, capable of quickly responding to network changes, reducing the delay and inconvenience caused by configuration updates; in addition, the automated process can ensure the accuracy and consistency of tags, improving the reliability of the configuration, thereby improving the overall reliability of the smart grid. Description of the Drawings

[0047] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0048] Figure 1 It is a schematic flowchart of the configuration file processing method provided by the embodiments of the present application.

[0049] Figure 2 It is a schematic diagram of the parsing interface of the configuration file provided by the embodiments of the present application;

[0050] Figure 3 It is a schematic diagram of the label file provided by the embodiments of the present application;

[0051] Figure 4 It is a functional module diagram of the configuration file processing device provided by the embodiments of the present application.

[0052] Figure 5 It is a schematic structural diagram of the computer device provided by the embodiments of the present application. Specific embodiments

[0053] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, rather than all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0054] Figure 1 It is a schematic flowchart of the configuration file processing method provided by the embodiments of the present application. The configuration file processing method includes the following steps.

[0055] S11, obtain the configuration file of the switch.

[0056] The switch in the embodiments of the present application refers to the intelligent substation process layer switch. The intelligent substation process layer switch is a highly reliable, high-performance, and manageable gigabit Ethernet switch used in the process layer network of the intelligent substation. The process layer network is responsible for transmitting key information such as sampled data and tripping signals. The intelligent substation process layer switch completes the digital sampling and tripping functions through intelligent terminals and merging units, further promoting the networking and fiberization of all secondary equipment in the substation.

[0057] The configuration file of the switch can be obtained from the file import interface. The file import interface refers to the graphical interface or web interface through which the network administrator operates for importing, exporting, or managing the switch configuration file. The switch configuration file contains various configuration information of the switch, such as port configuration, VLAN configuration, IP address, etc. These configuration files are used to ensure the normal operation of the switch and the stable transmission of data.

[0058] Suppose an enterprise has a complex network system that includes multiple switches. To ensure the stability and security of the network, users (such as network administrators) need to regularly back up and update the switch configuration files. When it is necessary to update the configuration of a certain switch, the network administrator can click the "Import Configuration File" option on the file import interface, such as a web interface. The computer device detects that the "Import Configuration File" option has received a click instruction and prompts the network administrator to upload a file. During or after the upload process, the web interface can display the detailed information of the configuration file for the network administrator to verify. After the network administrator confirms that the selected configuration file is correct and matches the switch to be updated, the network administrator can click "Start Import" to initiate the import process. The file import interface sends the imported configuration file to the specified switch and applies the configuration information therein.

[0059] Providing a file import interface can facilitate network administrators to conveniently import switch configuration files, thereby ensuring network stability and security.

[0060] Optionally, the configuration file processing method further includes:

[0061] Obtaining the file type of the configuration file;

[0062] Judging whether the file type is a preset file type;

[0063] When the file type is the preset file type, parsing the configuration information based on the switch configuration file;

[0064] When the file type is not the preset file type, displaying a preset prompt message.

[0065] The network administrator first prepares the switch configuration file to be imported on a secure computer. This file is usually a text file or an Excel file containing switch configuration information.

[0066] Obtain the extension name of the switch configuration file (such as.txt,.xlsx,.cfg, etc.), and determine the file type of the switch configuration file according to the obtained extension name. It is also possible to obtain the file content of the switch configuration file and identify the file type of the switch configuration file according to specific markers or metadata in the file content.

[0067] Compare the obtained file type with a set of preset and acceptable file types. The preset file types refer to the file types that can correctly parse and apply the configuration information.

[0068] If the imported file type matches the preset file type, execute the parsing process. If the imported file type does not match the preset file type, do not execute the parsing process, and at the same time display a preset prompt message to inform the network administrator that the uploaded file type is not supported, and suggest that the network administrator upload the correct type of file or reselect the file.

[0069] The above optional implementation methods make the entire import process of the switch configuration file more robust and flexible. By verifying the file type, it is possible to avoid attempting to parse unsupported file formats, thereby reducing the possibility of errors. At the same time, when the file type does not match, by displaying a prompt message, clear feedback can be provided to the network administrator to guide the network administrator to perform correct operations.

[0070] S12, parse the configuration information based on the configuration file.

[0071] After confirming that the type of the switch configuration file uploaded by the user meets the preset requirements, extract the various configuration information required by the switch from the configuration file.

[0072] Open the configuration file and read the content of the configuration file line by line or block by block until the end of the configuration file.

[0073] Parse according to the format of the configuration file (such as text format, Excel format, configuration file format of specific manufacturers, etc.). The parsing process can include identifying the structure of the file (such as the title row, data row, delimiter, etc.), and understanding the meaning of each field in the file. On the basis of parsing the file format, extract the configuration information required by the switch.

[0074] In an optional implementation manner, the parsing the configuration information based on the configuration file includes:

[0075] Use a FileReader object to read the worksheet in the configuration file;

[0076] Convert the data format of the worksheet to the target format;

[0077] Traverse each row of the worksheet in the target format through the `parseXlsx` function, and extract the target information related to the switch in each row;

[0078] Obtain the configuration information based on the target information.

[0079] The switch configuration file includes multiple worksheets. Use the `FileReader` object to read the worksheets in the switch configuration file uploaded by the user. The `FileReader` object is a JavaScript object used when processing file uploads and reads.

[0080] Since the original worksheet data format (such as the binary format of Excel) is not convenient for directly parsing and extracting information. Therefore, after reading the worksheet, it is necessary to convert its data format into a target format that is more suitable for subsequent processing. The target format can be JSON, an array, an object, or other data structures that are easier to program with.

[0081] Use the `parseXlsx` function to traverse each row of the worksheet converted to the target format. For each row, the `parseXlsx` function extracts the target information related to the switch. The target information can include, but is not limited to: port configuration (such as port number, port status (enabled / disabled), port speed, duplex mode, etc.), VLAN configuration (such as VLAN ID, VLAN name, VLAN members (which ports belong to this VLAN)), IP address configuration (such as the management IP address of the switch, interface IP address, etc.), other configurations (such as security policies, routing protocol configurations, etc.).

[0082] Integrate the extracted target information into the final configuration information. Specifically, combine multiple related fields into a configuration object, or merge multiple rows of data into a complete configuration set, as Figure 2 shown. The configuration information will be used in subsequent steps, such as updating the switch configuration, storing it in a database, or performing other processing.

[0083] In an optional implementation manner, the obtaining the configuration information based on the target information includes:

[0084] Perform deduplication processing on the target information;

[0085] Obtain the configuration information based on the target information after deduplication processing.

[0086] When parsing the switch configuration file, duplicate information may be encountered, especially when dealing with large configuration files or Excel files containing multiple worksheets. Such information is not substantially helpful for the final generation of the label file, but instead increases the complexity and size of the file. Through deduplication, these redundant information can be eliminated to ensure that each item in the configuration information is unique, making the configuration file more concise and clear, thus avoiding duplicate configurations or unnecessary processing in subsequent steps.

[0087] Deduplication can be performed based on hash values. For example, calculate a hash value for each configuration information and check whether the hash value already exists in the hash table. If it exists, it is regarded as duplicate information and deleted; if not, it is added to the hash table and the configuration information is retained. Deduplication can also be performed based on content comparison. For example, directly compare the content of each configuration information. If two pieces of information are exactly the same (or only differ in some negligible minor differences), they are regarded as duplicate information and one of them is deleted. Deduplication can also be performed based on rules. For example, according to a preset rule set (defining that some configuration items are mutually exclusive, or the values of some configuration items are unique within a certain range), screen and deduplicate the configuration information.

[0088] After deduplication, the original configuration data is streamlined into a set of non-redundant, accurate, and efficient configuration information. These configuration information are then used to generate the label file to guide the actual configuration of the switch.

[0089] It should be understood that during the parsing process, check whether there are missing fields in the configuration file. When it is checked that there are missing fields, an error prompt is provided to the user.

[0090] S13, store the configuration information in the target array.

[0091] Among them, the target array can be the switchConfigurations array.

[0092] After deduplication, the remaining target information (configuration information) is stored in the switchConfigurations array. Each element of the switchConfigurations array is an object containing configuration information. These objects have a fixed structure and contain various fields and values required for the switch configuration. The switchConfigurations array is a collection of configuration information, reflecting all the unique and valid configuration items extracted from the switch configuration file.

[0093] An array variable can be defined according to the type and quantity of configuration information as the target storage container (target array). Each piece of configuration information is converted into an array element (such as a string, object, etc.), and using a loop structure, each array element is added to the target array one by one.

[0094] Exemplarily, processed_config_info is a list containing configuration information, and target_array is the target array. By looping through processed_config_info and adding each element to target_array, the operation of storing configuration information in the target array is achieved.

[0095] S14, Traverse each element in the target array and generate corresponding label content based on the traversed element.

[0096] After the configuration information has been stored in the target array, create a label for each configuration item or data item in the target array that is easy to identify and describe its content.

[0097] In specific implementation, start from the first element of the target array and prepare to traverse. Use a loop structure (such as a for loop) to traverse each element in the array. During the traversal, analyze each element, extract its key information or features. According to the extracted information or features, generate a descriptive label content. This label can be a simple string or a structured data containing multiple fields. Store the generated label content in a new data structure (such as a list, dictionary, etc.).

[0098] It should be understood that since the elements in the target array are unique (each element represents a unique configuration item), the generated labels should also be unique to avoid confusion.

[0099] S15, Format the label content.

[0100] Format the generated label content. For example, adjust the text alignment, font size, color, etc., and add delimiters or line breaks to separate different labels. Through formatting, it can ensure that the content of the label file has a consistent appearance and format, improving readability and usability.

[0101] S16, Generate a label file based on the formatted label content.

[0102] Generating a label file based on the formatted label content is a process of outputting the processed data to the file system.

[0103] In an optional embodiment, generating the label file based on the formatted label content includes:

[0104] Create a document object using the Document class;

[0105] Use the generateTableRowsForCenterSwitch function to generate table rows in the document object and set the cell styles;

[0106] Fill the formatted label content into the cells to obtain the label file.

[0107] Use the Document class to create a new document object. The created document object will serve as the basis for generating the label file. The created document object can be a simple text file with each line containing a label and its corresponding value; it could also be a structured file such as JSON or XML, which contains multiple labels and nested structures.

[0108] Call the generateTableRowsForCenterSwitch function to generate table rows based on the label content and set appropriate styles (such as borders, background colors, fonts, etc.) for each cell. By generating table rows and setting cell styles, the label content can be organized and presented in a tabular form, making the label file more structured and easier to understand.

[0109] Finally, fill the formatted label content into the previously generated table cells. By filling the cells, the system can present the configuration information in the form of labels completely in the label file. After completion of filling, save the document and close the file stream to obtain the final label file, as Figure 3 shown.

[0110] In the above optional embodiment, a structured and easy-to-understand label file is generated through steps such as creating a document object, generating table rows, setting cell styles, and filling cells. This label file not only contains the specific content of the switch configuration information but also has good readability and usability, providing convenience for subsequent configuration management and automated deployment tasks.

[0111] Optionally, the configuration file processing method further includes:

[0112] Associate the configuration file with the label file to obtain an associated file;

[0113] Convert the associated file into a Blob object;

[0114] Create a download link pointing to the Blob object using URL.createObjectURL;

[0115] Simulate clicking the download link to automatically download the associated file.

[0116] Associate the original configuration file with the generated tag file. For example, the association between the configuration file and the tag file can be achieved through file names, file paths, metadata, etc., so that the two files can be easily found and referenced when needed.

[0117] Convert the associated file into a Blob (Binary Large Object) object. A Blob object is a class file object used in Web API to represent immutable, raw data. By converting the associated file into a Blob object, file data can be processed programmatically without directly operating on the file system. This facilitates the implementation of functions such as file download, upload, and preview.

[0118] Use the URL.createObjectURL method to create a temporary URL pointing to the Blob object. This URL is a reference to the Blob object in memory. By creating a download link pointing to the Blob object, a simple way to download the associated file can be provided without saving the file to the server, which helps improve the efficiency and security of file download.

[0119] Simulate the behavior of a user clicking the download link to automatically trigger the file download process. For example, by creating a hidden Label it and set its href attribute to the download link, then trigger a click event. By simulating a click on the download link, the function of automatically downloading associated files can be achieved without the user having to manually click the download button, improving the user experience and automation level, especially when batch downloading files.

[0120] Optionally, the configuration file processing method may further include:

[0121] Associate and store the label file with the version of the configuration file.

[0122] Ensure that the label is updated in a timely manner after each configuration change, facilitating tracking and management by the operation and maintenance personnel.

[0123] When storing the label file, record and associate the specific version of the switch configuration file corresponding to the label file. Whenever the configuration file changes, a new label file will be automatically generated, and the association information in the record table will be updated to ensure that the label file and the version of the configuration file are always consistent.

[0124] Through associated storage, the label corresponding to each version of the configuration file can be clearly traced. Whether for rolling back to a previous stable version or for analyzing the history of configuration changes, it helps the operation and maintenance personnel to quickly locate the configuration file of a specific version when needed. In addition, during the life cycle of the configuration file, it may go through multiple modifications and updates. By associating and storing the label file and the version of the configuration file, it can ensure that the configuration information reflected by the label is consistent with the actual content of the configuration file, avoiding information out-of-sync problems caused by configuration updates.

[0125] The configuration file processing method provided by the embodiments of this application obtains the current configuration file from the switch device. The configuration file usually contains various settings and parameters of the switch and serves as the basis for subsequent parsing and processing. After obtaining the configuration file, by parsing the configuration file, the original text data can be converted into structured configuration information, which facilitates subsequent storage and processing. After parsing the configuration information, for the convenience of subsequent processing and management, the configuration information is stored in a target array. Each element of the target array is an object containing configuration information, which makes it more convenient to traverse and operate. Traversing each element in the target array and generating corresponding tag content based on the traversed element can achieve further processing and sorting of the configuration information. The generated tag content can be used to identify and describe each piece of configuration information, facilitating subsequent processing and recognition. After generating the tag content, in order to ensure its uniform format, easy reading and recognition, the tag content is formatted. Through formatting, the readability and maintainability of the tag content can be improved. Finally, after the tag content is formatted, these contents are written into a tag file, realizing the structured storage of the processed configuration information. The tag file can be used to store and distribute the tags of the processed configuration information, facilitating subsequent use and management.

[0126] This application automatically generates a tag file based on the configuration file, reducing the operations of maintenance personnel in manually processing the configuration file, thereby reducing the error rate during the configuration process. At the same time, the automated process reduces the time and workload of maintenance personnel in manually generating tags, making the maintenance work more efficient, capable of quickly responding to network changes, and reducing the delays and inconveniences caused by configuration updates. In addition, the automated process can ensure the accuracy and consistency of the tags, improving the reliability of the configuration, and thus enhancing the overall reliability of the smart grid.

[0127] It should be noted that configuring the process layer switch is an important step to ensure the stability and efficiency of data transmission. However, during the configuration process, the reason for generating tags instead of directly generating or modifying the configuration file mainly lies in:

[0128] (1) Tags provide a way to quickly identify and locate switches and their configurations. By generating tags for the switch configuration file, maintenance personnel can more easily identify key information such as the configuration status, belonging VLAN, priority, etc. of each switch;

[0129] (2) The intuitiveness of tags enables maintenance personnel to quickly obtain the required information during on-site operations, reducing the time for referring to long configuration files.

[0130] Figure 4 It is a functional module diagram of the configuration file processing device provided by an embodiment of the present application.

[0131] In some embodiments, the configuration file processing device 40 may include multiple functional modules composed of program code segments. The program code of each program segment in the configuration file processing device 40 can be stored in the memory of the computer device and executed by at least one processor to execute (see details Figure 1 description) the function of generating configuration file tags.

[0132] In this embodiment, the configuration file processing device 40 can be divided into multiple functional modules according to its executed functions. The functional modules may include: an acquisition module 401, a parsing module 402, a storage module 403, a traversal module 404, a processing module 405, a generation module 406, an association module 407, a simulation module 408, a judgment module 409, and a display module 410. The module referred to in this application means a series of computer-readable instruction segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0133] The acquisition module 401 is used to acquire the configuration file of the switch;

[0134] The parsing module 402 is used to parse the configuration information based on the configuration file;

[0135] The storage module 403 is used to store the configuration information in a target array, and each element of the target array is an object containing the configuration information;

[0136] The traversal module 404 is used to traverse each element in the target array and generate corresponding label content based on the traversed element;

[0137] The processing module 405 is used to format the label content;

[0138] The generation module 406 is used to generate a label file based on the formatted label content.

[0139] The association module 407 is used to associate the configuration file with the label file to obtain an associated file;

[0140] The simulation module 408 is used to convert the associated file into a Blob object; create a download link pointing to the Blob object using URL.createObjectURL; simulate clicking the download link to automatically download the associated file.

[0141] The association module 407 is further used to associate and store the version of the label file with the configuration file.

[0142] The acquisition module 401 is further used to acquire the file type of the configuration file.

[0143] The judgment module 409 is used to judge whether the file type is a preset file type;

[0144] The parsing module 402 is further configured to, when the determination module 409 determines that the file type is the preset file type, parse the configuration information based on the configuration file;

[0145] The display module 410 is configured to, when the determination module 409 determines that the file type is not the preset file type, display a preset prompt message.

[0146] It should be understood that the various change modes and specific embodiments in the configuration file processing method provided in the foregoing embodiments are equally applicable to the configuration file processing apparatus in this embodiment. Through the detailed description of the foregoing configuration file processing method, those skilled in the art can clearly know the implementation process of the configuration file processing apparatus in this embodiment. For the sake of brevity of the specification, it will not be elaborated herein.

[0147] The configuration file processing apparatus provided in the embodiment of the present application obtains its current configuration file from a switch device. The configuration file usually contains various settings and parameters of the switch and is the basis for subsequent parsing and processing. After obtaining the configuration file, by parsing the configuration file, the original text data can be converted into structured configuration information, which facilitates subsequent storage and processing. After parsing to obtain the configuration information, for the convenience of subsequent processing and management, the configuration information is stored in a target array. Each element of the target array is an object containing configuration information, which can be more conveniently traversed and operated on. Traversing each element in the target array and generating corresponding tag content based on the traversed element can realize further processing and sorting of the configuration information. The generated tag content can be used to identify and describe each configuration information, which facilitates subsequent processing and recognition. After generating the tag content, in order to ensure its unified format, easy reading and recognition, the tag content is formatted. Through formatting, the readability and maintainability of the tag content can be improved. Finally, after the tag content is formatted, these contents are written into a tag file, realizing the preservation of the processed configuration information in a structured manner. The tag file can be used to store and distribute the tags of the processed configuration information, which facilitates subsequent use and management.

[0148] This application automatically generates a tag file based on the configuration file, reducing the operations of maintenance personnel manually processing the configuration file, thereby reducing the error rate in the configuration process; at the same time, the automated process reduces the time and workload of maintenance personnel manually generating tags, making the maintenance work more efficient, capable of quickly responding to network changes, and reducing the delay and inconvenience caused by configuration updates; in addition, the automated process can ensure the accuracy and consistency of the tags, improving the reliability of the configuration, thereby improving the overall reliability of the smart grid.

[0149] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, all or part of the steps of the above-mentioned configuration file processing method are implemented.

[0150] Refer to Figure 5 As shown, it is a schematic structural diagram of a computer device provided by an embodiment of the present application. In a preferred embodiment of the present application, the computer device 5 includes a memory 501, at least one processor 502, and at least one communication bus 503.

[0151] Those skilled in the art should understand that Figure 5 the structure of the computer device shown does not constitute a limitation on the embodiments of the present application. The computer device 5 may further include more or fewer other hardware or software than shown, or different component arrangements.

[0152] In some embodiments, the computer device 5 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits, programmable gate arrays, digital signal processors, and embedded devices, etc. The computer device 5 may further include a client device, and the client device includes, but is not limited to, any electronic product that can perform human-computer interaction with the client in ways such as a keyboard, a mouse, a remote control, a touchpad, or a voice control device. For example, a personal computer, a tablet computer, a smart phone, a digital camera, etc.

[0153] It should be noted that the computer device 5 is only an example, and other existing or future possible electronic products that can be adapted to the present application should also be included within the protection scope of the present application and are hereby incorporated by reference.

[0154] In some embodiments, a computer program is stored in the memory 501, and when the computer program is executed by the at least one processor 502, all or part of the steps in the described profile processing method are implemented. The memory 501 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically-erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc memory, a magnetic disk memory, a magnetic tape memory, or any other computer-readable medium capable of carrying or storing data. Further, the computer-readable storage medium mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, and the like.

[0155] In some embodiments, the at least one processor 502 is the control core (Control Unit) of the computer device 5, connecting various components of the entire computer device 5 through various interfaces and lines. By running or executing the programs or modules stored in the memory 501, and by invoking the data stored in the memory 501, various functions of the computer device 5 are executed and data is processed. For example, when the at least one processor 502 executes the computer program stored in the memory, all or part of the steps in the profile processing method described in the embodiments of the present application are implemented; or all or part of the functions of the profile processing device are implemented. The at least one processor 502 can be composed of integrated circuits. For example, it can be composed of a single packaged integrated circuit, or can be composed of multiple integrated circuits with the same or different functions packaged, including a combination of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.

[0156] In some embodiments, the at least one communication bus 503 is configured to implement connection communication between the memory 501 and the at least one processor 502, etc. Although not shown, the computer device 5 may further include a power source (such as a battery) for powering each component. Preferably, the power source can be logically connected to the at least one processor 502 through a power management device, so as to implement functions such as management of charging, discharging, and power consumption management through the power management device. The power source may further include any components such as one or more DC or AC power sources, a recharge device, a power failure detection circuit, a power converter or inverter, and a power status indicator. The computer device 5 may further include various sensors, a Bluetooth module, a Wi-Fi module, etc., which will not be elaborated here.

[0157] The integrated unit implemented in the form of a software functional module as described above can be stored in a computer-readable storage medium. The above software functional module stored in a storage medium includes several instructions for causing a computer device (which may be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the configuration file processing method described in various embodiments of the present application.

[0158] In several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.

[0159] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units. They may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

Claims

1. A configuration file processing method, characterized in that: The configuration file processing method comprises: Get the switch configuration file; Parsing the configuration file to obtain configuration information; The configuration information is stored in a target array, each element of the target array is an object containing the configuration information; Traversing each element in the target array and generating corresponding label content based on the traversed elements; Formatting the label content; Generate a tag file based on the formatted tag content.

2. The configuration file processing method according to claim 1, characterized in that: The configuration information obtained by parsing the configuration file includes: Use the FileReader object to read the worksheet in the configuration file; Convert the data format of the worksheet into a target format; Traverse each row of the worksheet in the target format through the parseXlsx function, and extract the target information related to the switch in each row; The configuration information is obtained based on the target information.

3. The configuration file processing method according to claim 2, characterized in that: The obtaining the configuration information based on the target information comprises: Performing deduplication processing on the target information; The configuration information is obtained based on the target information after deduplication processing.

4. The configuration file processing method according to claim 1, characterized in that: Generating a tag file based on the formatted tag content includes: Use the Document class to create a document object; Use the generateTableRowsForCenterSwitch function to generate table rows in the document object and set the cell style; The formatted label content is filled into the cell to obtain the label file.

5. The configuration file processing method according to claim 1, characterized in that: The configuration file processing method further includes: Associating the configuration file with the tag file to obtain an associated file; Convert the associated file into a Blob object; Use URL.createObjectURL to create a download link pointing to the Blob object; Simulate clicking the download link to automatically download the associated file.

6. The configuration file processing method according to claim 1, characterized in that: The configuration file processing method further includes: The tag file is stored in association with the version of the configuration file.

7. The configuration file processing method according to claim 1, characterized in that: The configuration file processing method further includes: Obtain the file type of the configuration file; Determining whether the file type is a preset file type; When the file type is the preset file type, performing the parsing based on the configuration file to obtain configuration information; When the file type is not the preset file type, a preset prompt message is displayed.

8. A configuration file processing device, characterized in that: The configuration file processing device comprises: The acquisition module is used to obtain the configuration file of the switch; A parsing module, used to parse the configuration file to obtain configuration information; A storage module, used for storing the configuration information in a target array, each element of the target array is an object containing the configuration information; A traversal module, used for traversing each element in the target array and generating corresponding label content based on the traversed elements; A processing module, used for formatting the label content; The generation module is used to generate a label file based on the formatted label content.

9. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the configuration file processing method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the configuration file processing method according to any one of claims 1 to 7 are implemented.