Method and system for accessing multi-protocol ammeters to same address of master station
By reconstructing the TCP connection between the Netty server and the electricity meter device and the dynamic processor pipeline, the system can identify and adapt to electricity meters with multiple protocols, solving the configuration complexity problem of electricity meters accessing the same master station and improving the system's flexibility and compatibility.
Patent Information
- Application Number
- CN202511801299.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-02
- Publication Date
- 2026-02-06
AI Technical Summary
When multiple types of electricity meters are connected to the same master station, the configuration process is cumbersome and inefficient, affecting the accuracy of data collection and system compatibility.
A Netty server is used to establish a TCP connection with the electricity meter device. The protocol detection processor identifies the communication protocol of the electricity meter device and dynamically reconstructs the processor pipeline, adding the corresponding processor chain for data parsing and business processing.
It enables intelligent adaptation of multiple protocol meters under the same master station address, simplifies the configuration process, improves system compatibility and maintenance efficiency, and optimizes resource utilization.
Smart Images

Figure CN121486475A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of metering equipment technology, specifically to a method and system for connecting multiple protocol electricity meters to the same address of a master station. Background Technology
[0002] In the field of electricity metering, diverse communication protocols coexist, including DLMS, G376.1, and proprietary protocols from various manufacturers. This leads to significant obstacles in data interaction between meters and the master station. Due to protocol differences, different meters need to connect to different address ports on the master station for protocol parsing to achieve data acquisition and command issuance. When meters using multiple protocols need to be connected to the same master station, the configuration process becomes extremely cumbersome and inefficient. The master station needs to configure the communication address, port number, and protocol parameters separately for each type of meter, which not only increases the complexity of system maintenance but also easily leads to configuration errors, thus affecting the accuracy and real-time performance of data acquisition. Furthermore, protocol differences can also cause compatibility issues between the master station and the meters, further exacerbating the difficulty of system integration.
[0003] Therefore, simplifying the configuration process for connecting multiple protocol meters to the same master station and improving system compatibility and maintenance efficiency has become an urgent problem to be solved in the field of power metering. Summary of the Invention
[0004] The technical problem to be solved by this invention is to provide a method and system for connecting multiple protocol electricity meters to the same address of the master station, which can simplify system configuration, optimize and integrate resources, and improve system compatibility and maintenance efficiency.
[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0006] Methods for connecting multiple types of electricity meters to the same address of the main station include:
[0007] After the meter device establishes a TCP connection with the Netty server, the Netty server initializes a corresponding processor pipeline and adds a protocol detection processor at the beginning of it.
[0008] After the processor pipeline receives the first packet of data sent by the corresponding electricity meter device, it uses its protocol detection processor to snoop on the first few bytes of the first packet of data to perform communication protocol matching.
[0009] After successfully identifying the communication protocol of the electricity meter device, the protocol detection processor will dynamically reconstruct the pipeline: first remove itself, then add a dedicated processor chain for the identified communication protocol, the processor chain including a protocol decoder and a service processor, and then pass the first packet data to the processor chain.
[0010] Optionally, the step of using its protocol detection processor to snoop on the first few bytes of the first packet data to perform communication protocol matching includes:
[0011] The protocol detection processor uses protocol detection logic methods to examine the first few bytes of the first packet data and initiates a multi-level matching mechanism:
[0012] First, perform a first-level feature header matching on the first few bytes; if it matches a suspected protocol, then perform a second-level payload parsing on the bytes following the first few bytes according to the complete format of the suspected protocol; if the parsing result matches the complete format of the suspected protocol, then the suspected protocol is determined to be the communication protocol of the electricity meter device.
[0013] Optionally, the step of using its protocol detection processor to snoop on the first few bytes of the first packet data to perform communication protocol matching further includes:
[0014] Upon successful matching of the first-level feature header, a multi-level verification mechanism is simultaneously initiated:
[0015] First, a first-level rapid verification is performed on the integrity and legality of the first packet data. If the verification fails, the communication protocol matching is determined to be unsuccessful. If the verification passes, the second-level load parsing in the multi-level matching mechanism is waited for to pass, and then a second-level complete verification is performed on the structure and semantics of the first packet data according to the suspected protocol. If the verification passes, the suspected protocol is determined to be the communication protocol of the electricity meter device.
[0016] Optionally, the fast verification of the first level in the multi-level verification mechanism includes fixed-position verification and calculation of the first packet data, and / or length field verification calculation.
[0017] Optionally, it also includes:
[0018] During the communication protocol matching process of the processor pipeline, the first packet data and its parsed data are temporarily stored in a temporary buffer, and after the processor chain is added, all the data in the temporary buffer is transferred to the processor chain.
[0019] Optionally, it also includes:
[0020] The processor receives data from the meter device after the first packet of data.
[0021] The processor chain first uses its protocol decoder to parse the received data according to the corresponding communication protocol; then it uses its service processor to perform corresponding service processing on the parsed data and generate a response frame according to the corresponding communication protocol.
[0022] Optionally, the processor pipeline incorporates a multi-protocol feature library;
[0023] The multi-protocol feature library includes metadata corresponding to each communication protocol; the metadata includes at least two of the following: magic number feature, keyword feature, byte sequence feature, length field position feature, and message start character feature.
[0024] Optionally, it also includes:
[0025] Configure a dedicated processor chain for the new communication protocol in the Netty server;
[0026] Configure the metadata corresponding to the newly added communication protocol in the built-in multi-protocol feature library of the processor pipeline.
[0027] Another technical solution provided by this invention is:
[0028] A system in which multiple types of electricity meters are connected to the same address of the master station includes electricity meter devices and a Netty server; the Netty server is configured with a processor pipeline, a protocol detection processor, and a processor chain dedicated to various communication protocols;
[0029] The electricity meter device is configured to perform the steps described above in the method for connecting multiple protocol electricity meters to the same address of the master station;
[0030] The Netty server is configured to perform the steps described above in the method of connecting multiple protocol electricity meters to the same address of the master station.
[0031] The processor pipeline is configured to execute the steps described above in the method for connecting multiple protocol electricity meters to the same address of the master station.
[0032] The protocol detection processor is configured to execute the steps described above in the method for connecting multiple protocol meters to the same address of the master station.
[0033] The dedicated processor chain is configured to execute the steps described above in the method for connecting multiple protocol electricity meters to the same address of the master station.
[0034] Optionally, the communication protocol of the meter device is one of DLMS, G376.1, COSEM, Modbus, IEC 62056 series standards, 645 protocol, and 698 protocol.
[0035] The beneficial effects of this invention are as follows: The method and system for connecting multiple protocol electricity meters to the same address of the master station provided by this invention utilizes "dynamic detection" and "pipeline reconstruction" technologies, which only require one master station address as a unified access point to intelligently adapt to the protocols of multiple heterogeneous electricity meter devices; it can simplify system configuration, significantly improve the system's flexibility, compatibility and maintenance efficiency, and achieve optimized resource integration. Attached Figure Description
[0036] Figure 1 A flowchart illustrating the method for connecting multiple protocol electricity meters to the same address of the master station according to an embodiment of the present invention;
[0037] Figure 2 A data interaction diagram illustrating a method for connecting multiple protocol electricity meters to the same address of a master station, provided as a specific embodiment of the present invention;
[0038] Figure 3 This is a flowchart illustrating the multi-level matching mechanism in a specific embodiment of the present invention;
[0039] Figure 4 This is a flowchart illustrating the multi-level matching mechanism combined with the multi-level verification mechanism in a specific embodiment of the present invention;
[0040] Figure 5 This is a schematic diagram of the structure of a system for connecting multiple protocol electricity meters to the same address of the master station, as provided in an embodiment of the present invention. Detailed Implementation
[0041] To explain in detail the technical principles, specific implementable solutions, possible application scenarios, and achievable objectives and effects of the present invention, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. It is understood that the embodiments described herein and the embodiments shown in the accompanying drawings are only used to more clearly illustrate the technical solutions of the present invention, and are therefore only examples intended to explain the present invention, and should not be construed as limiting the present invention. It should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.
[0042] Unlike existing technologies that require an extremely cumbersome and inefficient configuration process to support multiple protocol meters accessing the same master station, this invention utilizes "dynamic detection" and "pipeline reconstruction" technologies, which only require a single master station address as a unified access point to intelligently adapt to the protocols of various heterogeneous meter devices, thereby achieving optimized resource integration.
[0043] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0044] Explanation of technical terms involved in this invention:
[0045] (1) Channel, the network communication channel of the Netty server. One Channel corresponds to one network socket (such as TCP connection).
[0046] (2) Channel Pipeline is the dedicated event processing pipeline for each Channel in the Netty server. It maintains a doubly linked list internally, which consists of multiple Channel Handlers connected in sequence. It is responsible for transmitting and processing all events and data entering and leaving the Channel.
[0047] (3) Channel Handler: A typical Channel Pipeline contains two types of Handlers:
[0048] Inbound Handler: Handles inbound events (such as data reading, connection establishment, etc.); the corresponding inbound event processing flow is as follows: data arrives at the Channel from the network layer; it passes through all Inbound Handlers in the Pipeline in sequence, and each Handler can process the data (such as decoding, business logic); finally, it reaches the application layer.
[0049] Outbound Handler: Handles outbound events (such as data writing, connection closing, etc.); the corresponding outbound event handling process is as follows: the application layer initiates a write operation; the data starts from the end of the Pipeline and passes through all Outbound Handlers (such as encoding and encryption) in reverse order; finally, it is sent to the network through the Channel.
[0050] (4) ProtocolDetectorHandler is a processor in Netty used for protocol detection. It is called the protocol detection processor. Its main function is to identify the communication protocol used by the client connection (such as HTTP, gRPC, etc.) and dynamically configure the corresponding codec and request processor according to the detection results.
[0051] (5) ProtocolDetectorHandler.decode() is a core method inside the ProtocolDetectorHandler, namely the protocol detection logic method. It is specifically responsible for identifying the communication protocol (such as HTTP, gRPC, etc.) by checking the first few bytes of the connection without moving the read pointer, so as to determine the subsequent data processing logic of the entire connection.
[0052] Please see Figures 1 to 4 This invention provides a method for connecting multiple protocol-based electricity meters to the same address of a master station. For example... Figure 1As shown, and in combination Figure 2 To understand this, the method includes:
[0053] S1: The electricity meter device establishes a TCP connection with the Netty server.
[0054] Specifically, regardless of the communication protocol used (DLMS, G376.1, COSEM, Modbus, IEC 62056 series standards, 645 protocol, or 698 protocol, etc.), when a meter device needs to connect to the master station, it sends a SYN packet to a specified IP address and port of the Netty server to request the establishment of a TCP connection. The Netty server uses a non-blocking I / O model and efficiently processes the TCP connection requests initiated by the meter device through an event-driven mechanism. When the Netty server's operating system kernel receives the SYN packet and completes the three-way handshake, a complete TCP connection is established at the kernel level. At the same time, the operating system kernel also creates a core data structure for this TCP connection, namely a socket buffer, to store all information transmitted through the TCP connection, as well as all state information of the TCP connection. Subsequently, the Netty server will manage the raw byte stream sent by the corresponding meter device through this socket buffer (reading data for processing).
[0055] S2: The Netty server initializes a corresponding processor pipeline and adds a protocol detection processor at its beginning.
[0056] Specifically, after the Netty server successfully establishes a TCP connection with the electricity meter device, a network communication channel (Channel) will be created for the corresponding TCP connection; and a processor pipeline (ChannelPipeline) corresponding to the network communication channel (Channel) will be initialized; the processor pipeline (ChannelPipeline) contains multiple ordered ChannelHandlers, referred to as a Handler linked list.
[0057] Specifically, in this embodiment, the first Inbound Handler in the Handler chain, which is the starting position for processing inbound events, is configured as the ProtocolDetectorHandler, a processor for protocol detection.
[0058] The initialized processor pipeline ChannelPipeline is essentially an idle state detector used to monitor the connection activity of the corresponding network communication channel. Its core component is a protocol detector that uses protocol detection logic methods, capable of identifying the communication protocol of the corresponding electricity meter device based on the multi-protocol feature library built into the processor pipeline ChannelPipeline. The multi-protocol feature library includes metadata corresponding to each communication protocol (DLMS, G376.1, COSEM, Modbus, IEC 62056 series standards, 645 protocol, or 698 protocol, etc.); the metadata includes at least two of the following: magic number features, keyword features, byte sequence features, length field position features, and message start character features.
[0059] At this point, the Netty server only creates a corresponding processor pipeline for probing the communication protocol for each meter device that establishes a TCP connection with it, without enabling any business processors.
[0060] S3: The processor pipeline identifies the communication protocol based on the first packet data from the electricity meter device.
[0061] After successfully establishing a TCP connection with the Netty server, the electricity meter can begin data transmission. Specifically, the first data packet sent by the electricity meter (containing a heartbeat / login message) will enter the Netty server's kernel level through its dedicated network communication channel. After detecting the first data packet, the dedicated processor pipeline of this network communication channel will use its protocol detection processor to snoop on the first few bytes of the first data packet to perform communication protocol matching.
[0062] It is understandable that the format of the first data packet sent by the electricity meter is determined by the communication protocol used by the meter. The format of the first data packet varies significantly depending on the communication protocol used. For example, the first data packet sent by an electricity meter using the G376.1 protocol conforms to the characteristics of the G376.1 protocol (starting and ending with hexadecimal 68, and other features). The dedicated processor pipeline (ChannelPipeline) configured for each electricity meter identifies the communication protocol used by detecting the first data packet.
[0063] In some specific embodiments of this example, the process of the processor pipeline (ChannelPipeline) receiving the first packet of data sent by the meter device specifically includes:
[0064] S31: Data packets sent by the meter device arrive at the network communication channel specially created for it through the unified port of the master station;
[0065] S32: After the data packet enters the ChannelPipeline corresponding to the network communication channel, it arrives at the first Inbound Handler in the Handler chain, which is the ProtocolDetectorHandler added at the beginning, for corresponding processing. That is, it performs communication protocol matching by observing the first few bytes of the first packet data.
[0066] In some specific implementations of this embodiment, the processor pipeline ChannelPipeline performs communication protocol matching by detecting the first few bytes of the first packet data spied on by the processor, specifically including:
[0067] S33: ProtocolDetectorHandler, located at the beginning of the ChannelPipeline, uses the ProtocolDetectorHandler.decode() method to snoop on the first few raw bytes of the received first packet data.
[0068] S34: Initiate multi-level matching mechanism:
[0069] like Figure 3 As shown, it specifically includes the following two levels of matching:
[0070] (1) First-level feature head matching (fast filtering)
[0071] Action: The ProtocolDetectorHandler only examines the first few bytes (e.g., the first 4 / 8 or 20 bytes) of the initial packet data, performing header matching on these bytes based on the multi-protocol feature library built into the processor pipeline, ChannelPipeline. If a match is found with a suspected protocol X, the process proceeds to the second level of payload parsing; otherwise, no known features are matched, the TCP connection is closed or default processing is performed. It can be understood that the first few bytes of the initial packet data typically contain header features such as the communication protocol's "signature" or "magic number."
[0072] As a specific example, if the first three bytes read from the first packet data are 0xE6, 0xE7, and 0x00, then these three bytes precisely match the most typical feature of the DLMS protocol—the Logical Link Control (LLC) field “E6E7 00”; the detector can quickly determine that the first packet data matches the DLMS protocol.
[0073] If the first byte read from the first packet of data is 0x68, it precisely matches the start-of-frame character specified by the G376.1 protocol; the detector can quickly determine that the first packet of data matches the G376.1 protocol.
[0074] The first-level feature head matching described above enables extremely fast and negative exclusion; it features high speed (only requires reading and comparing a small amount of data, CPU cache friendly) and low cost (even if there is a false positive, the overall overhead is very small because the inspection speed is fast).
[0075] (2) Load analysis of the second stage (precise judgment)
[0076] Triggering condition: When the first packet of data passes the first-level feature header matching and is identified as "suspected" of a certain communication protocol X;
[0077] Action: The ProtocolDetectorHandler attempts to parse more data packet content (payload) according to the complete format of the suspected protocol; if the parsing result matches the complete format of the suspected protocol, then the suspected protocol X is determined to be the communication protocol of the meter device corresponding to the first packet of data.
[0078] As a specific example, for the first packet of data suspected to be "DLMS protocol", the ProtocolDetectorHandler will try to parse the first packet of data using a DLMS decoder. If the parsing is successful, the first packet of data is determined to be DLMS protocol; if the parsing fails, the TCP connection is closed or the default processing is performed.
[0079] For the first packet of data that is suspected to be "G376.1 protocol", the ProtocolDetectorHandler will attempt to parse the first packet of data using the G376.1 decoder. If the parsing is successful, the first packet of data is confirmed to be G376.1 protocol; if the parsing fails, the TCP connection will be closed or the default processing will be performed.
[0080] The second-level load analysis described above enables precise and definitive confirmation, exhibiting high accuracy.
[0081] The above-described implementation method addresses the question of "what protocol this data packet might use" through a multi-level matching mechanism. Starting with the fastest method and progressing to the slowest, it first uses a very low-cost approach to quickly filter out most mismatches, then performs more precise, in-depth analysis only on the "potentially matching" data.
[0082] In other specific embodiments of this example, based on the previous specific embodiment, during the communication protocol matching process of the processor pipeline (ChannelPipeline), such as Figure 4 As shown, it also includes:
[0083] S35: When the first-level feature head matching is successful, a multi-level verification mechanism is started simultaneously:
[0084] (1) First-level quick verification (integrity / rough legality check)
[0085] Triggering condition: When the first packet of data passes the first level of feature header matching in the multi-level matching mechanism and is identified as "suspected" of a certain communication protocol;
[0086] Action: The ProtocolDetectorHandler quickly checks the integrity and validity of the first packet data by determining some fixed and easily calculated checksums (such as "checksum" and "length field verification") in the first packet data. If the check fails, the communication protocol matching is determined to be unsuccessful, and the TCP connection is closed or default processing is performed. If the check passes, it waits for the second level of the multi-level matching mechanism to pass the payload parsing before entering the second level of complete verification.
[0087] Objective: To quickly determine whether any obvious errors occurred in the first packet of data during transmission, and to meet the conditions for further processing.
[0088] As a concrete example, the first-level fast verification is performed on the first packet of data using a checksum algorithm:
[0089] Calculate a checksum within a fixed range in the header of the first data packet (such as CRC8 in the header) and compare it with the checksum included in the packet. If they do not match, it means that the data is corrupted and can be discarded immediately.
[0090] As another concrete example, the first-level fast validation is performed using the "length field validation" algorithm on the initial packet data:
[0091] Parse the "payload length" field of the message in the first packet data and check if "ByteBuf.readableBytes()" is greater than or equal to "header length + payload length". If not, it means that it is currently only a half packet and we need to wait for more data. The detector will then exit this detection.
[0092] The first-level fast verification described above can quickly verify the integrity and legitimacy of data packets; it has the characteristics of low computational load (verifying only local data).
[0093] (2) Second-level complete verification (structural / semantic validity check)
[0094] Triggering conditions: The first-level fast verification is passed, and the second-level payload parsing in the multi-level matching mechanism is passed (suspected protocol is identified).
[0095] Action: Thoroughly verify the structure and semantics of the entire first packet of data. Specifically, perform a complete verification of the structure and semantics of the first packet of data according to the suspected protocol (the identification result of the second-level load parsing in the multi-level matching mechanism). If the verification fails, it is determined that the communication protocol matching has failed, and the TCP connection is closed or default processing is performed. If the verification passes, it is determined that the suspected protocol identified by the second-level load parsing in the multi-level matching mechanism is the communication protocol of the corresponding electricity meter.
[0096] Objective: To ensure that the initial data packet fully complies with the corresponding protocol specifications, and to prevent malicious or malformed data packets from entering the business system of the Netty server.
[0097] As a specific example, consider the first packet of data whose "suspected protocol" is DLMS. First, the detector will perform a structural verification:
[0098] The system checks if there are enough bytes in the receive buffer. Since DLMS frames typically begin with a specific start byte (e.g., 0x0F) followed by a length field, if the buffer is insufficient, the detector reads the length field (e.g., 2 bytes) from the first packet to calculate the length (L) of the entire APDU frame. It then waits until at least L bytes have accumulated in the receive buffer, ensuring a complete application layer data frame is in place. This step resolves the TCP packet fragmentation / reassembly issue.
[0099] Secondly, after confirming the frame is complete, the detector begins parsing byte by byte to perform semantic verification:
[0100] During parsing, the detector checks each Protocol Data Unit (APDU) tag to ensure it matches the expected position and value of the "suspected protocol" specification. This is because the structure of DLMS APDUs is strictly defined. For example, an AARQ message must follow a specific tag sequence. Here, by verifying the semantic correctness of the first packet's data, it ensures that the data is not a randomly ordered packet.
[0101] For the first packet of data that is "suspected to be" G376.1 protocol, the detector will first perform structural verification:
[0102] Check if there are enough bytes in the receive buffer. Specifically, search for a fixed start character (0x68) in the byte stream of the buffer. Once found, determine the end position of this frame in the byte field (L) and check if that byte is "0x16". If so, it confirms that a complete application layer data frame (data packet) has arrived.
[0103] Secondly, after confirming the frame is complete, the detector performs a "checksum" verification:
[0104] The detector extracts the received checksum from the complete data packet in the buffer; simultaneously, it recalculates the checksum of the data packets within the complete data packet (usually all data after length L and before the checksum) according to the algorithm specified by the "suspected protocol" (usually CRC16 or arithmetic sum); then it compares the calculated checksum with the received checksum; if they match, the verification passes, and the suspected protocol identified by the load parsing in the second level of the multi-level matching mechanism is determined to be the communication protocol of the corresponding electricity meter; if they do not match, the verification fails, the TCP connection is closed, or default processing is performed.
[0105] Through the complete verification at the second level mentioned above, the integrity and legality of the first packet data can be verified in a deep and accurate manner; it has the characteristics of depth (requiring inspection of the entire first packet data) and high security.
[0106] The above-described implementation method addresses the question of "Is this data packet complete and valid?" through a multi-level verification mechanism. It proceeds from simple to complex, first verifying simple, local constraints. If even simple conditions are not met, there is no need for complex global verification.
[0107] Specifically, the ProtocolDetectorHandler in this embodiment employs a parallel and interleaved approach of "multi-level matching mechanism" and "multi-level verification mechanism" to accurately and efficiently identify the communication protocol based on the first packet data sent by the meter device. It features high performance and high reliability, and can optimize performance to the maximum extent (avoiding deep parsing of all data packets) while ensuring accuracy and system security.
[0108] S4: After the ProtocolDetectorHandler successfully identifies the communication protocol of the electricity meter using the ProtocolDetectorHandler.decode() logic method, it performs dynamic pipeline reconstruction:
[0109] First, remove itself from the processor pipeline ChannelPipeline (remove the ProtocolDetectorHandler);
[0110] Secondly, a complete processor chain corresponding to the identified communication protocol is dynamically added; wherein, the processor chain includes the protocol decoder (such as G3761Decoder corresponding to "G376.1 protocol") and the business processor (such as G3761 BusinessHandler corresponding to "G376.1 protocol") corresponding to the identified communication protocol; as a specific example, in the protocol detection logic method ProtocolDetectorHandler.decode(), "pipeline.addLast()" and "pipeline.remove(this)" can be safely called to dynamically reconstruct the processor chain.
[0111] Finally, the first packet of data is passed to the processor chain for decoding and service processing.
[0112] In this step, the processor chain corresponding to the identified communication protocol is configured by dynamically reconfiguring the processor pipeline (ChannelPipeline). This not only achieves protocol adaptation (automatically identifying and loading the corresponding processor at runtime, realizing "intelligent wiring"), improving the system's flexibility, scalability, and resource utilization efficiency (the pipeline only contains the processors actually needed for the current connection, avoiding unnecessary processor overhead), but also ensures the continuity of data processing.
[0113] S5: The processor chain processes business data packets sent from the electricity meter device.
[0114] Specifically, after dynamic reconstruction, the dedicated processor pipeline (ChannelPipeline) for the electricity meter is configured with a processor chain corresponding to the communication protocol of the electricity meter. Subsequently, upon monitoring data packets sent by the corresponding electricity meter, the dedicated processor pipeline (ChannelPipeline) will directly hand them over to its processor chain for corresponding business data processing.
[0115] The processor chain receives data from the corresponding electricity meter device after the first packet of data; the processor chain first uses its protocol decoder to parse the received data according to the corresponding communication protocol; then it uses its service processor to perform corresponding service processing on the parsed data and generate a response frame according to the corresponding communication protocol.
[0116] As a specific example, after the processor receives the data packet sent by the meter device using the G376.1 protocol, it combines the data of the first packet received earlier, first uses the G3761Decoder to decode (unpack, verify, convert, etc.), and then uses the G3761 BusinessHandler to perform the corresponding business logic processing (meter reading, parameter configuration, etc.) to generate a response frame and return it to the meter device.
[0117] In this embodiment, during the communication protocol matching process of the processor pipeline ChannelPipeline, the first packet data and its parsed data are temporarily stored in a temporary buffer, and after the processor chain is added, all the data in the temporary buffer is transferred to the processor chain.
[0118] Here, not only is thread safety ensured during processor switching through memory barrier technology, but the state preservation mechanism based on temporary buffers can also effectively prevent data loss.
[0119] In particular, the method for connecting multiple protocol meters to the same address of the master station provided in this embodiment can also be dynamically expanded to easily support new protocols.
[0120] Specifically, the method for connecting multiple protocol meters to the same address of the master station in this embodiment further includes:
[0121] When there is a need for a new protocol extension, a dedicated processor chain for the new communication protocol is configured in the Netty server; and the metadata corresponding to the new communication protocol is configured in the built-in multi-protocol feature library of the processor pipeline.
[0122] In other words, it only requires adding the processor chain for the new protocol (supporting the processing of the new protocol) and the new protocol features (supporting the identification of the new protocol). This does not affect the processing of existing protocols, nor does it require a complex and inefficient configuration process. Therefore, this embodiment also has the flexibility to support the dynamic expansion of new protocols.
[0123] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a system for connecting multiple protocol electricity meters to the same address of the master station, as provided in an embodiment of the present invention.
[0124] This embodiment further extends any of the above embodiments to provide a system for connecting multiple protocol-based electricity meters to the same address of the master station. For example... Figure 5 As shown, the system includes:
[0125] The system includes a multi-protocol electricity meter device and a Netty server; the Netty server is configured with a processor pipeline, a protocol detection processor, and a dedicated processor chain for various communication protocols; the processor pipeline has a built-in multi-protocol feature library. Furthermore, the system is also configured with a temporary buffer (not shown in the figure) to temporarily store the initial packet data and its parsed data during the communication protocol matching process in the processor pipeline.
[0126] The electricity meter device is configured to perform the steps in the method for multiple protocol electricity meters to access the same address of the master station as described in any of the above embodiments.
[0127] The Netty server is configured to perform the steps in the method for connecting multiple protocol electricity meters to the same address of the master station as described in any of the above embodiments.
[0128] The processor pipeline is configured to execute the steps described in any of the above embodiments of the method for connecting multiple protocol electricity meters to the same address of the master station.
[0129] The protocol detection processor is configured to execute the steps in the method for connecting multiple protocol meters to the same address of the master station in any of the above embodiments.
[0130] The dedicated processor chain is configured to execute the steps in the method for connecting multiple protocol meters to the same address of the master station as described in any of the above embodiments.
[0131] The specific steps will not be described in detail here; please refer to the description in the above embodiments for more information.
[0132] In a specific application scenario, firstly, all meter devices with different protocols are configured with the same master station connection address to prepare for connecting all meters with different protocols to the master station system. Next, files are created for all meter devices, and the meters are installed. During this process, users can create meter asset files through the user management interface, filling in necessary information (such as device signal, meter reading method, etc.); on-site implementation personnel install the meter devices according to the meter design and installation requirements until they are in the designated positions. Then, the meter devices connect to the master station system via SIM cards, ensuring a stable network connection. Specifically, all meter devices with different protocols will establish connections with the master station system using the method described in the above embodiment for connecting multiple protocol meter devices to the same master station address. Finally, users can view and manage meter devices with different protocols through the system's front-end interface.
[0133] In summary, the method and system for connecting multiple protocol-compliant electricity meters to the same master station address provided by this invention allow electricity meter devices from different manufacturers and using different protocols to share the same master station port. It has at least the following advantages:
[0134] (i) Strong protocol adaptability;
[0135] (1) Dynamic detection: There is no need to pre-configure various meter device protocol types. During operation, it can automatically identify (supports mixed protocol scenarios such as DLMS and G376.1) and load the corresponding processor chain to achieve "intelligent access".
[0136] (2) Easy to expand: New protocols can be easily supported by simply adding the corresponding processor chain and new protocol features, without modifying the core logic (in accordance with the open / closed principle).
[0137] (II) High-performance processing
[0138] (1) Zero duplicate detection: Protocol identification is triggered only during the first connection. Subsequent data is directly processed by the corresponding processor chain, avoiding continuous parsing overhead.
[0139] (2) Resource optimization: By dynamically removing the ProtocolDetectorHandler, the pipeline is ensured to contain only the processors actually needed for the current connection, reducing redundant components in the pipeline and avoiding unnecessary processor overhead.
[0140] (3) Dynamic decoupling: Protocol identification, protocol processing and business logic are separated from each other, which is more conducive to system maintenance and management.
[0141] It should be noted that any reference signs placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0142] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0143] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0144] In the description of this invention, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0145] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0146] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.
[0147] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms should not be construed as necessarily referring to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0148] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for connecting multiple protocol electricity meters to the same address of a master station, characterized in that, include: After the meter device establishes a TCP connection with the Netty server, the Netty server initializes a corresponding processor pipeline and adds a protocol detection processor at the beginning of it. After the processor pipeline receives the first packet of data sent by the corresponding electricity meter device, it uses its protocol detection processor to snoop on the first few bytes of the first packet of data to perform communication protocol matching. After successfully identifying the communication protocol of the electricity meter device, the protocol detection processor will dynamically reconstruct the pipeline: first remove itself, then add a dedicated processor chain for the identified communication protocol, the processor chain including a protocol decoder and a service processor, and then pass the first packet data to the processor chain.
2. The method for connecting multiple protocol meters to the same address of the master station as described in claim 1, characterized in that, The method of using its protocol detection processor to snoop on the first few bytes of the first packet data to perform communication protocol matching includes: The protocol detection processor uses protocol detection logic methods to examine the first few bytes of the first packet data and initiates a multi-level matching mechanism: First, perform a first-level feature header matching on the first few bytes; if it matches a suspected protocol, then perform a second-level payload parsing on the bytes following the first few bytes according to the complete format of the suspected protocol; if the parsing result matches the complete format of the suspected protocol, then the suspected protocol is determined to be the communication protocol of the electricity meter device.
3. The method for connecting multiple protocol meters to the same address of the master station as described in claim 2, characterized in that, The method of using its protocol detection processor to snoop on the first few bytes of the first packet data to perform communication protocol matching also includes: Upon successful matching of the first-level feature header, a multi-level verification mechanism is simultaneously initiated: First, a first-level rapid verification is performed on the integrity and legality of the first packet data. If the verification fails, the communication protocol matching is determined to be unsuccessful. If the verification passes, the second-level load parsing in the multi-level matching mechanism is waited for to pass, and then a second-level complete verification is performed on the structure and semantics of the first packet data according to the suspected protocol. If the verification passes, the suspected protocol is determined to be the communication protocol of the meter device.
4. The method for connecting multiple protocol meters to the same address of the master station as described in claim 3, characterized in that, The first level of the multi-level verification mechanism, fast verification, includes fixed-position verification and calculation of the first packet data, and / or length field verification calculation.
5. The method for connecting multiple protocol meters to the same address of the master station as described in claim 1, characterized in that, Also includes: During the communication protocol matching process of the processor pipeline, the first packet data and its parsed data are temporarily stored in a temporary buffer, and after the processor chain is added, all the data in the temporary buffer is transferred to the processor chain.
6. The method for connecting multiple protocol meters to the same address of the master station as described in claim 1, characterized in that, Also includes: The processor receives data from the meter device after the first packet of data. The processor chain first uses its protocol decoder to parse the received data according to the corresponding communication protocol; then it uses its service processor to perform corresponding service processing on the parsed data and generate a response frame according to the corresponding communication protocol.
7. The method for connecting multiple protocol meters to the same address of the master station as described in claim 1, characterized in that, The processor pipeline incorporates a multi-protocol feature library; The multi-protocol feature library includes metadata corresponding to each communication protocol; the metadata includes at least two of the following: magic number feature, keyword feature, byte sequence feature, length field position feature, and message start character feature.
8. The method for connecting multiple protocol meters to the same address of the master station as described in claim 7, characterized in that, Also includes: Configure a dedicated processor chain for the new communication protocol in the Netty server; Configure the metadata corresponding to the newly added communication protocol in the built-in multi-protocol feature library of the processor pipeline.
9. A system in which multiple types of electricity meters are connected to the same address of the master station, characterized in that, It includes electricity meter equipment and a Netty server; the Netty server is configured with a processor pipeline, a protocol detection processor, and a processor chain dedicated to various communication protocols; The electricity meter device is configured to perform the steps in the method for multiple protocol electricity meters to access the same address of the master station as described in any one of claims 1 to 8; The Netty server is configured to perform the steps in the method for connecting multiple protocol electricity meters to the same address of the master station as described in any one of claims 1 to 8; The processor pipeline is configured to perform the steps described in any one of claims 1 to 8 of the above-mentioned method for connecting multiple protocol electricity meters to the same address of the master station. The protocol detection processor is configured to perform the following steps in the method for connecting multiple protocol meters to the same address of the master station as described in any one of claims 1 to 8; The dedicated processor chain is configured to execute the steps in the method for connecting multiple protocol meters to the same address of the master station as described in any one of claims 1 to 8.
10. The system for connecting multiple protocol meters to the same address of the master station as described in claim 9, characterized in that, The communication protocol of the electricity meter device is one of DLMS, G376.1, COSEM, Modbus, IEC 62056 series standards, 645 protocol, and 698 protocol.
Citation Information
Cited By
Secure element for metrology-type terminals, metrology system
CN122316637A
Secure element for metrology-type terminals, metrology system
CN122316637B