Multi-thread asynchronous communication and adaptive analysis intelligent device control system and method

The intelligent device control system, which utilizes multi-threaded asynchronous communication and adaptive parsing, solves the problems of communication blockage and poor protocol compatibility in industrial control by the host computer software. It achieves efficient multi-device collaborative control and intelligent diagnosis, thereby improving the system's real-time performance and reliability.

CN121559995APending Publication Date: 2026-02-24HUNAN AINES TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511754977.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-26
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Existing host computer software in industrial control suffers from problems such as single-threaded synchronous communication leading to blocking, poor protocol compatibility, and lack of intelligent diagnostic functions, resulting in insufficient system real-time performance and compatibility.

Method used

The intelligent device control system employs multi-threaded asynchronous communication and adaptive parsing, including a hardware layer interface module, a multi-threaded asynchronous communication module, an adaptive data parsing module, a data processing and storage module, an intelligent diagnostic module, and a real-time visualization module. It achieves decoupling through C++ object-oriented design, utilizes thread pools and asynchronous I/O modes for concurrent communication, and supports custom protocol parsing and intelligent diagnostics.

Benefits of technology

It achieves low latency and non-blocking concurrent communication among multiple devices, improves protocol compatibility and fault diagnosis efficiency, and enhances the real-time performance and reliability of industrial field equipment monitoring, making it suitable for scenarios such as smart manufacturing and smart warehousing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121559995A_ABST
    Figure CN121559995A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent equipment control system and method for multi-thread asynchronous communication and self-adaptive analysis. The intelligent equipment control system comprises a hardware layer interface module, a multi-thread asynchronous communication module, a self-adaptive data analysis module, a data processing and storage module and an intelligent diagnosis module. A multi-thread asynchronous communication architecture is constructed through the multi-thread asynchronous communication module to realize concurrent data interaction of multiple intelligent devices, communication protocols of different types of intelligent devices are compatible through the adaptive data analysis module, and an intelligent diagnosis function is integrated. The problems that a traditional upper computer is high in communication delay, poor in protocol compatibility, low in multi-device cooperative control efficiency and the like are solved, the real-time performance and reliability of industrial field device monitoring are improved, and the method is suitable for multi-device cooperative scenes such as intelligent manufacturing and intelligent storage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial control technology, and in particular to a smart device control system and method with multi-threaded asynchronous communication and adaptive parsing. Background Technology

[0002] As the core hub connecting underlying intelligent devices (such as sensors, actuators, PLCs, etc.) and users in industrial control, the performance of the host computer directly affects the real-time performance, stability, and compatibility of equipment monitoring. Existing host computer software still suffers from the following technical shortcomings: (1) The communication method mostly adopts a single-threaded synchronous mode. When multiple smart devices are connected, the overall communication is easily blocked due to the response delay of a certain smart device, and the real-time performance of the system is difficult to guarantee. (2) Data parsing usually relies on a fixed protocol format, which lacks flexibility when dealing with different manufacturers or types of devices. When connecting new types of devices (such as sensors from different manufacturers), the parsing module needs to be redeveloped, resulting in poor compatibility and high development and maintenance costs. (3) The system functions focus on data acquisition and status display, lacking intelligent diagnostic functions. When the equipment is abnormal, it can only provide basic alarms and cannot locate the root cause of the fault (such as communication packet loss, protocol error, equipment hardware abnormality, etc.), resulting in low troubleshooting efficiency.

[0003] C++ is widely used in host computer development due to its high execution efficiency and flexible memory control. However, existing C++-based implementations fail to fully utilize its multithreading concurrency and template metaprogramming features to systematically solve the aforementioned problems, resulting in severely limited adaptability in industrial scenarios with multi-device collaboration and high real-time requirements. Summary of the Invention

[0004] To address the problems existing in the prior art, this invention proposes a smart device control system and method with multi-threaded asynchronous communication and adaptive parsing, aiming to improve the real-time performance, protocol compatibility, and fault diagnosis efficiency of multi-device communication.

[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: On one hand, the present invention provides a smart device control system with multi-threaded asynchronous communication and adaptive parsing, comprising: The hardware layer interface module is used to encapsulate the driver logic of various hardware communication interfaces and provide a unified data transmission and reception interface. A multi-threaded asynchronous communication module, connected to the hardware layer interface module, is used to achieve concurrency with multiple smart devices using a thread pool and asynchronous I / O mode, and to avoid communication congestion through flow control; An adaptive data parsing module, connected to the multi-threaded asynchronous communication module, is used to parse the received raw data frames from the smart device into structured data according to a predefined protocol parsing template or custom parsing logic. The data processing and storage module, connected to the adaptive data parsing module, is used to cache real-time data and store historical data. The intelligent diagnostic module is connected to the multi-threaded asynchronous communication module and the data processing and storage module, respectively, and is used to detect anomalies in the timing characteristics of communication data, the content of device data, and locate fault types.

[0006] Furthermore, it also includes a real-time visualization module, which is connected to the data processing and storage module and the intelligent diagnostic module to realize the graphical display of data and human-computer interaction.

[0007] Furthermore, the system includes a hardware layer interface module, a multi-threaded asynchronous communication module, an adaptive data parsing module, a data processing and storage module, a real-time visualization module, and an intelligent diagnostic module. Each module is decoupled through C++ object-oriented design.

[0008] On the other hand, a smart device control method utilizing the above system is provided, comprising the following steps: Initialize the hardware layer interface module and load the device communication protocol configuration file; The multi-threaded asynchronous communication module is activated to allocate an independent communication sub-thread to each smart device and establish an asynchronous communication connection. The system receives raw data frames from smart devices in real time and parses them into structured data using the adaptive data parsing module. The parsed structured data is cached in the data processing and storage module; The intelligent diagnostic module detects anomalies in the communication status and data content from smart devices. If a fault is detected, an alarm is triggered and a solution is suggested.

[0009] Compared with the prior art, the technical effects of the present invention are as follows: This invention provides a multi-threaded asynchronous communication and adaptive parsing intelligent device control system, comprising a hardware layer interface module, a multi-threaded asynchronous communication module, an adaptive data parsing module, a data processing and storage module, and an intelligent diagnostic module. Each module is decoupled through C++ object-oriented design. The multi-threaded asynchronous communication module constructs a multi-threaded asynchronous communication architecture to achieve concurrent data interaction among multiple intelligent devices, realizing low latency and non-blocking multi-device concurrent communication and avoiding the performance bottleneck of single-threaded synchronous mode. The adaptive data parsing module is compatible with the communication protocols of different types of intelligent devices (such as Modbus, Profinet, and custom protocols), reducing secondary development costs. This invention also integrates intelligent diagnostic functions, achieving intelligent diagnosis and location of equipment anomalies through data feature analysis, improving fault diagnosis efficiency. This invention solves the problems of high communication latency, poor protocol compatibility, and low efficiency of multi-device collaborative control existing in traditional host computers, improving the real-time performance and reliability of industrial field equipment monitoring, and is suitable for multi-device collaborative scenarios such as intelligent manufacturing and intelligent warehousing. Attached Figure Description

[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.

[0011] Figure 1 A framework diagram of a smart device control system with multi-threaded asynchronous communication and adaptive parsing provided in one embodiment; Figure 2 A framework diagram of a smart device control system with multi-threaded asynchronous communication and adaptive parsing provided for another embodiment; Figure 3 This is a schematic diagram of the worker threads in a multi-threaded asynchronous communication module in one embodiment; Figure 4 This is a schematic diagram illustrating the status and allocation of device tasks in the system in one embodiment; Figure 5 This is a schematic diagram of a sliding window anomaly detection mechanism in one embodiment; Figure 6 This is a schematic diagram of a fault feature library in one embodiment. Detailed Implementation

[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.

[0013] One embodiment, referring to Figure 1 This paper proposes a multi-threaded asynchronous communication and adaptive parsing intelligent device control system, including: The hardware layer interface module is used to encapsulate the drive logic of hardware communication interfaces for various intelligent devices (such as sensors, PLCs, robotic arms, etc.) and provide a unified data transceiver interface. A multi-threaded asynchronous communication module, connected to the hardware layer interface module, is used to achieve concurrency with multiple smart devices using a thread pool and asynchronous I / O mode, and to avoid communication congestion through flow control; An adaptive data parsing module, connected to the multi-threaded asynchronous communication module, is used to parse the received raw data frames from the smart device into structured data according to a predefined protocol parsing template or custom parsing logic. The data processing and storage module, connected to the adaptive data parsing module, is used to cache real-time data and store historical data. The intelligent diagnostic module is connected to the multi-threaded asynchronous communication module and the data processing and storage module respectively, and is used to detect anomalies in the timing characteristics of communication data, the content of device data, and locate fault types. The real-time visualization module is connected to the data processing and storage module and the intelligent diagnostic module to realize the graphical display of data and human-computer interaction.

[0014] In the above embodiments, the modules are decoupled through C++ object-oriented design. Specifically, the hardware layer interface module defines a unified interface based on C++ abstract classes; the multi-threaded asynchronous communication module uses `std::thread` and `std::async` from the C++11 standard library to build a thread pool, and uses `std::condition_variable` to achieve thread synchronization. The communication process uses asynchronous I / O mode (based on the Boost.Asio library) to avoid blocking the main thread. The adaptive data parsing module defines a protocol parsing template based on C++ template metaprogramming. The data processing and storage module uses C++ STL containers (such as `std::unordered_map`) to cache real-time data, and uses `std::mutex` to ensure thread safety for multi-threaded data access; it uses an SQLite database (C++ interface encapsulation) to store historical data, supporting efficient queries by device ID and timestamp. The real-time visualization module implements the human-computer interaction interface based on the Qt framework (C++ GUI library).

[0015] In practical applications, intelligent device control systems employing multi-threaded asynchronous communication and adaptive parsing can refer to... Figure 2The design employs a layered and modular approach to construct a highly efficient, flexible, and intelligent equipment control system with diagnostic capabilities. The system is divided into a user interaction layer, a core function layer, and a hardware interface layer. These layers collaborate through a clear data flow to achieve precise monitoring and intelligent management of various industrial equipment. In the user interaction layer, the system provides rich human-machine interface components such as graphs, dashboards, equipment status lists, and alarm prompts through a real-time visualization module, allowing users to intuitively grasp the equipment's operating status. Simultaneously, by adding an operation input module, users can flexibly configure communication protocols, equipment parameters, and thread pool parameters, greatly improving the system's configurability and ease of use. The core function layer integrates four key modules: a multi-threaded asynchronous communication module that uses a thread pool mechanism and asynchronous I / O mode to allocate independent communication task units to each device and utilizes flow control algorithms to effectively avoid channel congestion during multi-device communication, ensuring the real-time performance and stability of data interaction in high-concurrency environments. The adaptive data parsing module, through a protocol template configuration unit and a protocol identifier, automatically identifies and parses the communication protocols of different devices, and reserves a custom parsing interface, significantly enhancing the system's compatibility and scalability with multi-protocol devices. The parsed structured data is cached and persisted by the data processing and storage module, and analyzed in real time by the intelligent diagnostic module. Through anomaly detection in communication status and device data, it achieves accurate fault location and intelligent alarms. The hardware layer interface module, located at the bottom layer, encapsulates various physical interfaces such as serial ports, Ethernet, and USB, providing unified device access and data transmission / reception services to the upper layer, effectively shielding the differences in underlying hardware. The system fundamentally improves the efficiency and real-time performance of multi-device collaborative control through a multi-threaded asynchronous communication architecture, significantly reduces the development and maintenance costs of protocol compatibility through the adaptive parsing mechanism, and comprehensively enhances the intelligence level of device monitoring by combining real-time diagnostic functions.

[0016] In one embodiment, the multi-threaded asynchronous communication module includes: A thread pool is used to manage a group of worker threads in a unified manner. Multiple device communication task units are provided, with each smart device corresponding to an independent device communication task unit. The device communication task units are submitted to the task queue in the thread pool and executed by worker threads. The worker threads in the thread pool are used to execute the device communication task units. The implementation of the device communication task units is based on asynchronous I / O mode. When a worker thread executes any device communication task unit, it initiates an I / O operation and then enters a schedulable state, thereby decoupling the worker thread from the I / O operation and achieving non-blocking communication. The flow control submodule uses the token bucket algorithm to limit the communication bandwidth of a single smart device, avoiding network congestion caused by multiple smart devices competing for bandwidth.

[0017] Reference Figure 3 This diagram illustrates the worker threads in a multi-threaded asynchronous communication module. The task queue receives and temporarily stores all communication tasks submitted by the system, enabling unified task management and scheduling. The task queue contains multiple pending device communication task units (tasks 1 to 4 are shown in the diagram; the actual number N dynamically corresponds to the number of connected smart devices). The thread pool initializes 10 worker threads (threads 1 to 10), which are created at system startup and run continuously. When idle, worker threads attempt to retrieve tasks from the task queue. Once successfully retrieved, they independently execute the data transmission and reception logic for the corresponding device. When the task queue is empty, worker threads enter a sleep state. When a new device communication task is added to the queue, the system sends a wake-up signal, notifying one or more idle worker threads to retrieve and execute the new task. This mechanism is typically implemented using `std::condition_variable`. The task queue decouples and buffers communication requests, utilizes a fixed number of worker threads to reuse system resources, and leverages the wake-up signal for precise thread scheduling. These three elements work together to enable the system to handle the concurrent communication needs of a large number of devices with limited thread resources, thereby fundamentally solving the blocking problem in the traditional single-threaded synchronous mode and ensuring high real-time performance and high throughput of communication.

[0018] Reference Figure 4This diagram illustrates the status and allocation of device tasks within a system in one embodiment. The system successfully connects eight heterogeneous smart devices and creates an independent device communication task unit for each device, dynamically scheduled and executed by worker threads in a thread pool. Devices 1, 2, and 3, etc., connect to devices using different protocols. Threads are used to execute different tasks, with one task monitoring one device. When a device connects, the thread pool allocates a corresponding number of threads to execute tasks (receiving data, issuing commands, checking heartbeats, etc.), while the remaining threads in the thread pool remain idle or paused. Specifically, the system creates a dedicated, persistent communication task for each device (e.g., the Modbus temperature and humidity sensor for device 1, the Profinet robotic arm controller for device 2, the EtherNet / IP PLC for device 8), logically ensuring the isolation and independence of communication between devices. Each device communication task is in various execution states. For example, performing I / O operations: Task 1 (device 1) is performing "periodic data reception," Task 2 (device 2) is "issuing commands," and Task 3 (device 3) is "checking heartbeats." Idle / Ready: Tasks 4 and 8 are displayed as "Idle," meaning they are ready to execute the next round of communication, but there is currently no I / O operation, and the corresponding threads may have been released to handle other tasks. Paused / Blocked: Task 4 (Device 4) is displayed as "Paused." This state can be caused by various reasons, such as waiting for the token bucket to replenish tokens, waiting for a device response timeout, or being actively suspended by the user, demonstrating the system's fine-grained control over the communication process. By managing device communication tasks in a task-oriented and state-based manner, and entrusting them to a thread pool for unified scheduling, concurrent execution and fine-grained control of multi-device communication tasks are achieved. It not only ensures the independent communication logic of each device but also ensures that the entire system remains efficient, stable, and responsive under high load through dynamic task state switching and dynamic allocation of thread resources.

[0019] The token bucket algorithm is used to limit the communication bandwidth of a single smart device. Specifically, the implementation process of the token bucket algorithm is as follows: S101: Initialize token bucket parameters: Initialize an independent token bucket for each smart device's communication sub-thread and configure its core parameters, including token generation rate, token bucket capacity, current number of tokens, and last update time; S102: Before the current communication sub-thread of the smart device needs to send data, a certain number of new tokens are dynamically generated and added to the token bucket based on the time difference between the current time and the last update time, and the current number of tokens after the addition does not exceed the capacity of the token bucket. S103: Determine whether the current number of tokens is greater than or equal to the number of tokens required for the data packet to be sent. If yes, deduct the corresponding number of tokens from the token bucket and perform an asynchronous data transmission operation. If no, pause data transmission, put the current smart device's communication sub-thread into a waiting state, and wake up the current smart device's communication sub-thread to try to retransmit the data after the number of tokens is replenished to a sufficient quantity.

[0020] In step S101, the token bucket initialization parameters include: Token generation rate (rate): the number of tokens generated per unit time (e.g., 1000 tokens / second, which can be calculated based on the device's bandwidth limit; 1 token corresponds to 1 byte or 1 data packet). Token bucket capacity (capacity): the maximum number of tokens that can be stored in the bucket (e.g., 500 tokens, determining the maximum burst traffic). Current token count (tokens): the initial value is capacity (allowing for initial bursts). Last update time (last_update_time): records the time when the last token was generated (used to calculate the time difference).

[0021] In step S102, a certain number of new tokens are dynamically generated and replenished into the token bucket based on the time difference between the current time and the last update time. The number of new tokens = token generation rate × time difference. If the replenished current token count is less than or equal to the token bucket capacity, the final current token count is the replenished current token count. If the replenished current token count is greater than the token bucket capacity, the final current token count is the token bucket capacity. This ensures that the replenished current token count does not exceed the token bucket capacity.

[0022] In step S103, the asynchronous data sending operation is implemented through the asynchronous write interface based on the Boost.Asio library to ensure that the communication sub-thread is not blocked after initiating the sending operation, thus avoiding blocking the main thread.

[0023] The token generation rate determines the average transmission rate of a device (e.g., 1000 tokens / second corresponds to 1000 bytes / second). By setting a fixed token generation rate, the system can strictly limit the average data transmission rate of each device within a predetermined range, thereby achieving precise control over network bandwidth, effectively avoiding instantaneous overload of the network link, and improving the stability and reliability of the entire communication channel.

[0024] When there are remaining tokens in the token bucket, data exceeding the rate (but not exceeding the capacity) can be sent for a short period to accommodate instantaneous peaks. By setting the token bucket capacity, the system allows devices to send data at a peak rate higher than the average rate for a short period when there are sufficient tokens, thus accommodating normal burst communication needs of devices (such as device startup reporting, event triggering, etc.) and ensuring the timely transmission of critical data. A balance between control and efficiency is achieved by ensuring that the long-term average bandwidth does not exceed the limit without sacrificing the real-time performance of short-term transmissions.

[0025] The above scheme binds an independent token bucket to each smart device, avoiding excessive bandwidth consumption by a single device and ensuring fairness in multi-device communication. This means that abnormal traffic from any device (such as continuous high load or malicious packet sending) will only consume its own token quota and will not preempt the communication resources of other devices, thereby achieving bandwidth resource isolation between devices, ensuring fairness in communication opportunities for all access devices, and fundamentally preventing the "avalanche" phenomenon of overall system communication congestion caused by a single device problem.

[0026] When the tokens in the smart device's independent token bucket are insufficient, the communication sub-thread waits for a token abundance signal via `std::condition_variable`. Once tokens are replenished (e.g., during a scheduled task or the next call to `refill_tokens()`), the waiting communication sub-thread is awakened, triggering asynchronous transmission. This process does not block the worker thread, which can handle other tasks during this time, making flow control itself a low-overhead, non-blocking operation.

[0027] Asynchronous I / O adaptation: Asynchronous data sending operations are implemented through asynchronous interfaces (such as async_write) in the Boost.Asio library. Asynchronous sending is triggered after successful token verification, avoiding blocking of child threads. After data sending is complete, subsequent logic (such as updating statistics) is handled through callback functions.

[0028] Furthermore, new tokens can be generated via scheduled tasks (e.g., replenishing every 10ms) or on-demand triggering (replenishing before sending). The former reduces computation frequency, while the latter offers higher precision. Token unit: The appropriate token unit (byte / data packet) is selected based on the scenario. Large granularity (data packet) is simple to implement, while small granularity (byte) provides more precise control. Thread safety: In a multi-threaded environment, the tokens and last_update_time of the token bucket must be protected by a mutex (std::mutex) to avoid concurrent modification conflicts.

[0029] In one embodiment, the adaptive data parsing module includes: The protocol template configuration unit is used to predefine protocol parsing templates and define and load format rules for various communication protocols through external configuration files; Protocol parsing template library, used to store a collection of protocol parsing templates; A protocol identifier is used to match the received raw data frames from the smart device with the format rules of each protocol parsing template in the protocol parsing template library; The data parsing unit is used to parse the template according to the successfully matched protocol or to perform the parsing task of the original data frame through a custom parsing interface.

[0030] In one embodiment, the custom parsing interface provides a dynamic link library loading mechanism or a script function registration mechanism, allowing users to inject custom parsing functions for unknown protocols at system runtime.

[0031] In one embodiment, the intelligent diagnostic module calculates and analyzes the communication packet loss rate and latency fluctuation within a set time window based on a sliding window anomaly detection mechanism, and determines the fault type by combining a preset threshold with a fault feature library.

[0032] In one embodiment, the intelligent diagnostic module includes: The anomaly detection unit calculates and analyzes the communication packet loss rate and latency fluctuation within a set time window based on the sliding window anomaly detection mechanism; A fault feature library is constructed using a hash table data structure to store the mapping relationship between fault types and corresponding data features. The diagnostic result output unit is used to output the fault type and solution to the real-time visualization module based on the analysis results of the anomaly detection unit and the mapping relationship of the fault feature library.

[0033] Reference Figure 6 This diagram illustrates a fault feature library in one embodiment. Internally, the fault feature library is implemented as a hash table. Each row clearly shows a key-value mapping pair. The key represents the fault type, such as communication anomaly, sensor anomaly, protocol error, etc. The value represents the data characteristics or judgment conditions of the fault. For communication anomalies, the characteristic is a packet loss rate greater than 5%; for sensor anomalies, the characteristic is a value exceeding the historical threshold range; and for protocol errors, the characteristic is a checksum mismatch.

[0034] In one embodiment, the intelligent device control method using the system described in any of the above embodiments includes the following steps: S201: Initialize the hardware layer interface module and load the device communication protocol configuration file; S202: Start the multi-threaded asynchronous communication module, allocate an independent communication sub-thread to each smart device, and establish an asynchronous communication connection; S203: Receive raw data frames from smart devices in real time, and parse the raw data frames into structured data through the adaptive data parsing module; S204: Cache the parsed structured data to the data processing and storage module; S205: The intelligent diagnostic module detects anomalies in the communication status and data content from the smart device. If a fault is detected, an alarm is triggered and a solution is provided.

[0035] In one embodiment, the multi-threaded asynchronous communication module is activated, and an independent communication sub-thread is allocated to each smart device to establish an asynchronous communication connection, including the following steps: S301: Initialize the thread pool and create a set number of worker threads; S302: Generate an independent device communication task for each connected smart device and submit it to the task queue of the thread pool; S303: The worker threads in the thread pool obtain and execute device communication tasks from the task queue; S304: During the execution of device communication tasks, asynchronous I / O operations based on Boost.Asio are used to perform data transmission and reception, thereby achieving non-blocking communication; S305: Before sending data, flow control is performed using the token bucket algorithm, and data can only be sent after obtaining a token.

[0036] In one embodiment, the adaptive data parsing module parses the original data frame into structured data, including the following steps: A predefined protocol parsing template is used to define and load format rules for various communication protocols through an external configuration file. These format rules include frame header identifier, field length, data type, verification method, and frame tail identifier. Load and parse the configuration file, and instantiate the format rules into a set of protocol parsing templates; After receiving the raw data frame from the smart device, the protocol template set is traversed, and the frame header features and checksum features of the raw data frame are matched with the format rules of each protocol parsing template. If a match is successful, the original data frame is parsed according to the matched protocol parsing template to extract structured data; If the match fails, a custom parsing is triggered, which calls the user-injected custom parsing logic to parse the original data frame and extract the structured data.

[0037] The intelligent diagnostic module monitors packet loss based on a sliding window anomaly detection mechanism. It calculates the packet loss rate within the current sliding window, and if the packet loss rate exceeds a set threshold (e.g., >5%), it triggers a communication anomaly alarm. By comparing sensor data with historical threshold ranges (stored in an SQLite database), it determines whether there is a hardware anomaly in the device.

[0038] Reference Figure 5 The diagram illustrates a sliding window anomaly detection mechanism in one embodiment. The intelligent diagnostic module monitors packet loss based on this mechanism. For example, if the sliding window size is set to 100ms, the module calculates the packet loss rate within the current sliding window. If the packet loss rate is greater than 5%, a communication anomaly alarm is triggered. Figure 5 As shown, in state 1 (initial window), the packet loss rate within the window is [2%, 3%, 4%, 6%, 5%], and the calculated average is 4.0%. Since the average is lower than the preset 5% fault threshold, the system determines that the current communication status is normal. In state 2 (after sliding 1 step), the window updates to [3%, 4%, 6%, 5%, 7%], and the new average is 5.0%. The average has reached the threshold, and the system is likely to trigger a warning state, indicating that the communication quality is deteriorating and the subsequent trend needs to be closely monitored. In state 3 (after sliding 2 steps), the window updates to [4%, 6%, 5%, 7%, 4%], and the new average is 5.2%. The average has exceeded the 5% threshold, and the system officially triggers a "communication anomaly" alarm, indicating that the fault has been confirmed. Compared with single-point instantaneous jitter, averaging the data within the window can effectively smooth short-term fluctuations and avoid false alarms. An alarm will only be triggered when the communication quality continues to deteriorate. The sliding window mechanism can ensure a fast response to faults (on the order of 100ms) without overreacting to a single anomaly, achieving a good balance between real-time performance and stability.

[0039] This invention can handle concurrent data interaction from ≥32 devices simultaneously, reducing communication latency to ≤10ms and solving the blocking problem of traditional single-threaded mode. The adaptive data parsing module supports ≥10 mainstream industrial protocols and custom protocols, eliminating the need to modify code when new smart devices are integrated, thus shortening the development cycle by over 60%. The intelligent diagnostic module can automatically locate over 95% of common faults (such as communication interruptions and data anomalies), improving troubleshooting efficiency. Based on the high-efficiency execution characteristics and modular design of C++, the system resource utilization (CPU / memory) is reduced by 30% compared to similar Java-developed host computers, making it suitable for resource-constrained scenarios such as embedded industrial hosts.

[0040] Matters not covered in this invention are common knowledge.

[0041] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0042] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these modifications and improvements all fall within the protection scope of this application.

[0043] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A smart device control system with multi-threaded asynchronous communication and adaptive parsing, characterized in that, include: The hardware layer interface module is used to encapsulate the driver logic of various hardware communication interfaces and provide a unified data transmission and reception interface. A multi-threaded asynchronous communication module, connected to the hardware layer interface module, is used to achieve concurrency with multiple smart devices using a thread pool and asynchronous I / O mode, and to avoid communication congestion through flow control; An adaptive data parsing module, connected to the multi-threaded asynchronous communication module, is used to parse the received raw data frames from the smart device into structured data according to a predefined protocol parsing template or custom parsing logic. The data processing and storage module, connected to the adaptive data parsing module, is used to cache real-time data and store historical data. The intelligent diagnostic module is connected to the multi-threaded asynchronous communication module and the data processing and storage module, respectively, and is used to detect anomalies in the timing characteristics of communication data, the content of device data, and locate fault types.

2. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to claim 1, characterized in that, It also includes a real-time visualization module, which is connected to the data processing and storage module and the intelligent diagnostic module to realize the graphical display of data and human-computer interaction.

3. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to claim 1, characterized in that, The multi-threaded asynchronous communication module includes: A thread pool is used to manage a group of worker threads in a unified manner. Multiple device communication task units are provided, with each smart device corresponding to an independent device communication task unit. The device communication task units are submitted to the task queue in the thread pool and executed by worker threads. The worker threads in the thread pool are used to execute the device communication task units. The implementation of the device communication task units is based on asynchronous I / O mode. When a worker thread executes any device communication task unit, it initiates an I / O operation and then enters a schedulable state, thereby decoupling the worker thread from the I / O operation and achieving non-blocking communication. The flow control submodule uses the token bucket algorithm to limit the communication bandwidth of a single smart device, avoiding network congestion caused by multiple smart devices competing for bandwidth.

4. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to any one of claims 1 to 3, characterized in that, The adaptive data parsing module includes: The protocol template configuration unit is used to predefine protocol parsing templates and define and load format rules for various communication protocols through external configuration files; Protocol parsing template library, used to store a collection of protocol parsing templates; A protocol identifier is used to match the received raw data frames from the smart device with the format rules of each protocol parsing template in the protocol parsing template library; The data parsing unit is used to parse the template according to the successfully matched protocol or to perform the parsing task of the original data frame through a custom parsing interface.

5. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to claim 4, characterized in that, The custom parsing interface provides a dynamic link library loading mechanism or a script function registration mechanism, allowing users to inject custom parsing functions for unknown protocols at runtime.

6. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to any one of claims 1, 2, 3, or 5, characterized in that, The intelligent diagnostic module calculates and analyzes the communication packet loss rate and latency fluctuation within a set time window based on the sliding window anomaly detection mechanism, and judges the fault type by combining the preset threshold and the fault feature library.

7. The intelligent device control system with multi-threaded asynchronous communication and adaptive parsing according to claim 6, characterized in that, The intelligent diagnostic module includes: The anomaly detection unit calculates and analyzes the communication packet loss rate and latency fluctuation within a set time window based on the sliding window anomaly detection mechanism; A fault feature library is constructed using a hash table data structure to store the mapping relationship between fault types and corresponding data features. The diagnostic result output unit is used to output the fault type and solution to the real-time visualization module based on the analysis results of the anomaly detection unit and the mapping relationship of the fault feature library.

8. The intelligent device control method using the system as described in claim 1, characterized in that, Includes the following steps: Initialize the hardware layer interface module and load the device communication protocol configuration file; The multi-threaded asynchronous communication module is activated to allocate an independent communication sub-thread to each smart device and establish an asynchronous communication connection. The system receives raw data frames from smart devices in real time and parses them into structured data using the adaptive data parsing module. The parsed structured data is cached in the data processing and storage module; The intelligent diagnostic module detects anomalies in the communication status and data content from smart devices. If a fault is detected, an alarm is triggered and a solution is suggested.

9. The intelligent device control method as described in claim 8, characterized in that, The multi-threaded asynchronous communication module is activated, and an independent communication sub-thread is allocated to each smart device to establish an asynchronous communication connection, including the following steps: Initialize the thread pool and create a set number of worker threads; A separate device communication task is generated for each connected smart device and submitted to the task queue of the thread pool; The worker threads in the thread pool retrieve and execute device communication tasks from the task queue; During the execution of device communication tasks, asynchronous I / O operations based on Boost.Asio are used to perform data transmission and reception, thereby achieving non-blocking communication; Before sending data, flow control is performed using the token bucket algorithm, and data can only be sent after obtaining a token.

10. The intelligent device control method as described in claim 8, characterized in that, The adaptive data parsing module parses the original data frame into structured data, including the following steps: A predefined protocol parsing template is used to define and load format rules for various communication protocols through an external configuration file. These format rules include frame header identifier, field length, data type, verification method, and frame tail identifier. Load and parse the configuration file, and instantiate the format rules into a set of protocol parsing templates; After receiving the raw data frame from the smart device, the protocol template set is traversed, and the frame header features and checksum features of the raw data frame are matched with the format rules of each protocol parsing template. If a match is successful, the original data frame is parsed according to the matched protocol parsing template to extract structured data; If the match fails, a custom parsing is triggered, which calls the user-injected custom parsing logic to parse the original data frame and extract the structured data.

Citation Information

Cited By

  • A method for handling MCU synchronization failure of a dual-redundant EPS

    CN122260769A