A method and system for collecting electric meter data based on DLT698.45-2017 protocol
By adding the DL/T 698.45-2017 protocol to the dictionary table of the gateway, automatically generating meter query messages and adopting a multi-threaded processing architecture, the problem that the DL/T 698.45-2017 protocol meter data collection method is difficult to simultaneously meet the requirements of active collection and passive monitoring is solved, and flexible meter data collection and efficient data transmission are achieved.
Patent Information
- Application Number
- CN202510866943.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2045-06-26
AI Technical Summary
In the existing technology, the meter data collection method of the DL/T 698.45-2017 protocol lacks an efficient message generation and parsing mechanism, making it difficult to simultaneously meet the needs of active collection and passive monitoring. In addition, the configuration flexibility is insufficient and it cannot adapt to the diverse collection scenarios in complex power grid environments.
By adding the DL/T 698.45-2017 protocol to the dictionary table of the gateway machine, the meter query message is automatically generated, the meter data query is performed regularly, and the interactive data is monitored through the serial port and the transmitted data is parsed to realize active query and passive monitoring of the meter data. The multi-threaded processing architecture is used to improve data collection efficiency.
It realizes flexible switching of meter data collection modes, can actively query and passively monitor data, optimizes the message processing mechanism, ensures data transmission security, improves collection efficiency and accuracy, and reduces system resource consumption.
Smart Images

Figure CN120416295B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a meter data collection method and system based on the DLT698.45-2017 protocol, which is suitable for real-time collection and management of meter data in smart grids, power monitoring systems and new energy scenarios, and belongs to substation technology. Background Art
[0002] The DL / T698.45-2017 protocol is an important communication protocol standard for China's power industry. It was issued by the National Energy Administration on November 15, 2017, and officially implemented on March 1, 2018. It is mainly used to standardize data communication between master stations, data collection terminals and electricity meters in power systems, and to improve the data collection efficiency, security and interoperability of smart grids. The protocol adopts an object-oriented design concept, abstracting power equipment (such as electricity meters and concentrators) into logical devices, and realizing data interaction through interface objects (such as pre-connection objects and application connection objects). It has high scalability and flexibility, supports multi-device collaboration, and plays an important role in many scenarios such as smart grids and power monitoring systems. For example, it can realize real-time data exchange between grid equipment, load management, remote meter reading, fault monitoring, etc. In addition, in the fields of industry and energy, it can realize the collection and transmission of high-precision power parameters (such as voltage, current, and power). At the same time, it also occupies an important position in the metering and communication of photovoltaic systems, energy storage equipment, and charging piles, promoting the intelligent transformation of power systems. Its high-precision measurement capability (such as support for 6 decimal places of electricity) provides a technical foundation for electricity bill settlement and energy management. With the popularization of new energy and Internet of Things technologies, it has broad application prospects in the future.
[0003] However, the existing DL / T 698.45-2017 protocol is highly complex. Its message structure includes multiple nested fields, a dynamic-length data field, and strict security verification rules, making development operations less convenient and intuitive. For example, the header checksum (HCS) and frame checksum (FCS) in the protocol are used to ensure data integrity and correctness. The header checksum remains unchanged if the meter address and client address remain unchanged, while the frame checksum verifies the entire frame (excluding the start and end characters and the FCS itself). Furthermore, the message contains the APDU sequence number and priority flag PIID (for client use) or the APDU sequence number and priority flag PIID-ACD with the ACD flag (for meter use). The service sequence number is generally auto-incremental and needs to be processed separately when sending the message. When the PIID or PIID-ACD is changed, the frame checksum of the entire message must be recalculated. These factors make meter data collection based on this protocol somewhat inconvenient and challenging in practical applications, such as the difficulty in conveniently implementing active querying of meter data and data monitoring without sending a query message.
[0004] Therefore, in the existing technology, the meter data collection method for the DLT698.45-2017 protocol lacks an efficient message generation and parsing mechanism, making it difficult to simultaneously meet the needs of active collection and passive monitoring. In addition, the configuration flexibility is insufficient and it cannot adapt to the diverse collection scenarios in complex power grid environments. Summary of the Invention
[0005] Purpose of the invention: In order to overcome the shortcomings of the prior art, the present invention provides a meter data acquisition method and system based on the DLT698.45-2017 protocol, which can automatically generate meter query messages according to the configured meter data points and perform meter data queries at regular intervals; at the same time, it can also meet the requirements of meter data monitoring. Without sending query messages, the method monitors the interactive data through the serial port, parses the transmitted data, obtains the meter data and transmits it to the upstream platform.
[0006] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is:
[0007] A method for collecting meter data based on the DLT698.45-2017 protocol is provided. The method includes adding the DLT698.45-2017 protocol (actively and periodically framing to query meter data based on the meter data point configuration of the connected meter), the DLT698.45-2017 protocol meter monitoring mode (passively monitoring meter data only, not actively sending query messages), and the communication node configuration to the gateway dictionary table. The meter and the corresponding meter data point are configured in the gateway database. The meter configuration information includes the meter ID, meter name, communication node ID, meter address, and reading cycle. The meter data point configuration information includes the meter data point ID, meter data point name, and meter data point parameter information. The meter data point parameter information includes the object attribute OAD, point data sequence number, and data type. The method includes the following steps:
[0008] Step 1: Load the communication protocol and communication node configuration; use the communication node ID as the index to store the communication node configuration information in the cache; filter by the communication node ID, load all meters from the gateway database, and use the meter ID as the index to store the meter configuration information in the cache; use the communication node ID, meter address, and object attribute OAD as the index to create a data point mapping table in the cache to represent the mapping relationship of the meter data points;
[0009] Step 2: Use the communication node ID as the index to preset a fixed message sending queue for each serial port in the cache, and store all query messages that need to be sent under the corresponding serial port; add a timer for each serial port and preset a temporary serial port sending queue; preset a temporary serial port receiving buffer for each serial port in the cache, and store all monitoring messages received by the corresponding serial port;
[0010] Step 3. Create a serial port processing thread for each serial port, including regular read and write processes and fast read processes;
[0011] If the temporary sending buffer of the serial port is empty and there is a read signal on the serial port, a fast reading process is used to take out the monitoring messages one by one from the temporary receiving queue of the serial port, and the message parsing interface is called to parse the monitoring messages;
[0012] If the temporary send buffer of the serial port is not empty, the conventional read and write process is used to take out the query messages one by one from the temporary send buffer of the serial port, write the query messages to the serial port after setting, and wait for the serial port response within the timeout period. When the query response message is received, the framing and unpacking function is called to perform unpacking processing until the query response message is received or the timeout period is reached, and then the next query message is processed;
[0013] Step 4. Call the message parsing interface to parse the monitored message, obtain the message type after preliminary parsing, discard cross-platform messages, and further parse the query response message and the meter report message to obtain relevant information including the meter address, one or more object attributes OAD and the corresponding data value; compare with the data point mapping table, first obtain the point data number according to the meter address and object attribute OAD, then find the data value corresponding to the point data number from the data value, and finally update the data value corresponding to the meter data point.
[0014] Specifically, in Step 2, a fixed message sending queue for each serial port is preset in the cache with the communication node ID as the index, and all query messages that need to be sent under the corresponding serial port are stored; all meter data points of a certain meter under a certain serial port are grouped, and the message encapsulation interface is called to frame the query message for each group, and the reading cycle, retransmission flag is true, the last sending time is 0, the sendable flag is true, and the meter address are set, and the query message is appended to the fixed message sending queue.
[0015] Specifically, in Step 2, a timer is added to each serial port, and a temporary serial port sending queue is preset; for the serial port of the DLT698.45-2017 protocol, the timer is started. When the timer arrives, the fixed message sending queue of the serial port is traversed to determine whether there is a query message with a sendable flag set to true. The query message is calculated based on the last sending time, the reading cycle, and the current time. If the sendable flag is true and the current time - the last sending time >= the reading cycle, the query message is appended to the temporary serial port sending queue, and the sendable flag of the query message is set to false. For the serial port of the DLT698.45-2017 protocol meter monitoring mode, the timer is turned off.
[0016] Specifically, in Step 3, a PIID cache is added to the serial port processing thread to store the PIID value. The PIID value is one byte, bit 7 is the service priority, bit 6 is the request access ACD flag, and the lower six bits represent the service sequence number. Before writing the query message to the serial port, the PIID value of the query message is updated first, and then the check code FCS of the query message is recalculated. The specific process is: before writing the query message to the serial port, the PIID value in the PIID cache is used to replace the PIID value of the query message, and then the PIID value in the PIID cache performs a self-increment of the service sequence number. At the same time, the query message recalculates the check code FCS according to the replaced PIID value, and uses the recalculated check code FCS to replace the check code FCS of the query message. Finally, the query message with the updated PIID value and check code FCS is written to the serial port.
[0017] Specifically, in Step 3, the position of the PIID value of the query message is: the position of the starting character 0x68 of the query message + 10 + the length of the meter address.
[0018] Specifically, in Step 3, when a conventional read and write process is used, query messages are taken out one by one from the temporary sending buffer of the serial port, the sendable flag is set to true, and the last sending time is set to the current time, and finally the query message is written to the serial port.
[0019] An electric meter data acquisition system based on the DLT698.45-2017 protocol includes an initialization configuration module, a message processing interface development module, a communication configuration loading module, a fixed message sending queue, a serial port temporary sending queue, a serial port temporary receiving queue, a serial port processing thread module, and a data point value matching module; the initialization configuration module includes a communication protocol configuration unit, a communication node configuration unit, an electric meter, and a corresponding electric meter data point configuration unit;
[0020] The communication protocol configuration unit is used to add the DLT698.45-2017 protocol and the DLT698.45-2017 protocol meter monitoring mode in the gateway machine dictionary table;
[0021] The communication node configuration unit is used to add a communication node to the gateway machine dictionary table, and the configuration information of the communication node includes the communication node ID, communication node name, communication mode, communication protocol and communication parameters;
[0022] The electricity meter and the corresponding electricity meter data point configuration unit are used to configure the electricity meter and the corresponding electricity meter data point in the gateway machine database. The configuration information of the electricity meter includes the electricity meter ID, the electricity meter name, the communication node ID, the electricity meter address and the reading cycle. The configuration information of the electricity meter data point includes the electricity meter data point ID, the electricity meter data point name and the electricity meter data point parameter information. The electricity meter data point parameter information includes the object attribute OAD, the point data sequence number and the data type;
[0023] The message processing interface module includes a message encapsulation interface and a message parsing interface; the message encapsulation interface automatically generates a query message that complies with the DLT698.45-2017 protocol; if the query message is a request to read an object, the input parameter only needs to provide the meter address and object attribute OAD; if the query message is a request to read multiple objects, the input parameter needs to provide the meter address and object attribute OAD list of the relevant meter; the message parsing interface parses a single frame of monitoring message that complies with the DLT698.45-2017 protocol. After receiving the monitoring message, the message parsing interface first performs preliminary parsing to obtain the message type: if the message type is a cross-platform query message, it is discarded; if the message type is a query response message and a meter reporting message, it is further parsed to obtain relevant information including the meter address, one or more object attribute OADs and corresponding data values;
[0024] The communication configuration loading module stores the configuration information of the communication node into the cache using the communication node ID as the index; filters all the meters from the gateway database using the communication node ID, and stores the configuration information of the meters into the cache using the meter ID as the index; establishes a data point mapping table in the cache using the communication node ID, meter address, and object attribute OAD as the index to represent the mapping relationship of the meter data points;
[0025] The fixed message sending queue is preset in the cache with the communication node ID as the index, and stores all query messages that need to be sent under the corresponding serial port;
[0026] The temporary serial port sending queue is preset in the cache with the communication node ID as the index, and stores the query messages that need to be sent within the timing range;
[0027] The serial port temporary receiving queue is preset in the cache with the communication node ID as the index, and stores all monitoring messages received by the corresponding serial port;
[0028] The serial port processing thread module uses the serial port processing thread to process the query messages and monitoring messages in the fixed message sending queue, the serial port temporary sending queue and the serial port temporary receiving queue;
[0029] The data point value matching module parses the monitored message based on the message parsing interface to obtain relevant information including the meter address, one or more object attributes OAD and the corresponding data value; compares it with the data point mapping table, first obtains the point data sequence number according to the meter address and object attribute OAD, then finds the data value corresponding to the point data sequence number from the data value, and finally updates the data value corresponding to the meter data point.
[0030] Specifically, the serial port processing thread module adopts the following serial port processing thread execution process:
[0031] Create a serial port processing thread for each serial port, and repeatedly check whether the connection is successful in the serial port processing thread. If the connection is disconnected, reconnect the serial port until the connection is successful. Add a PIID cache in the serial port processing thread to store the PIID value. The PIID value is one byte, bit 7 is the service priority, bit 6 is the request access ACD flag, and the lower six bits represent the service sequence number. The serial port processing thread includes regular read and write processes and fast read processes.
[0032] If the temporary sending buffer of the serial port is empty, it is determined whether there is a read signal on the serial port: if not, it waits; if so, it uses a fast reading process to take out the monitoring messages one by one from the temporary receiving queue of the serial port, and calls the message parsing interface to parse the monitoring messages;
[0033] If the temporary send buffer of the serial port is not empty, the conventional read and write process is used to take out the query messages one by one from the temporary send buffer of the serial port, set the sendable flag to true, and set the last send time to the current time. Finally, the query message is written to the serial port and waits for the serial port response within the timeout period. When the query response message is received, the framing and unpacking function is called to perform unpacking processing until the query response message is received or the timeout period is reached, and then the next query message is processed;
[0034] Before writing the query message to the serial port, the PIID value of the query message is updated first, and then the check code FCS of the query message is recalculated. The specific process is: before writing the query message to the serial port, the PIID value in the PIID cache is used to replace the PIID value of the query message, and then the PIID value in the PIID cache performs a self-increment of the service sequence number. At the same time, the query message recalculates the check code FCS according to the replaced PIID value, and uses the recalculated check code FCS to replace the check code FCS of the query message. Finally, the query message with the updated PIID value and check code FCS is written to the serial port.
[0035] Specifically, the initialization configuration module also includes a meter model and model data point preset unit, the preset information of the meter model includes a model ID and a model name, and the preset information of the model data point includes a model data point ID, a model data point name, a model ID and model data point parameter information; in the meter and the corresponding meter data point configuration unit, the configuration information of the meter and the corresponding meter data point is inherited from the meter model and the corresponding model data point, the configuration information of the meter includes the meter ID, the meter name, the model ID, the communication node ID, the meter address and the reading cycle, and the configuration information of the meter data point includes the meter data point ID, the meter data point name, the model data point ID and the meter data point parameter information.
[0036] Beneficial effects: The meter data acquisition method and system based on the DLT698.45-2017 protocol provided by the present invention has the following advantages over the prior art: 1. It realizes flexible switching of data acquisition modes, which can not only actively and regularly query meter data, but also passively monitor data to meet the needs of multiple scenarios; 2. It optimizes the message processing mechanism, and groups and frames the data points according to the serial port and meter during initialization to avoid frequent framing and improve efficiency; 3. It creates PIID self-increment and recalculates the FCS check code to ensure data transmission security; 4. It adopts a multi-threaded processing architecture to create an independent processing thread for each serial port to improve data acquisition and transmission efficiency; 5. It adds a monitoring mode, and only needs to change the protocol configuration in configuration to realize meter data monitoring, without rewriting related programs and codes, and does not affect normal use. In summary, the present invention can effectively improve the efficiency and accuracy of meter data acquisition, reduce system resource consumption, ensure data integrity and security, and is of great significance to the construction and development of smart grids. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is the data collection flow chart;
[0038] Figure 2 A flowchart for creating a fixed message sending queue;
[0039] Figure 3 This is the execution process diagram of the serial port processing thread. DETAILED DESCRIPTION
[0040] The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0041] A meter data acquisition system based on the DLT698.45-2017 protocol includes an initialization configuration module, a message processing interface development module, a communication configuration loading module, a fixed message sending queue, a serial port temporary sending queue, a serial port temporary receiving queue, a serial port processing thread module, and a data point value matching module; the initialization configuration module includes a communication protocol configuration unit, a communication node configuration unit, an meter model and a model data point presetting unit, an meter, and a corresponding meter data point configuration unit.
[0042] The communication protocol configuration unit is used to add the DLT698.45-2017 protocol and the DLT698.45-2017 protocol meter monitoring mode in the gateway dictionary table; the communication node configuration unit is used to add the communication node in the gateway dictionary table; the meter model and model data point preset unit is used to configure the meter model and model data point in the gateway database; the meter and corresponding meter data point configuration unit is used to configure the meter and the corresponding meter data point in the gateway database; the message processing interface module includes a message encapsulation interface and a message parsing interface; the communication configuration loading module stores the configuration information of the communication node in the cache with the communication node ID as the index, filters by the communication node ID, loads all meters from the gateway database, stores the configuration information of the meter in the cache with the meter ID as the index, and stores the configuration information of the meter in the cache with the communication node ID, The attribute OAD is used as an index to establish a data point mapping table in the cache to characterize the mapping relationship of the meter data points; the fixed message sending queue is preset in the cache with the communication node ID as an index, and stores all query messages that need to be sent under the corresponding serial port; the serial port temporary sending queue is preset in the cache with the communication node ID as an index, and stores the query messages that need to be sent within the timing range; the serial port temporary receiving queue is preset in the cache with the communication node ID as an index, and stores all monitoring messages received by the corresponding serial port; the serial port processing thread module adopts the serial port processing thread to process the query messages and monitoring messages in the fixed message sending queue, the serial port temporary sending queue and the serial port temporary receiving queue; the data point value matching module updates the data value corresponding to the meter data point based on the relevant information including the meter address, object attribute OAD and corresponding data value obtained by parsing the monitoring message through the message parsing interface.
[0043] An implementation method for an electric meter data acquisition system based on the DLT698.45-2017 protocol is mainly divided into three parts: system initialization configuration, message processing interface development, and data acquisition process. The following describes the method in detail with reference to specific implementation steps.
[0044] Part 1: System initialization configuration
[0045] Step 1: Communication protocol expansion
[0046] Add two communication protocols, DLT698.45-2017 protocol and DLT698.45-2017 protocol meter monitoring mode, as shown in Table 1, to the gateway dictionary table.
[0047] Table 1 Communication protocol configuration
[0048] Dictionary code Dictionary item ID name describe protocoltype 27 DLT698.45-2017 Agreement protocoltype 28 DLT698.45-2017 protocol meter monitoring mode
[0049] The DLT698.45-2017 protocol actively and regularly frames and queries the meter data according to the meter data point configuration of the connected meter; the DLT698.45-2017 protocol meter monitoring mode only passively monitors the meter data and does not actively send query messages.
[0050] Step 2: Preset the meter model and model data points
[0051] Add the meter model and the corresponding model data point in the gateway database. The preset information of the meter model includes but is not limited to the model ID and model name. The preset information of the model data point includes but is not limited to the model data point ID, model data point name, model ID and model data point parameter information.
[0052] For the model data points corresponding to the electricity meter model, the model data point parameter information includes the object attribute OAD, point data sequence number, data type, data offset, conversion coefficient and number of decimal places retained; each object attribute OAD includes more than one point data, the point data are sorted, and the point data are stored in the object attribute OAD in the order of the point data sequence number.
[0053] For an object attribute OAD, there may be a case where the data type is Array or Structure. In this case, multiple point data will be stored in the object attribute OAD by position. When it is necessary to parse the value of a specific point data in the object attribute OAD, the position information of the point data needs to be provided, and the point data sequence number is used to indicate the position of the point data. The default value of the point data sequence number generally indicates the point data at the first position; if the data type is other, then only one point data is stored in the object attribute OAD, and the default value of the point data sequence number directly points to the unique point data; generally speaking, the default value of the point data sequence number is 0.
[0054] Step 3. Communication node configuration
[0055] Add a communication node to the gateway dictionary table. The configuration information of the communication node includes but is not limited to the communication node ID, communication node name, communication mode, communication protocol and communication parameters.
[0056] For electricity meters, set the communication mode to serial communication and the communication protocol to DLT698.45-2017 or DLT698.45-2017 in meter monitoring mode. Communication parameters include serial port name, baud rate, parity bit, data bits, stop bits, and flow control.
[0057] Step 4. Configure the meter and meter data points
[0058] Add the electricity meter and the corresponding electricity meter data point to the gateway database. The configuration information of the electricity meter and the corresponding electricity meter data point is inherited from the electricity meter model and the corresponding model data point. The configuration information of the electricity meter includes but is not limited to the electricity meter ID, electricity meter name, model ID, communication node ID, electricity meter address and reading cycle. The configuration information of the electricity meter data point includes but is not limited to the electricity meter data point ID, electricity meter data point name, model data point ID and electricity meter data point parameter information.
[0059] Similar to the model data point parameter information, the meter data point parameter information includes object attribute OAD, point data sequence number, data type, data offset, conversion coefficient and number of decimal places.
[0060] Part 2: Message Processing Interface Development
[0061] Step 5. Develop message encapsulation interface
[0062] The message encapsulation interface covers reading a single object request, reading multiple object requests, and reading record-type object attributes, and automatically generates query messages that comply with the DLT698.45-2017 protocol.
[0063] For example, if the query message is a request to read one object, the input parameters only need to provide the meter address and object attribute OAD; if the query message is a request to read multiple objects, the input parameters need to provide the meter addresses and object attribute OAD list of the relevant meters.
[0064] Step 6. Develop message parsing interface
[0065] The message parsing interface is used to parse single-frame monitoring messages that comply with the DLT698.45-2017 protocol. Monitoring message types include query response messages, meter reporting messages proactively sent by the meter, and cross-platform query messages sent by other platforms. After receiving a monitoring message, the message parsing interface first performs a preliminary analysis to obtain the message type: if the message type is a cross-platform query message, it is discarded; if the message type is a query response message or meter reporting message, it is further parsed to obtain relevant information including the meter address, one or more object attributes (OADs), and the corresponding data values.
[0066] Part III: Data Collection Process
[0067] On the gateway side, develop Figure 2 The data collection process code of the electric meter is shown.
[0068] Step 7. Load configuration information
[0069] 7.1 Loading communication protocol configuration: Load the configuration information of DLT698.45-2017 protocol and DLT698.45-2017 protocol meter monitoring mode from the gateway dictionary table.
[0070] 7.2 Loading communication node configuration: Load the communication node from the gateway dictionary table, parse the serial port name, baud rate, parity bit, data bit, stop bit and flow control in the communication parameters, and store the communication node configuration information into the cache using the communication node ID as the index.
[0071] 7.3 Loading meter configuration: Filter by communication node ID, load all meters from the gateway database, obtain the meter ID, meter name, model ID, meter address and reading cycle, and store the meter configuration information in the cache using the meter ID as the index.
[0072] 7.4 Loading meter data point configuration: Filter by meter ID, load all meter data points from the gateway database, obtain the meter data point ID, meter data point name, and meter data point parameter information, and store the meter data point configuration information into the cache using the meter data point ID as the index. The meter data point parameter information includes the object attribute OAD, point data sequence number, data type, data offset, conversion coefficient, and number of decimal places.
[0073] 7.5 Generate data point mapping table: Use the communication node ID, meter address, and object attribute OAD as indexes to establish a data point mapping table in the cache to represent the mapping relationship of meter data points.
[0074] Step 8. Create a message queue
[0075] 8.1 Creating a Fixed Message Sending Queue
[0076] In the cache, a fixed message sending queue of each serial port is preset with the communication node ID as the index, and all query messages that need to be sent under the corresponding serial port are stored; Figure 2 As shown, all meter data points of a meter under a serial port are grouped, and the message encapsulation interface is called to perform query message framing on each group.
[0077] For example, the meter data points under a certain meter are grouped into groups of 5, and the data points with less than 5 are also grouped together. The message encapsulation interface is called to encapsulate the query message for each group. If the number of data points in a group is greater than 1, the message encapsulation interface for reading multiple object requests is called to encapsulate the query message. The input parameters include the meter address and the object attribute OAD list of all data points. The service priority and service sequence number in the default PIID value of the query message are 0. After the query message is generated, the query message is appended to the fixed message sending queue. If the number of data points in a group is equal to 1, the message encapsulation interface for reading an object request is called to encapsulate the query message. The input parameters include the meter address and the object attribute OAD list of the data point. The service priority and service sequence number in the default PIID value of the query message are 0. After the query message is generated, the query message is appended to the fixed message sending queue.
[0078] In addition to the meter address and object attribute OAD, you also need to set the query message reading cycle, the retransmission flag to true, the last transmission time to 0, and the sendable flag to true; generally speaking, the query message reading cycle is set to be consistent with the meter reading cycle.
[0079] After all meter data points of all meters under all serial ports are grouped and processed, the creation of the initial fixed message sending queue is completed.
[0080] 8.2 Creating a temporary serial port send queue
[0081] Add a timer for each serial port and preset a temporary sending queue for the serial port.
[0082] For the serial port of the DLT698.45-2017 protocol, start the timer (generally set to 1 second). When the timer arrives, traverse the fixed message sending queue of the serial port to determine whether there is a query message with the sendable flag set to true. Combine the last sending time, the read cycle and the current time to calculate. If the sendable flag is true and the current time - the last sending time >= the read cycle, then append the query message to the temporary sending queue of the serial port and set the sendable flag of the query message to false.
[0083] For the serial port in the DLT698.45-2017 protocol meter monitoring mode, turn off the timer or do not set the timer. There is no need to create a temporary serial port send queue.
[0084] 8.3 Creating a temporary serial port receiving queue
[0085] A temporary serial port receiving buffer is preset for each serial port in the cache to store all monitoring messages received by the corresponding serial port. The monitoring message types include query response messages, meter reporting messages actively reported by the meter, and cross-platform query messages issued by other platforms.
[0086] Step 9. Create a serial port processing thread
[0087] Create a serial port processing thread for each serial port. The execution process of the serial port processing thread is as follows: Figure 3 As shown; it is necessary to repeatedly determine whether the connection is successful in the serial port processing thread. If the connection is disconnected, reconnect the serial port first until the connection is successful.
[0088] A PIID cache is added to the serial port processing thread to store the PIID value. The PIID value is one byte, bit7 is the service priority, bit6 is the request access ACD flag, and the lower six bits represent the service sequence number; the serial port processing thread includes regular read and write processes and fast read processes.
[0089] 9.1 Fast Reading Process
[0090] If the temporary sending buffer of the serial port is empty, it is determined whether there is a read signal on the serial port: if not, it waits; if so, it uses a fast reading process to take out the monitoring messages one by one from the temporary receiving queue of the serial port, and calls the message parsing interface to parse the monitoring messages.
[0091] 9.2 General Reading and Writing Process
[0092] If the temporary send buffer of the serial port is not empty, the conventional read and write process is used to take out the query messages one by one from the temporary send buffer of the serial port, set the sendable flag to true, and set the last send time to the current time. Finally, the query message is written to the serial port and waits for the serial port response within the timeout period. When the query response message is received, the framing and unpacking function is called to perform unpacking processing until the query response message is received or the timeout period is reached, and the next query message is processed.
[0093] Before writing the query message to the serial port, the PIID value of the query message is updated first, and then the check code FCS of the query message is recalculated. The specific process is: before writing the query message to the serial port, the PIID value in the PIID cache is used to replace the PIID value of the query message, and then the PIID value in the PIID cache performs a self-increment of the service sequence number. At the same time, the query message recalculates the check code FCS according to the replaced PIID value, and uses the recalculated check code FCS to replace the check code FCS of the query message. Finally, the query message with the updated PIID value and check code FCS is written to the serial port.
[0094] The position of the PIID value of the query message is: the position of the starting character 0x68 of the query message + 10 + the length of the meter address.
[0095] Step 10: Match data point values
[0096] Call the message parsing interface to parse the monitored message, obtain the message type after preliminary parsing, discard cross-platform messages, and further parse the query response message and the meter report message to obtain relevant information including the meter address, one or more object attributes OAD and the corresponding data value (if the data type is Array or Structure, the returned data value may be a queue); compare with the data point mapping table, first obtain the point data sequence number based on the meter address and object attribute OAD, then find the data value corresponding to the point data sequence number from the data value, and finally update the data value corresponding to the meter data point.
[0097] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form, and any technical solutions obtained by equivalent replacement or equivalent transformation fall within the scope of protection of the present invention.
Claims
1. A method for collecting electric meter data based on the DLT698.45-2017 protocol, characterized by: Add the DLT698.45-2017 protocol, DLT698.45-2017 protocol meter monitoring mode, and communication node configuration to the gateway dictionary table; configure the meter and the corresponding meter data point in the gateway database; the meter configuration information includes the meter ID, meter name, communication node ID, meter address, and reading cycle; the meter data point configuration information includes the meter data point ID, meter data point name, and meter data point parameter information; the meter data point parameter information includes the object attribute OAD, point data sequence number, and data type; the method includes the following steps: Step 1: Load the communication protocol and communication node configuration; use the communication node ID as the index to store the communication node configuration information in the cache; filter by the communication node ID, load all meters from the gateway database, and use the meter ID as the index to store the meter configuration information in the cache; Using the communication node ID, meter address, and object attribute OAD as indexes, a data point mapping table is established in the cache to represent the mapping relationship of meter data points; Step 2: Use the communication node ID as the index to preset a fixed message sending queue for each serial port in the cache, and store all query messages that need to be sent under the corresponding serial port; add a timer for each serial port and preset a temporary serial port sending queue; preset a temporary serial port receiving buffer for each serial port in the cache, and store all monitoring messages received by the corresponding serial port; Step 3. Create a serial port processing thread for each serial port, including regular read and write processes and fast read processes; If the temporary sending buffer of the serial port is empty and there is a read signal on the serial port, a fast reading process is used to take out the monitoring messages one by one from the temporary receiving queue of the serial port, and the message parsing interface is called to parse the monitoring messages; If the temporary send buffer of the serial port is not empty, the conventional read and write process is used to take out the query messages one by one from the temporary send buffer of the serial port, write the query messages to the serial port after setting, and wait for the serial port response within the timeout period. When the query response message is received, the framing and unpacking function is called to perform unpacking processing until the query response message is received or the timeout period is reached, and then the next query message is processed; Step 4. Call the message parsing interface to parse the monitored message, obtain the message type after preliminary parsing, discard cross-platform messages, and further parse the query response message and the meter report message to obtain relevant information including the meter address, one or more object attributes OAD and the corresponding data value; compare with the data point mapping table, first obtain the point data number according to the meter address and object attribute OAD, then find the data value corresponding to the point data number from the data value, and finally update the data value corresponding to the meter data point.
2. The electric meter data acquisition method based on the DLT698.45-2017 protocol according to claim 1, characterized in that: In Step 2, a fixed message sending queue for each serial port is preset in the cache with the communication node ID as the index, and all query messages that need to be sent under the corresponding serial port are stored; all meter data points of a certain meter under a certain serial port are grouped, and the message encapsulation interface is called to frame the query message for each group, and the reading cycle, retransmission flag is true, the last sending time is 0, the sendable flag is true, and the meter address are set, and the query message is appended to the fixed message sending queue.
3. The electric meter data acquisition method based on the DLT698.45-2017 protocol according to claim 1, characterized in that: In the Step 2, a timer is added to each serial port, and a temporary serial port sending queue is preset; for the serial port of the DLT698.45-2017 protocol, the timer is started. When the timer arrives, the fixed message sending queue of the serial port is traversed to determine whether there is a query message with a sendable flag set to true. The query message is calculated based on the last sending time, the read cycle, and the current time. If the sendable flag is true and the current time - the last sending time >= the read cycle, the query message is appended to the temporary serial port sending queue, and the sendable flag of the query message is set to false. For the serial port of the DLT698.45-2017 protocol meter monitoring mode, the timer is turned off.
4. The electric meter data acquisition method based on the DLT698.45-2017 protocol according to claim 1, characterized in that: In Step 3, a PIID cache is added to the serial port processing thread to store the PIID value. The PIID value is one byte, bit 7 is the service priority, bit 6 is the ACD flag for requesting access, and the lower six bits represent the service sequence number. Before writing the query message to the serial port, the PIID value of the query message is updated first, and then the check code FCS of the query message is recalculated. The specific process is: before writing the query message to the serial port, the PIID value in the PIID cache is used to replace the PIID value of the query message, and then the PIID value in the PIID cache performs a self-increment of the service sequence number. At the same time, the query message recalculates the check code FCS according to the replaced PIID value, and uses the recalculated check code FCS to replace the check code FCS of the query message. Finally, the query message with the updated PIID value and check code FCS is written to the serial port.
5. The electric meter data acquisition method based on the DLT698.45-2017 protocol according to claim 2, characterized in that: In Step 3, the position of the PIID value of the query message is: the position of the starting character 0x68 of the query message + 10 + the length of the meter address.
6. The electric meter data acquisition method based on the DLT698.45-2017 protocol according to claim 1, characterized in that: In Step 3, when a conventional read and write process is used, query messages are taken out one by one from the temporary sending buffer of the serial port, the sendable flag is set to true, and the last sending time is set to the current time, and finally the query message is written to the serial port.
7. An electric meter data acquisition system based on the DLT698.45-2017 protocol, characterized by: It includes an initialization configuration module, a message processing interface development module, a communication configuration loading module, a fixed message sending queue, a serial port temporary sending queue, a serial port temporary receiving queue, a serial port processing thread module and a data point value matching module; the initialization configuration module includes a communication protocol configuration unit, a communication node configuration unit, an electric meter and a corresponding electric meter data point configuration unit; The communication protocol configuration unit is used to add the DLT698.45-2017 protocol and the DLT698.45-2017 protocol meter monitoring mode in the gateway machine dictionary table; The communication node configuration unit is used to add a communication node to the gateway machine dictionary table, and the configuration information of the communication node includes the communication node ID, communication node name, communication mode, communication protocol and communication parameters; The electricity meter and the corresponding electricity meter data point configuration unit are used to configure the electricity meter and the corresponding electricity meter data point in the gateway machine database. The configuration information of the electricity meter includes the electricity meter ID, the electricity meter name, the communication node ID, the electricity meter address and the reading cycle. The configuration information of the electricity meter data point includes the electricity meter data point ID, the electricity meter data point name and the electricity meter data point parameter information. The electricity meter data point parameter information includes the object attribute OAD, the point data sequence number and the data type; The message processing interface module includes a message encapsulation interface and a message parsing interface; the message encapsulation interface automatically generates a query message that complies with the DLT698.45-2017 protocol; the message parsing interface parses a single-frame monitoring message that complies with the DLT698.45-2017 protocol. After receiving the monitoring message, the message parsing interface first performs a preliminary analysis to obtain the message type: if the message type is a cross-platform query message, it is discarded; if the message type is a query response message or an electricity meter reporting message, it is further parsed to obtain relevant information including the meter address, one or more object attributes OADs, and corresponding data values; The communication configuration loading module stores the configuration information of the communication node into the cache using the communication node ID as an index; Filter by communication node ID, load all meters from the gateway database, and store the meter configuration information in the cache using the meter ID as the index; Using the communication node ID, meter address, and object attribute OAD as indexes, a data point mapping table is established in the cache to represent the mapping relationship of meter data points; The fixed message sending queue is preset in the cache with the communication node ID as the index, and stores all query messages that need to be sent under the corresponding serial port; The temporary serial port sending queue is preset in the cache with the communication node ID as the index, and stores the query messages that need to be sent within the timing range; The serial port temporary receiving queue is preset in the cache with the communication node ID as the index, and stores all monitoring messages received by the corresponding serial port; The serial port processing thread module uses the serial port processing thread to process the query messages and monitoring messages in the fixed message sending queue, the serial port temporary sending queue and the serial port temporary receiving queue; The data point value matching module parses the monitored message based on the message parsing interface to obtain relevant information including the meter address, one or more object attributes OAD and corresponding data values; According to the data point mapping table, first obtain the point data serial number according to the meter address and object attribute OAD, then find the data value corresponding to the point data serial number from the data value, and finally update the data value corresponding to the meter data point.
8. The electric meter data acquisition system based on the DLT698.45-2017 protocol according to claim 7, characterized in that: The serial port processing thread module uses the following serial port processing thread execution process: Create a serial port processing thread for each serial port, and repeatedly check whether the connection is successful in the serial port processing thread. If the connection is disconnected, reconnect the serial port until the connection is successful. Add a PIID cache in the serial port processing thread to store the PIID value. The PIID value is one byte, bit 7 is the service priority, bit 6 is the request access ACD flag, and the lower six bits represent the service sequence number. The serial port processing thread includes regular read and write processes and fast read processes. If the temporary sending buffer of the serial port is empty, it is determined whether there is a read signal on the serial port: if not, it waits; if so, it uses a fast reading process to take out the monitoring messages one by one from the temporary receiving queue of the serial port, and calls the message parsing interface to parse the monitoring messages; If the temporary send buffer of the serial port is not empty, the conventional read and write process is used to take out the query messages one by one from the temporary send buffer of the serial port, set the sendable flag to true, and set the last send time to the current time. Finally, the query message is written to the serial port and waits for the serial port response within the timeout period. When the query response message is received, the framing and unpacking function is called to perform unpacking processing until the query response message is received or the timeout period is reached, and then the next query message is processed; Before writing the query message to the serial port, the PIID value of the query message is updated first, and then the check code FCS of the query message is recalculated. The specific process is: before writing the query message to the serial port, the PIID value in the PIID cache is used to replace the PIID value of the query message, and then the PIID value in the PIID cache performs a self-increment of the service sequence number. At the same time, the query message recalculates the check code FCS according to the replaced PIID value, and uses the recalculated check code FCS to replace the check code FCS of the query message. Finally, the query message with the updated PIID value and check code FCS is written to the serial port.
9. The electric meter data acquisition system based on the DLT698.45-2017 protocol according to claim 7, characterized in that: The initialization configuration module also includes an electricity meter model and a model data point preset unit, wherein the preset information of the electricity meter model includes a model ID and a model name, and the preset information of the model data point includes a model data point ID, a model data point name, a model ID, and model data point parameter information; in the electricity meter and the corresponding electricity meter data point configuration unit, the configuration information of the electricity meter and the corresponding electricity meter data point is inherited from the electricity meter model and the corresponding model data point, wherein the configuration information of the electricity meter includes the electricity meter ID, the electricity meter name, the model ID, the communication node ID, the electricity meter address, and the reading cycle, and the configuration information of the electricity meter data point includes the electricity meter data point ID, the electricity meter data point name, the model data point ID, and the electricity meter data point parameter information.
Citation Information
Patent Citations
Gateway machine equipment Modbus data unvarnished transmission and protocol conversion method and gateway machine equipment Modbus data unvarnished transmission and protocol conversion device
CN119544821A
Power equipment intelligent gateway fault detection system based on Internet of Things
CN119906624A
Cited By
Electric energy meter data analysis method and electric energy meter
CN122527134A