A method and system for remote monitoring of tea leaf pretreatment equipment

By creating a composite state matrix in the tea leaf pretreatment equipment to manage QoS2 messages, batch persistence, and dynamic adjustment of timeout retransmission, the problems of storage resource occupation and retransmission caused by communication instability are solved, and the data transmission efficiency and integrity are improved.

CN123123396APending Publication Date: 2026-11-17XINYANG WENXIN TEA CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611526030.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In remote monitoring of tea leaf pretreatment equipment in mountainous or remote areas, unstable communication links lead to frequent message transmissions, high storage resource consumption, and unreasonable retransmission strategies, affecting communication efficiency and data integrity.

Method used

By creating a composite state matrix in volatile memory, QoS2 messages are managed and message activity is calculated. Message states are persisted in batches, and timeout retransmission policies and hash digest comparisons are dynamically adjusted to optimize the message interaction process.

Benefits of technology

It reduces storage hardware wear and tear, improves data integrity and communication efficiency, reduces network congestion and response latency, and achieves lightweight state synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123396A_ABST
    Figure CN123123396A_ABST
Patent Text Reader

Abstract

This invention provides a remote monitoring method and system for tea leaf pretreatment equipment, comprising: a monitoring terminal collecting equipment operating parameters to generate QoS2 messages with service identifiers and forming a message set; constructing a composite state matrix in volatile memory, using the unique message identifier as the first dimension index and a five-element state array as the second dimension to calculate message activity; updating the activity when the message transmission state changes, and batch writing the state to non-volatile memory; generating a response timeout duration based on the message activity and process stage time adjustment coefficient, combined with the basic timeout duration and adjustment factor, and starting a retransmission timer when sending a message; after the session is disconnected and reconnected, the terminal extracts message state items that have not completed the QoS2 protocol process to construct an ordered sequence, and generates a corresponding hash digest to upload to the server; when the digests are inconsistent, the terminal reports the ordered sequence of message state items, receives a list of differing message state items, and completes message retransmission or discard processing accordingly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of tea leaf pretreatment, and in particular relates to a remote monitoring method and system for tea leaf pretreatment equipment. Background Technology

[0002] In recent years, the informatization level of tea leaf pretreatment processes has been continuously improving. Real-time collection of equipment operating parameters through remote monitoring terminals has become an important means of ensuring the quality of tea processing. Since tea processing workshops are mostly located in mountainous or remote areas, wireless communication networks are easily affected by terrain, environment, and interference from on-site equipment, resulting in poor communication link stability. To ensure the reliability of core process data and control command transmission, monitoring systems typically employ QoS2-level messaging protocols that support "exactly-once" delivery semantics. During standard QoS2 protocol interaction, to avoid message loss or duplicate delivery, both communicating parties need to complete a multi-step confirmation process. The monitoring terminal also needs to continuously record message delivery status in non-volatile storage media to cope with unexpected power outages, network interruptions, or system anomalies.

[0003] In practical applications, tea leaf pretreatment equipment is typically equipped with multiple types of sensors, continuously generating high-frequency, multi-type operating parameters, resulting in frequent generation, acknowledgment, and status transitions of QoS2 messages. Conventional protocol processing methods usually perform a single write operation on non-volatile storage media each time the message status changes. Frequent fragmented I / O not only consumes system resources but may also accelerate the wear and tear of storage chips. Furthermore, existing message transmission mechanisms mostly use fixed acknowledgment timeout durations to trigger retransmissions, failing to dynamically adjust for the varying timeliness differences in data across different process stages such as withering, sorting, cleaning, and spreading. Fixed timeouts can easily trigger concentrated retransmissions during network congestion, increasing channel load, and may cause response delays after network recovery due to waiting for a fixed period. In addition, when field communication conditions are unstable, monitoring terminals are prone to session disconnections and reconnections. After reconnection, the terminal and server need to align the status of incompletely delivered QoS2 messages. Existing methods often rely on transmitting a complete list of unacknowledged messages, resulting in significant communication overhead in weak network environments. Therefore, there is an urgent need for an optimized remote monitoring data interaction scheme for equipment to reduce I / O losses during message status storage, adjust timeout retransmission strategies according to actual working conditions, and achieve lightweight status synchronization after disconnection and reconnection. Summary of the Invention

[0004] According to one aspect of the present invention, a remote monitoring method for tea leaf pretreatment equipment is proposed, which is used to rationally schedule the storage process of message status to reduce I / O loss and adjust the timeout retransmission strategy according to the actual working conditions, including the following steps: Based on the device operating parameters collected by the monitoring terminal, a QoS2 message carrying a service type identifier is generated, and multiple QoS2 messages are organized into a message set; a composite state matrix is ​​created for the message set in volatile memory. The composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation phase, message activity, persistence flag and timer start time as the second dimension, and the message activity is calculated. When the transmission status of any message in the message set changes, the message activity level is updated, the status information of all messages in the message set is written in batches to a non-volatile storage medium, and the persistence flag of the corresponding message is set to persistent after successful writing; when sending the QoS2 message, the message activity level of the message to be sent in the composite status matrix and the current process stage query time adjustment coefficient are used, and the response timeout duration is generated based on the basic timeout duration, the time adjustment coefficient and the adjustment factor to start the retransmission timer; After the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and sent to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with discrepancies, and performs retransmission or discard operations based on the list of message status items.

[0005] Optionally, the step of creating a composite state matrix for the message set in volatile memory, wherein the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array including the transmission count, QoS2 acknowledgment phase, message activity, persistence flag, and timer start time as the second dimension, including: Send a memory allocation instruction to allocate an independent data space of a preset capacity in volatile memory; Parse the header of the latest message that has entered memory, extract a fixed-length field as the unique identifier of the message, and store the identifier as the first dimension index in the composite state matrix; The send count, QoS2 confirmation phase, message activity, persistence flag, and timer start time in the five-element state array corresponding to the unique identifier in the composite state matrix are all initialized to preset default constant values.

[0006] Optionally, the calculation of message activity includes: When the service type of the message is identified as a mandatory service such as alarm interruption or device stoppage, a basic activity initial value is set to a preset constant. When the service type of the message is identified as a regular service such as withering, sorting, cleaning or spreading, the corresponding initial value of basic activity is determined according to the preset mapping table between service type and initial value of basic activity. The cumulative number of times the message was interrupted or unacknowledged during historical transmission is counted, and the cumulative number is multiplied by the system's built-in attenuation coefficient to obtain the activity deviation value; The remaining activity value is obtained by subtracting the activity deviation value from the initial basic activity value. When the remaining activity value is less than the preset positive lower limit value, it is corrected to the positive lower limit value, and the remaining activity value is used as the message activity value of the message.

[0007] Optionally, updating the message activity level when the transmission status of any message in the message set changes includes: When a QoS2 acknowledgment response message corresponding to the message is received, the current message activity value of the message is read from the composite state matrix; The calculated result is obtained by adding the read message activity value to the preset reward increment parameter; The calculation result is compared with a preset activity limit value. If the calculation result is greater than the preset activity limit value, the calculation result is corrected to the preset activity limit value. Otherwise, the calculation result remains unchanged, and the value after comparison is used as the latest message activity value and overwritten to the position corresponding to the message in the composite state matrix to complete the update.

[0008] Optionally, the step of batch writing the status information of all messages in the message set to a non-volatile storage medium, and setting the persistence flag of the corresponding message to persistent after successful writing, includes: Extract all messages to be batch persisted, and obtain the data stream of the message itself and its corresponding complete state information in the composite state matrix; The data stream of the message is concatenated with the complete status information and merged into a continuous data block or byte sequence; The storage control interface is invoked to write the data block or byte sequence as a whole into the storage area of ​​the non-volatile storage medium, and the persistence flag of the corresponding message is set to persistent after successful saving.

[0009] Optionally, the step of adjusting the query time based on the message activity of the message to be sent in the composite state matrix and the current process stage includes: The monitoring terminal determines the current tea leaf pretreatment process stage based on the service type identifier and one or more operating parameters, including temperature, humidity and motor speed. The process stage includes room temperature withering, sorting, washing and dehydration or hot air withering. Among them, when the real-time temperature parameter of the current pretreatment equipment read by the temperature sensing hardware is greater than or equal to the preset temperature threshold, it is determined that the current tea leaf pretreatment process is in the hot air withering stage. The preset process stage and time coefficient mapping table is invoked, and the corresponding configuration parameters are retrieved based on the current tea leaf pretreatment process stage and the current message activity interval. The values ​​in the configuration parameters are extracted as the time adjustment coefficients and used to calculate the response timeout duration.

[0010] Optionally, the generation of the response timeout based on the base timeout duration, the time adjustment coefficient, and the adjustment factor includes: Extract the preset base timeout duration, multiply the base timeout duration by the time adjustment coefficient obtained from the query, and obtain the first intermediate result; Obtain a preset negative time constant parameter, multiply the negative time constant parameter by the message activity of the current message, and obtain a negative adjustment factor determined by the message activity. The first intermediate result is added to the negative adjustment factor to obtain the final result. When the final result is less than the preset minimum timeout duration, the final result is corrected to the preset minimum timeout duration, and the final result is used as the generated response timeout duration.

[0011] Optionally, after the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and then sent to the server, including: Traverse the non-volatile storage medium and extract the message status entries of all messages that are persistently marked as persistent and have not completed the QoS2 protocol process; All extracted message status items are arranged according to a preset sorting rule and combined to generate a complete ordered sequence of message status items. The ordered sequence of message status items is input into the hash calculation unit, the hash algorithm is executed, and the hash digest corresponding to the ordered sequence of message status items is generated and output.

[0012] According to another aspect of the present invention, a remote monitoring system for tea leaf pretreatment equipment is provided, comprising the following modules: The acquisition module is used to generate QoS2 messages carrying service type identifiers based on the device operating parameters collected by the monitoring terminal, and organize multiple QoS2 messages into a message set; create a composite state matrix for the message set in volatile memory, wherein the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation stage, message activity, persistent flag and timer start time as the second dimension, and calculates the message activity; The generation module is used to update the message activity level when the transmission status of any message in the message set changes, batch write the status information of all messages in the message set to a non-volatile storage medium, and set the persistence flag of the corresponding message to persistent after successful writing; when sending the QoS2 message, it queries the time adjustment coefficient of the message to be sent in the composite status matrix and the current process stage, and generates the response timeout duration based on the basic timeout duration, the time adjustment coefficient and the adjustment factor to start the retransmission timer; The execution module is used to generate a hash digest of the ordered sequence of message status items based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process after the communication session is disconnected and reconnected, and send it to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with differences, and performs retransmission or discard operation based on the list of message status items.

[0013] Preferably, the step of creating a composite state matrix for the message set in volatile memory, wherein the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array including the transmission count, QoS2 acknowledgment phase, message activity, persistence flag, and timer start time as the second dimension, including: Send a memory allocation instruction to allocate an independent data space of a preset capacity in volatile memory; Parse the header of the latest message that has entered memory, extract a fixed-length field as the unique identifier of the message, and store the identifier as the first dimension index in the composite state matrix; The send count, QoS2 confirmation phase, message activity, persistence flag, and timer start time in the five-element state array corresponding to the unique identifier in the composite state matrix are all initialized to preset default constant values.

[0014] Preferably, the calculation of message activity includes: When the service type of the message is identified as a mandatory service such as alarm interruption or device stoppage, a basic activity initial value is set to a preset constant. When the service type of the message is identified as a regular service such as withering, sorting, cleaning or spreading, the corresponding initial value of basic activity is determined according to the preset mapping table between service type and initial value of basic activity. The cumulative number of times the message was interrupted or unacknowledged during historical transmission is counted, and the cumulative number is multiplied by the system's built-in attenuation coefficient to obtain the activity deviation value; The remaining activity value is obtained by subtracting the activity deviation value from the initial basic activity value. When the remaining activity value is less than the preset positive lower limit value, it is corrected to the positive lower limit value, and the remaining activity value is used as the message activity value of the message.

[0015] Preferably, updating the message activity level when the transmission status of any message in the message set changes includes: When a QoS2 acknowledgment response message corresponding to the message is received, the current message activity value of the message is read from the composite state matrix; The calculated result is obtained by adding the read message activity value to the preset reward increment parameter; The calculation result is compared with a preset activity limit value. If the calculation result is greater than the preset activity limit value, the calculation result is corrected to the preset activity limit value. Otherwise, the calculation result remains unchanged, and the value after comparison is used as the latest message activity value and overwritten to the position corresponding to the message in the composite state matrix to complete the update.

[0016] Preferably, the step of batch writing the status information of all messages in the message set to a non-volatile storage medium, and setting the persistence flag of the corresponding message to persistent after successful writing, includes: Extract all messages to be batch persisted, and obtain the data stream of the message itself and its corresponding complete state information in the composite state matrix; The data stream of the message is concatenated with the complete status information and merged into a continuous data block or byte sequence; The storage control interface is invoked to write the data block or byte sequence as a whole into the storage area of ​​the non-volatile storage medium, and the persistence flag of the corresponding message is set to persistent after successful saving.

[0017] Preferably, the step of adjusting the query time based on the message activity level of the message to be sent in the composite state matrix and the current process stage includes: The monitoring terminal determines the current tea leaf pretreatment process stage based on the service type identifier and one or more operating parameters, including temperature, humidity and motor speed. The process stage includes room temperature withering, sorting, washing and dehydration or hot air withering. Among them, when the real-time temperature parameter of the current pretreatment equipment read by the temperature sensing hardware is greater than or equal to the preset temperature threshold, it is determined that the current tea leaf pretreatment process is in the hot air withering stage. The preset process stage and time coefficient mapping table is invoked, and the corresponding configuration parameters are retrieved based on the current tea leaf pretreatment process stage and the current message activity interval. The values ​​in the configuration parameters are extracted as the time adjustment coefficients and used to calculate the response timeout duration.

[0018] Preferably, the generation of response timeout based on the base timeout duration, the time adjustment coefficient, and the adjustment factor includes: Extract the preset base timeout duration, multiply the base timeout duration by the time adjustment coefficient obtained from the query, and obtain the first intermediate result; Obtain a preset negative time constant parameter, multiply the negative time constant parameter by the message activity of the current message, and obtain a negative adjustment factor determined by the message activity. The first intermediate result is added to the negative adjustment factor to obtain the final result. When the final result is less than the preset minimum timeout duration, the final result is corrected to the preset minimum timeout duration, and the final result is used as the generated response timeout duration.

[0019] Preferably, after the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and then sent to the server, including: Traverse the non-volatile storage medium and extract the message status entries of all messages that are persistently marked as persistent and have not completed the QoS2 protocol process; All extracted message status items are arranged according to a preset sorting rule and combined to generate a complete ordered sequence of message status items. The ordered sequence of message status items is input into the hash calculation unit, the hash algorithm is executed, and the hash digest corresponding to the ordered sequence of message status items is generated and output.

[0020] The present invention has at least the following beneficial effects: 1. This invention manages QoS2 messages in a set manner and constructs a composite state matrix containing parameters such as message activity in volatile memory, thereby improving the centralized maintenance and fast access capability of message state.

[0021] 2. This invention performs batch non-volatile persistence when the message state changes, reducing high-frequency single writes to the storage medium, reducing storage hardware wear and tear, and improving data integrity under abnormal conditions.

[0022] 3. During message sending, this invention generates a response timeout duration based on message activity and the current process stage, enabling the retransmission strategy to match the data timeliness requirements under different operating conditions.

[0023] 4. By dynamically adjusting the response waiting time, this invention reduces invalid retransmissions and response delays caused by fixed timeouts, which helps alleviate network congestion and improve communication bandwidth utilization.

[0024] 5. When communication is disconnected and reconnected, this invention uses the ordered sequence hash digest of the message status item of the incomplete message for lightweight comparison, reducing the transmission of full status data and realizing fast verification and recovery of the QoS2 process. Attached Figure Description

[0025] Figure 1 A flowchart of the first embodiment; Figure 2 A schematic diagram of the QoS2 message collection, encapsulation, and service identifier generation process for tea leaf pretreatment equipment; Figure 3 The logic block diagram for generating the response timeout duration and starting the retransmission timer. Detailed Implementation

[0026] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0027] In the first embodiment, the present invention proposes a remote monitoring method for tea fresh leaf pretreatment equipment, such as... Figure 1 It includes the following steps: S1. Generate QoS2 messages carrying service type identifiers based on the device operation parameters collected by the monitoring terminal, and organize multiple QoS2 messages into a message set; create a composite state matrix for the message set in volatile memory, the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation stage, message activity, persistent flag and timer start time as the second dimension, and calculate the message activity.

[0028] The monitoring terminal collects real-time operating parameters of the tea leaf pretreatment equipment using temperature, humidity, and motor speed sensors. These parameters are converted into digital signals and encapsulated as a payload for a communication protocol. Without altering the fixed header format of the QoS2 standard message, a service type identifier byte representing the service category (withering, sorting, cleaning, spreading, alarm interruption, or equipment stoppage) is written into the service field of the application layer payload, generating a QoS2 message conforming to the message queue telemetry transmission protocol. A fixed time window is set, and all QoS2 messages generated within this window are aggregated into a message set in the same cache structure. A composite state matrix is ​​established, extracting the 16-bit message identifier of each message in the message set as the row index of the matrix. A five-element state array, consisting of the transmission count, QoS2 acknowledgment stage, message activity, persistence flag, and timer start time, is arranged sequentially and stored as the column data of the matrix. When calculating message activity, the monitoring terminal determines an initial base activity value based on the service type identifier. It then calculates the activity deviation value by combining the cumulative number of communication interruptions or unacknowledged messages during historical transmissions with the system's built-in attenuation coefficient. The message activity is obtained by subtracting the activity deviation value from the initial base activity value and applying a preset positive lower limit for amplitude correction. The processing flow for the monitoring terminal to collect operating parameters and generate QoS2 messages carrying service type identifiers is as follows: Figure 2 As shown.

[0029] In an optional embodiment, the step of creating a composite state matrix for the message set in volatile memory, the composite state matrix being indexed by the unique identifier of the message as the first dimension, and by a five-element state array including a send count, QoS2 acknowledgment phase, message activity, persistence flag, and timer start time as the second dimension, including: Send a memory allocation instruction to allocate an independent data space of a preset capacity in volatile memory; Parse the header of the latest message that has entered memory, extract a fixed-length field as the unique identifier of the message, and store the identifier as the first dimension index in the composite state matrix; The send count, QoS2 confirmation phase, message activity, persistence flag, and timer start time in the five-element state array corresponding to the unique identifier in the composite state matrix are all initialized to preset default constant values.

[0030] A 1MB independent data space is allocated in volatile memory. When a new message enters the memory cache, the message header is parsed, and a 16-bit fixed-length field at a specific byte position, such as 0x1A2B, is extracted as the message's unique identifier. This unique identifier is then stored in the composite state matrix as the first-dimensional index. The storage location corresponding to this unique identifier is located, and initialized default constant values ​​are written sequentially into the memory segment to construct a five-element state array. Specifically, the value representing the transmission count is initialized to 0; the value representing the QoS2 acknowledgment phase is initialized to 0x00, indicating the non-started phase; the value representing message activity is initialized to a baseline value of 100; the value representing the persistence flag is initialized to 0x00; and the unsigned 32-bit integer value representing the timer start time is initialized to 0x00000000, completing the initial state writing of this composite state matrix node.

[0031] In an optional embodiment, calculating message activity includes: When the service type of the message is identified as a mandatory service such as alarm interruption or device stoppage, a basic activity initial value is set to a preset constant. When the service type of the message is identified as a regular service such as withering, sorting, cleaning or spreading, the corresponding initial value of basic activity is determined according to the preset mapping table between service type and initial value of basic activity. The cumulative number of times the message was interrupted or unacknowledged during historical transmission is counted, and the cumulative number is multiplied by the system's built-in attenuation coefficient to obtain the activity deviation value; The remaining activity value is obtained by subtracting the activity deviation value from the initial basic activity value. When the remaining activity value is less than the preset positive lower limit value, it is corrected to the positive lower limit value, and the remaining activity value is used as the message activity value of the message.

[0032] Upon detecting a data packet, the service field of the application layer payload is read. If the parsed identifier value is 0x01 (alarm interruption) or 0x02 (device stoppage), it is determined to be a mandatory service, and the initial value of the message's basic activity level is set to the system's default constant of 100. The statistics module is called to count the cumulative number of times the message's communication connection was interrupted or no acknowledgment was received during historical transmission. Assuming the read value is 3, the system's built-in attenuation coefficient is extracted as 5. The processor performs a multiplication operation: activity deviation value = 3 × 5 = 15. Then, a subtraction operation is performed: remaining activity value = 100 - 15 = 85. A default safety protection lower limit value of 10 is set, and the calculated 85 is compared with 10. Since 85 is not less than 10, the remaining activity value of 85 is written into memory as the message's activity level for updating; if the calculated remaining activity value is 5 (less than 10), the value is corrected to 10 to reduce the risk of the message activity parameter decaying to 0 due to network deterioration.

[0033] S2, when the transmission status of any message in the message set changes, update the message activity, write the status information of all messages in the message set to a non-volatile storage medium in batches, and set the persistence flag of the corresponding message to persistent after successful writing; when sending the QoS2 message, query the time adjustment coefficient of the message to be sent in the composite status matrix and the current process stage, and generate the response timeout duration based on the basic timeout duration, the time adjustment coefficient and the adjustment factor to start the retransmission timer.

[0034] The monitoring terminal continuously listens for message transmission and reception events on the communication connection. When the message confirmation stage changes due to sending a publish message, sending a publish release message, receiving a publish received message from the server, or a publish completed message, the monitoring terminal triggers an activity update mechanism. It calculates the latest activity level of the message according to the confirmation response update steps described later and overwrites the original value in memory. If the update result exceeds a preset activity upper limit, it corrects it to the preset activity upper limit. The monitoring terminal adds all row vectors to be batch persisted in the composite state matrix corresponding to the message set containing the message to the persistence buffer queue. It packages the message data stream and composite state matrix data corresponding to the entire message set in memory at once and writes them in batches to consecutive sectors of electrically erasable read-only memory or flash memory. After successful batch writing, it confirms the persistence flag bit of the corresponding state record as persisted and synchronously updates the persistence flag field of the corresponding state record in the non-volatile storage medium.

[0035] When the monitoring terminal sends a QoS2 message, it reads the message activity level of the message to be sent from the composite state matrix and obtains the current tea leaf processing stage fed back by the sensor. The monitoring terminal has a pre-set two-dimensional relationship mapping table. Using the process stage as the row index and the data range where the message activity level falls as the column index, the monitoring terminal looks up the corresponding time adjustment coefficient in this mapping table. The monitoring terminal extracts the system's preset basic timeout duration, multiplies this basic timeout duration by the time adjustment coefficient to obtain the first intermediate result, and then multiplies the preset negative time constant parameter by the message activity level of the current message to obtain the negative adjustment factor. The first intermediate result and the negative adjustment factor are added to calculate the final response timeout duration. If the final response timeout duration is less than the preset minimum timeout duration, it is corrected to the preset minimum timeout duration. The process for generating the response timeout duration and starting the retransmission timer is as follows: Figure 3 As shown. The monitoring terminal uses the response timeout configuration to start a hardware timer. If no response message is received from the server before the timer countdown reaches zero, the retransmission process of the QoS2 message is triggered.

[0036] In an optional embodiment, updating the message activity level when the transmission status of any message in the message set changes includes: When a QoS2 acknowledgment response message corresponding to the message is received, the current message activity value of the message is read from the composite state matrix; The calculated result is obtained by adding the read message activity value to the preset reward increment parameter; The calculation result is compared with a preset activity limit value. If the calculation result is greater than the preset activity limit value, the calculation result is corrected to the preset activity limit value. Otherwise, the calculation result remains unchanged, and the value after comparison is used as the latest message activity value and overwritten to the position corresponding to the message in the composite state matrix to complete the update.

[0037] When the communication protocol stack recognizes a QoS2 acknowledgment message from the server, it extracts the 16-bit message identifier (e.g., 0x3F4C) from the message and uses this identifier to query the index mapping relationship or calculate the matrix row offset to locate the corresponding five-element state array in the volatile memory composite state matrix. By querying the five-element state array, the current message activity level is extracted; assuming the currently read memory value is 85, the preset reward increment parameter is retrieved, set to a constant of 5, and an addition operation is performed to calculate the new value: 85 + 5 = 90. If the system's preset activity level upper limit is 100, 90 is compared with 100. Since 90 does not exceed 100, it is kept as the new message activity level; if the calculated result exceeds 100, it is corrected to 100. To ensure data consistency, the calculated result 90 is converted to hexadecimal 0x5A and written to the corresponding position in the composite state matrix, completing the activity level update driven by the state change.

[0038] In an optional embodiment, the step of batch writing the state information of all messages in the message set to a non-volatile storage medium, and setting the persistence flag of the corresponding message to persistent after successful writing, includes: Extract all messages to be batch persisted, and obtain the data stream of the message itself and its corresponding complete state information in the composite state matrix; The data stream of the message is concatenated with the complete status information and merged into a continuous data block or byte sequence; The storage control interface is invoked to write the data block or byte sequence as a whole into the storage area of ​​the non-volatile storage medium, and the persistence flag of the corresponding message is set to persistent after successful saving.

[0039] After triggering the persistent storage event, the main control chip traverses the composite state matrix, searching for all message nodes to be persisted in batches. For each successfully matched message node, a 256-byte raw data stream is extracted, such as the tea leaf temperature and humidity alarm data stream. A complete five-element state array associated with this raw data stream is obtained, containing a 2-byte send count, a 1-byte QoS2 confirmation phase, a 1-byte message activity level, a 1-byte persistent flag, and a 4-byte timer start time, totaling a 9-byte continuous state data block. In a buffer, such as a 300-byte array space, the 256-byte data stream and the 9-byte state information are concatenated end-to-end to generate a 265-byte continuous binary data block. The 265-byte binary data block is written as a whole to a preset address on the non-volatile storage medium, such as 0x08040000. After receiving a successful write feedback, the persistence flag of the corresponding message node is updated to the persistent state. At the same time, the persistent state is synchronously written to the persistence flag field of the corresponding state record in the non-volatile storage medium to improve the integrity of the data state when the device recovers after power failure.

[0040] In an optional embodiment, the step of adjusting the query time based on the message activity of the message to be sent in the composite state matrix and the current process stage includes: The monitoring terminal determines the current tea leaf pretreatment process stage based on the service type identifier and one or more operating parameters, including temperature, humidity and motor speed. The process stage includes room temperature withering, sorting, washing and dehydration or hot air withering. Among them, when the real-time temperature parameter of the current pretreatment equipment read by the temperature sensing hardware is greater than or equal to the preset temperature threshold, it is determined that the current tea leaf pretreatment process is in the hot air withering stage. The preset process stage and time coefficient mapping table is invoked, and the corresponding configuration parameters are retrieved based on the current tea leaf pretreatment process stage and the current message activity interval. The values ​​in the configuration parameters are extracted as the time adjustment coefficients and used to calculate the response timeout duration.

[0041] The monitoring terminal's internal acquisition module polls the external temperature sensor every 500 milliseconds, converting the signal to obtain the real-time temperature parameter of the tea leaf pretreatment equipment (assumed to be 38.5℃). The main control unit compares this real-time temperature parameter with a preset temperature threshold stored in the storage area, set at 35.0℃. Since 38.5℃ ≥ 35.0℃, it is determined that the current tea leaf pretreatment process has entered the hot air withering stage. Based on this, a preset process stage and time coefficient mapping table is invoked, using 0x03 to represent the hot air withering stage as the row index key. Simultaneously, the message activity of the currently pending message is read, and its preset activity range is determined, using this range as the column index key. The corresponding unit in the mapping table is found based on the process stage and preset activity range, and the corresponding configuration parameters are obtained. The corresponding parameter value, such as 1.5, is extracted from this configuration parameter and provided as a time adjustment coefficient to the timeout calculation module to adjust the network response waiting time under the hot air withering stage and corresponding activity range.

[0042] Similarly, when the business type is identified as spreading greens and the real-time temperature parameter is less than the preset temperature threshold, it is determined that the current process is in the room temperature spreading greens stage. When the business type is identified as sorting, and the real-time speed parameter read by the motor speed sensor is greater than or equal to the preset speed threshold, the current process is determined to be in the sorting stage. When the business type is identified as cleaning, and the real-time humidity parameter read by the humidity sensing hardware is greater than or equal to the preset humidity threshold, the current process is determined to be in the cleaning and dehydration stage.

[0043] Accordingly, if the extracted business type identifier is spreading green, and the real-time temperature read is 25.0℃, which is less than the preset temperature threshold of 35.0℃, then it is determined that the current stage is spreading green at room temperature; if the extracted business type identifier is sorting, and the real-time motor speed read is 1200 rpm, which is greater than the preset speed threshold of 1000 rpm, then it is determined to be in the sorting stage; if the extracted business type identifier is cleaning, and the real-time ambient humidity read is 95%, which is greater than or equal to the preset humidity threshold of 85%, then it is determined to be in the cleaning and dehydration stage.

[0044] In an optional embodiment, the step of generating a response timeout based on the base timeout duration, the time adjustment coefficient, and the adjustment factor includes: Extract the preset base timeout duration, multiply the base timeout duration by the time adjustment coefficient obtained from the query, and obtain the first intermediate result; Obtain a preset negative time constant parameter, multiply the negative time constant parameter by the message activity of the current message, and obtain a negative adjustment factor determined by the message activity. The first intermediate result is added to the negative adjustment factor to obtain the final result. When the final result is less than the preset minimum timeout duration, the final result is corrected to the preset minimum timeout duration, and the final result is used as the generated response timeout duration.

[0045] The system reads the preset base timeout duration, set to 2000 milliseconds. It retrieves the time adjustment coefficient, which is 1.5. Multiplying 2000 by 1.5 yields a first intermediate result of 3000 milliseconds. It then reads the preset negative time constant parameter, set to -10 milliseconds per activity unit, and looks up the message activity level of the currently pending message, which is 90. Through multiplication, it calculates the negative adjustment factor as -10 × 90 = -900 milliseconds. This negative value indicates that when message activity is high, redundant waiting time should be reduced to expedite retransmission scheduling. The first intermediate result of 3000 milliseconds is added to the negative adjustment factor -900 milliseconds, resulting in 3000 + (-900) = 2100 milliseconds. If the calculated response timeout duration is less than the preset minimum timeout duration, it is corrected to the preset minimum timeout duration to reduce the occurrence of negative or excessively small timeout values ​​being written to the hardware timer. Configure the result 2100 as a timer timing parameter and output it as the response timeout duration.

[0046] S3, after the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process and sent to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with differences, and performs retransmission or discard operation based on the list of message status items.

[0047] The monitoring terminal detects an unexpected network connection loss with the server via a heartbeat keep-alive mechanism. After re-establishing the Transmission Control Protocol (TCP) connection, it reads the composite state matrix data stored in non-volatile storage, iterates through and checks the QoS2 acknowledgment phase fields in all five-element state arrays, filters out all historical messages that have not reached the publication completion phase, extracts the 16-bit message identifier and the corresponding QoS2 acknowledgment phase field of each message, and combines them into a message state item. The message state items are then sorted in ascending order of their identifier values ​​to generate an ordered sequence. A secure hash algorithm is performed on this ordered sequence to generate a 256-bit hash digest byte stream, which is then encapsulated in a control message and sent to the server. Upon receiving the message, the server performs the same sorting and hashing operation using the incomplete message state items for the corresponding session stored in its database. If the server finds a difference between the received hash digest and its locally calculated hash digest byte sequence, it issues a state desynchronization command to the monitoring terminal.

[0048] Upon receiving the instruction, the monitoring terminal encapsulates the generated ordered sequence of message status items into a data packet and sends it to the server. The server compares each received message status item with its local database record, extracting missing message status items, message status items processed by the server but still marked as incomplete by the monitoring terminal, and message status items with the same identifier but inconsistent QoS2 confirmation stage fields. This information is then compiled into a list of differing message status items and sent to the monitoring terminal. The monitoring terminal parses this list. For message identifiers corresponding to missing message status items from the server, it extracts the complete message content and its corresponding QoS2 confirmation stage, transmission count, and timer start time from the non-volatile storage medium. Based on the QoS2 confirmation stage, it restores the original protocol state context, allowing the message to continue execution of the corresponding publication confirmation or retransmission processing from the QoS2 process node it was at before the disconnection. For message identifiers processed by the server, the monitoring terminal performs a clearing operation, clearing the entire status record and message cache content of the corresponding message identifier from the non-volatile storage medium and random access memory, releasing system memory and flash memory space.

[0049] In an optional embodiment, after the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and then sent to the server, including: Traverse the non-volatile storage medium and extract the message status entries of all messages that are persistently marked as persistent and have not completed the QoS2 protocol process; All extracted message status items are arranged according to a preset sorting rule and combined to generate a complete ordered sequence of message status items. The ordered sequence of message status items is input into the hash calculation unit, the hash algorithm is executed, and the hash digest corresponding to the ordered sequence of message status items is generated and output.

[0050] After the monitoring terminal experiences an abnormal power outage and re-establishes the communication connection, it begins traversing the preset storage area of ​​the non-volatile storage medium. It reads the saved status data blocks and extracts data blocks that meet the conditions for being persistently marked as persistent and for not completing the QoS2 protocol process. For each data block that meets the incomplete protocol condition, it extracts the 16-bit message identifier and reads the corresponding QoS2 confirmation stage field, combining the two to form a message status item. A sorting algorithm is used to arrange the temporarily stored message status items according to a preset sorting rule, generating an ordered sequence of message status items. This ordered sequence of message status items is input into a hash calculation unit, and after calculation, a 32-byte hash digest corresponding to the ordered sequence of message status items is output as a comparison basis for the server to perform state consistency verification.

[0051] In the second embodiment, the present invention also proposes a remote monitoring system for tea leaf pretreatment equipment, comprising the following modules: The acquisition module is used to generate QoS2 messages carrying service type identifiers based on the device operating parameters collected by the monitoring terminal, and organize multiple QoS2 messages into a message set; create a composite state matrix for the message set in volatile memory, wherein the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation stage, message activity, persistent flag and timer start time as the second dimension, and calculates the message activity; The generation module is used to update the message activity level when the transmission status of any message in the message set changes, batch write the status information of all messages in the message set to a non-volatile storage medium, and set the persistence flag of the corresponding message to persistent after successful writing; when sending the QoS2 message, it queries the time adjustment coefficient of the message to be sent in the composite status matrix and the current process stage, and generates the response timeout duration based on the basic timeout duration, the time adjustment coefficient and the adjustment factor to start the retransmission timer; The execution module is used to generate a hash digest of the ordered sequence of message status items based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process after the communication session is disconnected and reconnected, and send it to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with differences, and performs retransmission or discard operation based on the list of message status items.

[0052] The above description represents the preferred embodiments of the present invention. It should be noted that, for those skilled in the art, various improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for remote monitoring of tea leaf pretreatment equipment, characterized in that, include: Based on the device operating parameters collected by the monitoring terminal, a QoS2 message carrying a service type identifier is generated, and multiple QoS2 messages are organized into a message set; a composite state matrix is ​​created for the message set in volatile memory. The composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation phase, message activity, persistence flag and timer start time as the second dimension, and the message activity is calculated. When the transmission status of any message in the message set changes, update the message activity, write the status information of all messages in the message set to a non-volatile storage medium in batches, and set the persistence flag of the corresponding message to persistent after successful writing. When sending the QoS2 message, the retransmission timer is started based on the message activity of the message to be sent in the composite state matrix and the query time adjustment coefficient of the current process stage, and the response timeout duration is generated based on the basic timeout duration, the time adjustment coefficient and the adjustment factor. After the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and sent to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with discrepancies, and performs retransmission or discard operations based on the list of message status items.

2. The method according to claim 1, characterized in that, The process involves creating a composite state matrix for the message set in volatile memory. This composite state matrix is ​​indexed by the unique identifier of each message as its first dimension, and by a five-element state array containing a send count, QoS2 acknowledgment phase, message activity, persistence flag, and timer start time as its second dimension. Send a memory allocation instruction to allocate an independent data space of a preset capacity in volatile memory; Parse the header of the latest message that has entered memory, extract a fixed-length field as the unique identifier of the message, and store the identifier as the first dimension index in the composite state matrix; The send count, QoS2 confirmation phase, message activity, persistence flag, and timer start time in the five-element state array corresponding to the unique identifier in the composite state matrix are all initialized to preset default constant values.

3. The method according to claim 1, characterized in that, The calculation of message activity includes: When the service type of the message is identified as a mandatory service such as alarm interruption or device stoppage, a basic activity initial value is set to a preset constant. When the service type of the message is identified as a regular service such as withering, sorting, cleaning or spreading, the corresponding initial value of basic activity is determined according to the preset mapping table between service type and initial value of basic activity. The cumulative number of times the message was interrupted or unacknowledged during historical transmission is counted, and the cumulative number is multiplied by the system's built-in attenuation coefficient to obtain the activity deviation value; The remaining activity value is obtained by subtracting the activity deviation value from the initial basic activity value. When the remaining activity value is less than the preset positive lower limit value, it is corrected to the positive lower limit value, and the remaining activity value is used as the message activity value of the message.

4. The method according to claim 3, characterized in that, The step of updating the message activity level when the transmission status of any message in the message set changes includes: When a QoS2 acknowledgment response message corresponding to the message is received, the current message activity value of the message is read from the composite state matrix; The calculated result is obtained by adding the read message activity value to the preset reward increment parameter; The calculation result is compared with a preset activity limit value. If the calculation result is greater than the preset activity limit value, the calculation result is corrected to the preset activity limit value. Otherwise, the calculation result remains unchanged, and the value after comparison is used as the latest message activity value and overwritten to the position corresponding to the message in the composite state matrix to complete the update.

5. The method according to claim 1, characterized in that, The step of batch writing the state information of all messages in the message set to a non-volatile storage medium, and setting the persistence flag of the corresponding message to persistent after successful writing, includes: Extract all messages to be batch persisted, and obtain the data stream of the message itself and its corresponding complete state information in the composite state matrix; The data stream of the message is concatenated with the complete status information and merged into a continuous data block or byte sequence; The storage control interface is invoked to write the data block or byte sequence as a whole into the storage area of ​​the non-volatile storage medium, and the persistence flag of the corresponding message is set to persistent after successful saving.

6. The method according to claim 1, characterized in that, The adjustment factor based on the message activity level of the message to be sent in the composite state matrix and the query time coefficient of the current process stage includes: The monitoring terminal determines the current tea leaf pretreatment process stage based on the service type identifier and one or more operating parameters, including temperature, humidity and motor speed. The process stage includes room temperature withering, sorting, washing and dehydration or hot air withering. Among them, when the real-time temperature parameter of the current pretreatment equipment read by the temperature sensing hardware is greater than or equal to the preset temperature threshold, it is determined that the current tea leaf pretreatment process is in the hot air withering stage. The preset process stage and time coefficient mapping table is invoked, and the corresponding configuration parameters are retrieved based on the current tea leaf pretreatment process stage and the current message activity interval. The values ​​in the configuration parameters are extracted as the time adjustment coefficients and used to calculate the response timeout duration.

7. The method according to claim 1, characterized in that, The response timeout duration generated based on the base timeout duration, the time adjustment coefficient, and the adjustment factor includes: Extract the preset base timeout duration, multiply the base timeout duration by the time adjustment coefficient obtained from the query, and obtain the first intermediate result; Obtain a preset negative time constant parameter, multiply the negative time constant parameter by the message activity of the current message, and obtain a negative adjustment factor determined by the message activity. The first intermediate result is added to the negative adjustment factor to obtain the final result. When the final result is less than the preset minimum timeout duration, the final result is corrected to the preset minimum timeout duration, and the final result is used as the generated response timeout duration.

8. The method according to claim 1, characterized in that, After the communication session is disconnected and reconnected, a hash digest of the ordered sequence of message status items is generated based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process, and then sent to the server, including: Traverse the non-volatile storage medium and extract the message status entries of all messages that are persistently marked as persistent and have not completed the QoS2 protocol process; All extracted message status items are arranged according to a preset sorting rule and combined to generate a complete ordered sequence of message status items. The ordered sequence of message status items is input into the hash calculation unit, the hash algorithm is executed, and the hash digest corresponding to the ordered sequence of message status items is generated and output.

9. A remote monitoring system for tea leaf pretreatment equipment, characterized in that, include: The acquisition module is used to generate QoS2 messages carrying service type identifiers based on the device operating parameters collected by the monitoring terminal, and organize multiple QoS2 messages into a message set; create a composite state matrix for the message set in volatile memory, wherein the composite state matrix is ​​indexed by the unique identifier of the message as the first dimension, and by a five-element state array containing the sending count, QoS2 confirmation stage, message activity, persistent flag and timer start time as the second dimension, and calculates the message activity; The generation module is used to update the message activity when the transmission status of any message in the message set changes, to write the status information of all messages in the message set in batches to a non-volatile storage medium, and to set the persistence flag of the corresponding message to persistent after successful writing. When sending the QoS2 message, the retransmission timer is started based on the message activity of the message to be sent in the composite state matrix and the query time adjustment coefficient of the current process stage, and the response timeout duration is generated based on the basic timeout duration, the time adjustment coefficient and the adjustment factor. The execution module is used to generate a hash digest of the ordered sequence of message status items based on the messages in the non-volatile storage medium that have not completed the QoS2 protocol process after the communication session is disconnected and reconnected, and send it to the server. When the server determines that the hash digest is inconsistent with its own record, the monitoring terminal sends the ordered sequence of message status items to the server to obtain a list of message status items with differences, and performs retransmission or discard operation based on the list of message status items.

10. The system according to claim 9, characterized in that, The process involves creating a composite state matrix for the message set in volatile memory. This composite state matrix is ​​indexed by the unique identifier of each message as its first dimension, and by a five-element state array containing a send count, QoS2 acknowledgment phase, message activity, persistence flag, and timer start time as its second dimension. Send a memory allocation instruction to allocate an independent data space of a preset capacity in volatile memory; Parse the header of the latest message that has entered memory, extract a fixed-length field as the unique identifier of the message, and store the identifier as the first dimension index in the composite state matrix; The send count, QoS2 confirmation phase, message activity, persistence flag, and timer start time in the five-element state array corresponding to the unique identifier in the composite state matrix are all initialized to preset default constant values.