Cross-platform data communication board data processing method and device

By creating the driver interface object layer and application program interface layer, designing protocol identification modules and buffer hierarchy mechanisms, and using lock-free concurrent queues and load balancing schedulers, it solves the cross-platform compatibility and performance bottlenecks of traditional communication boards, and realizes efficient and reliable data processing to meet diverse communication needs.

CN119420785BActive Publication Date: 2025-07-11KAIYUN LIANCHUANG (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510026296.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-07-11
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

Traditional industrial communication boards have poor cross-platform compatibility, obvious bottlenecks in high concurrent data processing performance, lack of effective data overflow processing mechanisms, the system is rigid in protocol parsing and conversion, insufficient interface abstraction and thread scheduling, serious resource waste or processing delays, high cost of driver interface packaging and protocol identification, and limited scalability of data processing flow.

Method used

By creating a driver interface object layer and an application program interface layer, a unified interface abstraction is realized, a protocol identification module and protocol template library is designed, a user-state event simulation mechanism and a buffer hierarchy mechanism are introduced, a lock-free concurrent queue is used to process real-time data, a disk map stores overflow data, and a load balancing scheduler is used to realize dynamic scaling of processing threads.

Benefits of technology

It breaks through the platform limitations and performance bottlenecks of traditional communication boards, provides efficient and reliable data processing solutions for industrial automation systems, supports flexible processing of multiple industrial protocols, realizes plug-and-play equipment, and improves the communication performance and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420785B_ABST
    Figure CN119420785B_ABST
Patent Text Reader

Abstract

The embodiments of this application provide a data processing method and device for cross-platform data communication board cards, which achieve unified interface abstraction by creating a driver interface object layer and an application program interface layer. The protocol recognition module and protocol template library are innovatively designed to support flexible protocol parsing and conversion. The user-state event simulation mechanism and buffer grading mechanism are introduced, the lock-free concurrent queue is used to process real-time data, the disk mapping is used to store overflow data, and the dynamic scaling of processing threads is achieved through the load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication board cards and provides an efficient and reliable data processing solution for industrial automation systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing, and particularly to a method and device for processing data of a cross-platform data communication board card. Background Art

[0002] Traditional methods for processing data of industrial communication board cards are usually developed for specific hardware platforms, with poor cross-platform compatibility. In the prior art, performance bottlenecks often occur when processing high-concurrency data, and there is a lack of an effective data overflow handling mechanism. The system is also relatively rigid in protocol parsing and conversion, making it difficult to adapt to diverse communication requirements.

[0003] At the same time, there are obvious deficiencies in interface abstraction and thread scheduling in the existing system. Traditional methods often adopt a fixed thread pool design, lacking dynamic scalability, and prone to resource waste or processing delays in scenarios with large load fluctuations. The system is also relatively simple in data cache management, failing to effectively balance memory usage and processing efficiency.

[0004] In addition, there are limitations in driver interface encapsulation and protocol recognition in the prior art. There is a lack of a unified interface abstraction layer, the protocol adaptation cost is relatively high, and the scalability of the data processing flow is limited. Solving these problems is of great significance for improving the performance and reliability of industrial communication systems. Summary of the Invention

[0005] In view of the problems in the prior art, this application provides a method and device for processing data of a cross-platform data communication board card, which can break through the platform limitations and performance bottlenecks of traditional communication board cards and provide an efficient and reliable data processing solution for industrial automation systems.

[0006] To solve at least one of the above problems, this application provides the following technical solutions:

[0007] In a first aspect, this application provides a method for processing data of a cross-platform data communication board card, including:

[0008] Creating a driver interface object layer, encapsulating the interface function prototypes in the driver interface object layer into an application programming interface layer, establishing a protocol recognition module and a protocol template library, where the protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into a protocol conversion engine; dividing the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board card type;

[0009] Build a user-mode event simulation mechanism, define an input / output event listening interface at the application programming interface layer. The input / output event listening interface establishes a buffer classification mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping; multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer; a load balancing scheduler is established, and the load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio;

[0010] Pass the implemented interface to the abstract board object in the application programming interface layer in the form of a function pointer. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation equipment, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointer to perform corresponding operations.

[0011] Further, create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, and loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into the protocol conversion engine, including:

[0012] Establish a board basic parameter configuration table and a board operation interface definition table in the driver layer, generate class definition code for the driver interface object layer according to the board basic parameter configuration table, parse the board operation interface definition table to obtain a list of interface function prototypes, encapsulate the list of interface function prototypes into the application programming interface layer through a function pointer mapping table, and establish a mapping relationship between the board operation functions and the interface layer functions;

[0013] Build a protocol parsing engine. The protocol parsing engine reads the preset protocol feature identification rules in the protocol template library, extracts features from the communication data packet header to obtain a protocol type identifier, retrieves a matching protocol parsing rule set from the protocol template library according to the protocol type identifier, and loads the protocol parsing rule set into the rule parser of the protocol conversion engine. The rule parser parses and converts the data according to the loaded rules.

[0014] Further, divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type, including:

[0015] Establish a board type recognition module. The board type recognition module reads the board hardware feature parameter table, parses the board function attribute identification bit to obtain the board type information, and extracts the corresponding interface function set from the interface function library according to the board type information, and generates an access control table for the data acquisition interface subset, an access control table for the data communication interface subset, and an access control table for the protocol communication interface subset;

[0016] Construct an interface organization manager. The interface organization manager reads the interface function definitions in each access control table, establishes an interface dependency graph, groups the interface functions based on the interface dependency graph, encapsulates the grouped interface functions into class library files for the corresponding subsets, and registers the class library files in the application programming interface layer and establishes a call mapping table.

[0017] Furthermore, construct a user-mode event simulation mechanism. Define an input / output event listening interface in the application programming interface layer. The input / output event listening interface establishes a buffer grading mechanism. The buffer grading mechanism includes a fast buffer and an overflow buffer. The fast buffer uses a lock-free concurrent queue to store real-time data, and the overflow buffer uses disk mapping to store over-limit data, including:

[0018] Create an event listener in the application programming interface layer. The event listener defines an input event handling function and an output event handling function, detects changes in the board status register through polling, converts the detected status changes into event messages, establishes an event message distribution table to record the correspondence between event types and handling functions, and calls the corresponding event handling functions according to the event message distribution table;

[0019] Construct a hierarchical buffer manager. The hierarchical buffer manager creates a lock-free concurrent queue based on the CAS algorithm as the fast buffer, creates a persistent storage area based on a memory-mapped file as the overflow buffer, sets the capacity threshold and data storage period of the fast buffer, and when the data volume in the fast buffer exceeds the capacity threshold or the data storage time exceeds the storage period, migrates the data to the overflow buffer.

[0020] Furthermore, multiple task processing threads are set in the lock-free concurrent queue. The task processing threads dynamically scale according to the system load threshold, and divert data to the overflow buffer when the data volume in the fast buffer exceeds the preset threshold; establish a load balancing scheduler. The load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio, including:

[0021] Build a thread pool manager, which creates a processing thread group and sets the initial number of threads. Establish a task waiting queue and a task distribution queue in the thread pool, monitor the CPU occupancy rate and memory usage rate of the system to calculate the system load value, dynamically adjust the number of active threads according to the system load value, recycle idle threads when the system load value exceeds the preset threshold, and create new processing threads when the system load value is lower than the preset threshold and there are pending tasks in the task waiting queue;

[0022] Create a load balancing scheduler, which collects the task queue lengths and processing delays of each processing thread to calculate the thread load scores, establishes a thread priority queue to store the thread load scores, calculates the task allocation weights based on the thread load scores, and distributes the pending data in the fast buffer and overflow buffer to the task queues of the corresponding processing threads according to the task allocation weights.

[0023] Further, pass the implemented interface to the abstract board object of the application programming interface layer in the form of a function pointer. The application programming interface layer receives data acquisition instructions and control instructions from industrial automation devices, including:

[0024] Build a board abstraction layer interface manager, which creates a board function description file, parses the board function description file to obtain a list of interface function declarations, builds a function pointer mapping table to store the memory addresses of the interface implementation functions, registers the function pointer mapping table into the abstract board object of the application programming interface layer, and establishes an interface function call link table to record the dependency relationship of function calls;

[0025] Create an instruction parsing processor, which receives data acquisition instructions and control instructions from industrial automation devices, performs syntax parsing on the instructions to obtain the operation code and parameter list, retrieves the corresponding interface function address from the function pointer mapping table according to the operation code, and calls the actual board operation function through the interface function address to execute the operations required by the instructions.

[0026] Further, send the data acquisition instructions and control instructions to the corresponding communication board through the function pointer to perform corresponding operations, including:

[0027] Build an instruction distributor, which parses the target board identifiers of the data acquisition instructions and control instructions, obtains the device descriptors of the target boards from the board registry, establishes board operation handles according to the device descriptors, obtains the corresponding board operation function addresses from the function pointer mapping table through the board operation handles, and generates a board instruction execution queue to store the instruction sequence to be executed;

[0028] Create an instruction execution scheduler. The instruction execution scheduler reads instructions from the instruction execution queue of the board, extracts the operation type and operation parameters of the instructions, calls the corresponding function pointer to execute the board operation function, creates an instruction execution status table to record the execution process and result of the instructions, and returns the instruction execution status table to the application programming interface layer for status update.

[0029] In a second aspect, the present application provides a cross-platform data communication board data processing device, including:

[0030] An interface object processing module, used to create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, create a protocol recognition module and a protocol template library. The protocol recognition module analyzes the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into a protocol conversion engine; divides the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type;

[0031] An event simulation module, used to construct a user-mode event simulation mechanism, define input / output event listening interfaces in the application programming interface layer. The input / output event listening interfaces establish a buffer hierarchical mechanism, and the buffer hierarchical mechanism includes a fast buffer and an overflow buffer. The fast buffer uses a lock-free concurrent queue to store real-time data, and the overflow buffer uses disk mapping to store over-limit data; multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer; a load balancing scheduler is established, and the load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to idle threads according to the thread load ratio;

[0032] A communication execution module, used to pass the implemented interfaces to the abstract board object of the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation equipment, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointers to perform corresponding operations.

[0033] In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of the cross-platform data communication board data processing method are implemented.

[0034] Fourthly, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the cross-platform data communication board data processing method are implemented.

[0035] Fifthly, the present application provides a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, the steps of the cross-platform data communication board data processing method are implemented.

[0036] As can be seen from the above technical solutions, the present application provides a cross-platform data communication board data processing method and device, which realizes unified interface abstraction by creating a driver interface object layer and an application program interface layer. The protocol recognition module and the protocol template library are innovatively designed to support flexible protocol parsing and conversion. The user-state event simulation mechanism and the buffer grading mechanism are introduced, and the lock-free concurrent queue is used to process real-time data. The disk mapping is used to store the overflow data, and the processing threads are dynamically scaled through the load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards and provides an efficient and reliable data processing solution for industrial automation systems. Description of the Drawings

[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0038] Figure 1 It is one of the flow diagrams of the cross-platform data communication board data processing method in the embodiments of the present application;

[0039] Figure 2 It is another flow diagram of the cross-platform data communication board data processing method in the embodiments of the present application;

[0040] Figure 3 It is yet another flow diagram of the cross-platform data communication board data processing method in the embodiments of the present application;

[0041] Figure 4 It is still another flow diagram of the cross-platform data communication board data processing method in the embodiments of the present application;

[0042] Figure 5 It is one of the flow diagrams of the cross-platform data communication board data processing method in the embodiments of the present application;

[0043] Figure 6It is the sixth flowchart diagram of the cross-platform data communication board data processing method in the embodiments of the present application;

[0044] Figure 7 It is the seventh flowchart diagram of the cross-platform data communication board data processing method in the embodiments of the present application;

[0045] Figure 8 It is the structural diagram of the cross-platform data communication board data processing device in the embodiments of the present application;

[0046] Figure 9 It is the structural diagram of the electronic device in the embodiments of the present application.

[0047] Reference numerals:

[0048] Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver program storage unit 9144, antenna 9111, speaker 9131, microphone 9132. Detailed implementation manners

[0049] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0050] In the technical solutions of the present application, the acquisition, storage, use, processing, etc. of data all comply with the relevant provisions of national laws and regulations.

[0051] Considering the problems existing in the prior art, the present application provides a cross-platform data communication board data processing method and device, which realize unified interface abstraction by creating a driver interface object layer and an application program interface layer. The protocol recognition module and the protocol template library are innovatively designed to support flexible protocol parsing and conversion. The user-state event simulation mechanism and the buffer grading mechanism are introduced, the lock-free concurrent queue is used to process real-time data, the disk mapping is used to store the overflow data, and the dynamic scaling of the processing threads is realized through the load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards and provides an efficient and reliable data processing solution for industrial automation systems.

[0052] In order to break through the platform limitations and performance bottlenecks of traditional communication boards and provide an efficient and reliable data processing solution for industrial automation systems, this application provides an embodiment of a data processing method for cross-platform data communication boards. Refer to Figure 1 The data processing method for cross-platform data communication boards specifically includes the following content:

[0053] Step S101: Create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain the protocol type identifier, loads the protocol parsing rules from the protocol template library according to the protocol type identifier, and writes the protocol parsing rules into the protocol conversion engine; divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type;

[0054] Optionally, this embodiment implements an efficient cross-platform communication board driver interface architecture. First, the implementation process is described in detail starting from the creation of the driver interface object layer. In the industrial automation field, there are various types of data acquisition boards, such as analog acquisition cards, digital I / O cards, bus communication cards, etc. These boards have different hardware characteristics and communication protocols.

[0055] To achieve unified management, this embodiment first constructs a board hardware abstraction layer. By parsing the hardware description file of the board, key parameters such as the register mapping table, interrupt configuration, DMA channel, etc. are extracted, and a hardware feature database is established. Based on these feature information, a hierarchical interface class structure is designed, including a basic interface class, a functional interface class, and an extended interface class. The basic interface class defines low-level operations such as reading and writing registers and configuring interrupts; the functional interface class implements service functions such as data acquisition and signal processing; the extended interface class supports the proprietary functions of specific boards.

[0056] The encapsulation of the interface function prototype adopts an innovative dynamic binding mechanism. First, a unified function prototype template is defined, including the type declarations of input parameters, output parameters, and return values. Then a function mapping table is established to store the correspondence between the interface function and the actual implementation. At runtime, the specific implementation is dynamically bound through function pointers, realizing the polymorphism of the interface. This design enables when adding support for a new board, only the corresponding interface function needs to be implemented without modifying the upper-layer application code.

[0057] The design of the protocol recognition module adopts a hierarchical processing strategy. At the physical layer, the synchronization and verification of data frames are realized; at the link layer, the fragmentation and recombination of data packets are carried out; at the application layer, the extraction and recognition of protocol features are realized. The feature extraction uses the sliding window algorithm to scan the data stream in real time. The extracted features include frame header format, function code distribution, data structure and other features, which constitute the fingerprint features of the protocol.

[0058] The protocol template library stores protocol definitions in XML format and supports hierarchical descriptions of protocols. Each protocol template contains four parts: protocol identification, data structure definition, parsing rules, and conversion rules. The protocol identification defines the unique identifier and version information of the protocol; the data structure definition describes the data format of the protocol; the parsing rules define the data parsing method; the conversion rules define the mapping relationship of protocol conversion.

[0059] This embodiment innovatively implements a dynamic loading mechanism for protocol parsing rules. After the protocol type is identified, the corresponding parsing rules are retrieved from the protocol template library. The rule loading adopts an incremental method, and only the necessary rule sets are loaded. By establishing a rule cache, the access speed of frequently used rules is improved. The rule loading process supports concurrent access, and a read-write lock mechanism is adopted to ensure data consistency.

[0060] The protocol conversion engine implements a pipeline processing architecture. The data first enters the preprocessing pipeline for data format standardization; then it enters the parsing pipeline to parse the data structure according to the loaded rules; finally, it enters the conversion pipeline to convert the data into the target format. Data is passed between each pipeline through a message queue, realizing asynchronous processing and improving processing efficiency.

[0061] In the division of the application program interface layer, this embodiment divides the interfaces into three subsets according to functional characteristics. The data acquisition interface subset is responsible for data acquisition and signal processing, including functions such as sampling rate configuration, trigger mode setting, and data caching; the data communication interface subset processes network communication to achieve reliable data transmission; the protocol communication interface subset is responsible for protocol processing, including protocol parsing, encapsulation, and conversion.

[0062] Each interface subset has implemented an independent resource management and exception handling mechanism. The reference counting method is used to manage the resource life cycle to avoid resource leakage. A thread-safe access control is implemented to ensure correctness in a multi-threaded environment. Through the event notification mechanism, collaborative work between subsets is realized.

[0063] The design of this embodiment effectively solves the problem of heterogeneous device communication in the industrial field. Through unified interface encapsulation, the differences of different hardware platforms are shielded; through a flexible protocol recognition and parsing mechanism, the processing of multiple industrial protocols is supported; through a reasonable interface division, the modularity and maintainability of the system are improved.

[0064] The comprehensive application of these technologies has significantly improved the communication performance and reliability of the system. In the actual industrial field, the system can quickly identify and process different types of communication protocols, supporting the plug-and-play of devices. Through the hierarchical interface design, the system can adapt to different types of industrial devices and achieve unified data acquisition and control. Especially in complex industrial environments, this flexible protocol processing mechanism provides strong support for device interconnection and interoperability.

[0065] Step S102: Build a user-mode event simulation mechanism. Define input / output event listening interfaces at the application programming interface layer. The input / output event listening interfaces establish a buffer hierarchical mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping. Multiple task processing threads are set in the lock-free concurrent queue. The task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds the preset threshold, the data is diverted to the overflow buffer. Establish a load balancing scheduler. The load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio.

[0066] Optionally, this embodiment implements an efficient user-mode event processing mechanism, mainly targeting the scenario of high-concurrency data acquisition and processing in the industrial automation field. First, the implementation process of the user-mode event simulation mechanism is described in detail.

[0067] This embodiment constructs an event-driven framework at the application programming interface layer. By establishing an event descriptor table, multiple event types including data acquisition events, communication events, and exception events are defined. Each event descriptor contains information such as event ID, priority, and processing function. The change of the hardware status register is monitored in a polling manner. When a status change is detected, a corresponding event message is generated.

[0068] The input / output event listening interface is designed using the observer pattern. Two core components, an event publisher and an event subscriber, are implemented. The event publisher is responsible for event collection and distribution, supporting event broadcast and multicast. The event subscriber is responsible for registering event processing functions, supporting dynamic subscription and cancellation. Through the establishment of an event routing table, accurate event delivery is achieved.

[0069] The buffer grading mechanism is the core innovation of this embodiment. The fast buffer is implemented based on a lock-free concurrent queue, and the CAS (Compare And Swap) operation is used to ensure concurrent safety. The queue nodes are organized in the form of an array, and each node contains a data block pointer and a status flag. To improve the memory utilization efficiency, a node pool mechanism is implemented, and the reuse of nodes is achieved through pre-allocation and recycling.

[0070] The overflow buffer is implemented using a memory-mapped file. First, a mapped file of a fixed size is created and mapped to the virtual memory space. The mapped memory is managed through a page replacement algorithm to achieve automatic data persistence. When the data volume in the fast buffer exceeds the threshold, a data migration mechanism is triggered to batch-write the data to the overflow buffer.

[0071] This embodiment innovatively implements a multi-threaded processing mechanism in a lock-free concurrent queue. Each processing thread maintains an independent task queue, and the work-stealing algorithm is used to achieve load balancing of tasks. The initial size of the thread pool is set according to the number of CPU cores, and the number of threads is dynamically adjusted by monitoring system load metrics. When the system load is detected to be too high, thread recycling is triggered; when tasks are backlogged, new processing threads are created.

[0072] The data shunting mechanism is controlled by the token bucket algorithm. By monitoring the change in the data volume of the fast buffer, the data inflow rate is calculated. When the data volume exceeds the preset threshold, the shunting strategy is started. The shunting process adopts a batch processing method, and the data blocks are packed and written to the overflow buffer. At the same time, a data index table is maintained to record the position information of the data in the overflow buffer.

[0073] The load balancing scheduler implements an innovative task allocation strategy. By collecting metrics such as the CPU usage rate, task queue length, and processing latency of the processing threads, the load score of the threads is calculated. A priority queue is constructed based on the load score to achieve priority scheduling of tasks. The scheduler regularly updates the thread status to ensure the real-time nature of task allocation.

[0074] This embodiment implements an adaptive task allocation algorithm. First, the load ratio of each thread is calculated as the weight factor for task allocation. Then, according to the priority and timeliness requirements of the data, a suitable target thread is selected. For data with high real-time requirements, it is preferentially allocated to a thread with a lighter load; for non-real-time data, it can be temporarily stored in the overflow buffer for processing.

[0075] In terms of exception handling, this embodiment implements a complete fault tolerance mechanism. When a processing thread exits abnormally, the thread can be automatically restored and tasks can be reallocated. By establishing a checkpoint mechanism, the recoverability of data processing is ensured. For the data in the overflow buffer, data consistency verification is implemented to avoid data loss or corruption.

[0076] The design of this embodiment effectively solves the problem of high-concurrency data processing in industrial fields. Through a hierarchical buffering mechanism, efficient data storage is achieved; through a lock-free concurrent queue, the concurrency of data processing is improved; through dynamic load balancing, reasonable utilization of system resources is ensured.

[0077] The comprehensive application of these technologies significantly enhances the data processing ability of the system. In actual industrial fields, the system can stably process high-speed data streams, ensuring the real-time and reliability of data. Especially in scenarios of data bursts, through reasonable data shunting and load balancing, system overload is effectively avoided, ensuring the continuity and reliability of industrial control.

[0078] Step S103: Pass the implemented interface to the abstract board object in the application programming interface layer in the form of a function pointer. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointer to perform corresponding operations.

[0079] Optionally, this embodiment implements a flexible interface transfer and instruction processing mechanism, mainly for the unified management requirements of multiple types of communication boards in the industrial automation field. The following details its technical implementation process.

[0080] This embodiment first constructs a function pointer mapping table. The mapping table is stored in a hash structure, with the key value being the interface identifier and the value being the corresponding function pointer. The mapping table supports dynamic updates. When new interfaces are implemented or existing interfaces are modified, the corresponding function pointers can be updated in real time. To ensure concurrent security, a read-write lock mechanism is used to protect access to the mapping table.

[0081] In the implementation of the abstract board object, a composite pattern design is adopted. Each board object includes a set of basic attributes and a set of operation interfaces. The basic attributes include information such as board type, communication parameters, and status flags; the set of operation interfaces is organized through an array of function pointers and supports multiple operation types. By establishing an interface version management mechanism, backward compatibility of the interfaces is ensured.

[0082] The process of passing function pointers adopts a registration-callback pattern. First, a unified interface registration function is defined in the application programming interface layer. This function receives the interface identifier and the function pointer as parameters. When the board driver is loaded, the implemented interface is registered to the interface layer through the registration function. The registration process performs parameter validity checks and type matching verifications.

[0083] This embodiment innovatively implements an instruction parsing mechanism. When receiving an instruction from an industrial automation device, instruction classification is first performed. Data acquisition instructions mainly include sampling parameter configuration, trigger control, data reading, etc.; control instructions include output control, mode switching, status setting, etc. The instruction parser extracts the operation code and parameters in the instruction and generates a standardized instruction description structure.

[0084] Instruction routing adopts a multi-level distribution strategy. First, the corresponding processing module is selected according to the instruction type, and then the specific board object is selected according to the target board identification. By querying the function pointer mapping table, the corresponding operation function address is obtained. To improve the query efficiency, a cache mechanism for the mapping table is implemented, and frequently used function pointers are stored in the fast cache.

[0085] During the instruction execution process, this embodiment implements a complete transaction management mechanism. Each instruction execution process is encapsulated as a transaction, including steps such as pre-execution status saving, operation execution, result verification, and status restoration. When the execution fails, it can automatically roll back to the pre-execution state. The execution process is recorded through transaction logs to support problem tracking and diagnosis.

[0086] Parameter passing is managed using smart pointers. During the function call process, the parameter data is encapsulated using smart pointers to ensure the automatic release of resources. For large data transfers, zero-copy technology is adopted, and the data buffer is directly passed through memory mapping to avoid unnecessary data copying.

[0087] This embodiment implements an asynchronous execution mechanism. For time-consuming operations, they are executed through asynchronous calls to avoid blocking the main thread. The asynchronous execution result is returned through a callback function to support chained processing. A timeout management mechanism is implemented, and when the execution time exceeds the preset threshold, the operation can be actively interrupted.

[0088] In terms of error handling, a hierarchical exception handling mechanism is implemented. At the function pointer call layer, possible access out-of-bounds and null pointer exceptions are captured; at the instruction execution layer, parameter errors and execution failure exceptions are handled; at the transaction management layer, status consistency exceptions are handled. The exception information includes detailed error codes and description information.

[0089] This embodiment particularly focuses on real-time requirements. For high-priority control instructions, a fast channel mechanism is implemented to bypass the regular instruction queue and execute directly. Through a priority scheduling algorithm, timely processing of critical instructions is ensured. An instruction merging mechanism is implemented to optimize consecutive instructions of the same type.

[0090] The comprehensive application of these technologies significantly improves the reliability and efficiency of the system. In the actual industrial field, this embodiment can stably process various control instructions, ensuring the real-time performance and reliability of instruction execution. Especially in complex control scenarios, through a flexible interface call mechanism and a perfect exception handling mechanism, the stable operation of the industrial control system is ensured.

[0091] The design of this embodiment effectively solves the core problems of communication control of industrial automation equipment. Through a unified interface transfer mechanism, the unified management of multiple communication boards is realized; through a reliable instruction processing mechanism, the accurate execution of control instructions is ensured; through a perfect exception handling mechanism, the fault tolerance of the system is improved. The application of these technologies enables the industrial control system to have higher reliability and flexibility.

[0092] As can be seen from the above description, the cross-platform data communication board data processing method provided by the embodiment of the present application can achieve unified interface abstraction by creating a driver interface object layer and an application program interface layer. The protocol recognition module and the protocol template library are innovatively designed to support flexible protocol parsing and conversion. The user-state event simulation mechanism and the buffer grading mechanism are introduced, the lock-free concurrent queue is used to process real-time data, the disk mapping is used to store overflow data, and the processing threads are dynamically scaled through the load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards, and provides an efficient and reliable data processing solution for industrial automation systems.

[0093] In an embodiment of the cross-platform data communication board data processing method of the present application, refer to Figure 2 , it may also specifically include the following content:

[0094] Step S201: Establish a board basic parameter configuration table and a board operation interface definition table in the driver layer, generate class definition code for the driver interface object layer according to the board basic parameter configuration table, parse the board operation interface definition table to obtain a list of interface function prototypes, encapsulate the list of interface function prototypes into the application program interface layer through a function pointer mapping table, and establish a mapping relationship between the board operation function and the interface layer function;

[0095] Step S202: Construct a protocol parsing engine, the protocol parsing engine reads the preset protocol feature identification rules in the protocol template library, extracts features from the communication data packet header to obtain a protocol type identifier, retrieves a matching protocol parsing rule set from the protocol template library according to the protocol type identifier, and loads the protocol parsing rule set into the rule parser of the protocol conversion engine, and the rule parser parses and converts the data according to the loaded rules.

[0096] Optionally, this embodiment implements a complete set of board driver interface generation and protocol parsing mechanisms for the unified management requirements of different types of communication boards in the industrial automation field. The following details its technical implementation process.

[0097] When constructing the board basic parameter configuration table at the driver layer, a hierarchical structure design is adopted. The configuration table includes three levels: hardware layer parameters, communication layer parameters, and function layer parameters. Hardware layer parameters define the physical characteristics of the board, such as register mapping, interrupt configuration, DMA channels, etc.; communication layer parameters include communication protocol types, baud rates, data formats, etc.; function layer parameters describe the functional characteristics of the board, such as sampling rates, trigger modes, data formats, etc.

[0098] This embodiment adopts a templatized design when defining the board operation interface. The interface definition table is described in XML format and includes information such as interface names, parameter lists, return value types, etc. By defining a unified interface description syntax, it supports the interface expression of different types of boards. Interface definitions support inheritance and composition relationships, facilitating the reuse and extension of interfaces.

[0099] The generation of class definition code for the driver interface object layer is automated. First, the board basic parameter configuration table is parsed to extract key parameter information. Then, based on predefined code templates, the attribute definitions, method declarations, and access controls of the class are automatically generated. The generated code includes necessary comments and documentation information to improve the maintainability of the code.

[0100] The implementation of the function pointer mapping table adopts a multi-level hash structure. The first-level hash table uses the board type as the key, and the second-level hash table uses the interface identifier as the key, with the corresponding function pointer as the value. This structure supports fast interface lookup and invocation. At the same time, a dynamic update mechanism for the mapping table is implemented, supporting interface registration and deregistration at runtime.

[0101] In the implementation of the protocol parsing engine, first, a protocol feature library is constructed. The feature library stores the feature patterns of various industrial protocols, including frame formats, function codes, verification methods, etc. The decision tree algorithm is used for feature matching to improve the accuracy and efficiency of protocol recognition. The feature extraction process supports fuzzy matching and can handle protocol variants and extensions.

[0102] The protocol type recognition adopts a multi-stage matching strategy. In the first stage, a quick filter is performed to quickly exclude non-matching protocols based on the key fields of the packet header; in the second stage, an exact match is performed to conduct a detailed feature comparison of the remaining candidate protocols; in the final stage, verification is performed to ensure the correctness of the recognition result.

[0103] This embodiment innovatively implements a dynamic loading mechanism for protocol parsing rules. The rule set is organized modularly and includes basic parsing rules, data conversion rules, and verification rules. The rule loading process supports incremental updates and only loads necessary rule modules. Through the rule caching mechanism, the access efficiency of frequently used rules is improved.

[0104] In the implementation of the rule parser, a pipeline processing model is adopted. The data first goes through a preprocessing stage to standardize the data format; then it enters the parsing stage to parse the data structure according to the loaded rules; finally, it is the conversion stage to convert the parsing result into the target format. The whole process supports parallel processing to improve the parsing efficiency.

[0105] The data conversion process implements a flexible mapping mechanism. By establishing a data field mapping table, the conversion relationship between the source format and the target format is defined. It supports complex data conversion rules, such as data type conversion, unit conversion, encoding conversion, etc. The configurability of data conversion is realized, which is convenient for adapting to different application requirements.

[0106] This embodiment pays special attention to the performance optimization of protocol parsing. A data caching mechanism is implemented to cache the parsing results and avoid repeated parsing. The zero-copy technology is adopted to reduce the memory copy during data transmission. Through the parallel processing mechanism, the processing efficiency of a large amount of data is improved.

[0107] In terms of exception handling, a complete error detection and recovery mechanism is implemented. For protocol parsing errors, the error location and cause can be accurately located, and the re-parsing of data is supported. The data integrity check is realized to ensure the correctness of the parsing results. Through the log recording mechanism, the tracking and diagnosis of problems are supported.

[0108] The comprehensive application of these technologies significantly improves the adaptability and reliability of industrial communication systems. In the actual industrial field, this embodiment can accurately identify and process various communication protocols and support the plug-and-play of devices. Especially in a complex multi-protocol environment, through the flexible protocol parsing mechanism, the reliability and efficiency of data communication are ensured.

[0109] The design of this embodiment effectively solves the protocol adaptation problem in industrial automation device communication. Through the unified interface generation mechanism, the standardization of the driver layer is realized; through the flexible protocol parsing mechanism, the processing of multiple communication protocols is supported; through the optimized performance design, the data processing efficiency is improved. The application of these technologies enables industrial control systems to have stronger interoperability and scalability.

[0110] In an embodiment of the data processing method of the cross-platform data communication board in this application, see Figure 3 , and it may specifically include the following content:

[0111] Step S301: Establish a board type recognition module. The board type recognition module reads the board hardware feature parameter table, parses the board function attribute identification bits to obtain the board type information, and extracts the corresponding interface function set from the interface function library according to the board type information, and generates an access control table for the data acquisition interface subset, an access control table for the data communication interface subset, and an access control table for the protocol communication interface subset;

[0112] Step S302: Construct an interface organization manager. The interface organization manager reads the interface function definitions in each access control table, establishes an interface dependency relationship graph, groups the interface functions based on the interface dependency relationship graph, encapsulates the grouped interface functions into class library files for the corresponding subsets, and registers the class library files in the application programming interface layer and establishes a call mapping table.

[0113] Optionally, this embodiment implements an intelligent board type recognition and interface management mechanism, mainly for the unified management requirements of various communication boards in industrial automation equipment. The following details its technical implementation process.

[0114] This embodiment first constructs a board hardware feature parameter table, which adopts a hierarchical data structure design. The parameter table includes a basic feature layer, a function feature layer, and an extended feature layer. The basic feature layer stores basic parameters such as hardware identification codes, version numbers, and manufacturer information; the function feature layer describes the function types, communication interface types, data processing capabilities, etc. of the board; the extended feature layer contains proprietary function parameters in specific application scenarios.

[0115] In the process of board type recognition, an innovative feature matching algorithm is implemented. First, read the hardware registers of the board to obtain the function attribute identification bits. Through bitmap parsing technology, extract the type information in the identification bits. An fuzzy matching mechanism is implemented to handle the compatibility problems of different version boards. When encountering a new model board, update the recognition rules through a feature learning algorithm.

[0116] The extraction of interface functions adopts an intelligent screening mechanism. According to the board type information, retrieve the matching function set from the interface function library. The function screening process considers the functional dependency relationship to ensure the integrity of the extracted function set. Function version management is implemented, supporting the coexistence and switching of different version interfaces.

[0117] The generation of the access control table adopts a multi-dimensional matrix structure. The access control table for the data acquisition interface subset includes function items such as acquisition parameter configuration, trigger control, and data reading; the access control table for the data communication interface subset includes function items such as communication parameter setting, data sending and receiving, and buffer management; the access control table for the protocol communication interface subset includes function items such as protocol parsing, data conversion, and protocol encapsulation.

[0118] In this embodiment, a graph theory algorithm is adopted in the implementation of the interface organization manager. First, an interface dependency graph is constructed, where nodes represent interface functions and edges represent the dependency relationships between functions. The dependency chains are analyzed through a depth-first search algorithm to identify strong and weak dependency relationships. Circular dependency detection is implemented to avoid interface call deadlocks.

[0119] The interface grouping process adopts a clustering analysis method. Based on the topological structure of the dependency graph, a community discovery algorithm is used to group the interface functions. The grouping process takes into account functional relevance and call frequency, and highly related interface functions are grouped into the same group. A dynamic grouping mechanism is implemented to support grouping adjustment during runtime.

[0120] The encapsulation of the class library files adopts a templatized design. Each subset of the class library contains interface declarations, implementation codes, and documentation. Conditional compilation of the interfaces is controlled through preprocessing directives to support transplantation across different platforms. A version control mechanism is implemented to ensure the consistency and traceability of the class library.

[0121] During the class library registration process, a dynamic loading mechanism is implemented. The application programming interface layer maintains a class library registry to record information about the loaded class libraries. Through symbol resolution technology, call mappings of the interface functions are established. Hot pluggable support is implemented to allow dynamic loading and unloading of class libraries during runtime.

[0122] The call mapping table adopts a multi-level cache structure. The first-level cache stores the direct call addresses of commonly used interfaces, and the second-level cache stores the complete mapping relationships. The cache content is optimized through a prediction algorithm to improve the interface call efficiency. Concurrent access control is implemented to ensure correctness in a multi-threaded environment.

[0123] This embodiment pays particular attention to the exception handling mechanism. During the interface call process, a complete error detection and recovery process is implemented. By establishing an error code mapping table, different types of exceptions are uniformly processed. Call chain tracking is implemented to support problem location and diagnosis.

[0124] In terms of performance optimization, a number of innovative technologies are adopted. The call overhead is reduced through function inlining optimization, the startup time is reduced using a lazy loading mechanism, asynchronous processing of interface calls is implemented, and the concurrent performance is improved.

[0125] The comprehensive application of these technologies significantly improves the maintainability and scalability of industrial control systems. In an actual industrial site, this embodiment can accurately identify various communication boards, automatically configure appropriate interface functions, and support plug-and-play of devices. Especially in a complex multi-device environment, through an intelligent interface management mechanism, the stable operation of the system is ensured.

[0126] The design of this embodiment effectively solves the core problems of industrial automation equipment interface management. Through a unified board card recognition mechanism, automatic configuration of equipment is achieved; through intelligent interface organization and management, the maintainability of the system is improved; through optimized performance design, the interface call efficiency is enhanced. The application of these technologies enables industrial control systems to have stronger adaptability and reliability.

[0127] In an embodiment of the data processing method for a cross-platform data communication board card in the present application, refer to Figure 4 , and it may specifically include the following content:

[0128] Step S401: Create an event listener at the application programming interface layer. The event listener defines an input event processing function and an output event processing function. By polling, it detects changes in the board card status register, converts the detected status changes into event messages, establishes an event message distribution table to record the correspondence between event types and processing functions, and calls the corresponding event processing function according to the event message distribution table;

[0129] Step S402: Construct a hierarchical buffer manager. The hierarchical buffer manager creates a lock-free concurrent queue based on the CAS algorithm as a fast buffer, creates a persistent storage area based on a memory-mapped file as an overflow buffer, sets the capacity threshold and data storage period of the fast buffer. When the data volume in the fast buffer exceeds the capacity threshold or the data storage time exceeds the storage period, the data is migrated to the overflow buffer.

[0130] Optionally, this embodiment implements an efficient event listening and buffer management mechanism, mainly for scenarios of high-frequency data acquisition and real-time processing in industrial automation equipment. The following details its technical implementation process.

[0131] This embodiment first establishes a status mapping table in the event listener. This table adopts a bitmap structure to record the meanings and change rules of each status bit of the board card. Through the hardware abstraction layer interface, direct access to the status register is achieved. The polling process adopts an adaptive strategy, dynamically adjusting the polling interval according to the status change frequency, ensuring real-time performance while avoiding resource waste.

[0132] The design of the event processing function adopts the template method pattern. The input event processing function is mainly responsible for data acquisition, signal processing, and data verification; the output event processing function is responsible for data sending, status update, and result confirmation. Each processing function includes three stages: preprocessing, core processing, and postprocessing, supporting customized expansion of the processing flow.

[0133] State change detection uses a differential comparison algorithm. By maintaining a state snapshot, the current state is compared with the previous state at the bit level to identify the changed state bits. The priority sorting of state changes is implemented to ensure that important state changes are processed first. For compound state changes, state machine parsing technology is used for decomposition processing.

[0134] The generation of event messages adopts a structured design. Each event message contains fields such as timestamp, event type, state value, and priority. The reuse of message objects is achieved through the message pool mechanism, reducing the memory allocation overhead. A message compression mechanism is implemented to merge consecutive similar events.

[0135] This embodiment innovatively implements an event message distribution mechanism. The distribution table adopts a multi-level hash structure, supporting fuzzy matching and exact matching of event types. By establishing an event processing pipeline, asynchronous and parallel processing of events is achieved. Event priority scheduling is implemented to ensure the timely processing of critical events.

[0136] In the implementation of the hierarchical buffer manager, the fast buffer constructs a lock-free concurrent queue based on the CAS (Compare And Swap) algorithm. The queue nodes are organized in an array form, and each node contains a data block pointer and a status flag. Concurrent access control is achieved through atomic operations, avoiding the performance overhead brought by using traditional lock mechanisms.

[0137] The capacity management of the fast buffer adopts a dynamic adjustment strategy. By monitoring the data inflow rate and processing rate, the buffer usage trend is predicted. When it is predicted that an overflow may occur, data migration is triggered in advance to avoid buffer blocking caused by burst data. A memory fragmentation reorganization mechanism is implemented to improve memory utilization efficiency.

[0138] The overflow buffer is based on a memory-mapped file to achieve persistent storage. First, a fixed-size mapped file is created, and the file is mapped to the virtual address space of the process. The mapped memory is managed through a page replacement algorithm to achieve automatic data persistence. An asynchronous writing mechanism is adopted to reduce the impact of IO operations on performance.

[0139] The data migration process implements a batch processing mechanism. When the migration condition is triggered, batch migration is performed in units of data blocks. Through double-buffering technology, continuous writing during the migration process is achieved. A data index table is maintained to record the location information of the data in the overflow buffer, supporting fast retrieval.

[0140] This embodiment pays special attention to the data consistency problem. During the data migration process, a transaction mechanism is adopted to ensure the atomicity of migration operations. A checkpoint mechanism is implemented to support data recovery in case of migration failure. Through a version control mechanism, data conflicts in concurrent access scenarios are handled.

[0141] In terms of performance optimization, a number of innovative technologies are adopted. Data copying is accelerated through SIMD instructions, memory pre-allocation is used to reduce the overhead of dynamic allocation, data compression storage is achieved, and storage efficiency is improved. At the same time, an intelligent prefetch mechanism is implemented to pre-load data blocks that may need to be accessed in advance.

[0142] The comprehensive application of these technologies significantly improves the data processing ability of industrial control systems. In actual industrial sites, this embodiment can stably process high-frequency acquisition data, ensuring the real-time and integrity of data. Especially in the case of data burst scenarios, through the hierarchical buffering mechanism, data loss and system blockage are effectively avoided.

[0143] The design of this embodiment effectively solves the core problems of high-speed data acquisition and processing in industrial automation equipment. Through an efficient event listening mechanism, real-time monitoring of device status is achieved; through innovative buffer management, the reliability of data processing is improved; through optimized performance design, the processing ability of the system is enhanced. The application of these technologies enables industrial control systems to have stronger data processing ability and reliability.

[0144] In an embodiment of the data processing method of the cross-platform data communication board in this application, refer to Figure 5 and it can also specifically include the following content:

[0145] Step S501: Construct a thread pool manager. The thread pool manager creates a processing thread group and sets the initial number of threads, establishes a task waiting queue and a task distribution queue in the thread pool, monitors the CPU occupancy rate and memory usage rate of the system to calculate the system load value, dynamically adjusts the number of active threads according to the system load value, reclaims idle threads when the system load value exceeds a preset threshold, and creates new processing threads when the system load value is lower than the preset threshold and there are pending tasks in the task waiting queue;

[0146] Step S502: Create a load balancing scheduler. The load balancing scheduler collects the task queue lengths and processing delays of each processing thread to calculate the thread load scores, establishes a thread priority queue to store the thread load scores, calculates the task allocation weights based on the thread load scores, and distributes the pending data in the fast buffer and the overflow buffer to the task queues of the corresponding processing threads according to the task allocation weights.

[0147] Optionally, this embodiment implements a set of intelligent thread management and load balancing mechanisms, mainly for the efficient scheduling requirements of complex data processing tasks in industrial automation equipment. The following details its technical implementation process.

[0148] In this embodiment, a resource monitoring mechanism is first established in the thread pool manager. By collecting system metrics such as CPU usage rate, memory occupancy rate, and IO waiting time, a multi-dimensional load evaluation model is constructed. The sliding window method is used to calculate the system load trend, and combined with the exponential smoothing algorithm to predict short-term load changes, realizing precise monitoring of resource usage.

[0149] The initialization of the thread pool adopts a hierarchical design. The core thread group is responsible for handling regular tasks, and the dynamic thread group is responsible for handling burst tasks. The number of core threads is set according to the number of CPU cores to ensure basic processing capabilities. The thread lifecycle is maintained by the thread state manager, supporting operations such as thread creation, suspension, resume, and destruction.

[0150] The task queue management adopts a multi-level queue structure. The task waiting queue is implemented using a priority queue, supporting dynamic adjustment of task priorities. The task distribution queue adopts the work stealing algorithm, allowing idle threads to obtain tasks from the queues of other busy threads. Task timeout management is implemented to avoid long-term task blocking.

[0151] This embodiment innovatively implements a thread dynamic scaling mechanism. By setting multiple load threshold intervals, different thread adjustment strategies are defined. When the system load continuously exceeds the upper threshold, the thread recycling process is triggered; when the load drops below the lower threshold and there are pending tasks, the thread expansion process is started. The change in the number of threads adopts a progressive strategy to avoid drastic fluctuations.

[0152] The thread recycling process implements an intelligent selection mechanism. Threads with the longest idle time are preferentially recycled, and the recycling objects are selected by maintaining thread activity records. An elegant exit mechanism is implemented to ensure that threads are recycled only after completing the current task. Thread context information is retained during the recycling process to support rapid recovery.

[0153] The creation of new threads adopts the template instantiation method. The thread creation process is uniformly managed by the thread factory, setting thread priorities and affinities. A thread warm-up mechanism is implemented to pre-initialize the thread running environment. The thread pool reuse strategy is adopted to reduce the overhead of thread creation and destruction.

[0154] The implementation of the load balancing scheduler adopts an adaptive algorithm. First, the performance metrics of each processing thread are collected, including the task queue length, average processing latency, CPU usage rate, etc. The thread load score is obtained through weighted calculation, and the score calculation takes into account the historical processing ability and the current load status.

[0155] The thread priority queue is implemented using a red-black tree, supporting fast sorting and updating of thread load scores. Thread identifiers and load scores are stored in the queue, and the queue order is maintained through periodic updates. A priority preemption mechanism is implemented, allowing high-priority tasks to interrupt the processing of low-priority tasks.

[0156] The calculation of task assignment weights adopts normalization processing. Based on the thread load score, the softmax function is used to calculate the task reception probability of each thread. The weight calculation takes into account the task type and processing difficulty, and assigns different weight coefficients to different types of tasks. Dynamic weight adjustment is implemented to optimize the allocation strategy according to the task processing effect.

[0157] The data allocation process implements a batch processing mechanism. Batch read the data to be processed from the fast buffer and the overflow buffer, and allocate it to each processing thread according to the calculated weight ratio. Through data locality optimization, relevant data is preferentially allocated to the same thread for processing. The task affinity mechanism is implemented to improve the cache utilization efficiency.

[0158] This embodiment particularly focuses on the real-time nature of task processing. By setting the task deadline, the dynamic promotion of task priority is realized. For tasks approaching the deadline, the task migration mechanism is triggered to transfer the task to a thread with lighter load for processing. The task pre-scheduling mechanism is implemented to plan the task execution order in advance.

[0159] A complete fault tolerance mechanism is implemented in terms of exception handling. When a thread exception is detected, a backup thread is automatically started to take over the task. Through the task checkpoint mechanism, support for task breakpoint recovery is provided. The task retry strategy is implemented to intelligently retry failed tasks.

[0160] The comprehensive application of these technologies significantly improves the task processing ability of the industrial control system. In the actual industrial field, this embodiment can efficiently process complex data processing tasks and ensure the reasonable utilization of system resources. Especially in the scenario of load fluctuation, through the intelligent scheduling mechanism, the stable operation of the system is guaranteed.

[0161] The design of this embodiment effectively solves the core problem of task scheduling in industrial automation equipment. Through the dynamic thread management mechanism, the elastic expansion and contraction of processing ability are realized; through the intelligent load balancing strategy, the resource utilization efficiency is improved; through the optimized task allocation mechanism, the processing performance is enhanced. The application of these technologies enables the industrial control system to have stronger task processing ability and reliability.

[0162] In an embodiment of the data processing method of the cross-platform data communication board card of the present application, see Figure 6 , and it may specifically include the following content:

[0163] Step S601: Construct a board abstraction layer interface manager. The board abstraction layer interface manager creates a board function description file, parses the board function description file to obtain a list of interface function declarations, constructs a function pointer mapping table to store the memory addresses of interface implementation functions, registers the function pointer mapping table into the abstract board object of the application programming interface layer, and establishes an interface function call link table to record the dependency relationships of function calls.

[0164] Step S602: Create an instruction parsing processor. The instruction parsing processor receives data acquisition instructions and control instructions from industrial automation devices, performs syntax parsing on the instructions to obtain operation codes and parameter lists, retrieves the corresponding interface function addresses from the function pointer mapping table according to the operation codes, and calls the actual board operation functions through the interface function addresses to execute the operations required by the instructions.

[0165] Optionally, this embodiment implements a complete set of board abstraction layer interface management and instruction processing mechanisms, mainly for the unified management requirements of multiple types of boards in industrial automation devices. The following details its technical implementation process.

[0166] This embodiment first establishes the template structure of the board function description file. The description file adopts the XML format and includes a basic information section, an interface declaration section, and a configuration parameter section. The basic information section records information such as the board model, version, and manufacturer; the interface declaration section defines all operation interfaces supported by the board, including function names, parameter types, return value types, etc.; the configuration parameter section stores the initialization parameters and runtime parameters of the board.

[0167] The parsing of the interface function declaration list adopts lexical analysis technology. By constructing a finite state machine, keywords, identifiers, and special symbols in the function declaration are identified. The parsing process supports function overloading and can handle interface functions with the same name but different parameters. A parameter type checking mechanism is implemented to ensure the correctness of the interface declaration.

[0168] The function pointer mapping table is implemented using a multi-level hash structure. The first-level hash table uses the operation type as the key, and the second-level hash table uses the specific interface identifier as the key, and the value is the memory address of the corresponding function. The mapping table supports dynamic updates. When the interface implementation changes, the corresponding function pointers can be updated in real time.

[0169] This embodiment innovatively implements an interface registration mechanism. In the abstract board object of the application programming interface layer, an interface registration table is established. The registration process includes interface verification, version checking, and conflict detection. Through the version management mechanism, the coexistence of multiple versions of interfaces is supported. The interface lifecycle management is implemented, and dynamic registration and cancellation of interfaces are supported.

[0170] The interface function call link table is designed in a graph structure. Nodes represent interface functions, and edges represent call relationships. The call chain is analyzed using the depth - first search algorithm to identify cyclic dependencies and deadlock risks. A call chain optimization mechanism is implemented to reduce unnecessary function call levels.

[0171] The implementation of the instruction parsing processor adopts a pipeline processing model. First, the received instructions are pre - processed, including format verification and character encoding conversion. Then it enters the syntax analysis stage, and a recursive descent parser is used to extract the operation code and parameters. A syntax error - tolerance mechanism is implemented to handle minor deviations in the instruction format.

[0172] The operation code parsing adopts a pattern - matching algorithm. An operation code dictionary is established to store all supported operation types. Fast matching is achieved through a trie structure, supporting fuzzy matching and alias matching. An operation code version management is implemented to handle the compatibility of different versions of instruction sets.

[0173] The processing of the parameter list adopts a type - safe design. A parameter type checking and conversion mechanism is implemented to ensure that the parameter format meets the interface requirements. Through parameter verification rules, the value range and dependency relationships of parameters are checked. Support for default value processing and optional parameter processing of parameters is provided.

[0174] This embodiment pays particular attention to the performance optimization of interface calls. A function pointer caching mechanism is implemented, and frequently used interface addresses are stored in a fast cache. Through an instruction batch - processing mechanism, consecutive similar instructions are merged to reduce the number of interface calls. Asynchronous call support is implemented to improve the concurrent processing ability.

[0175] In terms of error handling, a multi - layer protection mechanism is implemented. At the instruction parsing layer, syntax errors and parameter errors are captured; at the interface call layer, function call exceptions are handled; at the execution layer, operation failure exceptions are handled. Through an error tracking mechanism, problem location and diagnosis are supported.

[0176] The execution of the board operation functions adopts a transaction management method. Each operation is encapsulated as a transaction, including pre - execution checks, operation execution, result verification, and status rollback. The execution process is recorded through a transaction log to support the retry and recovery of operations.

[0177] This embodiment implements instruction priority management. For control instructions, the priority is higher than that of data acquisition instructions. The instructions to be executed are organized through a priority queue to ensure the timely response of critical operations. Instruction timeout processing is implemented to avoid long - term blocking.

[0178] The comprehensive application of these technologies significantly improves the reliability and efficiency of industrial control systems. In an actual industrial site, this embodiment can accurately process various control instructions and data acquisition instructions, ensuring the real-time performance and reliability of instruction execution. Especially in complex control scenarios, through a unified interface management and instruction processing mechanism, the stable operation of the system is ensured.

[0179] The design of this embodiment effectively solves the core problems of interface management and instruction processing of industrial automation equipment. Through unified abstract layer interface management, the standardization of device operations is achieved; through an efficient instruction processing mechanism, the execution efficiency of control instructions is improved; through a perfect exception handling mechanism, the reliability of the system is enhanced. The application of these technologies makes the industrial control system more adaptable and maintainable.

[0180] In an embodiment of the data processing method of the cross-platform data communication board card in this application, referring to Figure 7 , it may specifically include the following content:

[0181] Step S701: Construct an instruction dispatcher. The instruction dispatcher parses the target board card identifiers of data acquisition instructions and control instructions, obtains the device descriptors of the target board cards from the board card registry, establishes board card operation handles according to the device descriptors, obtains the corresponding board card operation function addresses from the function pointer mapping table through the board card operation handles, and generates a board card instruction execution queue to store the instruction sequence to be executed;

[0182] Step S702: Create an instruction execution scheduler. The instruction execution scheduler reads the instructions in the board card instruction execution queue, extracts the operation types and operation parameters of the instructions, calls the corresponding function pointers to execute the board card operation functions, establishes an instruction execution status table to record the execution process and execution results of the instructions, and returns the instruction execution status table to the application program interface layer for status update.

[0183] Optionally, this embodiment implements a complete set of instruction distribution and execution scheduling mechanisms, mainly for the precise control requirements of complex instruction sequences in industrial automation equipment. The following details its technical implementation process.

[0184] This embodiment first constructs a hierarchical structure of the board card registry. The registry adopts a tree structure, with the root node being the device manager, the intermediate nodes being the board card categories, and the leaf nodes being the specific board card instances. Each board card instance contains attributes such as device descriptors, communication parameters, and status information. Fast positioning and access to the board cards are achieved through an indexing mechanism.

[0185] The parsing of the device descriptor adopts the template matching method. The descriptor contains information such as hardware identification, communication interface, and functional characteristics. The board type is identified through the feature extraction algorithm, and the mapping relationship between board features and operation functions is established. The version management of the descriptor is realized, and the compatibility processing of different version boards is supported.

[0186] This embodiment innovatively realizes the board operation handle mechanism. The handle object encapsulates the operation interface and status information of the board, providing a unified access method. The life cycle of the handle is managed through reference counting, supporting the sharing and recycling of handles. The handle pool management is realized, optimizing the efficiency of handle allocation and release.

[0187] The management of the instruction sequence adopts a multi-level queue structure. According to the instruction priority and timing requirements, the instructions are allocated to different execution queues. The high-priority queue is used for emergency control instructions, the medium-priority queue is used for general control instructions, and the low-priority queue is used for data acquisition instructions. The dynamic scheduling between queues is realized to ensure the timely execution of critical instructions.

[0188] The implementation of the instruction execution scheduler adopts the event-driven model. An instruction execution state machine is established, defining the life cycle states of the instructions. The execution process of the instructions is controlled through state transition rules, including stages such as instruction parsing, parameter verification, execution preparation, and result processing. The state backtracking mechanism is realized, supporting the interruption and recovery of instruction execution.

[0189] The operation type recognition adopts the feature matching algorithm. An operation type dictionary is established, storing all supported operation modes. The rapid recognition of operation types is realized through the decision tree algorithm, supporting the decomposition processing of composite operations. The extension mechanism of operation types is realized, facilitating the addition of new operation supports.

[0190] The parameter processing adopts the type-safe mechanism. The parameter format conversion and validity verification are realized to ensure that the parameters meet the board requirements. The correlation relationship between parameters is analyzed through the parameter dependency graph to avoid parameter conflicts. The dynamic adjustment of parameters is supported to adapt to different operation scenarios.

[0191] The process of function pointer call realizes a complete protection mechanism. Through the function call wrapper, the exception handling and resource management are encapsulated. The function call timeout control is realized to avoid the risk of deadlock. The retry strategy for function calls is supported to improve the execution reliability.

[0192] This embodiment particularly focuses on the management of the instruction execution status. The status table adopts a matrix structure, recording the information of each stage of instruction execution. Including start time, execution progress, resource occupancy, completion status, etc. Through the status analysis algorithm, the execution effect is evaluated in real time, supporting the rapid response to abnormal situations.

[0193] Multiple innovations have been achieved in performance optimization. Through the instruction batch processing mechanism, similar instructions are merged to reduce execution overhead. Instruction pre-execution analysis is implemented to identify possible execution conflicts in advance. A parallel execution strategy is adopted to improve the instruction processing efficiency.

[0194] For status updates, an asynchronous notification mechanism is used. The execution status is transmitted through a message queue to avoid blocking the main processing flow. Compressed storage of status is implemented to reduce the transmission overhead of status information. Batch updates of status are supported to improve the update efficiency.

[0195] Multi-layer protection is implemented for exception handling. Operation exceptions are captured at the instruction execution layer, update exceptions are handled at the status management layer, and transmission exceptions are handled at the communication layer. Through the exception propagation mechanism, ensure that exceptions can be correctly processed and reported.

[0196] The comprehensive application of these technologies has significantly improved the instruction processing ability of industrial control systems. In actual industrial sites, this embodiment can efficiently process complex instruction sequences, ensuring the accuracy and reliability of instruction execution. Especially in high-load scenarios, through an intelligent scheduling mechanism, the stable operation of the system is guaranteed.

[0197] The design of this embodiment effectively solves the core problems of instruction processing in industrial automation equipment. Through a unified instruction distribution mechanism, precise control of instructions is achieved; through an efficient scheduling strategy, the instruction execution efficiency is improved; through a perfect status management, the reliability of the system is enhanced. The application of these technologies enables industrial control systems to have stronger instruction processing capabilities and stability.

[0198] In order to break through the platform limitations and performance bottlenecks of traditional communication boards and provide an efficient and reliable data processing solution for industrial automation systems, this application provides an embodiment of a cross-platform data communication board data processing device for implementing all or part of the content of the cross-platform data communication board data processing method, see Figure 8 , the cross-platform data communication board data processing device specifically includes the following:

[0199] The interface object processing module 10 is used to create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application program interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module analyzes the communication data characteristics to obtain the protocol type identifier, loads the protocol parsing rules from the protocol template library according to the protocol type identifier, and writes the protocol parsing rules into the protocol conversion engine; divides the application program interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type;

[0200] An event simulation module 20 is used to build a user-mode event simulation mechanism, define input / output event listening interfaces at the application programming interface layer. The input / output event listening interfaces establish a buffer hierarchical mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping; multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer; a load balancing scheduler is established, and the load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to idle threads according to the thread load ratio.

[0201] A communication execution module 30 is used to pass the implemented interfaces to the abstract board object at the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication boards through the function pointers to perform corresponding operations.

[0202] As can be seen from the above description, the cross-platform data communication board data processing device provided by the embodiments of the present application can achieve unified interface abstraction by creating a driver interface object layer and an application programming interface layer. Innovatively design a protocol recognition module and a protocol template library to support flexible protocol parsing and conversion. Introduce a user-mode event simulation mechanism and a buffer hierarchical mechanism, use a lock-free concurrent queue to process real-time data, store overflow data using disk mapping, and achieve dynamic scaling of processing threads through a load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards and provides an efficient and reliable data processing solution for industrial automation systems.

[0203] From the hardware level, in order to break through the platform limitations and performance bottlenecks of traditional communication boards and provide an efficient and reliable data processing solution for industrial automation systems, the present application provides an embodiment of an electronic device for implementing all or part of the content in the cross-platform data communication board data processing method. The electronic device specifically includes the following contents:

[0204] A processor, a memory, a communications interface, and a bus; wherein the processor, the memory, and the communications interface communicate with each other through the bus; the communications interface is used to implement information transmission between the cross-platform data communication board data processing device and related devices such as a core business system, a user terminal, and a related database; the logic controller may be a desktop computer, a tablet computer, a mobile terminal, etc., and this embodiment is not limited thereto. In this embodiment, the logic controller may be implemented with reference to the embodiments of the cross-platform data communication board data processing method and the embodiments of the cross-platform data communication board data processing device, the content of which is incorporated herein, and the repeated parts will not be elaborated.

[0205] It can be understood that the user terminal may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Among them, the smart wearable device may include smart glasses, a smart watch, a smart bracelet, etc.

[0206] In practical applications, part of the cross-platform data communication board data processing method may be executed on the electronic device side as described above, or all operations may be completed in the client device. Specifically, it can be selected according to the processing capacity of the client device and the limitations of the user usage scenario, etc. This application does not make any limitations in this regard. If all operations are completed in the client device, the client device may further include a processor.

[0207] The above-mentioned client device may have a communication module (i.e., a communication unit), and may be communicatively connected to a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and may also include a server on an intermediate platform in other implementation scenarios, such as a server on a third-party server platform communicatively linked to the task scheduling center server. The server may include a single computer device, or may include a server cluster composed of multiple servers, or a server structure of a distributed device.

[0208] Figure 9 This is a schematic block diagram of the system composition of the electronic device 9600 according to an embodiment of the present application. As Figure 9 shown, the electronic device 9600 may include a central processing unit 9100 and a memory 9140; the memory 9140 is coupled to the central processing unit 9100. It should be noted that this Figure 9 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0209] In one embodiment, the function of the cross-platform data communication board data processing method can be integrated into the central processing unit 9100. Among them, the central processing unit 9100 can be configured to perform the following controls:

[0210] Step S101: Create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into the protocol conversion engine; divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type;

[0211] Step S102: Construct a user-mode event simulation mechanism, define input / output event listening interfaces in the application programming interface layer. The input / output event listening interfaces establish a buffer grading mechanism, and the buffer grading mechanism includes a fast buffer and an overflow buffer. The fast buffer uses a lock-free concurrent queue to store real-time data, and the overflow buffer uses disk mapping to store over-limit data; multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer; establish a load balancing scheduler, and the load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio;

[0212] Step S103: Pass the implemented interfaces to the abstract board object in the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions from industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointers to perform corresponding operations.

[0213] As can be seen from the above description, the electronic device provided by the embodiment of the present application realizes unified interface abstraction by creating a driver interface object layer and an application programming interface layer. Innovatively designs a protocol recognition module and a protocol template library to support flexible protocol parsing and conversion. Introduces a user-mode event simulation mechanism and a buffer grading mechanism, uses a lock-free concurrent queue to process real-time data, disk mapping to store overflow data, and realizes the dynamic scaling of processing threads through a load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards, and provides an efficient and reliable data processing solution for industrial automation systems.

[0214] In another embodiment, the cross-platform data communication board data processing device can be configured separately from the central processing unit 9100. For example, the cross-platform data communication board data processing device can be configured as a chip connected to the central processing unit 9100, and the functions of the cross-platform data communication board data processing method can be implemented through the control of the central processing unit.

[0215] As Figure 9 shown, the electronic device 9600 may further include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It should be noted that the electronic device 9600 does not necessarily have to include Figure 9 all the components shown in Figure 9 ; in addition, the electronic device 9600 may further include

[0216] components not shown in Figure 9 ; reference may be made to the prior art.

[0217] Among them, the memory 9140 can be, for example, one or more of a buffer, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices. The above information related to failures can be stored, and in addition, programs for executing relevant information can also be stored. And the central processing unit 9100 can execute the program stored in the memory 9140 to implement information storage or processing, etc.

[0218] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to supply power to the electronic device 9600. The display 9160 is used for displaying display objects such as images and texts. The display can be, for example, an LCD display, but is not limited thereto.

[0219] The memory 9140 can be a solid-state memory. For example, a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It can also be such a memory that stores information even when powered off, can be selectively erased and has more data. Examples of such a memory are sometimes referred to as EPROMs, etc. The memory 9140 can also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, and the application / function storage unit 9142 is used to store application programs and function programs or the processes for operating the electronic device 9600 through the central processing unit 9100.

[0220] The memory 9140 may further include a data storage unit 9143 for storing data such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers of the electronic device for communication functions and / or for performing other functions of the electronic device (such as a messaging application, an address book application, etc.).

[0221] The communication module 9110 is a transmitter / receiver that transmits and receives signals via the antenna 9111. The communication module 9110 (transmitter / receiver) is coupled to the central processing unit 9100 to provide input signals and receive output signals, which may be the same as in the case of a conventional mobile communication terminal.

[0222] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module, and / or a wireless local area network module, etc. The communication module 9110 (transmitter / receiver) is also coupled to the speaker 9131 and the microphone 9132 via the audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby implementing normal telecommunication functions. The audio processor 9130 may include any suitable buffers, decoders, amplifiers, etc. In addition, the audio processor 9130 is also coupled to the central processing unit 9100, so that recording can be performed on the local machine through the microphone 9132, and the sound stored on the local machine can be played through the speaker 9131.

[0223] Embodiments of the present application also provide a computer-readable storage medium capable of implementing all steps of the cross-platform data communication board data processing method in which the execution subject in the above embodiments is a server or a client. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, all steps of the cross-platform data communication board data processing method in which the execution subject in the above embodiments is a server or a client are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0224] Step S101: Create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into an application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into a protocol conversion engine; divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type;

[0225] Step S102: Construct a user-mode event simulation mechanism, define input / output event listening interfaces at the application programming interface layer. The input / output event listening interfaces establish a buffer hierarchical mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping. Multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer. A load balancing scheduler is established, and the load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to idle threads according to the thread load ratio.

[0226] Step S103: Pass the implemented interfaces to the abstract board object at the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointers to perform corresponding operations.

[0227] As can be seen from the above description, the computer-readable storage medium provided by the embodiments of the present application realizes unified interface abstraction by creating a driver interface object layer and an application programming interface layer. Innovatively designs a protocol recognition module and a protocol template library, supporting flexible protocol parsing and conversion. Introduces a user-mode event simulation mechanism and a buffer hierarchical mechanism, uses a lock-free concurrent queue to process real-time data, disk mapping to store overflow data, and realizes dynamic scaling of processing threads through a load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards, providing an efficient and reliable data processing solution for industrial automation systems.

[0228] The embodiments of the present application also provide a computer program product that can implement all steps of the cross-platform data communication board data processing method with the execution subject being a server or a client in the above embodiments. When the computer program / instructions are executed by a processor, the steps of the cross-platform data communication board data processing method are implemented. For example, the computer program / instructions implement the following steps:

[0229] Step S101: Create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads protocol parsing rules from the protocol template library according to the protocol type identifier, and writes the protocol parsing rules into the protocol conversion engine. Divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type.

[0230] Step S102: Construct a user-mode event simulation mechanism. Define input / output event listening interfaces at the application programming interface layer. The input / output event listening interfaces establish a buffer hierarchical mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping. Multiple task processing threads are set in the lock-free concurrent queue, and the task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds the preset threshold, the data is diverted to the overflow buffer. A load balancing scheduler is established. The load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio.

[0231] Step S103: Pass the implemented interfaces to the abstract board object at the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions of industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointers to perform corresponding operations.

[0232] As can be seen from the above description, the computer program product provided by the embodiments of the present application realizes unified interface abstraction by creating a driver interface object layer and an application programming interface layer. Innovatively designs a protocol recognition module and a protocol template library, supporting flexible protocol parsing and conversion. Introduces a user-mode event simulation mechanism and a buffer hierarchical mechanism, uses a lock-free concurrent queue to process real-time data, stores overflow data using disk mapping, and realizes the dynamic scaling of processing threads through a load balancing scheduler. This method breaks through the platform limitations and performance bottlenecks of traditional communication boards, and provides an efficient and reliable data processing solution for industrial automation systems.

[0233] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a device, or a computer program product. Therefore, the present invention can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.

[0234] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (devices), and computer program products according to embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.

[0235] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.

[0236] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one flow Figure 1 one flow or multiple flows and / or blocks Figure 1 or means for implementing the functions specified in one block or multiple blocks.

[0237] Specific embodiments are applied in the present invention to elaborate on the principles and implementation manners of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, based on the idea of the present invention, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present invention.

Claims

1. A data processing method for a cross-platform data communication board, characterized in that, The method includes: Create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application programming interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into the protocol conversion engine; divide the application programming interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type; Construct a user-mode event simulation mechanism, define input / output event monitoring interfaces in the application programming interface layer. The input / output event monitoring interfaces establish a buffer classification mechanism, which includes a fast buffer and an overflow buffer. The fast buffer stores real-time data using a lock-free concurrent queue, and the overflow buffer stores over-limit data using disk mapping; Set multiple task processing threads in the lock-free concurrent queue. The task processing threads dynamically scale according to the system load threshold. When the data volume in the fast buffer exceeds a preset threshold, the data is diverted to the overflow buffer; establish a load balancing scheduler. The load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio. Specifically, it includes: Construct a thread pool manager. The thread pool manager creates a processing thread group and sets the initial number of threads, establishes a task waiting queue and a task distribution queue in the thread pool, monitors the CPU occupancy rate and memory usage rate of the system to calculate the system load value, dynamically adjusts the number of active threads according to the system load value, reclaims idle threads when the system load value exceeds a preset threshold, and creates new processing threads when the system load value is lower than the preset threshold and there are pending tasks in the task waiting queue; Create a load balancing scheduler. The load balancing scheduler collects the task queue lengths and processing delays of each processing thread to calculate the thread load scores, establishes a thread priority queue to store the thread load scores, calculates the task allocation weights based on the thread load scores, and distributes the pending data in the fast buffer and the overflow buffer to the task queues of the corresponding processing threads according to the task allocation weights; Pass the implemented interfaces to the abstract board card object in the application programming interface layer in the form of function pointers. The application programming interface layer receives data acquisition instructions and control instructions from industrial automation devices, and issues the data acquisition instructions and control instructions to the corresponding communication board cards through the function pointers to perform corresponding operations.

2. The data processing method of the cross-platform data communication board card according to claim 1, wherein The creation of the driver interface object layer, encapsulating the interface function prototypes in the driver interface object layer into the application programming interface layer, establishing a protocol recognition module and a protocol template library, the protocol recognition module parsing the communication data characteristics to obtain a protocol type identifier, loading a protocol parsing rule from the protocol template library according to the protocol type identifier, and writing the protocol parsing rule into the protocol conversion engine includes: Establish a board card basic parameter configuration table and a board card operation interface definition table at the driver layer. Generate class definition code for the driver interface object layer according to the board card basic parameter configuration table. Parse the board card operation interface definition table to obtain a list of interface function prototypes. Package the list of interface function prototypes into the application program interface layer through a function pointer mapping table, and establish a mapping relationship between the board card operation functions and the interface layer functions; Construct a protocol parsing engine. The protocol parsing engine reads the preset protocol feature identification rules in the protocol template library, extracts features from the communication data packet header to obtain a protocol type identifier, retrieves a matching protocol parsing rule set from the protocol template library according to the protocol type identifier, and loads the protocol parsing rule set into the rule parser of the protocol conversion engine. The rule parser parses and converts the data according to the loaded rules.

3. The data processing method of the cross-platform data communication board according to claim 1, characterized in that The application program interface layer is divided into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board card type, including: Establish a board card type recognition module. The board card type recognition module reads the board card hardware feature parameter table, parses the board card function attribute identification bit to obtain the board card type information, extracts the corresponding interface function set from the interface function library according to the board card type information, and generates an access control table for the data acquisition interface subset, an access control table for the data communication interface subset, and an access control table for the protocol communication interface subset; Construct an interface organization manager. The interface organization manager reads the interface function definitions in each access control table, establishes an interface dependency relationship graph, groups the interface functions based on the interface dependency relationship graph, packages the grouped interface functions into class library files for the corresponding subsets, and registers the class library files in the application program interface layer and establishes a call mapping table.

4. The data processing method of the cross-platform data communication board according to claim 1, characterized in that The construction of the user-mode event simulation mechanism defines an input / output event listening interface in the application program interface layer. The input / output event listening interface establishes a buffer grading mechanism. The buffer grading mechanism includes a fast buffer and an overflow buffer. The fast buffer uses a lock-free concurrent queue to store real-time data, and the overflow buffer uses disk mapping to store over-limit data, including: Create an event listener in the application program interface layer. The event listener defines an input event processing function and an output event processing function, detects changes in the board card status register through polling, converts the detected status changes into event messages, establishes an event message distribution table to record the correspondence between event types and processing functions, and calls the corresponding event processing functions according to the event message distribution table; Construct a hierarchical buffer manager. The hierarchical buffer manager creates a lock-free concurrent queue based on the CAS algorithm as the fast buffer, creates a persistent storage area based on a memory-mapped file as the overflow buffer, sets the capacity threshold and data storage period of the fast buffer. When the data volume in the fast buffer exceeds the capacity threshold or the data storage time exceeds the storage period, the data is migrated to the overflow buffer.

5. The data processing method of the cross-platform data communication board according to claim 1, wherein The interfaces to be implemented are passed to the abstract board object of the application interface layer in the form of function pointers. The application interface layer receives data acquisition instructions and control instructions for industrial automation devices, including: Construct an interface manager for the board abstraction layer. The interface manager for the board abstraction layer creates a board function description file, parses the board function description file to obtain a list of interface function declarations, constructs a function pointer mapping table to store the memory addresses of the interface implementation functions, registers the function pointer mapping table into the abstract board object of the application interface layer, and establishes an interface function call link table to record the dependency relationships of function calls; Create an instruction parsing processor. The instruction parsing processor receives data acquisition instructions and control instructions from industrial automation devices, performs syntax parsing on the instructions to obtain an operation code and a parameter list, retrieves the corresponding interface function address from the function pointer mapping table according to the operation code, and calls the actual board operation function through the interface function address to execute the operations required by the instructions.

6. The data processing method of the cross-platform data communication board according to claim 1, characterized in that The data acquisition instructions and control instructions are sent to the corresponding communication board through the function pointers to perform corresponding operations, including: Construct an instruction dispatcher. The instruction dispatcher parses the target board identifier of the data acquisition instructions and control instructions, obtains the device descriptor of the target board from the board registry, establishes a board operation handle according to the device descriptor, obtains the corresponding board operation function address from the function pointer mapping table through the board operation handle, and generates a board instruction execution queue to store the instruction sequence to be executed; Create an instruction execution scheduler. The instruction execution scheduler reads the instructions in the board instruction execution queue, extracts the operation type and operation parameters of the instructions, calls the corresponding function pointer to execute the board operation function, establishes an instruction execution status table to record the execution process and execution results of the instructions, and returns the instruction execution status table to the application interface layer for status update.

7. A data processing device for a cross-platform data communication board, characterized in that, The device includes: An interface object processing module, which is used to create a driver interface object layer, encapsulate the interface function prototypes in the driver interface object layer into the application interface layer, establish a protocol recognition module and a protocol template library. The protocol recognition module parses the communication data characteristics to obtain a protocol type identifier, loads a protocol parsing rule from the protocol template library according to the protocol type identifier, and writes the protocol parsing rule into a protocol conversion engine; divide the application interface layer into a data acquisition interface subset, a data communication interface subset, and a protocol communication interface subset according to the board type; An event simulation module, which is used to construct a user-mode event simulation mechanism, define an input / output event listening interface in the application interface layer. The input / output event listening interface establishes a buffer grading mechanism. The buffer grading mechanism includes a fast buffer and an overflow buffer. The fast buffer uses a lock-free concurrent queue to store real-time data, and the overflow buffer uses disk mapping to store over-limit data; Multiple task processing threads are set in the lock-free concurrent queue. The task processing threads dynamically scale according to the system load threshold. When the amount of data in the fast buffer exceeds the preset threshold, the data is split to the overflow buffer. A load balancing scheduler is established. The load balancing scheduler monitors the load status of the processing threads and distributes the data in the fast buffer and the overflow buffer to the idle threads according to the thread load ratio. Specifically, it includes: Construct a thread pool manager. The thread pool manager creates a processing thread group and sets the initial number of threads. A task waiting queue and a task distribution queue are established in the thread pool. The system load value is calculated by monitoring the CPU occupancy rate and memory usage rate of the system. The number of active threads is dynamically adjusted according to the system load value. When the system load value exceeds the preset threshold, the idle threads are recycled. When the system load value is lower than the preset threshold and there are pending tasks in the task waiting queue, new processing threads are created; Create a load balancing scheduler. The load balancing scheduler collects the task queue length and processing delay of each processing thread to calculate the thread load score. A thread priority queue is established to store the thread load scores. Based on the thread load scores, the task allocation weight is calculated, and the pending data in the fast buffer and the overflow buffer is distributed to the task queues of the corresponding processing threads according to the task allocation weight; A communication execution module is used to pass the implemented interface to the abstract board object of the application program interface layer in the form of a function pointer. The application program interface layer receives the data acquisition instructions and control instructions of the industrial automation device, and issues the data acquisition instructions and control instructions to the corresponding communication board through the function pointer to perform corresponding operations.

8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, When the processor executes the program, the steps of the cross-platform data communication board data processing method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the cross-platform data communication board data processing method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Network data capture and analysis system based on ARM framework hardware platform

    CN118573595A

  • Equipment access method and system based on protocol conversion

    CN119094626A