Serial data message queue processing method of gateway machine device and gateway machine device

By using the Modbus protocol and message attribute information processing, the problems of slow transmission rate and timeliness in serial communication in power substations were solved, enabling efficient processing of different types of data and improving data processing efficiency and feedback speed.

CN119520433BActive Publication Date: 2025-10-24NANJING ZHENGTU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In power substations, serial communication suffers from slow transmission rates and the inability to unify clock signals, resulting in unique message queue processing methods that make it difficult to effectively handle different types of sensor data, especially the timeliness requirements of switch and analog data.

Method used

The Modbus protocol is used to configure communication addresses and information points for sensors, and remote signaling, telemetry, remote control, and remote adjustment data are processed in batches. Message attribute information is added, and timers and message storage heaps are used to adjust the processing order. The Modbus message information processing queue is used to achieve timely and regular data processing.

Benefits of technology

It improves the data processing efficiency of serial communication, avoids message accumulation, enhances the timeliness of processing different types of data, reduces the CPU processing burden, and improves control and feedback speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119520433B_ABST
    Figure CN119520433B_ABST
Patent Text Reader

Abstract

The application discloses a serial port data message queue processing method and gateway machine equipment of gateway machine equipment, adopts Modbus protocol as a communication protocol, and stores sensor data points of the same sensor register address continuity, read-write function code same and four remote type consistent into a processing data stack, assembles the processing data stack into permanent Modbus message information; assembles the message processing instruction of remote control information point or remote adjustment information point into temporary Modbus message information, and the feedback information of corresponding remote signal information point and remote measurement information point is also assembled into temporary Modbus message information; adopts the mode that the timing traversal message storage stack is combined with host computer instruction, adds Modbus message information into the Modbus message information processing queue of serial port, and the serial port takes out Modbus message information in the Modbus message information processing queue one by one to carry out message processing. The application realizes the regularity of permanent Modbus message information processing, and considers temporary Modbus message information processing and timeliness.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a serial port data message queue processing method and a gateway device of the gateway device and belongs to the internal data transmission technology in a smart power transformation and distribution station. BACKGROUND

[0002] In a power transformation and distribution station, a large number of sensor devices use serial ports for data communication, and serial ports are also very commonly used device communication interfaces of a gateway device, and data communication between the two parties is performed by using a serial line; although serial port communication has the shortcoming of slow transmission speed, due to the advantages in compatibility, stability, cost effectiveness and flexibility, serial port communication still plays an indispensable role in a smart power transformation and distribution station.

[0003] The data packet content conforming to the serial port communication protocol comprises a start bit, main body data, a check bit and a stop bit, and the two parties of serial communication need to agree on the same baud rate, start bit, check bit, stop bit and data packet format to perform normal communication; since serial port communication is transmitted by bit, the transmission rate is slow, and since there is no unified clock signal between the sender and the receiver of serial port communication, the serial port communication message queue processing mode has certain particularity.

[0004] In a power transformation and distribution station, sensor devices involve various types of data, some are on-off quantity or state data, some are analog quantity data, and some are control data of the sensor devices, and the gateway device has different processing modes for these different types of data, for example, on-off quantity state data needs to frequently acquire data information, especially after switch control, on-off quantity control feedback needs to be obtained in time; and some analog quantity data generally changes little, and data information does not need to be frequently read, and the data acquisition interval can be appropriately lengthened. Therefore, different processing strategies need to be adopted for different data information, so as to avoid repeated and low-timeliness data processing. SUMMARY

[0005] The application aims at overcoming the shortcomings in the prior art, and provides a serial port data message queue processing method of a gateway device, fixed message storage stacks are designed to store various Modbus message information, and a Modbus message information processing queue is used to adjust the message processing order, so that repeated creation and deletion of messages can be avoided, and the permanent Modbus message information processing regularity is realized while the temporary Modbus message information processing timeliness is taken into account.

[0006] The technical scheme is as follows.

[0007] The serial data message queue processing method of a gateway machine device adopts Modbus protocol as a communication protocol, configures Modbus communication addresses for sensors, and configures register addresses, read-write function codes and four-remote types for sensor information points; for remote signaling information points and remote measurement information points, sensor data points with continuous register addresses, same read-write function codes and consistent four-remote types in the same sensor are stored in a processing data stack, the processing data stack is translated into a Modbus message, and permanent Modbus message information is formed by adding message attribute information to the Modbus message; message processing instructions of remote control information points or remote adjustment information points are assembled into temporary Modbus message information, and feedback information of corresponding remote signaling information points and remote measurement information points is also assembled into temporary Modbus message information; all Modbus message information of the same four-remote type is stored in a message storage stack in the memory, Modbus message information is added to a serial Modbus message information processing queue by combining the message storage stack with the instructions of the upper computer in a timing traversal manner, and the serial port takes out Modbus message information in the Modbus message information processing queue one by one to process the message.

[0008] Modbus is a serial communication protocol and has become an industry standard for communication protocols in the industrial field; Modbus protocol adopts a master / slave communication mode and a master asks and slave answers mode for data communication; Modbus message involves three information of communication addresses, read-write function codes and register addresses, and Modbus message can be generated according to Modbus message rules as long as the three information is obtained. In the case, each information point of remote control message and remote adjustment message is separately processed, and corresponding remote signaling message and remote measurement message (which can be considered as a result of responding to remote control message and remote adjustment message) is also separately processed to meet the timeliness requirements of regulation and feedback; and other remote signaling message and remote measurement message are combined and framed by using the register address continuity principle.

[0009] Specifically, the message attribute information includes an information point list, a message type, a message receiving length, a message reading period, a retransmission identifier, a Modbus message, a message lock, and a message processing timestamp; for the telesignaling information points and the telemetering information points, the message reading period, the message processing timestamp, and the retransmission identifier of the Modbus message information are comprehensively judged to determine whether the Modbus message information is added to the tail of the Modbus message information processing queue; for the Modbus message information of the remote control information points and the remote adjustment information points, 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 telesignaling information points and the telemetering information points fed back for the remote control information points and the remote adjustment information points, the Modbus message information is inserted into the head of the Modbus message information processing queue in real time or with a delay according to the host computer instruction.

[0010] Specifically, for the telesignaling information points and the telemetering information points, the message reading period, the message processing timestamp, and the retransmission identifier of the Modbus message information are comprehensively judged; if the retransmission identifier is true and the difference between the current time and the message processing timestamp is greater than the message reading period, the retransmission identifier is updated to false, and the Modbus message information is added to the tail of the Modbus message information processing queue; if the retransmission identifier is false, it indicates that the Modbus message information has been added to the Modbus message information processing queue and cannot be repeatedly added.

[0011] 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 determination result is obtained; when a certain Modbus message information is taken out 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 to avoid multiple threads processing the same Modbus message information at the same time, causing data disorder problems; each Modbus message information has a message lock.

[0012] Specifically, the method comprises the following steps:

[0013] Step 1, filing for each sensor and each sensor information point, configuring a Modbus communication address for the sensor, configuring a register address, a read-write function code, and four remote types for the sensor information point; the four remote types include telesignaling, telemetering, remote control, and remote adjustment, constructing the corresponding relationship between the specified remote control information points and the specified telesignaling information points, and constructing the corresponding relationship between the specified remote adjustment information points and the specified telemetering information points;

[0014] Step 2, the gateway machine loads the sensor and the configuration information of the sensor information point;

[0015] Step 3, for the remote information point and the remote measurement information point, the sensor information points are stored in a processing data stack according to the read-write function code and the four remote types of the sensor information points, and the register address range of the processing data stack is recorded. The information of each processing data stack is translated into a Modbus message, including the Modbus communication address of the sensor, the read-write function code, and the register address range. If the register address range of a processing data stack exceeds the length limit of the Modbus message, the register address range is split into two or more Modbus messages according to the length limit of the Modbus message. If the register address range of a processing data stack does not exceed the length limit of the Modbus message, a Modbus message is formed. Each Modbus message is added with message attribute information to form a Modbus message information, including the information point list, the message type, the message receiving length, the message reading period, the retransmission identifier, the Modbus message, the message lock, and the message processing timestamp. The message type is set as a permanent message. All Modbus message information of the same four remote type is stored in a message storage stack in the memory.

[0016] Step 4, a timer (usually a second-level timer) is added for each serial communication service. The gateway machine iterates through the message storage stack. When a Modbus message information is iterated, the message lock of the Modbus message information is first locked, then the retransmission identifier is confirmed to be true, and the difference between the current time and the message processing timestamp is further confirmed to be greater than the message reading period. The retransmission identifier is updated to be false, the Modbus message information is added to the tail of the Modbus message information processing queue, and the message lock of the Modbus message information is released. The next Modbus message information is iterated. If the retransmission identifier is confirmed to be false, or the difference between the current time and the message processing timestamp is confirmed to be less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is iterated.

[0017] 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 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 temporary message, and call the Modbus message information a remote adjustment message; if the gateway receives a remote control instruction or remote adjustment instruction, it directly adds the generated remote control message or remote adjustment message to the head of the Modbus message information processing queue;

[0018] 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 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 temporary message, and call the Modbus message information a telemetry message; if the gateway receives a telesignaling instruction or a telemetry instruction, it will immediately or delayedly add the associated telesignaling message or telemetry message to the head of the Modbus message information processing queue;

[0019] 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 (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, 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.

[0020] The application discloses a gateway device which adopts Modbus protocol as a communication protocol and realizes communication connection with sensors through a serial port.

[0021] The sensor and sensor information point configuration module configures Modbus communication addresses for the sensors, configures register addresses, read-write function codes and four-remote types for sensor information points, builds a corresponding relationship between specified remote control information points and specified remote signal information points, and builds a corresponding relationship between specified remote adjustment information points and specified remote measurement information points.

[0022] The permanent Modbus message translation module performs heap processing on the sensor information points according to the read-write function codes and the four-remote types of the sensor information points, stores 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 heap, translates the processing data heap into a Modbus message, and adds message attribute information to the Modbus message to form a permanent Modbus message.

[0023] The temporary Modbus message translation module assembles message processing instructions of the remote control information points or the remote adjustment information points into temporary Modbus message information, and assembles feedback information of the corresponding remote signal information points and remote measurement information points into temporary Modbus message information.

[0024] The message storage heap is a storage space in the memory and is used for storing all Modbus message information of the same four-remote type.

[0025] The message traversal module regularly traverses the message storage heap, comprehensively judges a message reading period, a message processing time stamp and a retransmission identifier of the Modbus message information, updates the retransmission identifier to false if the retransmission identifier is true and a difference between a current time and the message processing time stamp is greater than the message reading period, and adds the Modbus message information to the tail of the Modbus message information processing queue.

[0026] The message instruction receiving module receives remote control instructions or remote adjustment instructions sent by an upper computer, translates the remote control instructions or the remote adjustment instructions into remote control messages or remote adjustment messages, and directly adds the remote control messages or the remote adjustment messages to the head of the Modbus message information processing queue; receives remote signal data or remote measurement data fed back by the sensors, translates the remote signal data or the remote measurement data into remote signal messages or remote measurement messages, and adds the remote signal messages or the remote measurement messages to the head of the Modbus message information processing queue in real time or with a time delay.

[0027] The message processing module reads the Modbus message information processing queue in sequence. After reading a Modbus message information 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 the permanent message, the message processing time stamp is updated, the retransmission flag is updated to true, the message lock of the Modbus message information is released, and for the temporary message, the memory is released for message recycling. If the message processing fails, for the permanent message, the retransmission flag is updated to true, the message lock of the Modbus message information is released, and for the temporary message, the memory is released for message recycling.

[0028] Specifically, the permanent Modbus message translation module processes the sensor information points according to the read-write function code and the four-remote type, and stores the sensor information points with the same register address, the same read-write function code and the same four-remote type in a processing data stack, and records the register address range of the processing data stack. The information of each processing data stack is translated into a Modbus message. If the register address range of a processing data stack exceeds the length limit of the Modbus message, the register address range is split according to the length limit of the Modbus message to form two or more Modbus messages, otherwise one Modbus message is formed. The Modbus message is added with message attribute information to form a Modbus message information, and the message type is set to permanent message.

[0029] Specifically, the temporary Modbus message translation module translates the message processing instruction of the specified 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 as a temporary message, and refers to the Modbus message information as a remote control message; translates the feedback information of the specified 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 as a temporary message, and refers to the Modbus message information as a remote signaling message; translates the message processing instruction of the specified remote adjustment information point into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type as a temporary message, and refers to the Modbus message information as a remote adjustment message; and translates the feedback information of the specified remote measurement information point associated with the remote adjustment message into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type as a temporary message, and refers to the Modbus message information as a remote measurement message.

[0030] Specifically, the message traversal module periodically traverses the message storage stack. When a Modbus message information is traversed, the message lock of the Modbus message information is first locked, then it is confirmed that the retransmission identifier is true, and it is further confirmed that the difference between the current time and the message processing timestamp is greater than the message reading period. Then, the retransmission identifier is updated to false, the Modbus message information is added to the tail of the Modbus message information processing queue, and finally the message lock of the Modbus message information is released, and the next Modbus message information is traversed. If it is confirmed that the retransmission identifier is false, or the difference between the current time and the message processing timestamp is less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

[0031] Beneficial effects: The gateway device serial port data message queue processing method and gateway device provided by the application have the following advantages compared with the prior art: 1. The Modbus message is added with message reading period, message processing timestamp, retransmission identifier and other message attribute information, which avoids the message accumulation problem caused by the mismatch between the configured reading speed and the actual serial port reading and writing period if too many serial port access devices or too many sensor information points are connected; 2. The remote control message and remote adjustment message are inserted at the head of the Modbus message information processing queue, which improves the control and adjustment response speed and performance; 3. The remote signaling message and remote measurement message of the feedback data point are set as temporary messages, which improves the feedback speed of the control and adjustment; 4. The data stack is initialized according to the sensor communication address, register address range, read-write function code and four remote types of data points during initialization, which avoids repeated information point framing operations and reduces the CPU processing process; 5. The 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 avoids repeated creation and deletion of messages, and at the same time, the permanent Modbus message information processing regularity is realized, and the timeliness of temporary Modbus message information processing is considered. BRIEF DESCRIPTION OF DRAWINGS

[0032] Figure 1 The figure is a flowchart of the Modbus message information processing queue construction process in the method of the application.

[0033] Figure 2 The figure is a flowchart of the message processing process in the method of the application. DETAILED DESCRIPTION

[0034] The application will be specifically introduced in combination with the drawings and specific embodiments.

[0035] As shown in Figure 1 , Figure 2 , a gateway device serial port data message queue processing method comprises the following steps:

[0036] Step 1, file each sensor and each sensor information point, configure Modbus communication address for the sensor, configure register address, read-write function code and four remote types for the sensor information point; the four remote types include remote signaling, remote measurement, remote control and remote adjustment, the corresponding relationship between the specified remote control information point and the specified remote signaling information point is constructed, and the corresponding relationship between the specified remote adjustment information point and the specified remote measurement information point is constructed;

[0037] Step 2, the gateway machine loads the configuration information of the sensor and the sensor information point;

[0038] Step 3, for the remote information point and remote sensing information point, according to the read-write function code and four remote type of sensor information point, the same sensor in the register address continuous, read-write function code and four remote type consistent sensor information point is stored in a processing data stack, and the register address range of the processing data stack is recorded; the information of each processing data stack is translated into Modbus message, including the Modbus communication address of the sensor, the read-write function code, the register address range; if the register address range of a processing data stack exceeds the length limit of Modbus message, the register address range is split according to the length limit of Modbus message to form two or more Modbus messages; if the register address range of a processing data stack does not exceed the length limit of Modbus message, a Modbus message is formed; each Modbus message is added with message attribute information to form Modbus message information, and the message attribute information includes information point list, message type, message receiving length, message reading period, retransmission identification, Modbus message, message lock and message processing timestamp, and the message type is set as permanent message; all Modbus message information of the same four remote type is stored in a message storage stack in the memory;

[0039] Step 4, a timer is added for each serial communication service, and the gateway machine iterates the message storage stack, when a Modbus message information is iterated, the message lock of the Modbus message information is first locked, then the retransmission identification is confirmed to be true, and further the difference between the current time and the message processing timestamp is confirmed to be greater than the message reading period, then the retransmission identification is updated to false, the Modbus message information is added to the tail of the Modbus message information processing queue, and finally the message lock of the Modbus message information is released, and the next Modbus message information is iterated; if the retransmission identification is confirmed to be false, or the difference between the current time and the message processing timestamp is confirmed to be less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is iterated;

[0040] Step 5, the remote control command sent by the host computer to specify the remote control information point is translated into a Modbus message, the Modbus message is added with message attribute information to form a Modbus message information, and the message type is set as a temporary message, and the Modbus message information is called a remote control message; the remote control command sent by the host computer to specify the remote control information point is translated into a Modbus message, the Modbus message is added with message attribute information to form a Modbus message information, and the message type is set as a temporary message, and the Modbus message information is called a remote control message; if the gateway computer receives a remote control command or a remote control command, the generated remote control message or remote control message is directly added to the head of the Modbus message information processing queue;

[0041] Step 6, the remote control message associated with the remote control message is translated into a Modbus message, the Modbus message is added with message attribute information to form a Modbus message information, and the message type is set as a temporary message, and the Modbus message information is called a remote control message; the remote control message associated with the remote control message is translated into a Modbus message, the Modbus message is added with message attribute information to form a Modbus message information, and the message type is set as a temporary message, and the Modbus message information is called a remote control message; if the gateway computer receives a remote control command or a remote control command, the related remote control message or remote control message is added to the head of the Modbus message information processing queue in time or with a delay;

[0042] Step 7, a first-in-first-out Modbus message information processing queue is added for each serial communication service, a thread is started, and the Modbus message information processing queue is read in order in the thread. When the gateway computer reads a Modbus message information 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 executed: if the message processing is successful, for a permanent message, the message processing timestamp is updated, and the retransmission identifier 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 recycling; if the message processing fails, for a permanent message, the retransmission identifier 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 recycling.

[0043] Whether the message is processed successfully depends on the Modbus message content. For control messages and adjustment messages, there can be an action of writing to the serial port and an action of information feedback. If information feedback is needed to confirm whether the processing is successful, the message timeout time and the message receiving length need to be set. If the feedback message length is too short compared with the message receiving length, or the feedback message exceeds the message timeout time, it is considered that the message processing fails.

[0044] In the present case, each message attribute information is defined as follows:

[0045] 1. Information point list: used to record the sensor information point list involved in the Modbus message. After reading the sensor information point, the sensor information point data can be conveniently refreshed.

[0046] 2. Message type: including permanent message and temporary message. The permanent message represents a message that will exist permanently during the program duration. It is generally a sensor remote signaling or remote measurement data point message. The temporary message is generally a Modbus message generated by remote control or remote adjustment instruction and a Modbus message generated by feedback remote signaling or remote measurement data point. It needs to be released and deleted after use.

[0047] 3. Message receiving length: the receiving message length is generally determined by the register start and end range involved in the message, which is used as the basis for judging whether the message receiving is completed.

[0048] 4. Message reading period: generally determined according to the four remote types of the data stack. The remote signaling information point message reading period is short and needs to be read every unit period (generally seconds). The remote measurement data can extend the message reading period, which can be configured according to the demand.

[0049] 5. Resendable identification: to avoid the problems of too large Modbus message information processing queue or repeated content, if the Modbus message information is in the sending queue, the resendable identification is set to false, indicating that it cannot be sent again. Otherwise, the resendable identification is set to true, indicating that it can be sent again.

[0050] 6. Modbus message: the content of the Modbus message is determined and does not need to be changed. The Modbus message can be solidified.

[0051] 7. Message lock: to adapt to the multi-thread processing demand, a message lock is added to each Modbus message.

[0052] 8. Message processing timestamp: records the processing time of each Modbus message, which is used to judge whether the message processing period is exceeded.

[0053] All the message attribute information is combined into a Modbus message information, and is stored into different message storage stacks according to the four remote types.

[0054] A gateway device adopts Modbus protocol as a communication protocol, and realizes communication connection with sensors through a serial port, and comprises 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.

[0055] The sensor and sensor information point configuration module configures Modbus communication addresses for sensors, configures register addresses, read-write function codes and four remote types for sensor information points, constructs a corresponding relationship between specified remote control information points and specified remote signal information points, and constructs a corresponding relationship between specified remote adjustment information points and specified remote measurement information points.

[0056] The permanent Modbus message translation module processes register addresses, read-write function codes and four remote types of sensor information points according to remote signal information points and remote measurement information points, stores sensor information points with continuous register addresses, same read-write function codes and consistent four remote types in a same sensor into a processing data stack, and records register address ranges of the processing data stack; translates information of each processing data stack into a Modbus message, splits the register address range according to a Modbus message length limit if the register address range of a certain processing data stack exceeds the Modbus message length limit, forms two or more Modbus messages, or forms a Modbus message if not; adds message attribute information to the Modbus message to form a Modbus message information, and sets a message type as a permanent message.

[0057] The temporary Modbus message translation module translates the message processing instruction of the specified 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 as a temporary message, and refers to the Modbus message information as a remote control message; translates the feedback information of the specified 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 as a temporary message, and refers to the Modbus message information as a remote signaling message; translates the message processing instruction of the specified remote adjustment information point into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type as a temporary message, and refers to the Modbus message information as a remote adjustment message; and translates the feedback information of the specified remote measurement information point associated with the remote adjustment message into a Modbus message, adds message attribute information to the Modbus message to form Modbus message information, sets the message type as a temporary message, and refers to the Modbus message information as a remote measurement message.

[0058] The message storage stack is a storage space in the memory, and is used for storing all Modbus message information of the same four-remote type.

[0059] The message traversal module periodically traverses the message storage stack. When a Modbus message information is traversed, the message lock of the Modbus message information is first locked, then it is confirmed that the retransmission identifier is true, and it is further confirmed that the difference between the current time and the message processing time stamp is greater than the message reading period, the retransmission identifier is updated to be false, the Modbus message information is added to the tail of the Modbus message information processing queue, and finally the message lock of the Modbus message information is released, and the next Modbus message information is traversed. If it is confirmed that the retransmission identifier is false, or it is confirmed that the difference between the current time and the message processing time stamp is less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

[0060] The message instruction receiving module receives the remote control instruction or the remote adjustment instruction sent by the upper computer, first translates the remote control instruction or the remote adjustment instruction into a remote control message or a remote adjustment message, and then directly adds the remote control message or the remote adjustment message to the head of the Modbus message information processing queue; receives the remote signaling data or the remote measurement data fed back by the sensor, first translates the data or the remote measurement data into a remote signaling message or a remote measurement message, and then adds the remote signaling message or the remote measurement message to the head of the Modbus message information processing queue in real time or with a delay;

[0061] The message processing module reads the Modbus message information processing queue in sequence, reads one Modbus message information from the head of the Modbus message information processing queue each time, first locks the message lock of the Modbus message information, and then executes message processing; if the message processing is successful, for non-temporary message, the message processing time stamp is updated, the retransmission identification is updated to true, the message lock of the Modbus message information is released, and for temporary message, the memory is released for message recycling; if the message processing fails, for non-temporary message, the retransmission identification is updated to true, the message lock of the Modbus message information is released, and for temporary message, the memory is released for message recycling.

[0062] The basic principles, main features and advantages of the present application are shown and described above. Those skilled in the art should understand that the above-mentioned embodiments do not limit the present application in any form, and any technical solutions obtained by equivalent replacement or equivalent transformation fall within the protection scope of the present application.

Claims

1. A serial data message queue processing method for a gateway machine device, characterized by: Modbus protocol is used as the communication protocol, Modbus communication address is configured for the sensor, register address, read-write function code and four-remote type are configured for the sensor information point; for the remote information point and the remote measurement information point, the sensor data points with the same register address, the same read-write function code and the same four-remote type in the same sensor are stored in a processing data stack, the processing data stack is translated into a Modbus message, and permanent Modbus message information is formed by adding message attribute information to the Modbus message; 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 information point and remote measurement information point is also assembled into temporary Modbus message information; all the Modbus message information of the same four-remote type is stored in a message storage stack in the memory, the Modbus message information is added to the Modbus message information processing queue of the serial port by combining the message storage stack with the instructions of the upper computer, and the serial port takes out the Modbus message information in the Modbus message information processing queue one by one to process the message; The message attribute information includes an information point list, a message type, a message receiving length, a message reading period, a retransmission identifier, a Modbus message, a message lock and a message processing timestamp; for the remote information point and the remote measurement information point, the message reading period, the message processing timestamp and the retransmission identifier of the Modbus message information are comprehensively judged to determine whether the Modbus message information is added 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 instructions of the upper computer; for the Modbus message information of the remote information point and the remote measurement information point fed back to the remote control information point and the remote adjustment information point, the Modbus message information is inserted into the head of the Modbus message information processing queue in time or with a delay according to the instructions of the upper computer.

2. The method for processing serial data message queue of gateway machine equipment according to claim 1, characterized in that: For the remote information point and the remote measurement information point, the message reading period, the message processing timestamp and the retransmission identifier of the Modbus message information are comprehensively judged, if the retransmission identifier is true and the difference between the current time and the message processing timestamp is greater than the message reading period, the retransmission identifier is updated to false, and the Modbus message information is added to the tail of the Modbus message information processing queue.

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

4. The method of claim 1, wherein the gateway server device serial data packet queue processing method is characterized by: The method comprises the following steps: Step1, build a file for each sensor and each sensor information point, configure Modbus communication address for the sensor, configure register address, read-write function code and four remote types for the sensor information point; the four remote types include four types of remote signaling, remote measurement, remote control and remote adjustment, build the corresponding relationship between the specified remote control information point and the specified remote signaling information point, and build the corresponding relationship between the specified remote adjustment information point and the specified remote measurement information point; Step2, the gateway machine loads the configuration information of the sensor and the sensor information point; Step3, for remote signaling information points and remote measurement information points, according to the read-write function code and four remote types of sensor information points, the same sensor information points with continuous register address, same read-write function code and consistent four remote types are stored in a processing data stack, and the register address range of the processing data stack is recorded; the information of each processing data stack is translated into a Modbus message, including the Modbus communication address of the sensor, the read-write function code, and the register address range; if the register address range of a certain processing data stack exceeds the length limit of the Modbus message, the register address range is split according to the length limit of the Modbus message to form two or more Modbus messages; if the register address range of a certain processing data stack does not exceed the length limit of the Modbus message, a Modbus message is formed; add message attribute information to each Modbus message to form a Modbus message information, the message attribute information includes information point list, message type, message receiving length, message reading period, retransmission identification, Modbus message, message lock and message processing timestamp, and the message type is set to permanent message; all Modbus message information of the same four remote type is stored in a message storage stack in the memory; Step4, add a timer to each serial communication service, the gateway machine iterates the message storage stack at a fixed time, when it iterates to a certain Modbus message information, first locks the message lock of the Modbus message information, then confirms that the retransmission identification is true, and further confirms that the difference between the current time and the message processing timestamp is greater than the message reading period, then updates the retransmission identification to false, adds the Modbus message information to the tail of the Modbus message information processing queue, and finally releases the message lock of the Modbus message information, and iterates the next Modbus message information; if the retransmission identification is false, or the difference between the current time and the message processing timestamp is less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is iterated; 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 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 temporary message, and call the Modbus message information a remote adjustment message; if the gateway receives a remote control instruction or remote adjustment instruction, it directly adds the generated remote control message or remote adjustment message 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 temporary message, and refer to the Modbus message information as the 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 temporary message, and refer to the Modbus message information as the telemetry message; If the gateway receives a telesignaling command or a telemetering command, it will immediately or with delay 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 port 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, and the message lock of the Modbus message information is released. 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, and the message lock of the Modbus message information is released. For temporary messages, the memory is released for message recovery.

5. A gateway machine apparatus, characterized by: The Modbus protocol is used as the communication protocol, and the communication connection with the sensor is realized through the serial port. It includes 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; The sensor and sensor information point configuration module configures a Modbus communication address for the sensor, configures a register address, a read-write function code and a four-remote type for the sensor information point, constructs a corresponding relationship between a specified remote control information point and a specified remote signal information point, and constructs a corresponding relationship between a specified remote adjustment information point and a specified remote measurement information point; The permanent Modbus message translation module, for remote signal information points and remote measurement information points, performs a heap processing according to the read-write function code and the four-remote type of the sensor information point, stores sensor information points with continuous register addresses, the same read-write function code and the same four-remote type in the same sensor into a processing data heap, translates the processing data heap into a Modbus message, and adds message attribute information to the Modbus message to form a permanent Modbus message information; The temporary Modbus message translation module assembles message processing instructions of a remote control information point or a remote adjustment information point into a temporary Modbus message information, and feedback information of a corresponding remote signal information point and remote measurement information point is also assembled into a temporary Modbus message information; The message storage heap is a storage space in the memory, and is used for storing all Modbus message information of the same four-remote type; The message traversal module periodically traverses the message storage heap, comprehensively judges a message reading period, a message processing time stamp and a retransmission identifier of the Modbus message information, if the retransmission identifier is true and a difference between a current time and the message processing time stamp is greater than the message reading period, the retransmission identifier is updated to be false, and the Modbus message information is added to a tail of the Modbus message information processing queue; The message instruction receiving module receives a remote control instruction or a remote adjustment instruction sent by an upper computer, translates the remote control instruction or the remote adjustment instruction into a remote control message or a remote adjustment message, and then directly adds the remote control message or the remote adjustment message to a head of the Modbus message information processing queue; receives remote signal data or remote measurement data fed back by the sensor, translates the remote signal data or the remote measurement data into a remote signal message or a remote measurement message, and then adds the remote signal message or the remote measurement message to the head of the Modbus message information processing queue in real time or with a delay; The message processing module reads the Modbus message information processing queue in sequence, reads a Modbus message information from the head of the Modbus message information processing queue each time, locks the Modbus message information first, and then performs message processing; if the message processing is successful, for a permanent message, a message processing time stamp is updated, a retransmission identifier is updated to be true, and a message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recycling; if the message processing fails, for a permanent message, the retransmission identifier is updated to be true, and the message lock of the Modbus message information is released, and for a temporary message, the memory is released for message recycling.

6. The gateway server device of claim 5, wherein: The permanent Modbus message translation module, for the remote information points and the remote measurement information points, carries out the stack processing according to the read-write function code of the sensor information points and the four remote types, stores the sensor information points with the same register address in a sensor, the same read-write function code and the same four remote type in a processing data stack, and records the register address range of the processing data stack; translates the information of each processing data stack into a Modbus message, splits the register address range according to the Modbus message length limit if the register address range of a processing data stack exceeds the Modbus message length limit, forms two or more Modbus messages, or forms one Modbus message otherwise; adds the message attribute information to the Modbus message to form a Modbus message information, and sets the message type as a permanent message.

7. The gateway device of claim 5, wherein: The temporary Modbus message translation module translates the message processing instruction of the specified remote control information point into a Modbus message, adds the message attribute information to the Modbus message to form a Modbus message information, sets the message type as a temporary message, and calls the Modbus message information a remote control message; translates the feedback information of the specified remote information point associated with the remote control message into a Modbus message, adds the message attribute information to the Modbus message to form a Modbus message information, sets the message type as a temporary message, and calls the Modbus message information a remote information message; translates the message processing instruction of the specified remote regulation information point into a Modbus message, adds the message attribute information to the Modbus message to form a Modbus message information, sets the message type as a temporary message, and calls the Modbus message information a remote regulation message; translates the feedback information of the specified remote measurement information point associated with the remote regulation message into a Modbus message, adds the message attribute information to the Modbus message to form a Modbus message information, sets the message type as a temporary message, and calls the Modbus message information a remote measurement message.

8. The gateway device of claim 5, wherein: The message traversal module periodically traverses the message storage stack, when a Modbus message information is traversed, first locks the message lock of the Modbus message information, then confirms that the retransmission identifier is true, and further confirms that the difference between the current time and the message processing timestamp is greater than the message reading period, updates the retransmission identifier to false, adds the Modbus message information to the tail 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 the retransmission identifier is confirmed to be false, or the difference between the current time and the message processing timestamp is confirmed to be less than or equal to the message reading period, the message lock of the Modbus message information is released, and the next Modbus message information is traversed.

Citation Information

Patent Citations

  • Substation auxiliary equipment data acquisition system based on Modbus protocol

    CN114301998A

  • Power grid electrical state monitoring system

    CN116131449A