Gateway configuration method, device, and storage medium
Patent Information
- Application Number
- CN202611240272.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-17
- Publication Date
- 2026-09-22
AI Technical Summary
[0005]但是,二进制块要使用专用的工具进行解析和修改,其增加或修改一个参数可能引起整个数据结构变动,产生版本兼容性问题,在索引时依赖顺序遍历,当配置数据众多时,查找特定参数效率较低
在本实施例中,在电力系统的边缘网关中,第一通信端口接入电力系统的边缘集群连接、第二通信端口同时接入电力系统的监控平台及电力系统的多台电力终端,多台电力终端均接入监控平台;在上位机中,依据多台电力设备遵循异构的电力通讯规约对边缘网关构建层级结构的配置文件;在上位机中,依据配置文件的层级结构将配置文件编译为映像数据;在边缘网关中,从上位机获取映像数据时,加载映像数据,注册映像数据;在边缘网关中,若接收到应用程序的查询请求,则依据配置文件的层级结构读取映像数据中的目标参数,将目标参数发送至应用程序。配置文件结构清晰,具有自描述性,显著降低了配置参数的理解难度和人工操作错误率,提升了开发、调试和现场运维的效率;配置文件的层级结构易于拓展,新增配置项并不要求改变整体架构,提高了产品迭代中的兼容性;配置文件的层级结构便于内存映射与地址计算,可快速访问参数,提升了边缘网关运行时的性能;配置文件与底层存储实现分离,使得上位机配置工具与边缘网关的固件可以独立演进,同时也便于与其他系统进行数据交换;清晰的配置文件及其高效的访问机制减少了配置错误和运行时故障的概率,在整体上增强了边缘网关的运行稳定性。
Smart Images

Figure CN122802359A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of electric power, and in particular relates to a gateway configuration method, device and storage medium. Background Technology
[0002] In new power automation systems, the edge gateway acts as a hub, responsible for data communication with the upper-layer edge cluster and the lower-end smart power terminals.
[0003] The configuration of an edge gateway involves a large number of parameters, such as serial port channel parameters, network port channel parameters, communication protocol parameters, and data point tables (such as remote signaling, telemetry, and remote control).
[0004] Currently, this configuration data is typically stored and interacted with in the device as custom binary blocks.
[0005] However, binary blocks require specialized tools for parsing and modification. Adding or modifying a single parameter can alter the entire data structure, leading to version compatibility issues. Indexing relies on sequential traversal, which is inefficient when searching for specific parameters when there is a large amount of configuration data. Summary of the Invention
[0006] In view of this, the present invention provides a gateway configuration method, device and storage medium to improve the efficiency of configuring edge gateway parameters for power systems.
[0007] The first aspect of the present invention provides a gateway configuration method. In an edge gateway of a power system, a first communication port is connected to an edge cluster connection of the power system, and a second communication port is simultaneously connected to a monitoring platform of the power system and multiple power terminals of the power system. All of the multiple power terminals are connected to the monitoring platform. The method includes: In the host computer, a hierarchical configuration file is built for the edge gateway based on the heterogeneous power communication protocols of the multiple power devices. In the host computer, the configuration file is compiled into image data according to its hierarchical structure. In the edge gateway, when the image data is obtained from the host computer, the image data is loaded and the image data is registered. In the edge gateway, if a query request is received from an application, the target parameters in the image data are read according to the hierarchical structure of the configuration file, and the target parameters are sent to the application.
[0008] A second aspect of the present invention provides a gateway configuration system, the system comprising an edge gateway of a power system and a host computer, wherein a first communication port of the edge gateway is connected to the edge cluster connection of the power system, and a second communication port is simultaneously connected to the monitoring platform of the power system and multiple power terminals of the power system, and the multiple power terminals are all connected to the monitoring platform; The host computer is used to construct a hierarchical configuration file for the edge gateway based on the heterogeneous power communication protocols followed by the multiple power devices. The host computer is also used to compile the configuration file into image data according to the hierarchical structure of the configuration file; The edge gateway is used to load the image data and register the image data when it obtains the image data from the host computer. The edge gateway is also configured to, upon receiving a query request from an application, read the target parameters from the image data according to the hierarchical structure of the configuration file, and send the target parameters to the application.
[0009] A third aspect of the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the gateway configuration method as described in the first aspect above.
[0010] A fourth aspect of the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the gateway configuration method as described in the first aspect above.
[0011] A fifth aspect of the present invention provides a computer program product that, when run on a computer, causes the computer to execute the gateway configuration method as described in the first aspect above.
[0012] Compared with the prior art, the embodiments of the present invention have the following beneficial effects: In this embodiment, in the edge gateway of the power system, the first communication port is connected to the edge cluster connection of the power system, and the second communication port is simultaneously connected to the monitoring platform of the power system and multiple power terminals of the power system, all of which are connected to the monitoring platform. In the host computer, a hierarchical configuration file is constructed for the edge gateway according to the heterogeneous power communication protocol of multiple power devices. In the host computer, the configuration file is compiled into image data according to the hierarchical structure of the configuration file. In the edge gateway, when obtaining image data from the host computer, the image data is loaded and registered. In the edge gateway, if a query request from the application is received, the target parameters in the image data are read according to the hierarchical structure of the configuration file and sent to the application. The configuration file has a clear structure and is self-descriptive, significantly reducing the difficulty of understanding configuration parameters and the error rate of manual operation, thus improving the efficiency of development, debugging, and on-site operation and maintenance. The hierarchical structure of the configuration file is easy to extend; adding new configuration items does not require changes to the overall architecture, improving compatibility during product iteration. The hierarchical structure of the configuration file facilitates memory mapping and address calculation, enabling fast access to parameters and improving the performance of the edge gateway during runtime. The separation of the configuration file from the underlying storage implementation allows the host computer configuration tool and the edge gateway firmware to evolve independently, while also facilitating data exchange with other systems. The clear configuration file and its efficient access mechanism reduce the probability of configuration errors and runtime failures, enhancing the overall operational stability of the edge gateway. Attached Figure Description
[0013] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 This is a schematic diagram of a gateway configuration method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the multi-type edge gateway provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a configuration file provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an image file provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of a gateway configuration system provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0015] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of the present invention. However, those skilled in the art will recognize that the present application may be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted to avoid unnecessary detail that could obscure the description of the present application.
[0016] The technical solution of the present invention will be illustrated below through specific embodiments.
[0017] Reference Figure 1 The diagram illustrates a gateway configuration method provided by an embodiment of the present invention, which may specifically include the following steps: Step 101: In the host computer, construct a configuration file for the hierarchical structure of the edge gateway based on the heterogeneous power communication protocols of multiple power devices.
[0018] The edge gateway of the power system is a type of gateway device deployed at substations, distribution substations / transformer areas / towers, grid connection points of emerging market players such as distributed new energy sources, etc. It is responsible for collecting local power grid operation data, uploading it to the edge cluster, and realizing the switching of power grid operation mode, frequency regulation / peak regulation and other command operations. It has edge computing and cloud-edge collaborative application functions to support dispatching operation and market operation.
[0019] like Figure 2 As shown, edge gateways are classified into Type I, Type II, and Type III edge gateways based on their application scenarios and functional performance differences.
[0020] One type of edge gateway is implemented by an intelligent remote control unit, which directly connects to the OCS (Operation Control System) master station in various locations and can be applied to substations.
[0021] The Type II edge gateway has AC / DC analog quantity measurement and digital quantity input / output functions. It supports access to the distribution network OCS master station and edge cluster, realizes local electrical quantity acquisition box command processing, and supports local edge computing functions. It can be applied to distribution substations / transformer areas / towers, distributed new energy, energy storage, electric vehicle charging facilities and other occasions.
[0022] The three-type edge gateway collects data from the monitoring system (local or platform) of the access object, connects to the edge cluster, realizes the forwarding of data and commands, and supports local edge computing functions. That is, in the edge gateway of the power system, the first communication port is connected to the edge cluster of the power system, and the second communication port is connected to the monitoring platform of the power system and multiple power terminals of the power system (such as DTU (Data Transfer Unit), inverters, environmental monitoring sensors, etc.). Multiple power terminals are connected to the monitoring platform, which can be applied to integrated energy parks, virtual power plants and other occasions.
[0023] For the three types of edge gateways, power terminals often adopt heterogeneous power communication protocols, that is, multiple power communication protocols coexist, such as IEC 101, IEC 104, Modbus, IEC 61850, etc. IEC 104 identifies information points with digital data (such as ASDU type ID, information object address), while IEC 61850 identifies information points with string references (such as "UT811PROT_811 / GGIO1STAlm01"), and the data expression methods are significantly different.
[0024] In this embodiment, technicians can deploy personal computers or other electronic devices as host computers. Based on actual boundary conditions, the host computer can construct a hierarchical configuration file for the edge gateway according to the heterogeneous power communication protocols of the multiple power devices connected to the edge gateway.
[0025] In practical implementation, configuration files can define parameters hierarchically, such as... Figure 3 As shown, the configuration file includes a root node, which corresponds to the entire gateway device. The cluster_type identifies the configuration type and defines the gateway's model, version, hardware network card, serial port, and other basic resource parameters, corresponding to the overall configuration header (CfgHeader).
[0026] The root node's child nodes include channel nodes representing physical communication interfaces (such as serial ports, network ports, etc.) and power communication protocols. Here, clust_type is the channel ID, and different communication protocols correspond to different channel nodes, which are used for application layer registration.
[0027] The child nodes of a channel node include at least one of the following: The basic channel node describes the common parameters of the power communication protocol (i.e., protocol common parameters, such as protocol type, protocol version, timeout time, etc.), the link node describes the custom parameters of the power communication protocol (i.e., application custom structures, such as baud rate, data bits, etc.), the northbound forwarding table node represents the power information monitoring table used to send to the edge cluster, the service node describes the service parameters (such as sampling period, call period, etc.) when forwarding the power information monitoring table, and the device node of the power terminal (i.e. device).
[0028] The child nodes of a device node include at least one of the following: The parameter node describes the equipment parameters of the power equipment, and represents the southbound acquisition table node that originates from the power information monitoring table of the power equipment.
[0029] Each node is a DataCluster structure, carrying a cluster_type field to distinguish the service type, corresponding to the power communication service entity (such as channel, power equipment, service, four telemeters, etc.). It supports nested sub-dataClusters, and the child_type field distinguishes the format of the sub-nodes, realizing modular and self-descriptive organization of configuration.
[0030] In the configuration file, the basic configuration item ItemUnit is the smallest configuration unit, and its parent node is the data cluster DataCluster, which is used to describe common type parameters such as integer, floating-point number, string, and boolean. Each basic configuration item ItemUnit carries an explicit item identifier item_id to ensure version compatibility.
[0031] The power information monitoring table includes at least one of the following: remote signaling (YX), remote measurement (YC), remote control (YK), remote adjustment (YT), electricity consumption (DD), and set value (DZ).
[0032] The power information monitoring tables corresponding to the northbound forwarding nodes all contain the global information point identifier info_id_glb, as well as the modulo field, field transformation coefficient, and dead zone field. The modulo field, field transformation coefficient, and dead zone field are used for power telemetry value transformation and dead zone filtering.
[0033] The power information monitoring tables corresponding to the southbound acquisition table nodes all have multiple parameter slots (such as param1~6) that are common to heterogeneous power communication protocols. These multiple parameter slots are used to store parameters that conform to heterogeneous power communication protocols.
[0034] For example, for IEC 104 power equipment, parameter slots can use digital data storage ASDU (Application Service Data Unit) type and information object address, while for IEC 61850 power equipment, parameter slots can use string object reference (such as "UT811PROT_811 / GGIO1STAlm01 / stVal"). The data_type field of ItemUnit covers the data types of power information monitoring. For example, numeric types (DTYPE_SINT8~DTYPE_FLOAT) are adapted to IEC 104 information body values, string types (DTYPE_STRING) are adapted to IEC 61850 object reference names, structure types (DTYPE_STRUCT_USER) are adapted to complex information point descriptions, and so on.
[0035] The configuration file can adopt a segmented independent storage mechanism (identified by standalong_flag), which supports storing large configuration nodes (such as devices containing hundreds of information points) as separate files, avoiding excessively large single files and improving the flexibility of on-site configuration.
[0036] Typically, the configuration file set consists of a global index file and multiple business configuration files, supporting independent modification of single files and incremental updates.
[0037] For example, if the configuration file uses JSON format, it includes the following set of files: index.json5 is a global configuration index file that records the names and MD5 checksums of all business configuration files, enabling file chunk management and incremental updates, and avoiding full downloads every time.
[0038] cfg_device.json5 is the device's basic configuration file, corresponding to the CFG_TYPE_PROJECT_BASE type, which contains global parameters such as project information, network card configuration, and internal telemetry data.
[0039] comm0.json5 / comm1.json5 are serial port channel configuration files, corresponding to the CFG_TYPE_CHANN_SERIAL type. There is one file for each serial port, which carries the link parameters, protocol parameters and acquisition and forwarding configuration of the serial port channel.
[0040] socket0.json5 / socket1.json5 are the network interface channel configuration files, corresponding to the CFG_TYPE_CHANN_ETHER type. There is one file for each network interface, containing the link parameters, protocol parameters, and data collection and forwarding configurations for the network interface channel. Step 102: In the host computer, compile the configuration file into image data according to the hierarchical structure of the configuration file.
[0041] In the host computer, the configuration file is compiled according to its hierarchical structure and mapped into binary image data in local memory.
[0042] In the specific implementation, the image data includes configuration header data compiled for the configuration file, and DataCluster compiled for each node in the configuration file.
[0043] During the compilation process, the Rust compiler (pack.rs / lib_config.rs) is called to parse the input configuration file and verify its validity and completeness.
[0044] The FFI calls the C language configuration engine (CfgBase / CfgApp) to recursively build the memory image by following the tree structure of the configuration file.
[0045] For each node in the configuration file, taking the current node as the data cluster, the CfgClustInitia() interface is called to initialize the cluster head data. A channel node is a complete tree structure, and each of its child nodes executes the CfgClustInitia() interface to allocate cluster head memory space. Figure 4 As shown, the CfgAddBase32() and CfgAddBaseFloat() interfaces are called to write parameters of fixed length in the current node into the first data buffer (i.e., fixed-length data buffer). The CfgAddFlexiUnMarkString() interface is called to write parameters of variable length in the current node into the second data buffer (i.e., variable-length data buffer), and the third relative offset of the parameter in the second data buffer corresponding to the current data cluster is recorded.
[0046] After recursively constructing all sub-clusters, CfgClustSave() is called to save the current cluster data. The cluster head data and parameters of fixed length in the current node are written to the first data buffer (i.e., fixed-length data buffer), and parameters of variable length in the current node are written to the second data buffer (i.e., variable-length data buffer). The first and second relative offsets of the current data cluster in its parent node's data cluster are backfilled. At the same time, the statistical information of the parent node is updated, such as the number of sub-data clusters, the total number of bytes in the first data buffer of the parent data cluster, the total number of bytes in the second data buffer of the parent data cluster, the first checksum crc_item of the first data buffer, and the second checksum crc_flexi of the second data buffer.
[0047] When CfgClustSave() is called, the parent node's data cluster manages the write positions of both the first and second data buffers simultaneously, ensuring that child nodes are arranged adjacently in their respective buffers without gaps, thus providing a data foundation for subsequent addressing strategies.
[0048] Therefore, the image file adopts a continuous linear layout of configuration header CfgHeader and multiple data clusters. Each data cluster uses a two-level storage scheme of first data buffer and second data buffer, which helps to solve the management problem of variable configuration item length.
[0049] The first data buffer stores cluster head data, ItemUnit arrays, and custom structure tables. The data length is fixed, and it can be directly indexed by sequence number without pointers, making it CPU cache friendly.
[0050] The second data buffer stores strings and dynamic data in a compact manner according to their actual length, referenced by offsets, with zero memory fragmentation.
[0051] The overall layout is a contiguous memory block, with configuration header data, cluster header data, index items, and variable-length data arranged sequentially. It can be used after a single load, with no dynamic memory allocation overhead.
[0052] Furthermore, the cluster header data of each node corresponding to the DataCluster includes at least one of the following: The cluster's business type, clust_type, is used to match hierarchical paths; The index item_count within this data cluster represents the number of child nodes; When acting as a parent node, the first relative offset item_offset of the starting address of the first data buffer corresponding to the child node relative to the starting address of the first data buffer corresponding to the parent node; When acting as a parent node, the second relative offset val_flexi_offset of the starting address of the second data buffer corresponding to the child node relative to the starting address of the second data buffer corresponding to the parent node; The first checksum crc_item of the first data buffer protects the integrity of the first data buffer.
[0053] The second checksum crc_flexi of the second data buffer protects the integrity of the second data buffer.
[0054] In the first data buffer, each ItemUnit is fixed at 8 bytes, with the structure item_id (2 bytes), reserve (1 byte), data_type (1 byte), and val (4 bytes), and can be directly indexed by sequence number.
[0055] If the parameter is a fixed-length value such as an integer, floating-point, or boolean, the value is directly stored in the val field.
[0056] If the parameter is a variable-length data such as a string, the val field stores the third relative offset of the parameter in the second data buffer corresponding to this data cluster. It will be backfilled after the second data buffer is filled. That is, the third relative offset of the parameter with a fixed length in each node, including the parameter with a variable length in each node, is located in the second data buffer corresponding to the current node.
[0057] Custom structures such as four-way tables are stored sequentially into the first data buffer according to the table entries, maintaining memory contiguousness and ensuring efficient batch traversal.
[0058] In the second data buffer, all string type data (such as IEC 61850 object references, device names, and SCD file names) within this data cluster are collected and concatenated in order of actual length, without memory fragmentation; at the same time, the starting offset of each string is recorded and backfilled into the val field of the corresponding ItemUnit.
[0059] To address the storage requirements of string references with varying lengths in power communication protocols such as 61850, this embodiment utilizes indirect references via offsets, achieving both compact storage and fast access.
[0060] Step 103: In the edge gateway, when obtaining image data from the host computer, load the image data and register the image data.
[0061] The edge gateway downloads image data (such as .stru and .flex files) to its local memory through communication interfaces such as Ethernet and serial ports. The download process relies on the index.json5 verification mechanism and file fragment management capabilities to achieve incremental updates. That is, modified configuration files are recompiled and downloaded, eliminating the need to download all configurations in full each time, thus improving on-site operation and maintenance efficiency.
[0062] When the network management device powers on and starts up, it performs the image data loading operation. It supports segmented loading and does not require parsing the full configuration at once, making it suitable for resource-constrained embedded devices.
[0063] In the specific implementation, the loading operation of the image data is started by calling interfaces such as AppExtractConfig(). The CfgLoadClustEnter() and CfgLoadClustExit() interfaces are called layer by layer to traverse the data clusters of each node in the image data. When entering the data cluster of a child node, the first relative offset and the second relative offset corresponding to the data cluster of the parent node are accumulated respectively to obtain the first base address of the first data buffer and the second base address of the second data buffer corresponding to each node.
[0064] For each node in the image data, the first data buffer is loaded through interfaces such as CfgLoadChildStruct() and the second data buffer is loaded through interfaces such as CfgLoadChildFlexi().
[0065] During the loading process, for each node in the image data, the first checksum crc_item of the first data buffer and the second checksum crc_flexi of the second data buffer are determined.
[0066] The first data buffer is verified based on the first checksum crc_item, and the second data buffer is verified based on the second checksum crc_flexi.
[0067] If a DataCluster fails to verify, the location of the fault can be accurately pinpointed without affecting the normal loading of other DataClusters.
[0068] In this embodiment, image data can be registered when initializing the application layer.
[0069] In a practical implementation, the root node of the image data can be used to initialize hardware resources, such as physical interfaces like network cards and serial ports.
[0070] In the root node, a protocol number is agreed upon with the host computer in advance. Based on the protocol number, multiple idle queues are created and initialized during initialization for subsequent channel registration and resource allocation.
[0071] When loading a single channel configuration, channel resource registration is completed by leveraging the compactness and predefined nature of the memory layout.
[0072] Specifically, the data clusters corresponding to the channel nodes are read from the image data.
[0073] Write the data cluster to the queue that is in an idle state, switch the queue state from idle to occupied, and complete the channel registration.
[0074] Because the memory is configured as a contiguous, predefined structure, the process mainly involves calculating the addresses of data clusters and copying them to memory, without dynamic memory allocation, resulting in high efficiency.
[0075] After the channel registration is completed, continue loading the next level of data clusters to complete the specification instance initialization.
[0076] Extract sub-data clusters from the queue, and construct instances of the data clusters corresponding to the southbound acquisition table nodes and the data clusters corresponding to the northbound acquisition table nodes in the queue. Complete the initialization of forwarding rules and data processing logic (such as single and double points, merging points, logical operations, etc.) to form a complete closed loop for power remote acquisition and forwarding.
[0077] Step 104: In the edge gateway, if a query request from an application is received, the target parameters in the image data are read according to the hierarchical structure of the configuration file, and the target parameters are sent to the application.
[0078] During the operation of the edge gateway, if it receives a query request from an application, it reads the parameter item to be queried from the query request, reads the target parameter corresponding to the parameter item in the image data according to the hierarchical structure of the configuration file, and sends the target parameter to the application.
[0079] In the specific implementation, the target parameter can be quickly indexed and accessed based on the parameter offset. The memory address can be directly calculated through its base address and multi-level offset, so as to achieve fast access to the parameter with constant time complexity (O (1)). The first data buffer generated by the host computer has a built-in index number. When the device runs, the final storage location of the parameter can be directly calculated through the index number.
[0080] In one scenario, if the parameter item to be queried in the query request belongs to a parameter of fixed length, then the first relative offsets corresponding to each data cluster are added together sequentially to obtain the first base address of the data cluster to which the parameter item belongs.
[0081] The first data buffer of the data cluster to which the parameter item belongs is located based on the first base address, and the first memory address of the entry unit is calculated in the first data buffer according to the index number of the parameter item.
[0082] Read the value located at the first memory address (such as the val field in ItemUnit) to obtain the target parameter.
[0083] In this case, the address of the target parameter can be represented as: parent_absolute_offset_item + DataCluster.item_offset + item_index × sizeof(ItemUnit), where parent_absolute_offset_item is the first relative offset of the data cluster of the parent node of the current node in the first data buffer. The first relative offset of the data cluster of the parent node is accumulated for each layer of child nodes entered, and the first relative offset of the data cluster of the parent node is subtracted for each layer of child nodes exited. DataCluster.item_offset is the first relative offset of the current data cluster relative to its parent node, and sizeof(ItemUnit) is the item number (the parameter item to be queried) in the current data cluster, which is located by compensating with 8 bytes (ItemUnit is fixed to 8 bytes).
[0084] In another scenario, if the parameter item to be queried in the query request belongs to a parameter of variable length, then the first relative offsets corresponding to each data cluster are added together sequentially to obtain the second base address of the data cluster to which the parameter item belongs.
[0085] The first data buffer of the data cluster to which the parameter item belongs is located based on the second base address, and the second memory address of the entry unit is calculated in the first data buffer according to the index number of the parameter item.
[0086] Read the value located at the first memory address to obtain the third relative offset corresponding to the parameter item.
[0087] By sequentially superimposing the second relative offsets corresponding to each data cluster, the second base address of the data cluster to which the parameter item belongs is obtained.
[0088] Add the second base address to the third relative offset to obtain the absolute address, and read the value located at the absolute address to obtain the target parameter.
[0089] In this case, the address of the target parameter can be represented as: parent_absolute_offset_flexi + DataCluster.val_flexi_offset + ItemUnit.val.val_offset, where parent_absolute_offset_flexi is the second relative offset of the data cluster of the parent node of the current node in the second data buffer. The second relative offset of the parent node's data cluster is accumulated for each layer of child nodes entered, and subtracted for each layer of child nodes exited. DataCluster.val_flexi_offset is the second relative offset of the current data cluster relative to its parent node, and ItemUnit.val.val_offset is the third relative offset of the target parameter in the current data cluster.
[0090] In an addressing example, if the difference item to be queried is item_id=3 (IED name, string type) in the device parameters of power equipment 1 under channel 0, then the path hierarchy is root (root node), CLUST_SERV (data cluster of channel 0), CLUST_DEV (data cluster of power equipment 1), CLUST_DEV_PARA_BASE (data cluster of device parameters), ItemUnit [2], string.
[0091] In the first layer, i.e., the data cluster from the root node to channel 0, update the first base address: parent_absolute_offset_item += clust_root.item_offset (e.g., +0x0038, i.e., the 56-byte cluster header), update the second base address: parent_absolute_offset_flexi += clust_root.val_flexi_offset, match clust_type == CLUST_SERV, successfully locate the channel 0 data cluster, and proceed to the next layer.
[0092] In the second layer, from the data cluster of channel 0 to the data cluster of power device 1, update the first base address: parent_absolute_offset_item += CLUST_SERV.item_offset (e.g., +0x0038, accumulated to 0x00F0), traverse the child nodes of the data cluster of channel 0, match the child node of the device type, and enter the next layer.
[0093] In the third layer, that is, from the data cluster of device 0 to the data cluster of device parameters, the first base address is updated: parent_absolute_offset_item += CLUST_DEV.item_offset (e.g., +0x0038, accumulated to 0x0128), which matches the data cluster of CLUST_DEV_PARA_BASE, and the path location is completed.
[0094] The target data cluster contains 3 ItemUnits, namely device address, device type, and IED name, with a total length of 3×8=24 bytes. The offset of the first data buffer is 0x0128+0 = 0x0128. 24 bytes are copied from cfg_buf_struct[0x0128] to the temporary buffer to obtain 3 ItemUnit entries.
[0095] The total length of the second data buffer corresponding to the target data cluster is 18 bytes (containing two strings). The starting offset of the target parameter is: parent_absolute_offset_flexi+0, and 18 bytes are copied from cfg_buf_flexi[corresponding offset].
[0096] Find the 3rd ItemUnit, read its val.val_offset (the third relative offset of the string within the data cluster), and the final address of the string is: cfg_buf_flexi + parent_absolute_offset_flexi + val_flexi_offset + offset within the ItemUnit. Return this address pointer to complete the O(1) addressing.
[0097] In this embodiment, in the edge gateway of the power system, the first communication port is connected to the edge cluster connection of the power system, and the second communication port is simultaneously connected to the monitoring platform of the power system and multiple power terminals of the power system, all of which are connected to the monitoring platform. In the host computer, a hierarchical configuration file is constructed for the edge gateway according to the heterogeneous power communication protocol of multiple power devices. In the host computer, the configuration file is compiled into image data according to the hierarchical structure of the configuration file. In the edge gateway, when obtaining image data from the host computer, the image data is loaded and registered. In the edge gateway, if a query request from the application is received, the target parameters in the image data are read according to the hierarchical structure of the configuration file and sent to the application. The configuration file has a clear structure and is self-descriptive, significantly reducing the difficulty of understanding configuration parameters and the error rate of manual operation, thus improving the efficiency of development, debugging, and on-site operation and maintenance. The hierarchical structure of the configuration file is easy to extend; adding new configuration items does not require changes to the overall architecture, improving compatibility during product iteration. The hierarchical structure of the configuration file facilitates memory mapping and address calculation, enabling fast access to parameters and improving the performance of the edge gateway during runtime. The separation of the configuration file from the underlying storage implementation allows the host computer configuration tool and the edge gateway firmware to evolve independently, while also facilitating data exchange with other systems. The clear configuration file and its efficient access mechanism reduce the probability of configuration errors and runtime failures, enhancing the overall operational stability of the edge gateway.
[0098] It should be noted that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0099] Reference Figure 5 The diagram shows a gateway configuration system provided by an embodiment of the present invention. The system includes an edge gateway 510 of a power system and a host computer 520. In the edge gateway 510, a first communication port is connected to the edge cluster connection of the power system, and a second communication port is simultaneously connected to the monitoring platform of the power system and multiple power terminals of the power system. All of the multiple power terminals are connected to the monitoring platform. The host computer 520 is used to construct a hierarchical configuration file for the edge gateway based on the heterogeneous power communication protocols followed by the multiple power devices. The host computer 520 is also used to compile the configuration file into image data according to the hierarchical structure of the configuration file; The edge gateway 510 is used to load the image data and register the image data when it obtains the image data from the host computer. The edge gateway 510 is further configured to, upon receiving a query request from an application, read the target parameters in the image data according to the hierarchical structure of the configuration file, and send the target parameters to the application.
[0100] In one embodiment of the present invention, the configuration file includes a root node; The root node's child nodes include channel nodes representing physical communication interfaces and power communication protocols; The child nodes of the channel node include at least one of the following: The document describes the channel base node for the common parameters of the power communication protocol, the link node for the custom parameters of the power communication protocol, the northbound forwarding table node for sending the power information monitoring table to the edge cluster, the service node for describing the service parameters when forwarding the power information monitoring table, and the device node of the power terminal. The child nodes of the device node include at least one of the following: The parameter node describing the equipment parameters of the power equipment represents the southbound acquisition table node originating from the power information monitoring table of the power equipment.
[0101] In one embodiment of the present invention, the power information monitoring table includes at least one of remote signaling, remote measurement, remote control, remote adjustment, electricity consumption, and set value; The power information monitoring table corresponding to the northbound forwarding table node includes a global information point identifier, as well as a digital field, a field transformation coefficient, and a dead zone field. The digital field, the field transformation coefficient, and the dead zone field are used for power telemetry value transformation and dead zone filtering. The power information monitoring table corresponding to the southbound acquisition table node has multiple parameter slots that are common to heterogeneous power communication protocols. These multiple parameter slots are used to store parameters that conform to heterogeneous power communication protocols.
[0102] In one embodiment of the present invention, the image data includes configuration header data compiled for the configuration file, and data clusters compiled for each node in the configuration file; the edge gateway 510 is further configured to: For each node in the configuration file, with the current node as the data cluster, initialize the cluster head data, write the cluster head data and parameters of fixed length in the current node into the first data buffer, and write parameters of variable length in the current node into the second data buffer. The cluster head data corresponding to each node includes at least one of the following: When acting as a parent node, the first relative offset of the starting address of the first data buffer corresponding to the child node relative to the starting address of the first data buffer corresponding to the parent node; When acting as a parent node, the second relative offset of the starting address of the second data buffer corresponding to the child node relative to the starting address of the second data buffer corresponding to the parent node; The first checksum of the first data buffer; The second checksum of the second data buffer; The parameters with a fixed length within each node include the parameters with a variable length within each node, and the third relative offset of the second data buffer corresponding to the current node.
[0103] In one embodiment of the present invention, the edge gateway 510 is further configured to: The system iterates through each node in the image data. When entering the data cluster of a child node, it accumulates the first relative offset and the second relative offset corresponding to the data cluster of the parent node to obtain the first base address of the first data buffer and the second base address of the second data buffer corresponding to each node. For each node in the image data, the first data buffer and the second data buffer are loaded respectively; For each node in the image data, determine the first checksum of the first data buffer and the second checksum of the second data buffer; The first data buffer is verified based on the first check code, and the second data buffer is verified based on the second check code.
[0104] In one embodiment of the present invention, the edge gateway 510 is further configured to: Initialize hardware resources using the root node of the image data; Initialize multiple queues; Read the data clusters corresponding to the channel nodes from the image data; Write the data cluster into a queue that is currently idle, and then switch the queue from idle to occupied. The queue contains data cluster construction instances corresponding to the southbound acquisition table node and the data cluster corresponding to the northbound acquisition table node, respectively.
[0105] In one embodiment of the present invention, the edge gateway 510 is further configured to: If the parameter item to be queried in the query request belongs to a parameter with a fixed length, then the first relative offset corresponding to each data cluster is added in sequence to obtain the first base address of the data cluster to which the parameter item belongs; Based on the first base address, locate the first data buffer of the data cluster to which the parameter item belongs, and calculate the first memory address of the entry unit in the first data buffer according to the index number of the parameter item; Read the value located at the first memory address to obtain the target parameter.
[0106] In one embodiment of the present invention, the edge gateway 510 is further configured to: If the parameter item to be queried in the query request belongs to a parameter with a variable length, then the first relative offset corresponding to each data cluster is added in sequence to obtain the second base address of the data cluster to which the parameter item belongs. Based on the second base address, locate the first data buffer of the data cluster to which the parameter item belongs, and calculate the second memory address of the entry unit in the first data buffer according to the index number of the parameter item; Read the value located at the first memory address to obtain the third relative offset corresponding to the parameter item; By sequentially superimposing the second relative offsets corresponding to each data cluster, the second base address of the data cluster to which the parameter item belongs is obtained; Add the second base address to the third relative offset to obtain the absolute address; Read the value located at the absolute address to obtain the target parameter.
[0107] The present invention provides a gateway configuration system, which can be used to implement the steps in the aforementioned gateway configuration method embodiments.
[0108] It should be noted that the module division in the various gateway configuration systems provided in the above embodiments is illustrative and only represents one logical functional division. In actual implementation, other division methods may also be used. Furthermore, the functional modules in the various embodiments of this invention can be integrated into a single processor, exist as separate physical entities, or be integrated into a single module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0109] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the technical solution of the embodiments of the present invention can be embodied in the form of a computer program product, which is stored in a computer storage medium and includes several instructions to cause an electronic device or processor to execute all or part of the steps of the methods in the various embodiments of the present invention. The aforementioned computer storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0110] Furthermore, the gateway configuration system and gateway configuration method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0111] Reference Figure 6 The diagram illustrates an electronic device according to an embodiment of the present invention. Figure 6 As shown, the electronic device in this embodiment of the invention includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the above-described gateway configuration method embodiment. Alternatively, when the processor executes the computer program, it implements the functions of each module in the above-described gateway configuration system embodiment.
[0112] For example, the computer program may be divided into one or more modules, which are stored in the memory and executed by the processor to complete this application. The one or more modules may be a series of computer program instruction segments capable of performing a specific function, which can be used to describe the execution process of the computer program in the electronic device.
[0113] The electronic device may be a desktop computer, a cloud server, or other computing device. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that... Figure 6 This is merely one example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0114] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0115] The memory can be an internal storage unit of the electronic device, such as a hard drive or RAM. Alternatively, it can be an external storage device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. Furthermore, the memory can include both internal and external storage units. The memory is used to store the computer program and other programs and data required by the electronic device. The memory can also be used to temporarily store data that has been output or will be output.
[0116] This invention also discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the gateway configuration method as described in the foregoing embodiments.
[0117] This invention also discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the gateway configuration method as described in the foregoing embodiments.
[0118] This invention also discloses a computer program product that, when run on a computer, causes the computer to execute the gateway configuration method described in the foregoing embodiments.
[0119] The embodiments described above are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A gateway configuration method, characterized in that, In the edge gateway of the power system, a first communication port is connected to the edge cluster connection of the power system, and a second communication port is simultaneously connected to the monitoring platform of the power system and multiple power terminals of the power system. All of the multiple power terminals are connected to the monitoring platform. The method includes: In the host computer, a hierarchical configuration file is built for the edge gateway based on the heterogeneous power communication protocols of the multiple power devices. In the host computer, the configuration file is compiled into image data according to its hierarchical structure. In the edge gateway, when the image data is obtained from the host computer, the image data is loaded and the image data is registered. In the edge gateway, if a query request is received from an application, the target parameters in the image data are read according to the hierarchical structure of the configuration file, and the target parameters are sent to the application.
2. The method according to claim 1, characterized in that, The configuration file includes a root node; The root node's child nodes include channel nodes representing physical communication interfaces and power communication protocols; The child nodes of the channel node include at least one of the following: The document describes the channel base node for the common parameters of the power communication protocol, the link node for the custom parameters of the power communication protocol, the northbound forwarding table node for sending the power information monitoring table to the edge cluster, the service node for describing the service parameters when forwarding the power information monitoring table, and the device node of the power terminal. The child nodes of the device node include at least one of the following: The parameter node describing the equipment parameters of the power equipment represents the southbound acquisition table node originating from the power information monitoring table of the power equipment.
3. The method according to claim 2, characterized in that, The power information monitoring table includes at least one of the following: remote signaling, remote measurement, remote control, remote adjustment, electricity consumption, and set value. The power information monitoring table corresponding to the northbound forwarding table node includes a global information point identifier, as well as a digital field, a field transformation coefficient, and a dead zone field. The digital field, the field transformation coefficient, and the dead zone field are used for power telemetry value transformation and dead zone filtering. The power information monitoring table corresponding to the southbound acquisition table node has multiple parameter slots that are common to heterogeneous power communication protocols. These multiple parameter slots are used to store parameters that conform to the heterogeneous power communication protocols.
4. The method according to claim 1, characterized in that, The image data includes configuration header data compiled for the configuration file, and data clusters compiled for each node in the configuration file; the step of compiling the configuration file into image data according to the hierarchical structure of the configuration file includes: For each node in the configuration file, with the current node as the data cluster, initialize the cluster head data, write the cluster head data and parameters of fixed length in the current node into the first data buffer, and write parameters of variable length in the current node into the second data buffer. The cluster head data corresponding to each node includes at least one of the following: When acting as a parent node, the first relative offset of the starting address of the first data buffer corresponding to the child node relative to the starting address of the first data buffer corresponding to the parent node; When acting as a parent node, the second relative offset of the starting address of the second data buffer corresponding to the child node relative to the starting address of the second data buffer corresponding to the parent node; The first checksum of the first data buffer; The second checksum of the second data buffer; The parameters with a fixed length within each node include the parameters with a variable length within each node, and the third relative offset of the second data buffer corresponding to the current node.
5. The method according to claim 1, characterized in that, Loading the image data includes: The system iterates through each node in the image data. When entering the data cluster of a child node, it accumulates the first relative offset and the second relative offset corresponding to the data cluster of the parent node to obtain the first base address of the first data buffer and the second base address of the second data buffer corresponding to each node. For each node in the image data, the first data buffer and the second data buffer are loaded respectively; For each node in the image data, determine the first checksum of the first data buffer and the second checksum of the second data buffer; The first data buffer is verified based on the first check code, and the second data buffer is verified based on the second check code.
6. The method according to claim 1, characterized in that, The registration of the image data includes: Initialize hardware resources using the root node of the image data; Initialize multiple queues; Read the data clusters corresponding to the channel nodes from the image data; Write the data cluster into a queue that is currently idle, and then switch the queue from idle to occupied. The queue contains data cluster construction instances corresponding to the southbound acquisition table node and the data cluster corresponding to the northbound acquisition table node, respectively.
7. The method according to any one of claims 1-6, characterized in that, The step of reading the target parameters from the image data in local memory according to the hierarchical structure of the configuration file includes: If the parameter item to be queried in the query request belongs to a parameter with a fixed length, then the first relative offset corresponding to each data cluster is added in sequence to obtain the first base address of the data cluster to which the parameter item belongs; Based on the first base address, locate the first data buffer of the data cluster to which the parameter item belongs, and calculate the first memory address of the entry unit in the first data buffer according to the index number of the parameter item; Read the value located at the first memory address to obtain the target parameter.
8. The method according to any one of claims 1-6, characterized in that, The step of reading the target parameters from the image data in local memory according to the hierarchical structure of the configuration file includes: If the parameter item to be queried in the query request belongs to a parameter with a variable length, then the first relative offset corresponding to each data cluster is added in sequence to obtain the second base address of the data cluster to which the parameter item belongs. Based on the second base address, locate the first data buffer of the data cluster to which the parameter item belongs, and calculate the second memory address of the entry unit in the first data buffer according to the index number of the parameter item; Read the value located at the first memory address to obtain the third relative offset corresponding to the parameter item; By sequentially superimposing the second relative offsets corresponding to each data cluster, the second base address of the data cluster to which the parameter item belongs is obtained; Add the second base address to the third relative offset to obtain the absolute address; Read the value located at the absolute address to obtain the target parameter.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the gateway configuration method as described in any one of claims 1-8.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the gateway configuration method as described in any one of claims 1-8.