Methods, devices, equipment and media for multi-level adaptive time synchronization of intelligent fusion terminals

By employing a multi-level adaptive time synchronization method, the intelligent fusion terminal restores the time synchronization parameters after the system is powered on, utilizes heterogeneous communication channels to receive time information in parallel, dynamically adjusts the time synchronization period, and performs weighted fusion. This solves the problem of gradual decay of time synchronization accuracy in existing technologies, and achieves clock unification and data acquisition reliability across the entire station area.

CN123113279APending Publication Date: 2026-11-17NANJING NENGRUI AUTOMATION EQUIP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611602224.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-16
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing smart converged terminal time synchronization technologies suffer from problems such as coarse multi-time source switching strategies, lack of channel quality in handover decisions, fixed time synchronization periods that cannot be dynamically adjusted, ineffective suppression of slow drift in RTC crystal oscillators, and loss of time synchronization parameters after power failure. These issues lead to a gradual decrease in time synchronization accuracy, making it impossible to achieve clock uniformity across the entire station.

Method used

By employing a multi-level adaptive time synchronization method, the system recovers the time synchronization parameters from the non-volatile memory after power-on, receives time information in parallel through heterogeneous communication channels, performs communication quality assessment and delay correction, dynamically adjusts the time synchronization period, performs weighted fusion and deviation correction, achieves adaptive parameter adjustment, and performs step compensation through timer interrupts to ensure clock accuracy and parameter persistence.

Benefits of technology

It improves the timekeeping accuracy of intelligent fusion terminals, avoids invalid retransmissions, enables rapid recovery after power failure, provides a unified confidence basis for clocks across the entire station area, and ensures the consistency of timestamps in collected data and the reliability of fault tracing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123113279A_ABST
    Figure CN123113279A_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, device, and medium for multi-level adaptive time synchronization of an intelligent fusion terminal. The method includes: after the system is powered on, restoring synchronization parameters in stages from non-volatile memory and initializing the state machine; receiving time information from multiple time sources in parallel through at least two heterogeneous communication channels, performing communication quality assessment, calculating the drift rate based on the actual deviation after time synchronization and inputting it into a prediction model for state update and adaptive parameter adjustment, predicting the cumulative drift amount in the next cycle and converting it into compensation parameters, and performing step compensation of the clock through timed interrupts; writing the updated synchronization parameter increments into non-volatile memory, performing atomic write and abnormal rollback protection, and returning to the idle monitoring state. In this method, timekeeping accuracy is improved through multi-source fusion, channel awareness avoids invalid retransmissions, parameter persistence enables rapid recovery after power failure, and the timing parameters are sent to the terminal to provide confidence basis, achieving clock unification across the entire station area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of adaptive time synchronization technology, and in particular to a method, apparatus, device and medium for multi-level adaptive time synchronization of an intelligent fusion terminal. Background Technology

[0002] The intelligent converged terminal is a new generation of intelligent distribution transformer terminal that integrates the functions of distribution transformer terminals (TTU), concentrators, and smart three-phase meters. As the "smart brain" of the distribution transformer area and an edge device in a "cloud-pipe-edge-device" architecture, the intelligent converged terminal integrates electricity information collection, distribution transformer monitoring, edge computing, and remote control, realizing a comprehensive management hub of "one terminal per distribution transformer area." The intelligent converged terminal interacts with terminal devices such as smart meters, smart water meters, and smart gas meters within the distribution transformer area through an HPLC / HRF dual-mode communication network. The accuracy of its time reference directly determines the consistency of timestamps in the collected data across the entire distribution transformer area, the fairness of tiered billing, and the reliability of fault tracing.

[0003] Existing time synchronization technologies suffer from the following drawbacks: First, the multi-time source handover strategy is crude, resulting in time blind spots during the handover process and failing to incorporate channel quality into the handover decision. Second, the time synchronization period is fixed and cannot be dynamically adjusted according to network load, making it prone to retransmission storms in weak network environments due to invalid retransmissions. Third, there is a lack of effective suppression of slow drift in the RTC crystal oscillator, relying solely on periodic time synchronization correction, leading to persistent accumulated deviations. Fourth, time synchronization parameters are lost after power failure, requiring reconvergence upon restart. These problems are further amplified when the concentrator sends time synchronization commands to smart terminals—the terminal cannot reuse the concentrator's time synchronization context information, causing a gradual decrease in time synchronization accuracy. Existing technologies have not solved the comprehensive optimization problem of multi-source fusion, channel awareness, and terminal-coordinated time synchronization. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for multi-level adaptive time synchronization of intelligent fusion terminals, which improves timekeeping accuracy through multi-source fusion, avoids invalid retransmission through channel awareness, enables rapid recovery after power failure through parameter persistence, and provides confidence basis to the terminal through time synchronization parameters, thereby achieving clock unification across the entire station area.

[0005] In a first aspect, embodiments of the present invention provide a multi-level adaptive time synchronization method for an intelligent fusion terminal. The method includes: after the system is powered on, restoring time synchronization parameters in stages from a non-volatile memory and initializing a state machine; receiving time information from multiple time sources in parallel through at least two heterogeneous communication channels, performing communication quality assessment, and performing delay correction and anomaly removal on the time information from each time source to obtain effective time information; predicting the current network quality based on historical communication quality to dynamically adjust the time synchronization period, and switching the backup communication channel to hot standby state in advance based on the joint assessment results of channel quality and predicted network quality. When the time synchronization trigger time is reached, the valid time information is weighted and fused according to the credibility weight of each time source to obtain the reference time. The deviation between the reference time and the current clock is calculated, and the time synchronization operation with the corresponding priority is executed according to the deviation level. After the time synchronization is completed, the drift rate is calculated according to the actual deviation and input into the prediction model for state update and parameter adaptive adjustment. The cumulative drift amount in the next cycle is predicted and converted into compensation parameters. The clock is compensated in steps through timer interrupts. The updated time synchronization parameters are incrementally written to non-volatile memory, atomic write and abnormal rollback protection are performed, and the idle monitoring state is returned.

[0006] In a preferred embodiment of the present invention, the above-described hierarchical recovery of timing parameters from non-volatile memory specifically includes: firstly reading the most recent timestamp and frequency correction value from the first-level non-volatile memory, and immediately writing it into the clock coarse adjustment register after verification to achieve instantaneous recovery; reading the prediction model parameters from the second-level non-volatile memory, and resetting them to the default value if verification fails; and reading the static configuration from the third-level non-volatile memory, and degrading to blind timing mode if all reads fail.

[0007] In a preferred embodiment of the present invention, the above-described delay correction and anomaly removal of time information from each time source specifically includes: using an input capture module to record the physical layer arrival time of the time information frame and extracting the source timestamp; calculating half of the difference between the arrival time and the source timestamp for bidirectional interactive time sources as delay correction, and using a preset fixed delay compensation for broadcast time sources; calculating the deviation between the corrected time value and the current clock, and if the deviation is greater than the outlier threshold, determining that the data of the time source is invalid, and resetting its credibility weight to zero when the number of consecutive invalid data exceeds the threshold.

[0008] In a preferred embodiment of the present invention, the above-mentioned method of predicting the current network quality based on historical communication quality to dynamically adjust the time synchronization period specifically includes: maintaining a historical sequence of round-trip delays, updating the prediction model coefficients online using a recursive least squares method with a forgetting factor, calculating the predicted round-trip delay and prediction success rate of the next time synchronization request; if the network quality is better than a first threshold, the time synchronization period is extended to the maximum value; if it is between the first threshold and a second threshold, a medium period is maintained; if it is worse than the second threshold, a backoff strategy is triggered, and the backoff duration increases with the number of failures and has an upper limit.

[0009] In a preferred embodiment of the present invention, the above-mentioned weighted fusion of valid time information based on the credibility weight of each time source to obtain the reference time specifically includes: maintaining a credibility weight for each time source, calculated by weighting short-term stability, long-term deviation trend, and link quality; calculating the cumulative credibility weight after sorting all valid time information, and selecting the value where the cumulative weight first exceeds half of the total weight as the fusion reference time; when the individual weight of any information source at either end accounts for more than the proportion of the total weight, a minimum redundancy constraint is forcibly introduced.

[0010] In a preferred embodiment of the present invention, the deviation levels sequentially include a first threshold, a second threshold, and a third threshold, wherein the first threshold is less than the second threshold, and the second threshold is less than the third threshold; the step of performing time synchronization operation according to the deviation level with corresponding priority specifically includes: if the deviation is less than or equal to the first threshold, no time synchronization is initiated; if the deviation is greater than the first threshold and less than or equal to the second threshold, a low-priority unidirectional time synchronization is initiated; if the deviation is greater than the second threshold and less than or equal to the third threshold, a medium-priority bidirectional time synchronization is initiated; if the deviation is greater than the third threshold, the highest-priority time synchronization is initiated, the current task is preempted, and all available time sources are started to synchronize time, and the reference time is forcibly written into the clock hardware register.

[0011] In a preferred embodiment of the present invention, the step of writing the updated time synchronization parameter increment to the non-volatile memory and performing atomic write and abnormal rollback protection specifically includes: The current prediction model parameters are compared with the previously stored values. If the deviation is greater than the dynamic accuracy threshold, a write operation is triggered. The updated parameters and checksum are written to the buffer and then to the shadow register area. After verification, the address pointer is atomically switched to the main register area through a double buffering mechanism. If the time synchronization process times out and triggers a watchdog reset, the incomplete data is discarded and the system rolls back to the previous valid parameter. At the same time, the abnormal reset counter is incremented by 1. If the counter continuously exceeds the preset threshold, the crystal oscillator is determined to be abnormal. Drift prediction compensation is turned off and the system switches to pure passive timekeeping mode to report to the master station.

[0012] Secondly, embodiments of the present invention also provide a multi-level adaptive time synchronization device for an intelligent fusion terminal. The device includes: a communication quality assessment module, used to receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, perform communication quality assessment, and perform delay correction and anomaly removal on the time information from each time source to obtain valid time information; a time synchronization period dynamic adjustment module, used to predict the current network quality based on historical communication quality to dynamically adjust the time synchronization period, and to switch the backup communication channel to hot standby state in advance based on the joint assessment result of channel quality and predicted network quality; and a weighted fusion module, used to, when the time synchronization trigger time is reached... The system performs weighted fusion of valid time information based on the credibility weight of each time source to obtain the reference time, calculates the deviation between the reference time and the current clock, and performs time synchronization operations with corresponding priorities according to the deviation level. The parameter adaptive adjustment module is used to calculate the drift rate based on the actual deviation after time synchronization and input it into the prediction model for state update and parameter adaptive adjustment. It predicts the cumulative drift amount in the next cycle and converts it into compensation parameters, and performs step compensation of the clock through timer interrupts. The idle monitoring state return module is used to write the updated time synchronization parameter increment to non-volatile memory, perform atomic write and abnormal rollback protection, and return to the idle monitoring state.

[0013] Thirdly, embodiments of the present invention also provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the intelligent fusion terminal multi-level adaptive time synchronization method of the first aspect described above.

[0014] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the intelligent fusion terminal multi-level adaptive time synchronization method described in the first aspect.

[0015] The embodiments of the present invention bring the following beneficial effects: This invention provides a multi-level adaptive time synchronization method, apparatus, device, and medium for intelligent fusion terminals. After system power-on, time synchronization parameters are restored hierarchically from non-volatile memory and the state machine is initialized. Time information from multiple time sources is received in parallel through at least two heterogeneous communication channels. Communication quality is assessed, and delay correction and anomaly removal are performed on the time information from each time source to obtain valid time information. The current network quality is predicted based on historical communication quality to dynamically adjust the time synchronization period. Based on the joint evaluation results of channel quality and predicted network quality, the backup communication channel is switched to hot standby mode in advance. When the time synchronization trigger time is reached, the valid time information is weighted and fused according to the reliability weight of each time source to obtain the reference time. The deviation between the reference time and the current clock is calculated, and the corresponding priority time synchronization operation is performed according to the deviation level. After the time synchronization is completed, the drift rate is calculated based on the actual deviation and input into the prediction model for state update and parameter adaptive adjustment. The cumulative drift amount in the next cycle is predicted and converted into compensation parameters. The clock is compensated in steps through timed interrupts. The updated time synchronization parameters are incrementally written to non-volatile memory, atomic write and abnormal rollback protection are performed, and the system returns to the idle monitoring state. In this method, the timekeeping accuracy is improved through multi-source fusion, channel awareness avoids invalid retransmissions, parameter persistence enables rapid recovery after power failure, and the time synchronization parameters are sent to the terminal to provide a confidence basis, thereby achieving clock unification across the entire station area.

[0016] Other features and advantages of this disclosure will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.

[0017] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

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

[0019] Figure 1 A flowchart of a multi-level adaptive time synchronization method for an intelligent fusion terminal provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of a multi-level adaptive time synchronization device for an intelligent fusion terminal provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] The intelligent converged terminal is a new generation of intelligent distribution transformer terminal that integrates the functions of distribution transformer terminals (TTU), concentrators, and smart three-phase meters. As the "smart brain" of the distribution transformer area and an edge device in a "cloud-pipe-edge-device" architecture, the intelligent converged terminal integrates electricity information collection, distribution transformer monitoring, edge computing, and remote control, realizing a comprehensive management hub of "one terminal per distribution transformer area." The intelligent converged terminal interacts with terminal devices such as smart meters, smart water meters, and smart gas meters within the distribution transformer area through an HPLC / HRF dual-mode communication network. The accuracy of its time reference directly determines the consistency of timestamps in the collected data across the entire distribution transformer area, the fairness of tiered billing, and the reliability of fault tracing.

[0022] Existing time synchronization technologies suffer from the following drawbacks: First, the multi-time source handover strategy is crude, resulting in time blind spots during the handover process and failing to incorporate channel quality into the handover decision. Second, the time synchronization period is fixed and cannot be dynamically adjusted according to network load, making it prone to retransmission storms in weak network environments due to invalid retransmissions. Third, there is a lack of effective suppression of slow drift in the RTC crystal oscillator, relying solely on periodic time synchronization correction, leading to persistent accumulated deviations. Fourth, time synchronization parameters are lost after power failure, requiring reconvergence upon restart. These problems are further amplified when the concentrator sends time synchronization commands to smart terminals—the terminal cannot reuse the concentrator's time synchronization context information, causing a gradual decrease in time synchronization accuracy. Existing technologies have not solved the comprehensive optimization problem of multi-source fusion, channel awareness, and terminal-coordinated time synchronization.

[0023] Based on this, the present invention provides a multi-level adaptive time synchronization method, apparatus, device, and medium for intelligent fusion terminals. After system power-on, the method can hierarchically restore time synchronization parameters from non-volatile memory and initialize the state machine; receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, perform communication quality assessment, and perform delay correction and anomaly removal on the time information from each time source to obtain effective time information; predict the current network quality based on historical communication quality to dynamically adjust the time synchronization period; and switch the backup communication channel in advance based on the joint evaluation results of channel quality and predicted network quality. In hot standby mode, when the time synchronization trigger time is reached, the valid time information is weighted and fused according to the reliability weight of each time source to obtain the reference time. The deviation between the reference time and the current clock is calculated, and the corresponding priority time synchronization operation is performed according to the deviation level. After time synchronization is completed, the drift rate is calculated based on the actual deviation and input into the prediction model for state update and parameter adaptive adjustment. The cumulative drift amount in the next cycle is predicted and converted into compensation parameters. The clock is compensated in steps through timed interrupts. The updated time synchronization parameters are incrementally written to non-volatile memory, atomic write and abnormal rollback protection are performed, and the system returns to idle monitoring state. In this method, the timekeeping accuracy is improved through multi-source fusion, channel awareness avoids invalid retransmissions, parameter persistence enables rapid recovery after power failure, and the time synchronization parameters are sent to the terminal to provide a confidence basis, thereby achieving clock unification across the entire station area.

[0024] To facilitate understanding of this embodiment, a multi-level adaptive time synchronization method for an intelligent fusion terminal disclosed in this embodiment of the invention will first be described in detail.

[0025] Example 1 This invention provides a multi-level adaptive time synchronization method for intelligent fusion terminals. Figure 1 This is a flowchart illustrating a multi-level adaptive time synchronization method for an intelligent fusion terminal, provided as an embodiment of the present invention. Figure 1 As shown, the multi-level adaptive time synchronization method for the intelligent fusion terminal may include the following steps: Step S101: After the system is powered on, the timing parameters are restored hierarchically from the non-volatile memory and the state machine is initialized.

[0026] The tiered recovery process involves reading parameters sequentially from different levels of non-volatile memory according to their importance, update frequency, and recovery speed requirements. The specific sequence of actions in tiered recovery can be: first read FRAM, then EEPROM, and finally Flash; a CRC check is performed immediately after each level is read, and the data is loaded only if the check passes; if a level fails, a failure log is recorded, and the process continues to the next level.

[0027] The time synchronization parameters include all configuration and historical data related to clock synchronization, including at least: the timestamp (absolute time) of the most recent successful time synchronization, the crystal oscillator frequency correction value (such as the PPM compensation word), the time synchronization success flag, the horizontal component S and the trend component T of the double exponential smoothing model, the confidence weight of each time source, the network address, port, and protocol type of the time source, the version number of the temperature-drift rate lookup table, and the abnormal reset counter value.

[0028] The state machine is a set of logical states for controlling the time synchronization process, including at least the idle monitoring state, the backoff waiting state, the synchronization correction state, and the emergency synchronization state.

[0029] In practical applications, the MCU connects to FRAM (such as Fujitsu MB85RS256) via an SPI interface and to EEPROM (such as AT24C256) via an I2C interface, storing static configurations via internal Flash to simulate EEPROM. After MCU reset, it first executes the Bootloader to initialize peripherals such as the clock tree, GPIO, SPI, and I2C. It then reads the emergency parameter area from the FRAM, which is fixed at 16 bytes: 4 bytes for a timestamp, 4 bytes for a frequency correction value, 1 byte for a success flag, 1 byte for a CRC check, and 6 bytes for a reserved area. If the CRC check passes and the success flag is 0xA5, the timestamp is written to the RTC's coarse adjustment register, and the frequency correction value is written to the RTC's frequency compensation register. Next, it reads the model parameter area from the EEPROM, which is allocated 32 bytes: 4 bytes for the S value, 4 bytes for the T value, 4 bytes for α, 4 bytes for β, 4 bytes for the temperature lookup table version, and 12 bytes for a reserved area. If the check fails, α is set to 0.7, β to 0.3, and S and T to 0. The system reads the static configuration area from the Flash memory to obtain the NTP server address, GNSS enable flag, HPLC / HRF channel parameters, etc. If all reads fail, it enters blind time synchronization mode, which does not rely on historical parameters and directly attempts to obtain the time at fixed intervals. The time synchronization state machine is set to idle monitoring state, a basic timer with a 1-second cycle is started, and communication peripherals are enabled for listening.

[0030] In terms of performance, after a power failure and restart, the RTC coarse tuning can be restored within a short time (e.g., 10ms), avoiding long-term loss of synchronization. After the model parameters are restored, the drift prediction can take effect immediately without the need for re-convergence. Furthermore, the hierarchical storage reduces the wear and tear on the memory caused by high-frequency writes.

[0031] For example, when the intelligent fusion terminal is restored to power after a power outage for maintenance in the distribution area, or restarted after a momentary power failure, this step ensures that the terminal can quickly restore its timekeeping capability without affecting the temporal continuity of the collected data.

[0032] Specifically, the step of hierarchically recovering the time synchronization parameters from the non-volatile memory includes: firstly reading the most recent timestamp and frequency correction value from the first-level non-volatile memory, and immediately writing it into the clock coarse adjustment register after verification to achieve instantaneous recovery; reading the prediction model parameters from the second-level non-volatile memory, and resetting them to the default value if verification fails; and reading the static configuration from the third-level non-volatile memory, and degrading to blind time synchronization mode if all reads fail.

[0033] The first level of non-volatile memory refers to FRAM, which is used to store the most urgent parameters. The second level of non-volatile memory refers to EEPROM, which is used to store model parameters. The third level of non-volatile memory refers to the MCU's internal Flash memory, which is used to store infrequently changing configurations.

[0034] In practical applications, after power-on, the MCU reads 16 bytes starting from FRAM address 0x0000 via SPI, including a 4-byte timestamp, a 4-byte frequency correction value, a 1-byte flag, and a 1-byte CRC. The CRC uses CRC-8 with a polynomial of 0x07; if the check passes and the flag is 0xA5, the timestamp is written to the RTC's TIME register, and the frequency correction value is written to the RTC's FREQ register. It then reads 32 bytes starting from EEPROM address 0x0000 via I2C, including S, T, α, β, etc. The CRC uses CRC-16 with a polynomial of 0x1021; if the check fails, S=0, T=0, α=0.7, β=0.3. It also reads the NTP server IP, port, GNSS enable, HPLC / HRF channel parameters, etc.; if all readings fail (e.g., due to Flash corruption), it enters blind time synchronization mode, attempting an NTP broadcast request once per hour.

[0035] In terms of performance, RTC is restored within 10ms, avoiding time reset to zero after restart; model parameters are restored quickly, and drift predictions take effect immediately; and time synchronization can still be attempted even in extreme cases.

[0036] Step S102: Receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, evaluate the communication quality, and perform delay correction and anomaly removal on the time information from each time source to obtain valid time information.

[0037] Among them, heterogeneous communication channels are channels that use different physical media and communication protocols, such as HPLC (high-speed power line carrier) and HRF (low-power wireless), or 4G / 5G public network and Ethernet.

[0038] Among them, multiple time sources are devices or systems that provide time references, including the master station NTP server, GNSS satellites (GPS / BeiDou), HPLC network reference time (NTB), local RTC backup clock, etc.

[0039] Communication quality metrics may include: Packet Error Rate (PER), Signal-to-Noise Ratio (SNR), Received Signal Strength Index (RSSI), Round-Trip Time (RTT), and Jitter. Time information may include: Source Timestamp, Physical Layer Arrival Time, Protocol Type, and Source Identifier. Delay correction values ​​may include: One-way transmission delay and fixed broadcast delay. Anomaly removal criteria may include: Absolute deviation exceeding an outlier threshold (e.g., 10 minutes). Communication quality assessment specifically includes measuring and statistically analyzing indicators such as packet error rate, signal-to-noise ratio, latency, and jitter of the channel. For example, communication quality assessment can be performed by statistically analyzing the packet error rate and average RTT of the past 20 communications every 5 seconds, and calculating the weighted channel quality index Q = 0.6 × (1 - PER) + 0.4 × (SNR / SNR_max).

[0040] In practical applications, the MCU enables two UART interfaces, connecting to the HPLC and HRF modules respectively; simultaneously, one UART is enabled to connect to the GNSS module. All three interfaces receive data via interrupts. Utilizing the MCU's timer input capture function, the timer count is recorded and converted into a microsecond-level timestamp when the last byte of the data frame is received. For NTP bidirectional interaction: the transmission time T1, reception time T2, source response time T3, and local response time T4 are recorded, and the round-trip time (RTT) is calculated as (T4-T1)-(T3-T2), with the one-way delay equal to RTT / 2. For broadcast (e.g., HPLC NTB): a preset fixed delay is used, which can be obtained through factory calibration or field measurement, with an empirical value of 2ms~10ms. For GNSS: the GNSS module directly outputs UTC time; the delay is mainly due to serial port transmission delay, with an empirical value of 1ms~5ms, which can be calculated based on the baud rate. The corrected time value is compared with the current RTC reading. If the absolute difference is greater than 10 minutes, the data is discarded, and the consecutive invalidity counter for that time source is incremented by 1. If the number of consecutive invalidities is greater than or equal to 3, the confidence weight of that time source is reset to 0.

[0041] In terms of effectiveness, multi-channel parallel reception improves the success rate of acquiring time information, delay correction eliminates fixed deviations caused by the transmission path, and anomaly removal prevents erroneous time sources from contaminating the fusion results.

[0042] For example, the intelligent converged terminal simultaneously receives the master station's NTP time via the 4G public network, satellite time via GNSS, and local reference time via HPLC. When the 4G signal is weak, GNSS and HPLC can still provide time information, ensuring uninterrupted time synchronization.

[0043] Specifically, the delay correction and anomaly removal of time information from each time source includes: using the input capture module to record the physical layer arrival time of the time information frame and extracting the source timestamp; calculating half of the difference between the arrival time and the source timestamp for bidirectional interactive time sources as delay correction, and using a preset fixed delay compensation for broadcast time sources; calculating the deviation between the corrected time value and the current clock, and if the deviation is greater than the outlier threshold, determining that the data from that time source is invalid, and resetting its credibility weight to zero when the number of consecutive invalid data exceeds the threshold.

[0044] Among them, bidirectional interactive methods such as NTP and broadcast methods such as HPLC NTB; the empirical value for the outlier threshold is 10 minutes; and the empirical value for the consecutive invalid number threshold is 3 times.

[0045] In practical applications, the receive completion pin of the communication module is connected to the MCU timer capture channel. When frame reception is complete, the hardware automatically latches the timer count value, which corresponds to a microsecond-level time. The software parses the source timestamp from the message; NTP: records T1 (send), T2 (arrival), T3 (source reply), T4 (local receive reply), RTT=(T4-T1)-(T3-T2), one-way delay=RTT / 2; broadcast: the preset delay empirical value is 5ms, which can be calibrated through field testing; calculate |T_corrected-T_RTC|, if >10 minutes, discard, invalid counter +1. If the counter ≥3, then C_i=0.

[0046] In terms of effectiveness, it eliminates timestamp errors caused by software interruption delays; corrects transmission path delays to improve time accuracy; and prevents erroneous time sources from contaminating the fusion results.

[0047] Step S103: Predict the current network quality based on historical communication quality to dynamically adjust the synchronization period, and switch the backup communication channel to hot standby state in advance based on the joint evaluation results of channel quality and predicted network quality.

[0048] In hot standby mode, the backup channel remains powered on, synchronized, and ready to transmit at any time, but does not transmit service data. Switching the backup communication channel to hot standby mode in advance allows the MCU to send AT commands or register configuration commands to the backup channel module, waking it from sleep mode, loading communication parameters, and periodically sending synchronization beacons; at the same time, the main channel's transmit enable is disabled, but the receive listening function is maintained.

[0049] Historical communication quality records can include: the most recent L RTT sequences (L≥10) and success rate sequences. Prediction model: ARIMA(1,0,1) or recursive least squares with a forgetting factor. Time synchronization period can include: minimum period (e.g., 1 hour), medium period (e.g., 6 hours), and maximum period (e.g., 24 hours). Joint evaluation factor: P_switch=ω1×(1 / Q)+ω2×D_pred. Pre-switch threshold: empirically 0.7~0.9, which can be determined based on on-site debugging and is not limited here.

[0050] In practical applications, two circular queues of length 20 are allocated in RAM to store RTT and success rate, respectively. A recursive least squares method with a forgetting factor λ=0.98 is used to update the autoregressive coefficient φ and moving average coefficient θ of ARIMA(1,0,1). Predicting the next RTT: D_pred=φ·D_last+θ·ε_last+μ. Predicting the success rate: R_pred=weighted average of historical success rates. If D_pred<200ms and R_pred>98%, the period is set to 24 hours. If 200ms≤D_pred<1000ms, the period is set to 6 hours. If D_pred≥1000ms or R_pred<70%, a backoff strategy is triggered: next time synchronization = current time + min(2^f×60s, 3600s), where f is the number of consecutive failures. Calculating the joint evaluation factor P_switch=0.5×(1 / Q)+0.5×D_pred. If P_switch > 0.8, a synchronization training sequence is sent to the backup channel. This sequence is a known pseudo-random code used to measure the current channel characteristics of the backup channel and establish synchronization. The backup channel enters hot standby mode, ready to take over at any time.

[0051] In terms of effectiveness, it avoids frequent retransmissions under weak network conditions, saving bandwidth and power consumption; pre-switching eliminates handover blind spots and improves time synchronization continuity; dynamic period balances time synchronization accuracy and communication overhead.

[0052] For example, during peak electricity consumption periods (such as 19:00-21:00), when 4G network congestion is predicted to increase RTT, the intelligent converged terminal automatically extends the time calibration period from 6 hours to 24 hours and switches the HPLC channel to hot standby mode in advance.

[0053] Specifically, the step of predicting the current network quality based on historical communication quality to dynamically adjust the time synchronization period includes: maintaining a historical sequence of round-trip delays, updating the prediction model coefficients online using a recursive least squares method with a forgetting factor, and calculating the predicted round-trip delay and prediction success rate for the next time synchronization request; if the network quality is better than a first threshold, the time synchronization period is extended to the maximum value; if it is between the first and second thresholds, a medium period is maintained; if it is worse than the second threshold, a backoff strategy is triggered, and the backoff duration increases with the number of failures and has an upper limit.

[0054] Among them, the empirical value of the forgetting factor λ can be 0.98; the empirical value of the first threshold can be 200ms, the empirical value of the second threshold can be 1000ms; and the empirical value of the retreat limit can be 3600 seconds.

[0055] Step S104: When the time synchronization trigger time is reached, the valid time information is weighted and fused according to the credibility weight of each time source to obtain the reference time, the deviation between the reference time and the current clock is calculated, and the time synchronization operation with the corresponding priority is executed according to the deviation level.

[0056] Wherein, the credibility weight C_i = w1×(1 / σ_i) + w2×(1 / |δ_i|) + w3×q_i. Short-term stability σ_i: the variance of the most recent 5 deviations. Long-term deviation trend δ_i: the slope of the most recent 10 deviations. Link quality q_i: the communication quality index Q. Weighted median fusion: the value corresponding to a cumulative weight exceeding 50% after sorting. Deviation levels: Th1 (e.g., 50ms), Th2 (e.g., 500ms), Th3 (e.g., 5s).

[0057] The time synchronization operation performed according to the deviation level can be as follows: at low priority, the MCU only sets the NTP transmission flag; at medium priority, the MCU starts the NTP state machine; at high priority, the MCU calls the task suspension function to pause the acquisition task and start all time source receive interrupts.

[0058] In practical applications, for each time source, maintain an array of the most recent 5 time synchronization deviations and calculate the variance σ_i; calculate the linear regression slope δ_i of the most recent 10 deviations; obtain the current link quality q_i; and calculate C_i=0.4×(1 / σ_i)+0.3×(1 / |δ_i|)+0.3×q_i after normalization. Arrange the valid time values ​​in ascending order: T1, T2, T3; calculate the cumulative weights: W1=C1, W2=C1+C2, W3=C1+C2+C3; select Ti, where the cumulative weight is first greater than or equal to 50% of the total weight, as the base time; if the weight of a certain time source is greater than 80%, the weight of the second-best time source is forcibly reduced to 20% to prevent single-source dominance; calculate the deviation: Δ=|base time - current RTC time|; Δ≤Th1: no time synchronization, only maintain drift compensation; Th1<Δ≤Th2: low-priority one-way time synchronization, only send one NTP request, do not wait for a reply, and directly use the received server time; Th2<Δ≤Th3: medium-priority two-way time synchronization, fully execute four timestamp exchanges of NTP, calculate RTT and compensate; Δ>Th3: highest-priority time synchronization, suspend the data acquisition task, start parallel time synchronization of all time sources, and write the fused base time directly into the RTC hardware register.

[0059] In terms of effectiveness, weighted fusion improves the anti-interference capability of the reference time; hierarchical time synchronization avoids unnecessary communication overhead; and emergency time synchronization ensures rapid correction of critical deviations.

[0060] For example, if the intelligent fusion terminal detects that the RTC deviation reaches 3 seconds (>Th3), it immediately suspends the current acquisition task, acquires the time from three sources in parallel (4G, GNSS, and HPLC), and forces the weighted fusion to write it into the RTC, ensuring that the billing data is not abnormal due to time errors.

[0061] Specifically, the step of weighting and fusing valid time information according to the credibility weight of each time source to obtain the base time includes: maintaining a credibility weight for each time source, calculated by weighting short-term stability, long-term deviation trend and link quality; calculating the cumulative credibility weight after sorting all valid time information, and selecting the value where the cumulative weight first exceeds half of the total weight as the fusion base time; and forcibly introducing a minimum redundancy constraint when the individual weight of any information source at either end accounts for more than the proportion of the total weight.

[0062] Wherein, short-term stability σ_i, long-term deviation trend δ_i, and link quality q_i are represented. C_i = 0.4 × (1 / σ_i) + 0.3 × (1 / |δ_i|) + 0.3 × q_i. σ_i is the variance of the deviation over the last 5 times, and δ_i is the slope of the deviation over the last 10 times.

[0063] where T1<T2<T3, the cumulative weights W1=C1, W2=C1+C2, W3=C1+C2+C3. Select Ti where Wi≥0.5·W_total. If C1>0.8·W_total, the weight of C2 is forcibly compromised by 20%, that is, T_fusion=0.8·T1+0.2·T2.

[0064] In step S105, after time calibration is completed, the drift rate is calculated according to the actual deviation and input into the prediction model for state update and adaptive parameter adjustment, the cumulative drift amount in the next cycle is predicted and converted into a compensation parameter, and step compensation is performed on the clock through a timer interrupt.

[0065] where the inputting the drift rate into the prediction model for state update and adaptive parameter adjustment specifically includes: letting the clock deviation after the t-th time calibration be e_t and the interval be Δt_t, calculating the measured drift rate r_t=(e_t-e_{t-1}) / Δt_t; inputting r_t into the double exponential smoothing model, updating the level component S_t=α·r_t+(1-α)·(S_{t-1}+T_{t-1}) and the trend component T_t=β·(S_t-S_{t-1})+(1-β)·T_{t-1}; calculating the mean square error of the most recent multiple prediction errors, increasing α if the mean square error continuously increases, and decreasing α if the mean square error continuously decreases.

[0066] where the predicting the cumulative drift amount and converting it into a compensation parameter to perform step compensation through a timer interrupt specifically includes: calculating the predicted cumulative drift amount Δe_pred=(S_t+T_t)·Δt_next in the next time calibration cycle according to the updated level component S_t and trend component T_t; calculating the equivalent frequency deviation step size according to the cumulative drift amount and the clock crystal oscillator tuning coefficient; splitting the step size into an integer part and a fractional part by using the clock timer interrupt, distributing compensation pulses at the minute level using Σ-Δ modulation technology, and gradually adjusting the clock timekeeping frequency.

[0067] In practical applications, record the deviation e_t before the current time calibration, the previous deviation e_{t-1}, and the interval Δt_t, then r_t = (e_t - e_{t-1}) / Δt_t. Update the double exponential smoothing: S_t = α·r_t + (1-α)·(S_{t-1} + T_{t-1}); T_t = β·(S_t - S_{t-1}) + (1-β)·T_{t-1}; initial values ​​S_0 = 0, T_0 = 0, α = 0.7, β = 0.3. Calculate the mean square error (MSE) of the most recent three predictions; if MSE continuously increases, α = min(α + 0.05, 0.95); if MSE continuously decreases, α = max(α - 0.01, 0.5). Δe_pred = (S_t + T_t) · Δt_next; Assuming the RTC crystal oscillator tuning coefficient K = 0.1ppm / LSB, then Δ_PPM = Δe_pred / (Δt_next · 0.1); In the RTC's minute interrupt, ∑-Δ modulation is used: an accumulator acc is maintained, and acc += Δ_PPM is added up for each interrupt; if acc ≥ 1, a +1ppm compensation pulse is output, and acc -= 1; if acc ≤ -1, a -1ppm pulse is output, and acc += 1. Thus, the average compensation frequency is equal to Δ_PPM.

[0068] In terms of performance, it continuously suppresses drift between two time calibrations, improving timekeeping accuracy; adaptive parameters enable the model to adapt to temperature changes and aging; and step compensation avoids the impact of time jumps on billing data.

[0069] For example, in high-temperature environments during summer, the daily RTC drift of intelligent fusion terminals reaches 2 seconds. The double exponential smoothing model predicts a cumulative drift of 1.5 seconds for the next cycle, and by fine-tuning the RTC frequency every minute, the actual deviation is controlled within 50ms.

[0070] The deviation levels include a first threshold, a second threshold, and a third threshold in sequence, with the first threshold being less than the second threshold and the second threshold being less than the third threshold.

[0071] Among them, the empirical value of Th1 can be 50ms, the empirical value of Th2 can be 500ms, and the empirical value of Th3 can be 5s.

[0072] Where Δ ≤ 50ms, the state machine remains idle. 50ms < Δ ≤ 500ms, an NTP request is sent without waiting for a reply, and the server time is used directly. 500ms < Δ ≤ 5s, four complete NTP interactions are performed, and RTT is calculated and compensated. Δ > 5s, the acquisition task is suspended, the three sources are processed in parallel, and the merged data is directly written to the RTC register.

[0073] Specifically, the step of performing time synchronization operations with corresponding priorities based on deviation levels includes: if the deviation is less than or equal to the first threshold, no time synchronization is initiated; if the deviation is greater than the first threshold and less than or equal to the second threshold, a low-priority unidirectional time synchronization is initiated; if the deviation is greater than the second threshold and less than or equal to the third threshold, a medium-priority bidirectional time synchronization is initiated; if the deviation is greater than the third threshold, the highest-priority time synchronization is initiated, the current task is preempted, and all available time sources are started to synchronize in parallel, and the reference time is forcibly written into the clock hardware register.

[0074] Step S106: Write the updated time synchronization parameter increment to the non-volatile memory, perform atomic write and exception rollback protection, and return to the idle monitoring state.

[0075] Among them, incremental write means writing only the parameters that have changed, rather than all parameters; atomic write means that the write operation either succeeds completely or fails completely, without any intermediate state of partial write; abnormal rollback protection means that if a power failure or reset occurs during the write process, it can be restored to the valid state before the write; idle monitoring state is a state of the time synchronization state machine, indicating that time synchronization is not required at present, and only monitoring is performed.

[0076] Among them, the empirical value of the dynamic precision threshold is 0.1ppm or 0.01 seconds; the shadow register area is a reserved backup area in the non-volatile memory; the double buffering mechanism achieves atomicity by switching address pointers; the empirical value of the watchdog overflow time is 5 seconds; the abnormal reset counter is used to record the number of consecutive abnormal resets.

[0077] Specifically, returning to the idle monitoring state can be achieved by setting the state machine variable to IDLE, re-enabling the time synchronization timer, and waiting for the next trigger.

[0078] In practical applications, the current S_t is compared with the previously stored S_last. If |S_t-S_last|>0.01, a write operation is triggered. The new parameters and CRC32 are written to the RAM buffer. The contents of the buffer are written to the shadow register area of ​​the non-volatile memory. The shadow register area is read, and the CRC is verified. After the verification is successful, the address pointer register is modified to point to the shadow register area, and the original main register area is marked as the shadow area. This address pointer switching is implemented through the double buffering function of the MCU's Flash controller. The switching process is a single instruction and has atomicity. If the watchdog times out (5 seconds) during the write process, a hardware reset is triggered. After the reset, if the previous time synchronization completion flag is found to be invalid in step 1, the main register area (i.e., the valid data before the write) is read for restoration. The abnormal reset counter is incremented by 1. If the counter is ≥3 consecutively, the crystal oscillator is determined to be abnormal, drift prediction compensation is turned off, the system switches to pure passive timekeeping mode, and the master station is notified.

[0079] In terms of effectiveness, it reduces the number of times the memory is erased and written, extending its lifespan; it prevents parameter damage caused by power failure; and it improves system reliability through abnormal reset protection.

[0080] For example, if the intelligent fusion terminal is struck by lightning and loses power during parameter writing, it will automatically roll back to the previous valid parameters after restarting, and the time synchronization function will not be affected, so maintenance personnel will not need to recalibrate on-site.

[0081] Specifically, the step of writing the updated time synchronization parameters incrementally into the non-volatile memory and performing atomic write and abnormal rollback protection includes: comparing the current prediction model parameters with the last stored value, and triggering a write when the deviation is greater than the dynamic accuracy threshold; writing the updated parameters and checksum into the buffer and then into the shadow register area, and atomically switching the address pointer to the main register area through a double buffering mechanism after verification; if the time synchronization process times out and triggers a watchdog reset, discarding the incomplete data and rolling back to the previous valid parameter, while incrementing the abnormal reset counter by 1; if the counter continuously exceeds the preset threshold, determining that the crystal oscillator is abnormal, disabling drift prediction compensation, and switching to pure passive timekeeping mode to report to the master station.

[0082] Furthermore, the method also includes the following steps: Extract the credibility score corresponding to the fusion reference time for this time synchronization, the horizontal and trend components of the current prediction model, and the statistical values ​​of the transmission delay correction values ​​of each time source, and encapsulate them into a time synchronization coordination message; send the time synchronization coordination message to each smart terminal in the area through the local communication network, so that the terminal can decide whether to adopt the time synchronization command based on the credibility score, perform local frequency fine-tuning based on the horizontal and trend components, and perform transmission delay compensation based on the delay statistics.

[0083] The multi-level adaptive time synchronization method for intelligent fusion terminals provided in this invention can be implemented by: 1) restoring time synchronization parameters in stages from non-volatile memory and initializing the state machine after system power-on; 2) receiving time information from multiple time sources in parallel through at least two heterogeneous communication channels, evaluating communication quality, and performing delay correction and anomaly removal on the time information from each time source to obtain valid time information; 3) predicting the current network quality based on historical communication quality to dynamically adjust the time synchronization cycle, and 4) switching the backup communication channel to hot standby state in advance based on the joint evaluation results of channel quality and predicted network quality; 5) when the time synchronization trigger time is reached, weighted fusion of the valid time information according to the credibility weight of each time source to obtain the reference time, calculating the deviation between the reference time and the current clock, and performing time synchronization operations with corresponding priorities according to the deviation level; 6) calculating the drift rate based on the actual deviation after time synchronization and inputting it into the prediction model for state update and parameter adaptive adjustment, predicting the cumulative drift amount in the next cycle and converting it into compensation parameters, and performing step compensation of the clock through timed interrupts; 7) writing the updated time synchronization parameter increments into non-volatile memory, performing atomic write and anomaly rollback protection, and returning to the idle monitoring state. In this approach, timekeeping accuracy is improved through multi-source fusion, channel awareness avoids invalid retransmissions, parameter persistence enables rapid recovery after power failure, and time synchronization parameters are sent to the terminal to provide a basis for confidence, thereby achieving clock unification across the entire station area.

[0084] Example 2 Corresponding to the above method embodiments, this invention provides a multi-level adaptive time synchronization device for intelligent fusion terminals. Figure 2 This is a schematic diagram of the structure of a multi-level adaptive time synchronization device for an intelligent fusion terminal provided in an embodiment of the present invention, as shown below. Figure 2 As shown, the intelligent fusion terminal multi-level adaptive time synchronization device may include: The time synchronization parameter hierarchical recovery module 201 is used to hierarchically recover the time synchronization parameters from the non-volatile memory and initialize the state machine after the system is powered on. The communication quality assessment module 202 is used to receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, perform communication quality assessment, and perform delay correction and anomaly removal on the time information from each time source to obtain valid time information. The time synchronization period dynamic adjustment module 203 is used to dynamically adjust the time synchronization period based on the prediction of the current network quality according to the historical communication quality, and to switch the backup communication channel to hot standby state in advance based on the joint evaluation results of channel quality and predicted network quality. The weighted fusion module 204 is used to obtain a reference time by weighting and fusing the valid time information according to the credibility weight of each time source when the time synchronization trigger time is reached, calculate the deviation between the reference time and the current clock, and perform the corresponding priority time synchronization operation according to the deviation level. The parameter adaptive adjustment module 205 is used to calculate the drift rate based on the actual deviation after time calibration and input it into the prediction model for state update and parameter adaptive adjustment. It predicts the cumulative drift in the next cycle and converts it into compensation parameters. It performs step compensation of the clock through timer interrupt. The idle monitoring state return module 206 is used to write the updated time synchronization parameter increment to the non-volatile memory, perform atomic write and abnormal rollback protection, and return to the idle monitoring state.

[0085] The intelligent fusion terminal multi-level adaptive time synchronization device provided in this invention can, after system power-on, hierarchically restore time synchronization parameters from non-volatile memory and initialize the state machine; receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, perform communication quality assessment, and perform delay correction and anomaly removal on the time information of each time source to obtain effective time information; predict the current network quality based on historical communication quality to dynamically adjust the time synchronization cycle, and switch the backup communication channel to hot standby state in advance based on the joint evaluation results of channel quality and predicted network quality; when the time synchronization trigger time is reached, the effective time information is weighted and fused according to the credibility weight of each time source to obtain the reference time, calculate the deviation between the reference time and the current clock, and perform time synchronization operation with corresponding priority according to the deviation level; after time synchronization is completed, the drift rate is calculated based on the actual deviation and input into the prediction model for state update and parameter adaptive adjustment, predict the cumulative drift amount in the next cycle and convert it into compensation parameters, and perform step compensation of the clock through timed interrupts; the updated time synchronization parameter increment is written to non-volatile memory, atomic write and anomaly rollback protection are performed, and the device returns to the idle monitoring state. In this approach, timekeeping accuracy is improved through multi-source fusion, channel awareness avoids invalid retransmissions, parameter persistence enables rapid recovery after power failure, and time synchronization parameters are sent to the terminal to provide a basis for confidence, thereby achieving clock unification across the entire station area.

[0086] In some embodiments, it is also used to preferentially read the most recent timestamp and frequency correction value from the first-level non-volatile memory, and immediately write it into the clock coarse adjustment register after the verification is successful to achieve instantaneous recovery; read the prediction model parameters from the second-level non-volatile memory, and reset them to the default value if the verification fails; read the static configuration from the third-level non-volatile memory, and degenerate to blind time calibration mode if all reads fail.

[0087] In some embodiments, the system is further configured to use the input capture module to record the physical layer arrival time of the time information frame and extract the source timestamp; calculate half of the difference between the arrival time and the source timestamp for bidirectional interactive time sources as a delay correction, and use a preset fixed delay compensation for broadcast time sources; calculate the deviation between the corrected time value and the current clock, and if the deviation is greater than the outlier threshold, determine that the data of the time source is invalid this time, and reset its credibility weight to zero when the number of consecutive invalid times exceeds the threshold.

[0088] In some embodiments, the system is also used to maintain the historical sequence of round-trip delays, update the prediction model coefficients online using the recursive least squares method with a forgetting factor, and calculate the predicted round-trip delay and prediction success rate for the next time synchronization request. If the network quality is better than the first threshold, the time synchronization period is extended to the maximum value. If it is between the first threshold and the second threshold, a medium period is maintained. If it is worse than the second threshold, a backoff strategy is triggered. The backoff duration increases with the number of failures and has an upper limit.

[0089] In some embodiments, it is also used to maintain a credibility weight for each time source, which is calculated by weighting short-term stability, long-term deviation trend and link quality; calculate the cumulative credibility weight after sorting all valid time information, and select the value at which the cumulative weight first exceeds half of the total weight as the fusion reference time; when the individual weight of any information source at both ends accounts for more than the proportion of the total weight, the minimum redundancy constraint is forcibly introduced.

[0090] In some embodiments, the deviation level includes a first threshold, a second threshold, and a third threshold in sequence, wherein the first threshold is less than the second threshold, and the second threshold is less than the third threshold; it is also used to not initiate time synchronization if the deviation is less than or equal to the first threshold; and to initiate low-priority one-way time synchronization if the deviation is greater than the first threshold and less than or equal to the second threshold. If the value is greater than the second threshold and less than or equal to the third threshold, then initiate a medium-priority bidirectional time synchronization. If the value exceeds the third threshold, the highest priority time synchronization is initiated, preempting the current task and starting parallel time synchronization with all available time sources, forcibly writing the reference time into the clock hardware register. In some embodiments, it is also used to compare the current prediction model parameters with the last stored value, and trigger a write when the deviation exceeds the dynamic accuracy threshold; after writing the updated parameters and checksum into the buffer, they are written into the shadow register area, and after verification, the address pointer is atomically switched to the main register area through a double buffering mechanism; if the time synchronization process times out and triggers a watchdog reset, the incomplete data is discarded and the previous valid parameter is rolled back, while the abnormal reset counter is incremented by 1; if the counter continuously exceeds the preset threshold, the crystal oscillator is determined to be abnormal, drift prediction compensation is turned off, and the system is switched to pure passive timekeeping mode to report to the master station.

[0091] The device provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.

[0092] Example 3 This invention also provides an electronic device for running the above-described intelligent fusion terminal multi-level adaptive time synchronization method; see [link to previous document]. Figure 3The diagram shows the structure of an electronic device, which includes a memory 500 and a processor 501. The memory 500 is used to store one or more computer instructions, which are executed by the processor 501 to realize the above-mentioned intelligent fusion terminal multi-level adaptive time synchronization method.

[0093] Furthermore, Figure 3 The electronic device shown also includes a bus 502 and a communication interface 503. The processor 501, the communication interface 503 and the memory 500 are connected via the bus 502.

[0094] The memory 500 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 503 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 502 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 3 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0095] Processor 501 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 501 or by instructions in software form. Processor 501 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 500, and processor 501 reads information from memory 500 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0096] This invention also provides a computer-readable storage medium storing computer-executable instructions. When these computer-executable instructions are called and executed by a processor, they cause the processor to implement the aforementioned multi-level adaptive time synchronization method for intelligent fusion terminals. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0097] The computer program product for the multi-level adaptive time synchronization method for intelligent fusion terminals provided in this embodiment of the invention includes a computer-readable storage medium storing non-volatile program code executable by a processor. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0098] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0099] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0100] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0101] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0102] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0103] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A multi-level adaptive time synchronization method for intelligent fusion terminals, characterized in that, The method includes: After the system is powered on, the timing parameters are restored hierarchically from the non-volatile memory and the state machine is initialized; Time information from multiple time sources is received in parallel through at least two heterogeneous communication channels. Communication quality is evaluated, and delay correction and anomaly removal are performed on the time information from each time source to obtain effective time information. Based on historical communication quality, the current network quality is predicted to dynamically adjust the synchronization cycle, and based on the joint evaluation results of channel quality and predicted network quality, the backup communication channel is switched to hot standby state in advance. When the time synchronization trigger time is reached, the valid time information is weighted and fused according to the credibility weight of each time source to obtain the reference time. The deviation between the reference time and the current clock is calculated, and the time synchronization operation with the corresponding priority is executed according to the deviation level. After time calibration, the drift rate is calculated based on the actual deviation and input into the prediction model for state update and parameter adaptive adjustment. The cumulative drift in the next cycle is predicted and converted into compensation parameters. The clock is compensated stepwise through timer interrupt. Write the updated time synchronization parameters incrementally to non-volatile memory, perform atomic write and exception rollback protection, and return to idle monitoring state.

2. The method according to claim 1, characterized in that, The step-by-step recovery of timing parameters from non-volatile memory specifically includes: The most recent timestamp and frequency correction value are read first from the first-level non-volatile memory. After verification, they are immediately written to the clock coarse adjustment register to achieve instantaneous recovery. The prediction model parameters are read from the second-level non-volatile memory; if the verification fails, they are reset to the default values. The static configuration is read from the third-level non-volatile memory. If all reads fail, the system degrades to blind time calibration mode.

3. The method according to claim 1, characterized in that, The delay correction and anomaly removal of time information from each time source specifically includes: The physical layer arrival time of time information frames is recorded using the input capture module, and the source timestamp is extracted. For bidirectional interactive time sources, half of the difference between the arrival time and the source timestamp is used as a delay correction, while for broadcast time sources, a preset fixed delay compensation is used. Calculate the deviation between the corrected time value and the current clock. If the deviation is greater than the outlier threshold, the data from that time source is determined to be invalid. When the number of consecutive invalid values ​​exceeds the threshold, the confidence weight is reset to zero.

4. The method according to claim 1, characterized in that, The method of predicting the current network quality based on historical communication quality to dynamically adjust the time synchronization period specifically includes: Maintain the historical sequence of round-trip delays, use the recursive least squares method with forgetting factor to update the prediction model coefficients online, and calculate the predicted round-trip delay and prediction success rate for the next time synchronization request; If the network quality is better than the first threshold, the calibration period will be extended to the maximum value. If it is between the first and second thresholds, the medium period will be maintained. If it is worse than the second threshold, the backoff strategy will be triggered. The backoff time increases with the number of failures and has an upper limit.

5. The method according to claim 1, characterized in that, The process of weighting and fusing valid time information according to the credibility weights of each time source to obtain the base time specifically includes: For each time source, maintain a credibility weight calculated by weighting short-term stability, long-term deviation trend, and link quality. After sorting all valid time information, calculate the cumulative credibility weight, and select the value at which the cumulative weight first exceeds half of the total weight as the fusion benchmark time; When the individual weight of any information source at either end exceeds the dictatorship threshold in proportion to the total weight, a minimum redundancy constraint is forcibly introduced.

6. The method according to claim 1, characterized in that, The deviation levels sequentially include a first threshold, a second threshold, and a third threshold, with the first threshold being less than the second threshold and the second threshold being less than the third threshold; the step of performing time synchronization operations with corresponding priorities according to the deviation levels specifically includes: If the deviation is less than or equal to the first threshold, time synchronization will not be initiated. If the value is greater than the first threshold and less than or equal to the second threshold, then initiate a low-priority one-way time synchronization. If the value is greater than the second threshold and less than or equal to the third threshold, then initiate a medium-priority bidirectional time synchronization. If the value exceeds the third threshold, the highest priority time synchronization is initiated, the current task is preempted, and all available time sources are started to synchronize in parallel, forcibly writing the reference time into the clock hardware register.

7. The method according to claim 1, characterized in that, The step of writing the updated time synchronization parameter increment to non-volatile memory and performing atomic write and exception rollback protection specifically includes: The current prediction model parameters are compared with the previously stored values. A write operation is triggered when the deviation exceeds the dynamic accuracy threshold. After writing the update parameters and checksum into the buffer, write them into the shadow register area. After verification, the address pointer is atomically switched to the main register area through a double buffering mechanism. If the time synchronization process times out and triggers a watchdog reset, the incomplete data for this time will be discarded and the process will roll back to the previous valid parameter. At the same time, the abnormal reset counter will be incremented by 1. If the counter continuously exceeds the preset threshold, the crystal oscillator is determined to be abnormal, drift prediction compensation is turned off, and the system is switched to pure passive timekeeping mode to report to the master station.

8. A multi-level adaptive time synchronization device for an intelligent fusion terminal, characterized in that, The device includes: The time synchronization parameter hierarchical recovery module is used to hierarchically recover the time synchronization parameters from the non-volatile memory and initialize the state machine after the system is powered on; The communication quality assessment module is used to receive time information from multiple time sources in parallel through at least two heterogeneous communication channels, assess the communication quality, and perform delay correction and anomaly removal on the time information from each time source to obtain valid time information. The time synchronization cycle dynamic adjustment module is used to predict the current network quality based on historical communication quality to dynamically adjust the time synchronization cycle, and to switch the backup communication channel to hot standby state in advance based on the joint evaluation results of channel quality and predicted network quality. The weighted fusion module is used to weight and fuse the valid time information according to the credibility weight of each time source when the time synchronization trigger time is reached to obtain the reference time, calculate the deviation between the reference time and the current clock, and perform the corresponding priority time synchronization operation according to the deviation level. The parameter adaptive adjustment module is used to calculate the drift rate based on the actual deviation after time calibration and input it into the prediction model for state update and parameter adaptive adjustment. It predicts the cumulative drift in the next cycle and converts it into compensation parameters. It performs step compensation of the clock through timer interrupt. The idle monitoring state return module is used to write the updated time synchronization parameter increment to non-volatile memory, perform atomic write and abnormal rollback protection, and return to the idle monitoring state.

9. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the multi-level adaptive time synchronization method for intelligent fusion terminals as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the multi-level adaptive time synchronization method for intelligent fusion terminals as described in any one of claims 1 to 7.