Mass spectrometer control box reliable communication method and device

CN122985698APending Publication Date: 2026-10-27THE 718TH RES INST OF CHINA STATE SHIPBUILDING CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610818704.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-08
Publication Date
2026-10-27

AI Technical Summary

Benefits of technology

[0013]与现有技术相比,本公开的有益效果是:①提升了控制指令传输的确定性与低延迟性:通过动态优先级量化计算算法,将优先级从定性分类升级为多因子加权量化计算,结合无条件抢占式调度,保证 P0 级实时控制指令的毫秒级甚至微秒级响应,解决了传统方法中优先级响应不确定的问题,满足质谱仪高精度扫描的实时性要求;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985698A_ABST
    Figure CN122985698A_ABST
Patent Text Reader

Abstract

A mass spectrometer control box reliable communication method and device, the main steps include: establishing a multi-thread task model and initializing a communication queue; intelligent scheduling of communication instructions; data verification and reception confirmation by the receiver. The method and device integrate dynamic priority quantization algorithm, adaptive hybrid scheduling algorithm, intelligent differentiated retransmission algorithm and other core algorithms through the integrated architecture of multi-thread cooperation, queue intelligent management, multi-algorithm fusion scheduling, multiple verification and prediction recovery, realizing low-delay deterministic transmission of control instructions, complete and reliable upload of collected data, and improving system resource utilization and adaptive capacity of communication links.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mass spectrometry analysis instrument control technology, and in particular to a reliable communication method and device for a mass spectrometry control box, used for high-performance and high-reliability data communication between the host computer and the mass spectrometry control box, and between various functional modules inside the control box. Background Technology

[0002] The overall performance of a mass spectrometer largely depends on the real-time performance and communication reliability of its control system. However, the communication methods used in traditional mass spectrometer control boxes have several limitations, mainly manifested in the lack of quantization algorithm support for real-time control, the lack of adaptive data scheduling, the fixed retransmission mechanism leading to resource waste, the link monitoring only being able to passively recover, and the queue management being prone to congestion. Specifically: (1) Traditional communication architecture only makes simple qualitative division of instruction priority without quantitative calculation model. It cannot be dynamically adjusted according to link status, queue load and instruction urgency, resulting in a lack of determinism in the preemption response of high priority control instructions and difficulty in stably meeting millisecond-level latency requirements. (2) The scheduling mechanism is mostly a single preemptive or fair scheduling, without the support of a fusion algorithm. It cannot dynamically adjust the bandwidth allocation of low-priority data streams when high-priority instructions burst, which easily leads to channel congestion or resource idleness. It is difficult to balance system throughput and real-time performance. (3) The retransmission mechanism adopts a fixed interval and fixed number of retransmission strategies, without taking into account the instruction priority and link status for differentiated design, which can easily lead to untimely retransmission of high-priority instructions and excessive consumption of communication resources by retransmission of low-priority instructions. (4) Link status monitoring can only be passively triggered to recover after an anomaly occurs. There is no mechanism for early prediction and pre-treatment. The response delay due to link quality deterioration will lead to a large number of data packets being lost, affecting the integrity of mass spectrometry data acquisition. (5) The queue management adopts a fixed cache threshold and has no dynamic congestion control algorithm. When the data flow fluctuates instantaneously, queue overflow or cache idleness may occur, which cannot smooth the fluctuation peak of the data flow. (6) In multi-core processor systems, traditional thread management and scheduling algorithms are disconnected, and CPU core resources cannot be dynamically allocated according to the algorithm execution results, resulting in low efficiency of resource coordination between communication I / O and data operation.

[0003] Existing technologies do not design a multi-algorithm collaborative communication system adapted to the communication scenarios of mass spectrometers, which is suitable for the characteristics of mass spectrometry control commands and data streams. They cannot ensure the stability and reliability of returned data while taking into account the real-time performance of communication, data integrity and system resource utilization, and thus cannot meet the stringent requirements of high-precision mass spectrometry analysis for communication systems. Summary of the Invention

[0004] To address the above issues, this disclosure combines multi-threaded division of labor with intelligent queue management, incorporating five core algorithms: dynamic priority quantization calculation, adaptive hybrid scheduling, intelligent differentiated retransmission, link state perception and predictive recovery, and queue dynamic buffer congestion control. This constructs a high-performance and reliable communication method for mass spectrometry control boxes based on multi-algorithm collaboration, achieving low-latency deterministic transmission of control commands and complete and reliable uploading of acquired data, while also adaptively and efficiently utilizing communication resources and proactively tolerating faults and enabling rapid recovery.

[0005] The core of this method lies in constructing an integrated collaborative communication architecture that integrates multi-threaded division of labor, intelligent queue management, multi-algorithm fusion scheduling, and multiple verification and predictive recovery. This architecture involves a host computer, a master control unit (within the control box), and multiple slave control units (scanning voltage control, ion source control, vacuum gauge control, data acquisition unit, etc.). It quantifies, dynamically, and adaptively upgrades the original communication mechanism through five core algorithms. The specific technical solution is divided into three main steps: thread and queue initialization, multi-algorithm fusion scheduling, and multiple verification and predictive recovery. Each step incorporates specific algorithm models and quantitative calculation logic.

[0006] Specifically, it includes: S1 creates multiple independent execution threads and defines the core division of labor. At the same time, it uses dynamic queue caching congestion control to build an adaptive FIFO buffer queue that can expand or shrink and prevent congestion, thereby realizing the logical separation of communication I / O operations and data processing and decoupling the direct dependencies between threads. S2 performs quantization priority calculation on communication commands and executes an adaptive hybrid scheduling of preemptive, weighted fair queue and traffic shaping based on the priority result to ensure low-latency transmission of high-priority commands while also ensuring bandwidth for low-priority data streams. S3 performs multiple verifications and predictive recovery to achieve reliable data transmission and adaptive fault tolerance of the link.

[0007] Furthermore, step S1 specifically includes: S11, create an independent execution thread, including: Data transmission thread: used for data preprocessing, data packet encapsulation, updating data packet priority according to the calculation results of dynamic priority quantization algorithm, and handing it over to the serial port management thread for transmission; Serial port management thread: used for initialization of the underlying serial port, resource management and physical layer data transmission and reception, real-time collection of link status parameters and uploading to the communication control thread, providing data support for algorithm calculation; Data receiving thread: Used to read raw data from the receiving buffer, parse the protocol, perform CRC check and sequence number verification, put data that passes the verification into the receiving queue, and record the error of data packets that fail the verification and feed it back to the data sending thread; Communication control thread: Used in the core execution unit of the algorithm, responsible for the calculation of the core algorithm, business logic processing, thread scheduling and queue management; The communication control thread is bound to the main CPU core, and the other threads are bound to the slave cores. S12: Construct two main buffer queues, a send queue and a receive queue, and divide them into sub-queues according to instruction type. Threads share queues for data transfer through a producer-consumer model, using mutexes and condition variables to ensure data consistency. Simultaneously, a dynamic queue buffer congestion control algorithm is introduced to achieve adaptive adjustment of the queue buffer. The specific calculation and execution logic is as follows: Let the maximum basic cache threshold of the queue be Real-time cache usage is The instantaneous enqueue rate of the data stream is The outgoing speed is The congestion warning threshold is The congestion relief threshold is The dynamic expansion coefficient is k; when and If the congestion persists for t1, it is determined to be queue congestion; when and If the congestion persists for t2, it is determined that the congestion has been resolved. During congestion, the queue buffer capacity is dynamically expanded. Simultaneously, the communication control thread sends a flow shaping instruction to the data sending thread to reduce the enqueue rate of low-priority data streams; after congestion is relieved, the queue buffer capacity is restored to [previous capacity]. The flow shaping command failed. when This triggers a low-priority data packet discarding mechanism, prioritizing the buffer space for high-priority real-time control commands. The discarded data packets are recorded with their sequence numbers, and retransmission is triggered once the queue is idle.

[0008] Furthermore, step S2 specifically includes: S21, Design a multi-factor weighted dynamic priority quantization model: convert the priority of communication commands into a computable quantized value P:

[0009] in The weighting coefficients for each factor are dynamically adjusted according to the mass spectrometer's operating mode. P1: Instruction type factor, 100 for real-time control instructions and 50 for data stream instructions; P2: Instruction urgency factor, P2=100 / (tout), where tou is the instruction timeout time; P3: Link status factor, P3=H×100, where H is the link health; P4: Queue load factor ; Priority is determined according to the established rules: P is divided into 3 levels based on the calculation results. It is the highest priority level, P0. It is the second highest priority level, P1. It is a normal priority level P2; Priority rules are dynamically updated: When the link status or queue load changes, the communication control thread recalculates P and updates the priority identifier of the data packet in real time; S22, adaptive hybrid scheduling, specific execution logic: P0 level highest priority instructions: adopt unconditional preemptive scheduling; at the same time, the transmission of P0 level instructions uses dedicated channel bandwidth to ensure the determinism of its transmission; P1 and P2 level ordinary priority instructions: use weighted fair queue scheduling; The communication control thread monitors the load status and link bandwidth utilization of each sub-queue in real time. When a P0-level instruction burst is detected or the link bandwidth utilization is ≥80%, dynamic scheduling parameter adjustment is triggered. When the P0-level instruction burst ends and the link bandwidth utilization is ≤60%, the scheduling parameters are restored to the default value. Set dynamic delay transmission parameters for P1 and P2 level data stream commands in the transmission queue. , Calculated dynamically based on the mass spectrometry scanning frequency f. This ensures the stability of the scanned data while avoiding a decrease in communication speed caused by fixed delays.

[0010] Furthermore, step S3 specifically includes: S31, add identification information to each data packet, including: sequence number SN, CRC32 check code, and instruction priority identifier P. The receiver performs triple verification of sequence number continuity, CRC32 integrity, and priority identifier consistency. S32 dynamically calculates the retransmission trigger time tre, maximum retransmission count Nmax, and retransmission interval tint based on the instruction priority P and link health H, enabling fast retransmission of high-priority instructions and on-demand retransmission of low-priority instructions, as detailed below: Retransmission trigger time: , Based on the trigger time; Maximum number of retransmissions: ; Retransmission interval: , The base interval is n, where n is the number of retransmissions. Differential retransmission is implemented according to the following strategy: P0 level highest priority instruction: Immediate continuous retransmission, , The retransmission interval is dynamically adjusted according to the link health status until an ACK is received or the status is reached. If the maximum number of attempts is reached and the error still fails, a system-level alarm will be triggered and the error will be marked. P1 level, second highest priority instruction: fast delayed retransmission. , Selective retransmission is used, only retransmitting lost or corrupted data packets reported by NACK; P2 level normal priority instruction: Delayed retransmission as needed. , Retransmission is triggered only when the link bandwidth utilization is ≤50%. If the maximum number of retransmissions is reached and the transmission still fails, the data packet is discarded and the sequence number is recorded. The packet will be retransmitted when the system is idle. For retransmitted data packets, their priority value P is temporarily increased to improve the retransmission success rate. S33, Link Health Measurement Model and Anomaly Prediction: Define link state parameters, including: bit error rate (BER), latency jitter (J), bandwidth utilization (BU), and connection persistence (C), and construct a quantitative model for link health (H) as follows:

[0011] in: For the maximum permissible bit error rate, Maximum allowable delay jitter; Connection persistence C: Continuous uninterrupted communication time ≥ 10s, set to 1. Take 0.5, and take 0 if it is less than 5s; Health status grading: 0.8≤H≤1 is excellent, 0.5≤H<0.8 is good, 0.2≤H<0.5 is poor, and H<0.2 is abnormal; The sliding window method is used for link anomaly prediction, including: using T as the sliding window, calculating the rate of change of link health within the window in real time. ,when And currently When the link is deemed to be at high risk, a pre-handling mechanism is triggered. The pre-processing mechanism includes: the communication control thread immediately issuing a flow control command to reduce the transmission rate of low-priority data streams, increase the dedicated bandwidth of P0-level commands, and simultaneously initiate the initialization of the backup communication link to prepare for link switching. After an anomaly occurs, a tiered recovery process is triggered, including: Level 1 recovery: resetting the communication port and reinitializing the serial port parameters; Level 2 recovery: switching to the backup communication link; Level 3 recovery: performing system-level communication reinitialization. After the link is restored, the communication control thread sends test data packets to verify the link health. Afterwards, normal scheduling and transmission strategies are restored, and data lost during the restoration process is recovered. Level data packets trigger retransmission.

[0012] A reliable communication device for a mass spectrometer control box using the above method mainly includes: The thread management module is used to create multiple independent execution threads and define the core division of labor. At the same time, it uses dynamic queue caching congestion control to build an adaptive FIFO buffer queue that can expand or shrink and prevent congestion. The intelligent scheduling module is used to quantify and prioritize communication commands and execute adaptive hybrid scheduling based on the priority results. The verification and confirmation module is used to perform multiple verifications and predictive recovery to achieve reliable data transmission and adaptive fault tolerance of the link.

[0013] Compared with the prior art, the beneficial effects of this disclosure are: ① Improved determinism and low latency of control command transmission: By using a dynamic priority quantization calculation algorithm, the priority is upgraded from qualitative classification to multi-factor weighted quantization calculation. Combined with unconditional preemptive scheduling, the millisecond or even microsecond response of P0 level real-time control commands is guaranteed, which solves the problem of uncertain priority response in traditional methods and meets the real-time requirements of high-precision scanning of mass spectrometers. ② Ensures the integrity and reliability of data transmission: Through triple data integrity verification + intelligent differentiated retransmission algorithm, combined with dynamic adjustment of retransmission parameters based on link health, the data packet loss rate is reduced to 10%. -7 The following approach avoids resource waste caused by fixed retransmissions and ensures complete uploading of mass spectrometry acquisition data even in complex electromagnetic environments. ③ Achieved adaptive and efficient utilization of communication resources: Through the adaptive hybrid scheduling algorithm and the queue dynamic buffer congestion control algorithm, the dynamic allocation of channel bandwidth, CPU cores and buffer resources was realized, which solved the problem of resource idleness and congestion coexisting in the traditional method. The system resource utilization rate was improved by more than 60%, while taking into account real-time performance and throughput. ④ Improved fault tolerance and stability of link communication: Through link status perception and predictive recovery algorithm, passive recovery is upgraded to active prediction + pre-processing + rapid recovery. The response time of link anomaly is shortened to less than 10ms, and the recovery success rate is increased to 99.9%, avoiding mass spectrometry data acquisition interruption caused by link quality deterioration. ⑤ It lays the communication foundation for improving the overall performance of the mass spectrometer: it realizes low-latency transmission of control commands, reliable uploading of acquired data, and efficient utilization of system resources, and solves the core problem of "difficulty in balancing data stability and real-time transmission" in traditional communication methods for mass spectrometers, thus significantly improving the scanning accuracy, data acquisition efficiency, and system stability of the mass spectrometer. Attached Figure Description

[0014] The above and other objects, features and advantages of this disclosure will become more apparent from the more detailed description of exemplary embodiments of this disclosure taken in conjunction with the accompanying drawings, in which the same reference numerals generally represent the same components.

[0015] Figure 1 This is an overall flowchart of an exemplary embodiment according to the present disclosure; Figure 2 A schematic diagram illustrating the core implementation mechanism and collaborative relationship of threads and queues; Figure 3 The flowchart of the dynamic priority quantization calculation and adaptive hybrid scheduling algorithm; Figure 4 The process of intelligent differentiated retransmission and link status awareness prediction and recovery algorithm. Detailed Implementation

[0016] Preferred embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be thorough and complete, and will fully convey the scope of the present disclosure to those skilled in the art.

[0017] This disclosure constructs a high-performance, highly reliable, and adaptive communication method for mass spectrometry control boxes through multi-algorithm fusion and quantization calculation.

[0018] In one exemplary implementation, the overall process is as follows: Figure 1 As shown, the main steps include: Step 1: Establish a multi-threaded task model to implement intelligent queue management and dynamic buffer congestion control. The entire process is as follows: Figure 1 As shown, four independent execution threads are created and their core functions are defined. A dynamic queue buffer congestion control algorithm is designed, and an adaptive FIFO buffer queue that can expand / shrink and prevent congestion is constructed. This achieves logical separation between communication I / O operations and data computation, decoupling direct dependencies between threads and laying the foundation for algorithm execution.

[0019] Step 2: Execute multi-algorithm fusion scheduling to achieve instruction quantization priority and adaptive transmission. The entire process is as follows: Figure 1 As shown. This step is the core algorithm execution stage, integrating a dynamic priority quantization calculation algorithm and an adaptive hybrid scheduling algorithm. First, the communication instructions are quantized and prioritized (rather than simply classified qualitatively). Then, based on the priority results, an adaptive hybrid scheduling algorithm of preemptive + weighted fair queue (WFQ) + traffic shaping is executed to ensure low-latency transmission of high-priority instructions while also ensuring bandwidth for low-priority data streams.

[0020] Step 3: Perform multiple verifications and predictive recovery to achieve reliable data transmission and adaptive fault tolerance of the link. The entire process is as follows: Figure 1 As shown. This step integrates a data integrity verification mechanism, an intelligent differentiated retransmission algorithm, and a link status awareness and predictive recovery algorithm, upgrading the traditional "passive verification + fixed retransmission + post-event recovery" to "active verification + quantized retransmission + predictive recovery," ensuring the integrity of data transmission and the stability of link communication.

[0021] The specific operation in step 1 is as follows: Step 1.1: Create four independent execution threads: a data sending thread, a data receiving thread, a serial port management thread, and a communication control thread. Each thread adopts a multi-core resource allocation strategy of core binding + priority scheduling. The communication control thread is bound to the main CPU core, and the other threads are bound to secondary cores to avoid core resource contention. The core division of labor for each thread is as follows: Data sending thread: responsible for data preprocessing, data packet encapsulation (adding sequence number, CRC check code, priority identifier, and instruction type), updating data packet priority according to the calculation result of dynamic priority quantization algorithm, and handing it over to the serial port management thread for sending.

[0022] Serial port management thread: Focuses on the initialization, resource management and physical layer data transmission and reception of the underlying serial port, collects link status parameters (bit error rate, latency jitter, bandwidth utilization) in real time and uploads them to the communication control thread to provide data support for algorithm calculation.

[0023] Data receiving thread: Responsible for reading raw data from the receiving buffer, parsing the protocol, performing CRC check and sequence number verification, putting data that passes the verification into the receiving queue, and recording errors for data packets that fail the verification and feeding them back to the data sending thread.

[0024] Communication control thread: As the core execution unit of the algorithm, it is responsible for the calculation of the five core algorithms, business logic processing, thread scheduling and queue management, and is the "brain" of the entire communication architecture.

[0025] Step 1.2: Construct two main buffer queues, namely a sending queue and a receiving queue, divide them into sub-queues by instruction type (a real-time control instruction sub-queue and a data flow instruction sub-queue). Queues are shared between threads for data transmission through the producer-consumer model, and mutex locks and condition variables are adopted to ensure data consistency; at the same time, a queue dynamic buffer congestion control algorithm is introduced to realize adaptive regulation of queue buffer, and the core calculation and execution logic are as follows: Define core quantization parameters: Let the maximum basic buffer threshold of the queue be , the real-time buffer occupancy be , the instantaneous enqueue rate of data flow be , the dequeue rate be , the congestion warning threshold be (taken as ×70%), the congestion clearance threshold be (taken as ×30%), and the dynamic expansion coefficient be k (1<k≤1.5, dynamically adjusted according to link bandwidth utilization); Congestion judgment: and last for t1 (5ms), it is determined that the queue is congested; when and last for t2 (10ms), it is determined that the congestion is cleared; Dynamic buffer regulation: When congestion occurs, the queue buffer capacity is dynamically expanded to , and the communication control thread sends a traffic shaping instruction to the data sending thread to reduce the enqueue rate of low-priority data flow; after the congestion is cleared, the queue buffer capacity is restored to , and the traffic shaping instruction becomes invalid; Queue overflow protection: When , a low-priority data packet discarding mechanism is triggered, the buffer space for high-priority real-time control instructions is preferentially guaranteed, the sequence numbers of the discarded data packets are recorded, and retransmission is triggered after the queue is idle.

[0026] The specific operations in Step 2 are as follows: Step 2.1: A dynamic priority quantization calculation algorithm, which realizes dynamic calibration of instruction priority.

[0027] Design a multi-factor weighted dynamic priority quantization model, convert the priority into a computable quantization value P (the larger P is, the higher the priority is), dynamically calculate according to four factors: instruction type, urgency, link state, and queue load, and the core quantization formula is as follows:

[0028] where is the weight coefficient of each factor, satisfying The adjustment is made dynamically according to the mass spectrometer's operating mode (e.g., in scanning mode). In data acquisition mode, ); P1: Command type factor, real-time control commands (multiplier voltage setting, protection current setting, etc.) are set to 100, data stream commands (mass number point voltage, mass spectrometry acquisition data, etc.) are set to 50; P2: Instruction urgency factor, calculated based on instruction timeout time, P2=100 / (tout), where tou is the instruction timeout time (ms). The shorter the timeout time, the higher the urgency. P3: Link status factor, calculated based on link health H, P3 = H × 100, where H is the link health (0 ≤ H ≤ 1, calculated from bit error rate and latency jitter, see step 3.3). P4: Queue load factor, calculated based on the cache occupancy rate of the corresponding sub-queue. The lower the queue occupancy rate, the higher the load factor. The algorithm executes according to the priority rules of the partitioning. Based on the calculation results, P is divided into 3 levels. It has the highest priority (P0 level). It is the second highest priority (P1 level). The P2 level is the normal priority level; the P0 level is dedicated to real-time control commands and supports channel preemption; the P1 / P2 levels are data stream commands, executed according to weighted fair scheduling. Priority rules are dynamically updated. When the link status or queue load changes (change rate ≥ 10%), the communication control thread recalculates P and updates the priority identifier of the data packet in real time to ensure the dynamic adaptability of priority.

[0029] Step 2.2 Adaptive Hybrid Scheduling Algorithm for Differentiated and Adaptive Instruction Transmission. Based on dynamic priority quantization results, an adaptive hybrid scheduling algorithm combining preemptive scheduling, weighted fair queues (WFQ), and dynamic traffic shaping is designed. The core of this algorithm is to dynamically adjust the scheduling strategy based on priority levels, queue load, and link bandwidth to achieve the optimal balance between overall system throughput and real-time performance. Specific execution logic is as follows: P0-level highest priority instructions: Unconditional preemptive scheduling is adopted. When a P0-level instruction enters the transmission queue, the serial port management thread immediately interrupts the currently transmitting P1 / P2-level instructions and allocates channel resources to the P0-level instructions. The interrupted P1 / P2-level instructions record the transmission breakpoint, and transmission continues from the breakpoint after the P0-level instructions are transmitted. At the same time, the transmission of P0-level instructions uses dedicated channel bandwidth (30% of the channel bandwidth is reserved and used only for P0-level instructions) to ensure the determinism of its transmission. P1 / P2 level ordinary priority instructions: Weighted Fair Queuing (WFQ) scheduling is used, assigning different bandwidth weights WP1 and WP2 to the P1 and P2 level sub-queues, satisfying WP1:WP2=2:1. The remaining 70% of the channel bandwidth is allocated in round-robin according to the weights. The calculation formula is as follows: in, Allocate bandwidth to the corresponding sub-queue. To reserve the remaining channel bandwidth after reserving the P0 level bandwidth; Dynamic traffic shaping and scheduling parameter adjustment: The communication control thread monitors the load status and link bandwidth utilization of each sub-queue in real time. When a burst of P0-level instructions is detected (inbound traffic per second ≥ N, where N is the mass spectrometer's rated threshold) or link bandwidth utilization ≥ 80%, dynamic scheduling parameter adjustment is triggered: temporarily increasing the dedicated bandwidth for P0-level instructions to 50% and reducing the bandwidth allocation for P1 / P2-level instructions; performing traffic shaping on P2-level instructions according to... Limit its dequeue rate; when a P0 level instruction burst ends and the link bandwidth utilization is ≤60%, the scheduling parameters are restored to their default values; Intelligent control of command delay transmission: To address the stability requirements of mass spectrometry scan data, dynamic delay transmission parameters are set for P1 / P2 level data stream commands in the transmission queue. , Dynamically calculated based on the mass spectrometry scanning frequency f ( This ensures the stability of the scanned data while avoiding a decrease in communication speed caused by fixed delays.

[0030] The specific operations in step 3 are as follows: This step integrates a data integrity verification mechanism, an intelligent differentiated retransmission algorithm, and a link status awareness and predictive recovery algorithm, upgrading the traditional "passive verification + fixed retransmission + post-event recovery" to "active verification + quantized retransmission + predictive recovery," ensuring the integrity of data transmission and the stability of link communication. The core implementation is as follows: Step 3.1 Multiple verifications of data integrity to achieve accurate verification of data packets. Three levels of identification information (sequence number SN, CRC32 checksum, and instruction priority identifier P) are added to each data packet. The receiver performs triple verification: sequence number continuity check + CRC32 integrity check + priority identifier consistency check. The core logic is as follows: CRC32 integrity check: The receiver performs a CRC32 calculation on the data packet and compares it with the checksum in the data packet. If they do not match, the data packet is considered corrupted. Sequence number continuity check: The receiver records the sequence number of the received data packets. If a sequence number change is detected, it is determined that the data packet is lost. Priority identifier consistency check: The receiver verifies whether the priority identifier of the data packet is consistent with the priority list issued by the communication control thread. If they are inconsistent, the data packet is determined to have been tampered with. Verification result processing: For data packets that pass verification, the receiver returns an acknowledgment message (ACK) with a sequence number and priority identifier; for data packets that fail verification (damaged / lost / tampered with), the receiver returns a negative acknowledgment message (NACK), records the error type and sequence number, and triggers a retransmission request.

[0031] Step 3.2 Intelligent Differentiated Retransmission Algorithm: Implementing Quantized Retransmission Based on Priority and Link Status Breaking through the limitations of traditional fixed retransmission, an intelligent differentiated retransmission model based on priority and link health is designed. According to the instruction priority P and link health H, the retransmission trigger time tre, maximum retransmission count Nmax, and retransmission interval tint are dynamically calculated. This enables fast retransmission of high-priority instructions and on-demand retransmission of low-priority instructions, avoiding resource waste. The core formula is as follows: Calculation of core quantization parameters: Retransmission trigger time: , The base trigger time is 1ms (default). The higher the priority, the shorter the trigger time. Maximum number of retransmissions: The result is rounded up. The higher the priority and the better the link health, the more maximum retransmissions are allowed. Retransmission interval: An exponential backoff optimization algorithm is used. , The base interval is 0.5ms by default, and n is the number of retransmissions. The worse the link health, the larger the retransmission interval should be to avoid link congestion. Differential retransmission is implemented according to the following strategy: P0 level highest priority instruction: Immediate continuous retransmission, , The retransmission interval is dynamically adjusted according to the link health status until an ACK is received or the status is reached. If the maximum number of attempts is reached and the error still fails, a system-level alarm will be triggered and the error will be marked. P1 level, second highest priority instruction: fast delayed retransmission. , Selective retransmission is employed (only the lost / corrupted data packets reported by NACK are retransmitted). P2 level normal priority instruction: Delayed retransmission as needed. , Retransmission is triggered only when the link bandwidth utilization is ≤50%. If the maximum number of retransmissions is reached and the transmission still fails, the data packet is discarded and the sequence number is recorded. The packet will be retransmitted when the system is idle. For retransmitted data packets, their priority value P is temporarily increased by 20% to ensure the transmission priority of retransmitted data and improve the retransmission success rate.

[0032] Step 3.3 Link state awareness and predictive recovery algorithm to achieve proactive fault tolerance and fast recovery of the link. The design incorporates a link health metric model and anomaly prediction algorithm, upgrading the traditional "post-event recovery" to "real-time perception + early prediction + pre-handling + rapid recovery." This involves real-time monitoring of the communication link's health status, early prediction of anomaly risks, pre-handling before anomalies occur, and rapid triggering of the recovery process after anomalies occur. The core implementation is as follows: Link health quantification calculation: Define four link state parameters: Bit Error Rate (BER), Latency J, Bandwidth Utilization (BU), and Connection Persistence (C), and construct a quantification model for link health H, with the formula as follows:

[0033] in: Maximum allowable bit error rate (default) ), Maximum allowable latency jitter (default 5ms); Connection persistence C: Continuous uninterrupted communication time ≥ 10s, set to 1. Take 0.5, and take 0 if it is less than 5s; Health status grading: 0.8≤H≤1 is excellent, 0.5≤H<0.8 is good, 0.2≤H<0.5 is poor, and H<0.2 is abnormal; Implement a link anomaly prediction algorithm. A sliding window method is used, with T (10s) as the sliding window, to calculate the rate of change of link health within the window in real time. ,when (Health continues to decline) and currently When the link is deemed to be at high risk, a pre-handling mechanism is triggered. Implement a pre-treatment and recovery mechanism.

[0034] Pre-processing (high risk): The communication control thread immediately issues a flow control command to reduce the transmission rate of low-priority data streams, increase the dedicated bandwidth of P0 level commands to 50%, and simultaneously initiate the initialization of the backup communication link to prepare for link switching. Passive recovery (an anomaly occurs, H<0.2): Triggers a tiered recovery process. Level 1 recovery: Resets the communication port and reinitializes the serial port parameters; Level 2 recovery: Switches to the backup communication link; Level 3 recovery: Performs system-level communication reinitialization. Post-recovery verification: After the link is restored, the communication control thread sends test data packets to verify the link health. Afterwards, normal scheduling and transmission strategies are restored, and data lost during the restoration process is recovered. Level data packets trigger retransmission.

[0035] Application Examples A high-performance and reliable communication method for mass spectrometry control boxes based on multi-algorithm collaboration is proposed and applied to the development of RGA mass spectrometers. For the scanning mode (core requirements: low latency of control commands and stable scanning data) and data acquisition mode (core requirements: data integrity and guaranteed bandwidth) of the RGA mass spectrometer, the parameters of five core algorithms are customized. The specific implementation steps are as follows: Step 1: Initialize multithreading and queues, and configure congestion control algorithm parameters. Four independent threads are created: a device sending thread, a data receiving thread, a serial port management thread, and a communication control thread. The communication control thread is bound to CPU core 0, and the other threads are bound to cores 1 and 2. Mutexes and condition variables are used to ensure thread synchronization. Construct a send queue and a receive queue, divided into P0 / P1 / P2 level sub-queues, and set the basic queue parameters: Qmax=1024 data packets, Qwarn=717, Qrel=307, and dynamic expansion coefficient k=1.5; Configure the time parameters for the queue dynamic caching congestion control algorithm: t1=5ms, t2=10ms, and limit the low-priority enqueue rate of traffic shaping to 50%. The serial port management thread initializes the underlying serial port, sets the baud rate to 115200bps, and enables link status parameter acquisition at a frequency of 100Hz (acquiring bit error rate, latency jitter, and bandwidth utilization every 10ms).

[0036] Step 2: Configure the parameters of the dynamic priority and adaptive hybrid scheduling algorithm, and execute instruction scheduling. For the scanning mode of the RGA mass spectrometer, configure the weight coefficients of the dynamic priority quantization algorithm as follows: W1=0.4, W2=0.2, W3=0.3, W4=0.1; the basic trigger time t0=1ms, the scanning frequency f=100Hz, and the data stream command delay parameter tdelay=1 / 100×50%=5ms. The communication control thread performs quantization priority calculation on the instructions. For example, for the voltage doubling setting instruction (P0 level): P1=100, tout=1ms (P2=100), H=0.9 (P3=90), Qnow / Qmax=20% (P4=80), the calculated value is P=0.4×100+0.2×100+0.3×90+0.1×80=95, which is determined to be P0 level. Adaptive hybrid scheduling algorithm execution: 30% of the channel bandwidth (34560bps) is reserved for P0 level instructions, and the remaining 70% of the bandwidth is allocated to P1 / P2 level instructions. The weight ratio WP1:WP2=2:1, that is, P1 level is allocated 47040bps and P2 level is allocated 23520bps. When a P0-level command burst occurs (≥20 enqueues per second), dynamic parameter adjustments are triggered: the dedicated bandwidth for P0-level commands is increased to 50%, the traffic of P2-level commands is shaped, and the outqueue rate is limited to 50%. After the burst ends, the default parameters are restored.

[0037] Step 3: Configure the parameters of the multi-verification and predictive recovery algorithm to achieve reliable transmission. Data integrity verification: A 32-bit sequence number, CRC32 checksum, and priority identifier are added to the data packet. The receiver performs triple verification. If the verification fails, NACK is returned. Intelligent Differentiated Retransmission Algorithm Configuration (Scanning Mode): Basic retransmission interval tint0 = 0.5ms, P0 level instruction tre = 0, Nmax = 10; P1 level tre = 0.3ms, Nmax = 5; P2 level tre = 0.8ms, Nmax = 2; Link State Awareness and Predictive Recovery Algorithm Configuration: BERmax=10 6. Jmax = 5ms, sliding window T = 10s, anomaly prediction threshold ΔH / ΔT ≤ 0.1 During pre-processing, the P0 level bandwidth is increased to 50%, and the backup link is RS485, with dual redundancy with the main link (RS232); Link anomaly recovery: When H < 0.2, first perform level 1 recovery (reset serial port). If H is still < 0.2, switch to backup RS485 link. After recovery, send test data packets. After verifying that H ≥ 0.8, resume normal scheduling. Trigger retransmission for P0 level instructions lost during recovery.

[0038] Implementation effect After this method was implemented in an RGA mass spectrometer, the following results were achieved: The response delay of the P0 level real-time control command is stable within 0.5ms, which meets the millisecond-level control requirements of the mass spectrometer. The data packet loss rate of mass spectrometry acquisition data was reduced to 5×10^-8, and data integrity was significantly improved; The CPU resource utilization rate of the communication system increased from 30% to 80%, and the channel bandwidth utilization rate increased from 40% to 90%, resulting in a significant improvement in resource utilization efficiency. In complex electromagnetic environments, the success rate of pre-handling link anomalies reaches 90%, the anomaly recovery time is ≤10ms, and the mass spectrometer can work continuously without data acquisition interruption. The algorithm parameters for scanning mode and data acquisition mode can be switched with one click, adapting to different working requirements of RGA mass spectrometers, and the system has good adaptability and scalability.

[0039] The above technical solutions are merely exemplary embodiments of the present invention. For those skilled in the art, based on the application methods and principles disclosed in the present invention, it is easy to make various types of improvements or modifications, and not limited to the methods described in the specific embodiments of the present invention. Therefore, the methods described above are merely preferred and not restrictive.

Claims

1. A reliable communication method for a mass spectrometer control box, characterized in that, Includes the following steps: S1 creates multiple independent execution threads and defines the core division of labor. At the same time, it uses dynamic queue caching congestion control to build an adaptive FIFO buffer queue that can expand or shrink and prevent congestion, thereby realizing the logical separation of communication I / O operations and data processing and decoupling the direct dependencies between threads. S2 performs quantization priority calculation on communication commands and executes an adaptive hybrid scheduling of preemptive, weighted fair queue and traffic shaping based on the priority result to ensure low-latency transmission of high-priority commands while also ensuring bandwidth for low-priority data streams. S3 performs multiple verifications and predictive recovery to achieve reliable data transmission and adaptive fault tolerance of the link.

2. The method according to claim 1, characterized in that, Step S1 specifically includes: S11, create an independent execution thread, including: Data transmission thread: used for data preprocessing, data packet encapsulation, updating data packet priority according to the calculation results of dynamic priority quantization algorithm, and handing it over to the serial port management thread for transmission; Serial port management thread: used for initialization of the underlying serial port, resource management and physical layer data transmission and reception, real-time collection of link status parameters and uploading to the communication control thread, providing data support for algorithm calculation; Data receiving thread: Used to read raw data from the receiving buffer, parse the protocol, perform CRC check and sequence number verification, put data that passes the verification into the receiving queue, and record the error of data packets that fail the verification and feed it back to the data sending thread; Communication control thread: Used in the core execution unit of the algorithm, responsible for the calculation of the core algorithm, business logic processing, thread scheduling and queue management; The communication control thread is bound to the main CPU core, and the other threads are bound to the slave cores. S12: Construct two main buffer queues, a send queue and a receive queue, and divide them into sub-queues according to instruction type. Threads share queues for data transfer through a producer-consumer model, using mutexes and condition variables to ensure data consistency. Simultaneously, a dynamic queue buffer congestion control algorithm is introduced to achieve adaptive adjustment of the queue buffer. The specific calculation and execution logic is as follows: Let the maximum basic cache threshold of the queue be Real-time cache usage is The instantaneous enqueue rate of the data stream is The outgoing speed is The congestion warning threshold is The congestion relief threshold is The dynamic expansion coefficient is k; when and If the congestion persists for t1, it is determined to be queue congestion; when and If the congestion persists for t2, it is determined that the congestion has been resolved. During congestion, the queue buffer capacity is dynamically expanded. Simultaneously, the communication control thread sends a flow shaping instruction to the data sending thread to reduce the enqueue rate of low-priority data streams; after congestion is relieved, the queue buffer capacity is restored to [previous capacity]. The flow shaping command failed. when This triggers a low-priority data packet discarding mechanism, prioritizing the buffer space for high-priority real-time control commands. The discarded data packets are recorded with their sequence numbers, and retransmission is triggered once the queue is idle.

3. The method according to claim 2, characterized in that, Step S2 specifically includes: S21, Design a multi-factor weighted dynamic priority quantization model: convert the priority of communication commands into a computable quantized value P: in The weighting coefficients for each factor are dynamically adjusted according to the mass spectrometer's operating mode. P1: Instruction type factor, 100 for real-time control instructions and 50 for data stream instructions; P2: Instruction urgency factor, P2=100 / (tout), where tou is the instruction timeout time; P3: Link status factor, P3=H×100, where H is the link health; P4: Queue load factor ; Priority is determined according to the established rules: P is divided into 3 levels based on the calculation results. It is the highest priority level, P0. It is the second highest priority level, P1. It is a normal priority level P2; Priority rules are dynamically updated: When the link status or queue load changes, the communication control thread recalculates P and updates the priority identifier of the data packet in real time; S22, adaptive hybrid scheduling, specific execution logic: P0 level highest priority instructions: adopt unconditional preemptive scheduling; at the same time, the transmission of P0 level instructions uses dedicated channel bandwidth to ensure the determinism of its transmission; P1 and P2 level ordinary priority instructions: use weighted fair queue scheduling; The communication control thread monitors the load status and link bandwidth utilization of each sub-queue in real time. When a P0-level instruction burst is detected or the link bandwidth utilization is ≥80%, dynamic scheduling parameter adjustment is triggered. When the P0-level instruction burst ends and the link bandwidth utilization is ≤60%, the scheduling parameters are restored to the default value. Set dynamic delay transmission parameters for P1 and P2 level data stream commands in the transmission queue. , Calculated dynamically based on the mass spectrometry scanning frequency f. This ensures the stability of the scanned data while avoiding a decrease in communication speed caused by fixed delays.

4. The method according to claim 2 or 3, characterized in that, Step S3 specifically includes: S31, add identification information to each data packet, including: sequence number SN, CRC32 check code, and instruction priority identifier P. The receiver performs triple verification of sequence number continuity, CRC32 integrity, and priority identifier consistency. S32 dynamically calculates the retransmission trigger time tre, maximum retransmission count Nmax, and retransmission interval tint based on the instruction priority P and link health H, enabling fast retransmission of high-priority instructions and on-demand retransmission of low-priority instructions, as detailed below: Retransmission trigger time: , Based on the trigger time; Maximum number of retransmissions: ; Retransmission interval: , The base interval is n, and n is the number of retransmissions. Differential retransmission is implemented according to the following strategy: P0 level highest priority instruction: Immediate continuous retransmission, , The retransmission interval is dynamically adjusted according to the link health status until an ACK is received or the status is reached. If the maximum number of attempts is reached and the error still fails, a system-level alarm will be triggered and the error will be marked. P1 level, second highest priority instruction: fast delayed retransmission. , Selective retransmission is used, only retransmitting lost or corrupted data packets reported by NACK; P2 level normal priority instruction: Delayed retransmission as needed. , Retransmission is triggered only when the link bandwidth utilization is ≤50%. If the maximum number of retransmissions is reached and the transmission still fails, the data packet is discarded and the sequence number is recorded. The packet will be retransmitted when the system is idle. For retransmitted data packets, their priority value P is temporarily increased to improve the retransmission success rate. S33, Link Health Measurement Model and Anomaly Prediction: Define link state parameters, including: bit error rate (BER), latency jitter (J), bandwidth utilization (BU), and connection persistence (C), and construct a quantitative model for link health (H) as follows: in: For the maximum permissible bit error rate, Maximum allowable delay jitter; Connection persistence C: Continuous uninterrupted communication time ≥ 10s, set to 1. Take 0.5, and take 0 if it is less than 5s; Health status grading: 0.8≤H≤1 is excellent, 0.5≤H<0.8 is good, 0.2≤H<0.5 is poor, and H<0.2 is abnormal; The sliding window method is used for link anomaly prediction, including: using T as the sliding window, calculating the rate of change of link health within the window in real time. ,when And currently When the link is deemed to be at high risk, a pre-handling mechanism is triggered. The pre-processing mechanism includes: the communication control thread immediately issuing a flow control command to reduce the transmission rate of low-priority data streams, increase the dedicated bandwidth of P0-level commands, and simultaneously initiate the initialization of the backup communication link to prepare for link switching. After an anomaly occurs, a tiered recovery process is triggered, including: Level 1 recovery: resetting the communication port and reinitializing the serial port parameters; Level 2 recovery: switching to the backup communication link; Level 3 recovery: performing system-level communication reinitialization. After the link is restored, the communication control thread sends test data packets to verify the link health. Afterwards, normal scheduling and transmission strategies are restored, and data lost during the restoration process is recovered. Level 1 data packet triggers retransmission.

5. A reliable communication device for a mass spectrometer control box using the method described in any one of claims 1-4, characterized in that, include: The thread management module is used to create multiple independent execution threads and define the core division of labor. At the same time, it uses dynamic queue caching congestion control to build an adaptive FIFO buffer queue that can expand or shrink and prevent congestion. The intelligent scheduling module is used to quantify and prioritize communication commands and execute adaptive hybrid scheduling based on the priority results. The verification and confirmation module is used to perform multiple verifications and predictive recovery to achieve reliable data transmission and adaptive fault tolerance of the link.