Serial port data message queue processing method of gateway machine equipment and gateway machine equipment

By using the Modbus protocol and message attribute information in the gateway device, the serial data message queue in the power substation distribution station house is solved, and the problem of duplication and low-timed processing is achieved, and the timeliness and regularity of data processing is achieved.

CN119520433AActive Publication Date: 2025-02-25NANJING ZHENGTU INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411732929.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-02-25
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

In power substation distribution stations, it is difficult for the prior art to effectively process serial communication message queues of different types of data, resulting in duplication and low-timed processing.

Method used

A serial data packet queue processing method for gateway equipment is designed, using Modbus protocol and message attribute information, and by timely traversing the message storage heap and Modbus message information processing queue, adjusting the message processing order, avoiding repeated creation and deletion of messages, and realizing the regularity and timeliness of permanent and temporary messages.

Benefits of technology

It effectively avoids the problem of packet accumulation, improves the control and adjustment response speed, reduces the repeated frame-grouping operations during CPU processing, and realizes the timeliness and regularity of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520433A_ABST
    Figure CN119520433A_ABST
Patent Text Reader

Abstract

The invention discloses a serial port data message queue processing method of gateway machine equipment and the gateway machine equipment, which adopt a Modbus protocol as a communication protocol, and store sensor data points with continuous register addresses, same read-write function codes and consistent four remote types in the same sensor into a processing data stack; the processing data heap is assembled into permanent Modbus message information; message processing instructions of the remote control information points or the remote regulation information points are assembled into temporary Modbus message information, and feedback information of the corresponding remote signaling information points and the corresponding remote measurement information points are also assembled into temporary Modbus message information; the Modbus message information is added into a Modbus message information processing queue of a serial port in a mode of combining regular traversal of a message storage pile and an upper computer instruction, and the serial port takes out the Modbus message information in the Modbus message information processing queue one by one for message processing. According to the method, the timeliness of temporary Modbus message information processing is considered while the permanent Modbus message information processing regularity is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a serial port data message queue processing method of a gateway device and the gateway device, belonging to the internal data transmission technology in a smart substation. Background Art

[0002] In power substations, there are a large number of sensor devices that use serial ports for data communication. Serial ports are also very commonly used device communication interfaces on gateway devices. Serial lines are used for data communication between the two communicating parties. Although serial port communication has the disadvantage of slow transmission speed, it still plays an indispensable role in smart substations due to its advantages in compatibility, stability, cost-effectiveness and flexibility.

[0003] The data packet content that complies with the serial communication protocol includes the start bit, main data, check bit and stop bit. The two parties in serial communication need to agree on the same baud rate, start bit, check bit, stop bit and data packet format to communicate normally. Since serial communication is sent by bit, the transmission rate is slow, and since there is no unified clock signal between the sender and receiver of serial communication, the serial communication message queue processing method has certain particularities.

[0004] In the power substation, sensor equipment involves various types of data, some of which are switch quantity or status data, some are analog data, and some are control data of sensor equipment. The gateway equipment processes these different types of data in different ways. For example, switch quantity status data requires frequent acquisition of data information, especially after switch control, it is necessary to obtain switch quantity control feedback in a timely manner; while some analog quantity data generally does not change much, and does not need to read data information frequently, and the data collection interval can be appropriately extended. Therefore, different processing strategies need to be adopted for different data information to avoid repeated and inefficient data processing. Summary of the invention

[0005] Purpose of the invention: In order to overcome the deficiencies in the prior art, the present invention provides a serial port data message queue processing method for a gateway device, designs a fixed message storage stack to store various Modbus message information, and uses a Modbus message information processing queue to adjust the message processing order, which can avoid repeated creation and deletion of messages, and while achieving the regularity of permanent Modbus message information processing, take into account the timeliness of temporary Modbus message information processing.

[0006] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is: A method for processing serial port data message queues of gateway equipment adopts Modbus protocol as communication protocol, configures Modbus communication address for sensor, configures register address, read / write function code and four remote types for sensor information point; for remote signal information point and telemetry information point, stores sensor data points with continuous register address, same read / write function code and consistent four remote types in the same sensor into a processing data pile, translates the processing data pile into Modbus message, adds message attribute information to Modbus message to form permanent Modbus message information; stores remote control information into Modbus message pile ... The message processing instructions of the remote control point or remote adjustment information point are assembled into temporary Modbus message information, and the feedback information of the corresponding remote signal information point and telemetry information point is also assembled into temporary Modbus message information; all Modbus message information of the same four remote types are stored in a message storage pile in the memory, and the Modbus message information is added to the Modbus message information processing queue of the serial port by combining the timed traversal of the message storage pile with the host computer instructions. The serial port takes out the Modbus message information in the Modbus message information processing queue one by one for message processing.

[0007] Modbus is a serial communication protocol that has become the industry standard for communication protocols in the industrial field. The Modbus protocol uses a master / slave communication mode and a master-question-slave-answer mode for data communication. Modbus messages involve three pieces of information: communication address, read / write function code, and register address. As long as these three pieces of information are obtained, Modbus messages can be generated according to Modbus message rules. In this case, for remote control messages and remote adjustment messages, each information point must be processed separately, and the corresponding remote signal messages and telemetry messages (which can be considered as the result of responding to remote control messages and remote adjustment messages) must also be processed separately to meet the timeliness requirements of regulation and feedback. For other remote signal messages and telemetry messages, this case uses the principle of register address continuity for combined area framing.

[0008] Specifically, the message attribute information includes an information point list, a message type, a message receiving length, a message reading cycle, a resendable flag, a Modbus message, a message lock, and a message processing timestamp; for telesignal information points and telemetering information points, the message reading cycle, message processing timestamp, and resendable flag of the Modbus message information are comprehensively judged to determine whether to add the Modbus message information to the end of the Modbus message information processing queue; for the Modbus message information of the remote control information point and the remote adjustment information point, the Modbus message information is directly inserted into the head of the Modbus message information processing queue according to the host computer instruction; for the Modbus message information of the remote signaling information point and the telemetering information point fed back to the remote control information point and the remote adjustment information point, the Modbus message information is immediately or delayed inserted into the head of the Modbus message information processing queue according to the host computer instruction.

[0009] Specifically, for the telesignaling information point and the telemetering information point, the message reading cycle, message processing timestamp and resendable flag of the Modbus message information are comprehensively judged. If the resendable flag is true, and the difference between the current time and the message processing timestamp is greater than the message reading cycle, the resendable flag is updated to false, and the Modbus message information is added to the end of the Modbus message information processing queue; if the resendable flag is false, it means that the Modbus message information has been added to the Modbus message information processing queue and cannot be added repeatedly.

[0010] Specifically, when organizing the Modbus message information processing queue, if a certain Modbus message information is traversed and it is determined whether the Modbus message information needs to be added to the Modbus message information processing queue, the message lock is first locked, and the message lock is released after the confirmation result is obtained; when the serial port takes out a certain Modbus message information from the Modbus message information processing queue for message processing, the message lock is first locked, and the message lock is released after the message processing is completed. The message lock is designed in this case to avoid multiple threads processing the same Modbus message information at the same time, causing data confusion; each Modbus message information has a message lock.

[0011] Specifically, the method comprises the following steps: Step 1. Create files for each sensor and each sensor information point, configure the Modbus communication address for the sensor, configure the register address, read / write function code and four remote types for the sensor information point; the four remote types include remote communication, remote measurement, remote control and remote adjustment, establish the corresponding relationship between the specified remote control information point and the specified remote communication information point, and establish the corresponding relationship between the specified remote adjustment information point and the specified remote measurement information point; Step 2: The gateway loads the configuration information of the sensor and sensor information points; Step 3. For the telesignaling information points and telemetering information points, the sensor information points are divided into piles according to the read / write function code and the four remote types. The sensor information points with continuous register addresses, the same read / write function code and the same four remote types in the same sensor are stored in a processing data pile, and the register address range of the processing data pile is recorded; the information of each processing data pile is translated into a Modbus message, including the Modbus communication address, read / write function code and register address range of the sensor; if the register address range of a processing data pile exceeds the Modbus message length limit, the Modbus message length limit is used as a reference for the processing data pile. The register address range is split to form more than two Modbus messages; if the register address range of a certain processing data stack does not exceed the Modbus message length limit, a Modbus message is formed; message attribute information is added to each Modbus message to form Modbus message information, and the message attribute information includes information point list, message type, message receiving length, message reading cycle, resendable identification, Modbus message, message lock and message processing timestamp, and the message type is set to a permanent message; all Modbus message information of the same four-remote type is stored in a message storage stack in the memory; Step 4. Add a timer (usually a second-level timer) for each serial communication service. The gateway machine periodically traverses the message storage stack. When traversing a certain Modbus message information, first lock the message lock of the Modbus message information, then confirm that the resend flag is true, and further confirm that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then update the resend flag to false, and add the Modbus message information to the end of the Modbus message information processing queue, and finally release the message lock of the Modbus message information, and traverse the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then release the message lock of the Modbus message information, and traverse the next Modbus message information; Step 5. Translate the remote control instruction of the designated remote control information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote control message; Translate the remote adjustment instruction of the designated remote adjustment information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote adjustment message; If the gateway receives a remote control instruction or a remote adjustment instruction, the generated remote control message or remote adjustment message is directly added to the head of the Modbus message information processing queue; Step 6. Translate the telesignaling data fed back by the designated telesignaling information point associated with the remote control message into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a telesignaling message; translate the telemetry data fed back by the designated telemetry information point associated with the remote adjustment message into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a telemetry message; if the gateway receives a telesignaling instruction or a telemetry instruction, it immediately or with delay adds the associated telesignaling message or telemetry message to the head of the Modbus message information processing queue; Step 7. Add a first-in-first-out Modbus message information processing queue for each serial communication service, start the thread, and read the Modbus message information processing queue in sequence in the thread. Every time the gateway reads a Modbus message information from the head of the Modbus message information processing queue (and also deletes it from the Modbus message information processing queue), it first locks the message lock of the Modbus message information, and then performs message processing: If the message processing is successful, for permanent messages, the message processing timestamp is updated, and the resend flag is updated to true, and the message lock of the Modbus message information is released. For temporary messages, the memory is released for message recycling to prevent memory leakage; if the message processing fails, for permanent messages, the resend flag is updated to true, the message lock of the Modbus message information is released, and for temporary messages, the memory is released for message recycling to prevent memory leakage.

[0012] A gateway device adopts Modbus protocol as a communication protocol and realizes communication connection with a sensor through a serial port, including a sensor and a sensor information point configuration module, a permanent Modbus message translation module, a temporary Modbus message translation module, a message storage stack, a message traversal module, a message instruction receiving module, a Modbus message information processing queue and a message processing module; The sensor and sensor information point configuration module configures the Modbus communication address for the sensor, configures the register address, read / write function code and four remote types for the sensor information point, builds the corresponding relationship between the designated remote control information point and the designated remote signaling information point, and builds the corresponding relationship between the designated remote adjustment information point and the designated telemetry information point; The permanent Modbus message translation module performs pile processing for the telesignaling information points and the telemetering information points according to the read / write function codes and four remote types of the sensor information points, stores the sensor information points with continuous register addresses, the same read / write function codes and the same four remote types in the same sensor into a processing data pile, translates the processing data pile into Modbus messages, and adds message attribute information to the Modbus messages to form permanent Modbus message information; The temporary Modbus message translation module assembles the message processing instructions of the remote control information point or the remote adjustment information point into temporary Modbus message information, and the feedback information of the corresponding remote signaling information point and the remote measurement information point is also assembled into temporary Modbus message information; The message storage stack is a storage space in the memory, which is used to store all Modbus message information of the same four-remote type; The message traversal module periodically traverses the message storage heap, comprehensively judges the message reading cycle, message processing timestamp and resendable flag of the Modbus message information, and if the resendable flag is true, and the difference between the current time and the message processing timestamp is greater than the message reading cycle, the resendable flag is updated to false, and the Modbus message information is added to the end of the Modbus message information processing queue; The message instruction receiving module receives the remote control instruction or remote adjustment instruction sent by the host computer, first translates the remote control instruction or remote adjustment instruction into the remote control message or remote adjustment message, and then directly adds the remote control message or remote adjustment message to the head of the Modbus message information processing queue; receives the remote signaling data or telemetry data fed back by the sensor, first translates the data or telemetry data into the remote signaling message or telemetry message, and then instantly or with delay adds the remote signaling message or telemetry message to the head of the Modbus message information processing queue; The message processing module reads the Modbus message information processing queue in sequence, and each time a Modbus message information is read from the head of the Modbus message information processing queue, the message lock of the Modbus message information is first locked, and then the message processing is performed: if the message processing is successful, for a permanent message, the message processing timestamp is updated, and the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery; if the message processing fails, for a permanent message, the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery.

[0013] Specifically, the permanent Modbus message translation module performs pile processing for the telesignaling information points and telemetering information points according to the read / write function codes and four remote types of the sensor information points, stores the sensor information points with continuous register addresses, the same read / write function codes and the same four remote types in the same sensor into a processing data pile, and records the register address range of the processing data pile; translates the information of each processing data pile into a Modbus message, and if the register address range of a processing data pile exceeds the Modbus message length limit, splits the register address range with reference to the Modbus message length limit to form more than two Modbus messages, otherwise forms one Modbus message; adds message attribute information to the Modbus message to form Modbus message information, and sets the message type to a permanent message.

[0014] Specifically, the temporary Modbus message translation module translates the message processing instruction of the designated remote control information point into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message; translates the feedback information of the designated remote signaling information point associated with the remote control message into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message. The message information is called a telesignal message; the message processing instruction of the designated telecontrol information point is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a telecontrol message; the feedback information of the designated telemetry information point associated with the telecontrol message is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a telemetry message.

[0015] Specifically, the message traversal module periodically traverses the message storage heap, and when traversing to a certain Modbus message information, first locks the message lock of the Modbus message information, then confirms that the resend flag is true, and further confirms that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then updates the resend flag to false, and adds the Modbus message information to the end of the Modbus message information processing queue, and finally releases the message lock of the Modbus message information, and traverses the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

[0016] Beneficial effects: The serial port data message queue processing method and gateway device provided by the present invention have the following advantages over the prior art: 1. Add message attribute information such as message reading cycle, message processing timestamp, and resend flag to each Modbus message, thereby avoiding the message accumulation problem caused by too many devices connected to the same serial port or too many sensor information points, and the mismatch between the configured reading speed and the actual serial port reading and writing cycle; 2. Insert remote control messages and remote adjustment messages to the head of the Modbus message information processing queue to improve the control and adjustment response speed and performance; 3. Insert the remote signal message of the feedback data point into the queue head of the Modbus message information processing queue to improve the control and adjustment response speed and performance; 4. The telemetry messages are set as temporary messages, which improves the feedback speed of control and regulation; 4. During initialization, the data stack is initialized and processed according to the sensor communication address, register address range, read and write function code and four remote types of data points, which can avoid repeated information point framing operations and reduce the CPU processing process; 5. A fixed message storage stack is designed to store various Modbus message information, and the Modbus message information processing queue is used to adjust the message processing order, which can avoid repeated creation and deletion of messages, and realize the regularity of permanent Modbus message information processing while taking into account the timeliness of temporary Modbus message information processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A schematic diagram of the construction process of a Modbus message information processing queue in the method of the present invention; Figure 2 The figure is a flow chart of message processing in the method of the present invention. DETAILED DESCRIPTION

[0018] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0019] like Figure 1 , Figure 2The present invention shows a method for processing a serial port data message queue of a gateway device, comprising the following steps: Step 1. Create files for each sensor and each sensor information point, configure the Modbus communication address for the sensor, configure the register address, read / write function code and four remote types for the sensor information point; the four remote types include remote communication, remote measurement, remote control and remote adjustment, establish the corresponding relationship between the specified remote control information point and the specified remote communication information point, and establish the corresponding relationship between the specified remote adjustment information point and the specified remote measurement information point; Step 2: The gateway loads the configuration information of the sensor and sensor information points; Step 3. For the telesignaling information points and telemetering information points, the sensor information points are divided into piles according to the read / write function code and the four remote types. The sensor information points with continuous register addresses, the same read / write function code and the same four remote types in the same sensor are stored in a processing data pile, and the register address range of the processing data pile is recorded; the information of each processing data pile is translated into a Modbus message, including the Modbus communication address, read / write function code and register address range of the sensor; if the register address range of a processing data pile exceeds the Modbus message length limit, the Modbus message length limit is used as a reference for the processing data pile. The register address range is split to form more than two Modbus messages; if the register address range of a certain processing data stack does not exceed the Modbus message length limit, a Modbus message is formed; message attribute information is added to each Modbus message to form Modbus message information, and the message attribute information includes information point list, message type, message receiving length, message reading cycle, resendable identification, Modbus message, message lock and message processing timestamp, and the message type is set to a permanent message; all Modbus message information of the same four-remote type is stored in a message storage stack in the memory; Step 4. Add a timer for each serial communication service. The gateway machine periodically traverses the message storage stack. When traversing a certain Modbus message information, first lock the message lock of the Modbus message information, then confirm that the resend flag is true, and further confirm that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then update the resend flag to false, and add the Modbus message information to the end of the Modbus message information processing queue, and finally release the message lock of the Modbus message information, and traverse the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then release the message lock of the Modbus message information, and traverse the next Modbus message information; Step 5. Translate the remote control instruction of the designated remote control information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote control message; Translate the remote adjustment instruction of the designated remote adjustment information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote adjustment message; If the gateway receives a remote control instruction or a remote adjustment instruction, the generated remote control message or remote adjustment message is directly added to the head of the Modbus message information processing queue; Step 6, translate the telesignaling data fed back by the designated telesignaling information point associated with the remote control message into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a telesignaling message; translate the telemetry data fed back by the designated telemetry information point associated with the remote adjustment message into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a telemetry message; if the gateway machine receives a telesignaling instruction or a telemetry instruction, it immediately or with delay adds the associated telesignaling message or telemetry message to the head of the Modbus message information processing queue; Step 7. Add a first-in-first-out Modbus message information processing queue for each serial communication service, start the thread, and read the Modbus message information processing queue in sequence within the thread. Every time the gateway reads a Modbus message information from the head of the Modbus message information processing queue, it first locks the message lock of the Modbus message information, and then performs message processing: If the message processing is successful, for permanent messages, the message processing timestamp is updated, and the resend flag is updated to true, the message lock of the Modbus message information is released, and for temporary messages, the memory is released for message recovery; if the message processing fails, for permanent messages, the resend flag is updated to true, the message lock of the Modbus message information is released, and for temporary messages, the memory is released for message recovery.

[0020] Whether the message is processed successfully depends on the content of the Modbus message. For control messages and adjustment messages, there may be actions of writing to the serial port and information feedback. If information feedback is required to confirm whether the processing is successful, the message timeout and message receiving length need to be set. When the feedback message length is too short compared with the message receiving length, or the feedback message exceeds the message timeout, the message processing is considered to have failed.

[0021] In this case, the attribute information of each message is defined as follows: 1. Information point list: used to record the list of sensor information points involved in the Modbus message. After reading the sensor information point, the sensor information point data can be easily refreshed; 2. Message type: including permanent messages and temporary messages. Permanent messages refer to messages that will exist permanently during the program duration, generally sensor telemetry or telemetry data point messages. Temporary messages are Modbus messages generated by remote control or remote adjustment instructions and Modbus messages generated by feedback telemetry or telemetry data points. They need to be released and deleted after use. 3. Message receiving length: The length of the received message is generally determined by the start and end range of the registers involved in the message, which serves as the basis for judging whether the message has been received; 4. Message reading cycle: Generally determined according to the four remote types of the processing data pile. The message reading cycle of the remote signal information point is short and needs to be read in a unit cycle (generally seconds); the message reading cycle of telemetry data can be extended, which can be configured according to needs; 5. Resendable flag: To avoid problems such as too large a Modbus message processing queue or repeated content, if the Modbus message is in the sending queue: set the resendable flag to false, indicating that it cannot be sent again; otherwise, set the resendable flag to true, indicating that it can be sent again; 6. Modbus message: After the content of the Modbus message is determined, it does not need to be changed and the Modbus message can be solidified; 7. Message lock: To meet the needs of multi-threaded processing, add a message lock for each Modbus message; 8. Message processing timestamp: records the processing time of each Modbus message, which is used to determine whether the message processing cycle is exceeded.

[0022] All the above message attribute information is combined into one Modbus message information, and stored in different message storage piles according to the four remote types.

[0023] A gateway device adopts Modbus protocol as a communication protocol and realizes communication connection with a sensor through a serial port, including a sensor and sensor information point configuration module, a permanent Modbus message translation module, a temporary Modbus message translation module, a message storage stack, a message traversal module, a message instruction receiving module, a Modbus message information processing queue and a message processing module.

[0024] The sensor and sensor information point configuration module configures the Modbus communication address for the sensor, configures the register address, read and write function code and four remote types for the sensor information point, establishes the corresponding relationship between the specified remote control information point and the specified remote signal information point, and establishes the corresponding relationship between the specified remote adjustment information point and the specified telemetry information point.

[0025] The permanent Modbus message translation module performs pile processing for the telesignaling information points and telemetering information points according to the read / write function codes and four remote types of the sensor information points, stores the sensor information points with continuous register addresses, the same read / write function codes and the same four remote types in the same sensor into a processing data pile, and records the register address range of the processing data pile; translates the information of each processing data pile into a Modbus message, and if the register address range of a processing data pile exceeds the Modbus message length limit, splits the register address range with reference to the Modbus message length limit to form more than two Modbus messages, otherwise forms one Modbus message; adds message attribute information to the Modbus message to form Modbus message information, and sets the message type to a permanent message.

[0026] The temporary Modbus message translation module translates the message processing instruction of the designated remote control information point into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message; translates the feedback information of the designated remote signaling information point associated with the remote control message into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message. The information is called a remote signal message; the message processing instruction of the designated remote adjustment information point is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a remote adjustment message; the feedback information of the designated telemetry information point associated with the remote adjustment message is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a telemetry message.

[0027] The message storage stack is a storage space in the memory, which is used to store all Modbus message information of the same four-remote type.

[0028] The message traversal module periodically traverses the message storage heap, and when traversing to a certain Modbus message information, first locks the message lock of the Modbus message information, then confirms that the resend flag is true, and further confirms that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then updates the resend flag to false, and adds the Modbus message information to the end of the Modbus message information processing queue, and finally releases the message lock of the Modbus message information, and traverses the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

[0029] The message instruction receiving module receives the remote control instruction or remote adjustment instruction sent by the host computer, first translates the remote control instruction or remote adjustment instruction into the remote control message or remote adjustment message, and then directly adds the remote control message or remote adjustment message to the head of the Modbus message information processing queue; receives the remote signaling data or telemetry data fed back by the sensor, first translates the data or telemetry data into the remote signaling message or telemetry message, and then instantly or with delay adds the remote signaling message or telemetry message to the head of the Modbus message information processing queue; The message processing module reads the Modbus message information processing queue in sequence, and each time a Modbus message information is read from the head of the Modbus message information processing queue, the message lock of the Modbus message information is first locked, and then the message processing is performed: if the message processing is successful, for a non-temporary message, the message processing timestamp is updated, and the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery; if the message processing fails, for a non-temporary message, the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery.

[0030] 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 solution obtained by equivalent replacement or equivalent transformation falls within the protection scope of the present invention.

Claims

1. A method for processing a serial port data message queue of a gateway device, characterized in that: The Modbus protocol is used as the communication protocol, the Modbus communication address is configured for the sensor, and the register address, read-write function code and four remote types are configured for the sensor information point; for the remote signal information point and the telemetry information point, the sensor data points with continuous register addresses, the same read-write function code and the same four remote types in the same sensor are stored in a processing data pile, the processing data pile is translated into a Modbus message, and the message attribute information is added to the Modbus message to form permanent Modbus message information; the message processing instructions of the remote control information point or the remote adjustment information point are assembled into temporary Modbus message information, and the feedback information of the corresponding remote signal information point and the telemetry information point is also assembled into temporary Modbus message information; all Modbus message information of the same four remote types are stored in a message storage pile in the memory, and the Modbus message information is added to the Modbus message information processing queue of the serial port by combining the timed traversal of the message storage pile with the host computer instruction, and the serial port takes out the Modbus message information in the Modbus message information processing queue one by one for message processing.

2. The method for processing serial port data message queues of a gateway device according to claim 1, characterized in that: The message attribute information includes an information point list, a message type, a message receiving length, a message reading cycle, a resendable flag, a Modbus message, a message lock and a message processing timestamp; for a telesignal information point and a telemetering information point, the message reading cycle, the message processing timestamp and the resendable flag of the Modbus message information are comprehensively judged to determine whether to add the Modbus message information to the tail of the Modbus message information processing queue; for the Modbus message information of the remote control information point and the remote adjustment information point, the Modbus message information is directly inserted into the head of the Modbus message information processing queue according to the host computer instruction; for the Modbus message information of the telesignal information point and the telemetering information point fed back to the remote control information point and the remote adjustment information point, the Modbus message information is immediately or delayed inserted into the head of the Modbus message information processing queue according to the host computer instruction.

3. The method for processing serial port data message queues of a gateway device according to claim 2, characterized in that: For telesignaling information points and telemetering information points, the message reading cycle, message processing timestamp and resendable flag of the Modbus message information are comprehensively judged. If the resendable flag is true and the difference between the current time and the message processing timestamp is greater than the message reading cycle, the resendable flag is updated to false and the Modbus message information is added to the end of the Modbus message information processing queue.

4. The method for processing serial port data message queues of a gateway device according to claim 2, characterized in that: When organizing the Modbus message information processing queue, if a certain Modbus message information is traversed and it is determined whether the Modbus message information needs to be added to the Modbus message information processing queue, the message lock is first locked, and the message lock is released after the determination result is obtained; When the serial port takes out a Modbus message from the Modbus message processing queue for message processing, the message lock is first locked, and the message lock is released after the message processing is completed.

5. The method for processing serial port data message queues of a gateway device according to claim 1, characterized in that: The method comprises the following steps: Step 1. Create files for each sensor and each sensor information point, configure the Modbus communication address for the sensor, configure the register address, read / write function code and four remote types for the sensor information point; the four remote types include remote communication, remote measurement, remote control and remote adjustment, establish the corresponding relationship between the specified remote control information point and the specified remote communication information point, and establish the corresponding relationship between the specified remote adjustment information point and the specified remote measurement information point; Step 2: The gateway loads the configuration information of the sensor and sensor information points; Step 3. For the telesignaling information points and telemetering information points, the sensor information points are divided into piles according to the read / write function code and the four remote types. The sensor information points with continuous register addresses, the same read / write function code and the same four remote types in the same sensor are stored in a processing data pile, and the register address range of the processing data pile is recorded; the information of each processing data pile is translated into a Modbus message, including the Modbus communication address, read / write function code and register address range of the sensor; if the register address range of a processing data pile exceeds the Modbus message length limit, the Modbus message length limit is used as a reference for the processing data pile. The register address range is split to form more than two Modbus messages; if the register address range of a certain processing data stack does not exceed the Modbus message length limit, a Modbus message is formed; message attribute information is added to each Modbus message to form Modbus message information, and the message attribute information includes information point list, message type, message receiving length, message reading cycle, resendable identification, Modbus message, message lock and message processing timestamp, and the message type is set to a permanent message; all Modbus message information of the same four-remote type is stored in a message storage stack in the memory; Step 4. Add a timer for each serial communication service. The gateway machine periodically traverses the message storage stack. When traversing a certain Modbus message information, first lock the message lock of the Modbus message information, then confirm that the resend flag is true, and further confirm that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then update the resend flag to false, and add the Modbus message information to the end of the Modbus message information processing queue, and finally release the message lock of the Modbus message information, and traverse the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then release the message lock of the Modbus message information, and traverse the next Modbus message information; Step 5. Translate the remote control instruction of the designated remote control information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote control message; Translate the remote adjustment instruction of the designated remote adjustment information point sent by the host computer into a Modbus message, add message attribute information to the Modbus message to form Modbus message information, set the message type to a temporary message, and call the Modbus message information a remote adjustment message; If the gateway receives a remote control instruction or a remote adjustment instruction, the generated remote control message or remote adjustment message is directly added to the head of the Modbus message information processing queue; Step 6, translating the telesignaling data fed back by the designated telesignaling information point associated with the remote control message into a Modbus message, adding message attribute information to the Modbus message to form Modbus message information, setting the message type to a temporary message, and calling the Modbus message information a telesignaling message; translating the telemetry data fed back by the designated telemetry information point associated with the remote adjustment message into a Modbus message, adding message attribute information to the Modbus message to form Modbus message information, setting the message type to a temporary message, and calling the Modbus message information a telemetry message; If the gateway receives a telesignaling command or a telemetering command, it will immediately or delayedly add the associated telesignaling message or telemetering message to the head of the Modbus message information processing queue; Step 7. Add a first-in-first-out Modbus message information processing queue for each serial communication service, start the thread, and read the Modbus message information processing queue in sequence within the thread. Every time the gateway reads a Modbus message information from the head of the Modbus message information processing queue, it first locks the message lock of the Modbus message information, and then performs message processing: If the message processing is successful, for permanent messages, the message processing timestamp is updated, and the resend flag is updated to true, the message lock of the Modbus message information is released, and for temporary messages, the memory is released for message recovery; if the message processing fails, for permanent messages, the resend flag is updated to true, the message lock of the Modbus message information is released, and for temporary messages, the memory is released for message recovery.

6. A gateway device, characterized in that: The Modbus protocol is used as the communication protocol, and the communication connection with the sensor is realized through the serial port, including the sensor and sensor information point configuration module, the permanent Modbus message translation module, the temporary Modbus message translation module, the message storage pile, the message traversal module, the message instruction receiving module, the Modbus message information processing queue and the message processing module; The sensor and sensor information point configuration module configures the Modbus communication address for the sensor, configures the register address, read / write function code and four remote types for the sensor information point, builds the corresponding relationship between the designated remote control information point and the designated remote signaling information point, and builds the corresponding relationship between the designated remote adjustment information point and the designated telemetry information point; The permanent Modbus message translation module performs pile processing for the telesignaling information points and the telemetering information points according to the read / write function codes and four remote types of the sensor information points, stores the sensor information points with continuous register addresses, the same read / write function codes and the same four remote types in the same sensor into a processing data pile, translates the processing data pile into Modbus messages, and adds message attribute information to the Modbus messages to form permanent Modbus message information; The temporary Modbus message translation module assembles the message processing instructions of the remote control information point or the remote adjustment information point into temporary Modbus message information, and the feedback information of the corresponding remote signaling information point and the remote measurement information point is also assembled into temporary Modbus message information; The message storage stack is a storage space in the memory, which is used to store all Modbus message information of the same four-remote type; The message traversal module periodically traverses the message storage heap, comprehensively judges the message reading cycle, message processing timestamp and resendable flag of the Modbus message information, and if the resendable flag is true, and the difference between the current time and the message processing timestamp is greater than the message reading cycle, the resendable flag is updated to false, and the Modbus message information is added to the end of the Modbus message information processing queue; The message instruction receiving module receives the remote control instruction or remote adjustment instruction sent by the host computer, first translates the remote control instruction or remote adjustment instruction into the remote control message or remote adjustment message, and then directly adds the remote control message or remote adjustment message to the head of the Modbus message information processing queue; receives the remote signaling data or telemetry data fed back by the sensor, first translates the data or telemetry data into the remote signaling message or telemetry message, and then instantly or with delay adds the remote signaling message or telemetry message to the head of the Modbus message information processing queue; The message processing module reads the Modbus message information processing queue in sequence, and each time a Modbus message information is read from the head of the Modbus message information processing queue, the message lock of the Modbus message information is first locked, and then the message processing is performed: if the message processing is successful, for a permanent message, the message processing timestamp is updated, and the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery; if the message processing fails, for a permanent message, the resendable flag is updated to true, the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recovery.

7. The gateway device according to claim 6, wherein: The permanent Modbus message translation module performs pile processing for the telesignaling information points and telemetering information points according to the read / write function codes and four remote types of the sensor information points, stores the sensor information points with continuous register addresses, the same read / write function codes and the same four remote types in the same sensor into a processing data pile, and records the register address range of the processing data pile; translates the information of each processing data pile into a Modbus message, and if the register address range of a processing data pile exceeds the Modbus message length limit, splits the register address range with reference to the Modbus message length limit to form more than two Modbus messages, otherwise forms one Modbus message; adds message attribute information to the Modbus message to form Modbus message information, and sets the message type to a permanent message.

8. The gateway device according to claim 6, wherein: The temporary Modbus message translation module translates the message processing instruction of the designated remote control information point into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message; translates the feedback information of the designated remote signaling information point associated with the remote control message into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type to a temporary message, and calls the Modbus message information a remote control message. The information is called a remote signal message; the message processing instruction of the designated remote adjustment information point is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a remote adjustment message; the feedback information of the designated telemetry information point associated with the remote adjustment message is translated into a Modbus message, message attribute information is added to the Modbus message to form Modbus message information, the message type is set to a temporary message, and the Modbus message information is called a telemetry message.

9. The gateway device according to claim 6, wherein: The message traversal module periodically traverses the message storage heap, and when traversing to a certain Modbus message information, first locks the message lock of the Modbus message information, then confirms that the resend flag is true, and further confirms that the difference between the current time and the message processing timestamp is greater than the message reading cycle, then updates the resend flag to false, and adds the Modbus message information to the end of the Modbus message information processing queue, and finally releases the message lock of the Modbus message information, and traverses the next Modbus message information; if it is confirmed that the resend flag is false, or it is confirmed that the difference between the current time and the message processing timestamp is less than or equal to the message reading cycle, then the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

Citation Information

Patent Citations

  • A cyclic queue-based telemetry data real-time processing system and method

    CN109743291A

  • Batch data transmission method and device

    CN110311847A

  • Substation auxiliary equipment data acquisition system based on Modbus protocol

    CN114301998A

  • Power grid electrical state monitoring system

    CN116131449A

  • Blank mask and photomask using the same

    KR102503790B1

Cited By

  • Multi-protocol wired sensor plug-and-play and communication parallel processing method and system

    CN121509541A

  • Method and system for multi-protocol wired sensor plug and play with communication parallel processing

    CN121509541B