Multi-source time signal seamless switching method and time service device

CN122932875APending Publication Date: 2026-10-16NAT TIME SERVICE CENT CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

[0005]本发明实施例提供一种多源时间信号无缝切换方法及授时装置,以至少解决主用时间源异常切换时因硬切换机制无法实现无缝切换,导致输出时间出现相位跳变、频率不连续,无法满足高精度场景对时间同步连续性与精度要求的技术问题

Benefits of technology

本发明提出了一种多源时间信号无缝切换方法及授时装置,通过构建涵盖可用性、精度、稳定性的三维时间质量因子评估体系,结合滑动窗口异常跳变检测与分级惩罚机制,能够精准甄别弱信号与伪信号,避免劣质时间源误接入;通过归一化动态加权融合结合权重变化速率限制,避免传统固定优先级硬切换模式,实现多源权重的平滑渐变,避免权重突变引发的输出抖动;通过针对即将承接主导权的时间源提前开展相位预测补偿,结合过渡窗口内的平滑合成机制,可实现切换全程频率连续、相位单调变化;同时针对北斗信号恢复的回切场景采用同机制平滑迁移,可避免传统硬切回引发的时序扰动,充分满足高精度场景对时间同步连续性与可靠性的要求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122932875A_ABST
    Figure CN122932875A_ABST
Patent Text Reader

Abstract

The application discloses a kind of multi-source time signal seamless switching method and time service device;The method comprises: obtaining the output signal of Beidou satellite time source, NTP network time source and local time-keeping time source, and the output signal is uniformly packaged as timestamp;Quantitative evaluation is carried out to each time source, and initial score is obtained;While performing abnormal jump detection, the initial score is corrected, and the real-time time quality factor value of each time source is output;Based on the real-time time quality factor value, the weight of each time source is calculated, and the reference time is generated;Extract the historical time deviation sequence, calculate the pre-compensation amount, and perform fine tuning or calibration on the target time source, generate the output time of the switching period based on the real-time weight distribution;And the change trajectory of weight is constrained, and the continuous time signal is output;The application solves the technical problem that hard switching mechanism cannot realize seamless switching when the main time source abnormally switches, and cannot meet the requirements of high-precision scene for time synchronization continuity and precision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the technical field of time synchronization and timing, and more specifically, to a method and timing device for seamless switching of multi-source time signals. Background Technology

[0002] With the development of technologies such as 5G communication, smart grid synchronization phasor measurement, high-frequency financial transaction timestamp calibration, and industrial automation time-sensitive networking (TSN), the accuracy requirements for time synchronization in core information systems have been raised to the sub-microsecond to nanosecond level, while stringent requirements have been placed on the continuity and reliability of time synchronization.

[0003] Currently, time synchronization mainly relies on BeiDou satellite navigation timing, NTP (Network Time Protocol) network timing, and local crystal oscillator timekeeping. While BeiDou timing accuracy can reach 10-100ns, its signal is susceptible to blockage, electromagnetic interference, and multipath effects. NTP timing is flexible in deployment, but its accuracy is typically only in the millisecond range under wide area networks due to network jitter and routing asymmetry. Local timekeeping relies on temperature-controlled crystal oscillators or rubidium clocks, and its accuracy gradually deteriorates over time after a loss of lock. To ensure continuity, the industry generally adopts a multi-source redundancy architecture, switching to a backup source when the primary source fails.

[0004] However, existing switching mechanisms generally suffer from significant drawbacks: signal quality assessment often employs a simple "present / absent" binary decision, lacking the ability to finely distinguish weak or spurious signals; switching strategies are mostly statically prioritized, unable to dynamically optimize weights based on real-time signal quality; thirdly, they often use hard switching methods, lacking phase pre-synchronization and smooth transition mechanisms, resulting in noticeable phase jumps and frequency discontinuities during switching, making it difficult to meet the requirements of high-precision scenarios such as power synchronization phasor measurement; fourthly, the lack of a smooth transition design when switching back to the primary source after external signal recovery easily leads to system timing disorders. Therefore, there is an urgent need for a method and device capable of achieving seamless switching between multiple signal sources. Summary of the Invention

[0005] This invention provides a method and timing device for seamless switching of multi-source time signals, which at least solves the technical problem that when the primary time source is switched abnormally, the hard switching mechanism cannot achieve seamless switching, resulting in phase jumps and frequency discontinuities in the output time, which cannot meet the requirements of time synchronization continuity and accuracy in high-precision scenarios.

[0006] According to one aspect of the present invention, a method for seamless switching of multi-source time signals is provided. The method may include: acquiring output signals from a BeiDou satellite time source, an NTP network time source, and a local timekeeping source; and uniformly encapsulating the output signals into a standardized timestamp, wherein the timestamp is used to record the specific time value corresponding to the time source. The availability status, time deviation accuracy, and historical stability of each time source are quantitatively evaluated to obtain an initial score. At the same time, abnormal jump detection is performed based on sliding window statistics, and a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value of each time source. The weights of each time source are calculated based on the real-time time quality factor value. The weights are then normalized. Based on the normalized weights, the timestamps output by each time source are weighted and synthesized to generate the reference time currently in use. At the same time, a weight change rate limiting mechanism is introduced to constrain the weight adjustment range within adjacent periods. During the gradual adjustment of weights, for the target time source whose weight is continuously rising and is expected to become the highest weight, the historical time deviation sequence between the timestamp of the target time source and the reference time is extracted, the pre-compensation amount is calculated, and the frequency fine-tuning or timestamp interpolation calibration is performed on the target time source based on the pre-compensation amount. The pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed. Within the transition window, based on real-time weight allocation, the timestamps output by each time source are weighted and synthesized. During the synthesis process, a pre-compensation amount is superimposed to generate the output time of the switching period. A smoothing algorithm is used to constrain the trajectory of weight changes, control the weight ratio of each time source within the transition window, and output a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching.

[0007] Optionally, anomaly jump detection is performed based on sliding window statistics, and a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value of each time source. This includes: collecting a time deviation sequence containing multiple consecutive sampling points based on a sliding window, calculating the mean and standard deviation of the time deviation sequence; if the jump amplitude of multiple consecutive sampling points in the time deviation sequence exceeds the normal range of fluctuation, it is determined to be an abnormal jump; based on the jump amplitude, a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value of each time source.

[0008] Optionally, based on the jump amplitude, a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value for each time source, including: when the jump amplitude is less than a first threshold, the initial score is reduced by a first proportion; when the jump amplitude is greater than or equal to the first threshold and less than a second threshold, the initial score is reduced by a second proportion, wherein the second threshold is greater than the first threshold; when the jump amplitude is greater than or equal to the second threshold and less than a third threshold, the initial score is reduced by a third proportion, wherein the second threshold is less than the third threshold; when the jump amplitude exceeds the allowable limit or a continuous jump occurs, the penalty coefficient is set to zero, the initial score corresponding to the penalty coefficient is reduced to zero, and the time source corresponding to the jump amplitude is determined to be invalid.

[0009] Optionally, the method further includes: when the failed BeiDou satellite time source recovers to normal and the real-time time quality factor value of the BeiDou satellite time source stabilizes above the qualified threshold for several cycles, extracting the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time, calculating the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time, and performing frequency fine-tuning or timestamp interpolation calibration on the BeiDou satellite time source based on the pre-compensation amount; within the transition window, gradually increasing the weight of the BeiDou satellite time source according to the smoothing algorithm, and simultaneously decreasing the weight of other time sources, and the single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism, until the weight of the BeiDou satellite time source recovers to the highest weight.

[0010] Optionally, the availability status, time deviation accuracy, and historical stability of each time source are quantitatively evaluated, including: monitoring the status identifier bits carried by the standardized timestamps of each time source, extracting the signal lock status, network response status, or local clock operation status, and generating an initial score for the availability dimension; calculating the absolute value of the time deviation between the timestamps output by each time source and the reference time, and generating an initial score for the accuracy dimension; and calculating the deviation dispersion and frequency drift of the timestamps of each time source within a preset sliding window, and generating an initial score for the stability dimension.

[0011] According to one aspect of the present invention, a time synchronization device with seamless switching of multiple time signals is provided; the time synchronization device includes: an interface module, used to acquire output signals from a BeiDou satellite time source, an NTP network time source and a local timekeeping source, and to encapsulate the output signals into a standardized timestamp, wherein the timestamp is used to record the specific time value corresponding to the time source; The time quality assessment module is used to quantitatively evaluate the availability status, time deviation accuracy, and historical stability of each time source to obtain an initial score. At the same time, it performs abnormal jump detection based on sliding window statistics, introduces a penalty coefficient to dynamically correct the initial score, and outputs the real-time time quality factor value of each time source. The fusion decision module is used to calculate the weight of each time source based on the real-time time quality factor value, normalize the weight, and then perform weighted synthesis of the timestamps output by each time source based on the normalized weight to generate the reference time in use. At the same time, a weight change rate limiting mechanism is introduced to constrain the weight adjustment range within adjacent periods. The phase synchronization module is used to extract the historical time deviation sequence between the timestamp of the target time source and the reference time for the target time source whose weight is continuously rising and is expected to become the highest weight during the gradual adjustment of weight. It calculates the pre-compensation amount and performs frequency fine-tuning or timestamp interpolation calibration on the target time source based on the pre-compensation amount. The pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed. The clock output module is used to continuously weight and synthesize the timestamps output by each time source based on real-time weight allocation within the transition window. During the synthesis process, a pre-compensation amount is superimposed to generate the output time of the switching period. A smoothing algorithm is used to constrain the change trajectory of the weights, control the weight ratio of each time source within the transition window, and output a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching.

[0012] Optionally, the timing device further includes: The phase synchronization module is also used to extract the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time after the failed BeiDou satellite time source is restored to normal and the real-time time quality factor value of the BeiDou satellite time source is stable above the qualified threshold for several cycles, calculate the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time, and perform frequency fine-tuning or timestamp interpolation calibration on the BeiDou satellite time source based on the pre-compensation amount. The fusion decision module is also used to gradually increase the weight of the BeiDou satellite time source within the transition window according to the smoothing algorithm, while simultaneously reducing the weight of other time sources. The single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism until the weight of the BeiDou satellite time source is restored to the highest weight.

[0013] The beneficial effects of this invention are: This invention proposes a seamless switching method and timing device for multi-source time signals. By constructing a three-dimensional time quality factor evaluation system covering availability, accuracy, and stability, and combining a sliding window anomaly jump detection and graded penalty mechanism, it can accurately identify weak signals and spurious signals, avoiding the misconnection of inferior time sources. Through normalized dynamic weighted fusion combined with weight change rate limitation, it avoids the traditional fixed-priority hard switching mode, achieving a smooth and gradual change of multi-source weights and avoiding output jitter caused by sudden weight changes. By performing phase prediction compensation in advance for the time source about to take over the dominant position, combined with a smooth synthesis mechanism within the transition window, it can achieve continuous frequency and monotonic phase change throughout the switching process. At the same time, for the BeiDou signal recovery back-switching scenario, the same mechanism is used for smooth migration, which can avoid the timing disturbances caused by traditional hard switching back, fully meeting the requirements of high-precision scenarios for time synchronization continuity and reliability. Attached Figure Description

[0014] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings: Figure 1 This is a flowchart of a method for seamless switching of multi-source time signals according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the time quality assessment process according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the dynamic weighted fusion process according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the phase prediction compensation process according to an embodiment of the present invention; Figure 5 This is a schematic diagram comparing the effects of traditional hard switching and seamless switching according to an embodiment of the present invention. Detailed Implementation

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

[0016] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0017] Example According to embodiments of the present invention, a method and timing device for seamless switching of multi-source time signals are provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system containing at least one set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0018] Figure 1 This is a flowchart of a method for seamless switching of multi-source time signals according to an embodiment of the present invention, such as... Figure 1 As shown, the method may include the following steps: Step S101: Obtain the output signals from the BeiDou satellite time source, the NTP network time source, and the local timekeeping time source, and encapsulate the output signals into a standardized timestamp. The timestamp is used to record the specific time value corresponding to the time source.

[0019] In the technical solution provided in step S101 of the present invention, for the BeiDou satellite time source, a BeiDou PCIe timing card is used to access it through the PCIe interface. The original parameters output by the timing card include carrier-to-noise ratio, lock status, number of visible satellites, etc. The rising edge interrupt of the 1PPS pulse output by the timing card is captured and the local counter is read. At the same time, the time, minute and second information of the synchronously sent TOD message is parsed, and the absolute timestamp is concatenated and encapsulated. If the timing card is in a lost-lock state, the time validity flag in the timestamp is set to 0, and the lock status field is marked as abnormal in the quality parameter structure.

[0020] For the NTP network time source, an Ethernet interface is used for access. An NTP client is run to initiate a time query to the upstream NTP server every 10ms. The local request sending time T1 and message receiving time T4 are recorded. The network round-trip time and time deviation are calculated by combining the message receiving time T2 and sending time T3 returned by the server. The deviation sequence of multiple consecutive cycles is filtered to eliminate network jitter and then encapsulated with a timestamp. If no response is received from the server for 3 consecutive cycles, the time validity flag in the timestamp is set to 0.

[0021] For the local timekeeping source, a temperature-controlled crystal oscillator is used as the core timekeeping device. A 1PPS signal is output through a frequency divider circuit. The measurement module uses the most recent valid external time source as a reference and measures the phase difference between the local 1PPS and the reference source every second. The local absolute time is calculated by combining the historical calibration data. If the timekeeping duration exceeds the preset duration after the most recent valid external calibration, the calibration validity field in the quality parameter structure is marked as expired.

[0022] Step S102: Quantitatively evaluate the availability status, time deviation accuracy, and historical stability of each time source to obtain an initial score; at the same time, perform abnormal jump detection based on sliding window statistics, introduce a penalty coefficient to dynamically correct the initial score, and output the real-time time quality factor value of each time source.

[0023] In the technical solution provided in step S102 of the present invention, quantitative scoring is carried out from three dimensions: availability, accuracy, and stability. The scoring of each dimension adopts a normalization rule of 0 to 100 points: the availability dimension evaluates the signal locking status, network connectivity, and local clock health status. Among them, the Beidou satellite time source is determined based on the locking status and carrier-to-noise ratio. When locked and the carrier-to-noise ratio is at a high level, the score is 100, and when unlocked, it is 0. The NTP network time source is determined based on network connectivity and round-trip delay. When the delay is less than 10ms, the score is 100, and when it is greater than 100ms or there is no response, it is 0. The local timekeeping source is determined based on the temperature control status and calibration validity period. When the temperature control is normal and the calibration validity period has not expired, the score is 100, when the temperature control is abnormal, it is 0, and when the calibration validity period expires, it decreases linearly according to the expiration time.

[0024] The accuracy dimension assesses the time deviation and frequency shift between each time source and the local reference, with a maximum score of 100 points. The larger the deviation, the lower the score. The stability dimension is based on a sliding window of the most recent 100 sampling points (corresponding to 1 second duration), calculating the standard deviation of time deviation and the standard deviation of frequency drift, and scoring them according to a preset threshold, with a maximum score of 100 points. The larger the fluctuation, the lower the score.

[0025] After completing the 3D scoring, anomaly jump detection is performed based on sliding window statistics: maintaining a time deviation sequence containing 100 consecutive sampling points. Calculate the sequence mean with standard deviation When three consecutive sampling points satisfy | |>3 The time interval is determined to be an abnormal jump; a graded penalty coefficient is introduced based on the jump amplitude. Dynamically adjust the initial score: when the jump amplitude is less than 200ns =0.8, from 200 ns to 1 μs =0.5, from 1μs to 10μs =0.2, greater than 10μs or when continuous jumps occur =0, directly remove the time source.

[0026] The real-time time quality factor value for each time source is calculated using the following formula:

[0027] in, , , For the dimension weight coefficients, satisfying , This is the penalty coefficient for the aforementioned abnormal jump.

[0028] For example, suppose that at a certain moment, the BeiDou satellite time source experiences a decrease in carrier-to-noise ratio and a 300ns jump due to obstruction. , 4. 3. Usability score A=60, accuracy score P=80, stability score S=70, corresponding to =0.5, substituting into the formula, we get TQF=0.5×(0.3×60+0.4×80+0.3×70)=32.5; the NTP network time source network is normal, availability score A=100, accuracy score P=80, stability score S=85. =1.0, TQF=88.0; Local timekeeping source calibration validity period not expired, availability score A=100, accuracy score P=90, stability score S=75. =1.0, TQF=88.5; It should be noted that this is only an example and does not limit the specific values.

[0029] Step S103: Calculate the weight of each time source based on the real-time time quality factor value, normalize the weight, and then weight and synthesize the timestamps output by each time source based on the normalized weight to generate the reference time in use. At the same time, introduce a weight change rate limiting mechanism to constrain the weight adjustment range within adjacent periods.

[0030] In the technical solution provided by step S103 of the present invention, the initial weights of each time source are calculated based on the real-time TQF value, and normalization processing is performed: the TQF value of each time source is divided by the sum of the TQF values ​​of all available sources (i.e., sources whose TQF is not 0), so that the sum of all weights is constant to 1; if a time source is determined to be ineffective due to abnormal jump (i.e., penalty coefficient), If the value is 0 and TQF is zero, its weight is directly set to 0, it does not participate in the normalization calculation, and it is automatically removed from the fusion link.

[0031] Based on the normalized weights, a weighted arithmetic synthesis is performed on the absolute time values ​​carried by the timestamps output from each time source, using the following formula:

[0032] in, Let be the normalized weight for the i-th time source. The time value corresponding to the standardized timestamp of the i-th time source is synthesized. This is the reference time currently in use, which will serve as a unified reference for subsequent phase deviation calculations and pre-compensation calculations.

[0033] To avoid sudden weight changes caused by normal fluctuations in TQF, which in turn lead to output time jitter, a weight change rate limiting mechanism is introduced. The maximum weight adjustment range in the order period is 0.05: if the difference between the target weight of a certain time source in the current period and the actual weight in the previous period exceeds 0.05, the transition is completed gradually in multiple periods to ensure that the weight adjustment range in each period does not exceed 0.05, thus achieving a smooth and gradual change in weight.

[0034] For example, taking the three-source evaluation data disclosed in step S102 at a certain moment as an example: Beidou satellite time source TQF=32.5, NTP network time source TQF=88.0, local timekeeping time source TQF=88.5, the sum of the three source TQFs is 32.5+88.0+88.5=209.0. After normalization, the Beidou satellite time source... =32.5 / 209.0≈0.156, Time Source Weight of NTP Network =88.0 / 209.0≈0.421, local timekeeping source weight =88.5 / 209.0≈0.423; Assuming the BeiDou satellite time source weight was 0.520 in the previous cycle and the target weight for this cycle is 0.156, the difference of 0.364 far exceeds the single-cycle adjustment limit of 0.05. Therefore, the actual weight will gradually transition over 6 cycles according to the rhythm of 0.520→0.470→0.420→0.370→0.320→0.270. The weights of the NTP network time source and the local timekeeping time source will increase synchronously and in reverse, with no sudden weight changes throughout the process; If the TQF of the BeiDou satellite time source continues to decrease to =0, its weight is directly reduced to zero, and it automatically switches to the dual-source fusion mode of NTP network time source and local time source without manual intervention.

[0035] Step S104: During the gradual adjustment of weights, for the target time source whose weight is continuously increasing and is expected to become the highest weight, extract the historical time deviation sequence between the timestamp of the target time source and the reference time, calculate the pre-compensation amount, and perform frequency fine-tuning or timestamp interpolation calibration on the target time source based on the pre-compensation amount. The pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed.

[0036] In the technical solution provided by step S104 of the present invention, the weight adjustment process is the weight smooth change process constrained by the weight change rate limiting mechanism in step S103; the target time source with continuously rising weight and expected to become the highest weight refers to the time source in which the weight shows a continuous upward trend during the normalized weight dynamic adjustment process and is predicted to obtain the maximum normalized weight at the end of the transition window.

[0037] Once the target time source is identified, the time value carried by the standardized timestamp output by the target time source is extracted and the difference is made with the reference time value currently in use to obtain a continuous historical phase deviation sequence. For example, the historical phase deviation sequence of the most recent 200 sampling periods (corresponding to 2 seconds) is used as the calculation input to ensure prediction accuracy.

[0038] The pre-compensation amount is calculated based on historical phase deviation sequences. An autoregressive moving average prediction model is used to fit the sequence, and the model parameters are solved using the least squares method. The phase deviation between the timestamp of the target time source and the currently used reference time at the moment the weight adjustment is completed is predicted, and the correction value corresponding to this phase deviation is the pre-compensation amount. The formula is:

[0039] in, Let t be the phase deviation between the target time source and the reference time being used. , , , These are the model parameters obtained through least squares fitting. It is white noise.

[0040] For example, during the gradual weight adjustment process, the weight of the local timekeeping source continuously increases, and it is expected to become the source with the highest weight at the end of the 60-millisecond transition window T_transition. The historical phase deviation sequence of the most recent 200 cycles between the local timekeeping source and the reference time being used is retrieved and substituted into the model. After fitting the parameters, the phase deviation at the moment when the weight adjustment is completed is predicted. The predicted value is approximately +52 ns. Based on this prediction, the frequency adjustment is calculated. : = / T_transition=52ns / 60ms=0.867ppm Calibrate the target time source based on the pre-compensation amount: If the frequency fine-tuning method is used, the frequency of the local time source is increased by 0.867ppm during the 60ms transition period to keep its phase trajectory aligned with the reference time being used; if the timestamp interpolation calibration method is used, 52ns is directly subtracted from the standardized timestamp value output by the local time source to achieve phase pre-alignment.

[0041] Step S105: Within the transition window, based on real-time weight allocation, the timestamps output by each time source are continuously weighted and synthesized. During the synthesis process, a pre-compensation amount is superimposed to generate the output time of the switching period. A smoothing algorithm is used to constrain the trajectory of weight change, control the weight ratio of each time source within the transition window, and output a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching.

[0042] In the technical solution provided in step S105 of the present invention, the transition window is a pre-configured fixed duration period, for example, its length is 60ms, corresponding to 6 system scheduling cycles of 10ms, which is specifically used to complete the smooth migration of weights from the current distribution to the target distribution, avoiding temporal abrupt changes caused by hard switching.

[0043] Within the transition window, the time values ​​carried by the standardized timestamps output by each time source are further weighted and synthesized based on the real-time normalized weights output in step S103 (i.e., the weighted fusion operation periodically performed in step S103 continues during the switching period). During the synthesis process, the pre-compensation amount output in step S104 needs to be superimposed: if step S104 performs frequency fine-tuning on the target time source, the pre-compensation amount is already reflected in the output phase of the target time source, and its timestamp value is directly used during synthesis; if step S104 performs timestamp interpolation calibration, the pre-compensation amount needs to be superimposed as a correction value on the timestamp value of the target time source before participating in the weighted synthesis to ensure that the phase trajectory of the target time source is completely aligned with the reference time being used.

[0044] A smoothing algorithm is used to constrain the trajectory of weight changes, strictly controlling the rate of change of the weight ratio of each time source within the transition window, and adhering to the limit of the maximum weight adjustment amplitude in a single cycle: for example, assuming the maximum weight adjustment amplitude is 0.05, that is, within any two adjacent 10ms scheduling cycles, the weight change amplitude of any time source shall not exceed 0.05. If the difference between the target weight and the current weight exceeds this limit, the transition is completed gradually in multiple scheduling cycles to ensure that the weight change has a continuous and smooth trajectory without abrupt changes.

[0045] For example, assuming the maximum weight adjustment is 0.05, when the BeiDou satellite time source's time quality factor drops to 32.5 due to obstruction, requiring a switch from the primary source to the NTP network time source and the local timekeeping source, the transition window length is 60ms, comprising six 10ms scheduling cycles. Initially, the weight of the BeiDou satellite time source is 0.520, the NTP network time source weight is 0.240, and the local timekeeping source weight is 0.240, with target weights of 0.156, 0.421, and 0.423 respectively. Limited by the single-cycle adjustment range of 0.05, the BeiDou satellite time... The weight of the source gradually decreases in the rhythm of 0.520→0.470→0.420→0.370→0.320→0.270, and is then fine-tuned to the target value of 0.156 after the 6th cycle; the weight of the NTP network time source gradually increases in the rhythm of 0.240→0.290→0.340→0.390→0.440→0.490, and is then fine-tuned to 0.421 after the 6th cycle; the weight of the local timekeeping source gradually increases in the rhythm of 0.240→0.290→0.340→0.390→0.440→0.490, and is then fine-tuned to 0.423 after the 6th cycle. Throughout the transition process, the weight changes remain continuous and gradual, without any abrupt jumps. Meanwhile, for the local time source with a pre-compensation amount of 52ns calculated in step S104, its timestamp value is subtracted by 52ns before participating in the weighting calculation, ensuring that its phase is completely aligned with the reference time being used.

[0046] After the above processing, the phase jump of the output switching time signal is less than 8ns throughout the entire process, with no second jumps or phase glitches, achieving a completely seamless switching effect. If the signal quality of the BeiDou satellite time source recovers in the future, when performing the back-switching operation, the same 60ms transition window, single-cycle weight adjustment limit of 0.05, and the same smoothing algorithm are used to gradually restore the weight of the BeiDou satellite time source to the highest weight, avoiding the introduction of new timing disturbances during the back-switching process.

[0047] The method described in this embodiment will be further described below.

[0048] As an optional implementation, step S102 involves performing abnormal jump detection based on sliding window statistics, introducing a penalty coefficient to dynamically correct the initial score, and outputting the real-time time quality factor value for each time source. This includes: collecting a time deviation sequence containing multiple consecutive sampling points based on a sliding window, calculating the mean and standard deviation of the time deviation sequence; if the jump amplitude of multiple consecutive sampling points in the time deviation sequence exceeds the normal range of fluctuation, it is determined to be an abnormal jump; based on the jump amplitude, introducing a penalty coefficient to dynamically correct the initial score, and outputting the real-time time quality factor value for each time source.

[0049] In this embodiment, this step is a detailed implementation of the time source health assessment. Its input is the standardized timestamp of each time source output in step S101, and its output is the real-time time quality factor value of each time source after dynamic correction. This is used to further eliminate risky time sources with instantaneous disturbances based on the initial score.

[0050] The sliding window is a continuous sampling interval of fixed length, for example, its size is 200 sampling points, corresponding to an observation duration of 2 seconds; based on this sliding window, the time deviation sequence of each time source is collected, that is, the set of differences between the time value carried by the standardized timestamp output by the time source and the reference time value being used within 200 consecutive sampling periods.

[0051] Calculate the statistical characteristics of the time deviation sequence: first, the mean of the time deviation sequence, reflecting the level of deviation of the time source; second, the standard deviation of the time deviation sequence, reflecting the degree of jitter of the time source. Based on the mean and standard deviation, determine the normal range of fluctuation.

[0052] Perform abnormal jump detection: If the jump amplitude of 5 or more consecutive sampling points in the time deviation sequence exceeds the normal range of the above fluctuation, it is judged as an abnormal jump; the jump amplitude refers to the absolute value of the change in the time deviation of a single sampling point relative to the previous sampling point.

[0053] For example, taking the BeiDou satellite time source as an example, assuming the normal range is the mean ± 3 times the standard deviation, and the calculated mean of the time deviation sequence within a certain sliding window is +15 nanoseconds and the standard deviation is 4 nanoseconds, then the normal range of fluctuation is +3 nanoseconds to +27 nanoseconds. If the time deviation of 6 consecutive sampling points in this time deviation sequence is +16 nanoseconds, +28 nanoseconds, +45 nanoseconds, +42 nanoseconds, +39 nanoseconds, and +37 nanoseconds respectively, with jump amplitudes of 12 nanoseconds, 17 nanoseconds, 3 nanoseconds, 3 nanoseconds, and 2 nanoseconds starting from the second point, all exceeding the upper limit of the normal range of +27 nanoseconds, and the number of consecutive points exceeding the limit reaches 6, it meets the judgment condition of "the jump amplitude of 5 consecutive sampling points exceeds the normal fluctuation range", and is therefore marked as an abnormal jump.

[0054] After confirming an abnormal jump, a penalty coefficient is introduced to dynamically correct the initial score based on the jump magnitude. Specifically, a tiered threshold system based on standard deviation and corresponding reduction ratios are pre-defined: the first threshold is 1 standard deviation, the second threshold is 3 standard deviations, and the third threshold is 5 standard deviations; at the same time, corresponding reduction ratios are defined: for example, the first ratio is 10%, the second ratio is 30%, and the third ratio is 50%; when the jump magnitude is less than the first threshold, the initial score is reduced according to the first ratio. When the jump amplitude is greater than or equal to the first threshold and less than the second threshold, the initial score is reduced by a second ratio, where the second threshold is greater than the first threshold; when the jump amplitude is greater than or equal to the second threshold and less than the third threshold, the initial score is reduced by a third ratio, where the second threshold is less than the third threshold; when the jump amplitude exceeds the allowable limit or a continuous jump occurs, the penalty coefficient is set to zero, the initial score corresponding to the penalty coefficient is reduced to zero, and the time source corresponding to the jump amplitude is determined to be invalid; that is, the larger the jump amplitude, the smaller the penalty coefficient value.

[0055] For example, assuming the first threshold is 5 nanoseconds, the second threshold is 15 nanoseconds, and the third threshold is 30 nanoseconds, this threshold system is determined based on the standard deviation obtained from sliding window statistics. That is, the first threshold is 1 standard deviation, the second threshold is 3 standard deviations, and the third threshold is 5 standard deviations. In the aforementioned example scenario, the standard deviation is 4 nanoseconds, so the corresponding values ​​are 4 nanoseconds, 12 nanoseconds, and 20 nanoseconds. At the same time, the corresponding reduction ratios are defined: the first ratio is 10% (i.e., retaining 90% of the initial score), the second ratio is 30% (i.e., retaining 70% of the initial score), and the third ratio is 50% (i.e., retaining 50% of the initial score). When the jump amplitude is less than the first threshold (5 nanoseconds), it is judged as a slight fluctuation, and the initial score is reduced according to the first ratio. For example, if the initial score of the Beidou satellite time source is 95 points, and the jump amplitude of a certain sampling point is 3 nanoseconds (less than 5 nanoseconds), then the corrected real-time time quality factor value is 95 × (1 - 10%) = 85.5 points, with a corresponding penalty coefficient of 0.9.

[0056] When the jump amplitude is greater than or equal to the first threshold and less than the second threshold (15 nanoseconds), it is judged as a moderate anomaly, and the initial score is reduced according to the second ratio. Continuing with the previous example, if the single jump amplitude of the Beidou satellite time source is 12 nanoseconds (between 5 nanoseconds and 15 nanoseconds), then the corrected real-time time quality factor value is 95×(1-30%)=66.5 points, and the corresponding penalty coefficient is 0.7.

[0057] When the jump amplitude is greater than or equal to the second threshold and less than the third threshold (30 nanoseconds), it is judged as a serious anomaly, and the initial score is reduced according to the third ratio; for example, if the initial score of the Beidou satellite time source is 95 points, and the jump amplitude of a certain sampling point is 22 nanoseconds (between 15 nanoseconds and 30 nanoseconds), then the corrected real-time time quality factor value is 95×(1-50%)=47.5 points, and the corresponding penalty coefficient is 0.5.

[0058] When the jump amplitude exceeds the allowable limit (i.e., greater than or equal to the third threshold of 30 nanoseconds), or when continuous jumps occur (e.g., the jump amplitude of 5 or more consecutive sampling points exceeds the normal range of fluctuation), the time source is determined to be invalid, the penalty coefficient is set to zero, and the initial score is directly reduced to zero. For example, if the jump amplitude of 6 consecutive sampling points of the Beidou satellite time source exceeds 30 nanoseconds (exceeding the allowable limit) within a certain sliding window, or as in the above example, 6 consecutive sampling points exceed the normal range of "mean ± 3 times standard deviation" (constituting continuous jumps), then its penalty coefficient is set to 0, the real-time time quality factor value is corrected to 95 × 0 = 0 points, and the Beidou satellite time source is simultaneously marked as invalid, and its timestamp data will no longer be adopted in subsequent weight allocation.

[0059] In one specific embodiment, the penalty coefficient can be calculated through a refined mapping of the jump severity to achieve a smooth correspondence with the aforementioned grading rules. The calculation method involves taking the largest single jump amplitude among consecutive abnormal sampling points and dividing it by the half-width of the normal range (i.e., three times the standard deviation). For example, following the previous example, if the largest single jump amplitude is 17 nanoseconds and the half-width of the normal range is 12 nanoseconds, the jump severity is 17 / 12 ≈ 1.417. According to the mapping relationship, when the jump severity is greater than 1.0, the penalty coefficient is 0.7. Assuming the initial score of the BeiDou satellite time source is 95 points, the corrected real-time time quality factor value is 95 × 0.7 = 66.5 points. This calculation result is consistent with the aforementioned grading rule that a penalty coefficient of 0.7 corresponds to a moderate anomaly (12 nanoseconds).

[0060] If no abnormal jumps meeting the above conditions are detected in the time deviation sequence, the penalty coefficient is 1.0, and the real-time time quality factor value is equal to the initial score. For example, if the mean of the time deviation sequence of the NTP network time source within the same sliding window is +120 nanoseconds and the standard deviation is 20 nanoseconds, and the jump amplitude of all sampling points does not exceed the normal range of ±60 nanoseconds, and there are no abnormal jumps in 5 consecutive sampling points, then its penalty coefficient is 1.0. If the initial score is 85 points, the corrected real-time time quality factor value is still 85 points.

[0061] As an optional embodiment, the method further includes: when the failed BeiDou satellite time source recovers to normal and the real-time time quality factor value of the BeiDou satellite time source stabilizes above the qualified threshold for several consecutive cycles, extracting the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time, calculating the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time, and performing frequency fine-tuning or timestamp interpolation calibration on the BeiDou satellite time source based on the pre-compensation amount; within the transition window, gradually increasing the weight of the BeiDou satellite time source according to the smoothing algorithm, while simultaneously decreasing the weight of other time sources, and the single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism, until the weight of the BeiDou satellite time source recovers to the highest weight.

[0062] In this embodiment, this step is used to preprocess and smooth the weight of the restored BeiDou satellite time source; its input is BeiDou satellite time source data that has been marked as invalid but whose current real-time time quality factor value meets the standard, and its output is the BeiDou satellite time source that has been calibrated and whose weight has been restored to the highest weight.

[0063] Specifically, when the BeiDou satellite time source is determined to be faulty, its status is continuously monitored. When the real-time time quality factor value of the BeiDou satellite time source stabilizes above the qualified threshold for several cycles, confirming its recovery, the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time is extracted. Based on this historical time deviation sequence, a pre-compensation amount is calculated. For example, a set of historical time deviation sequences in the early stage of BeiDou satellite time source recovery is extracted, and its average value is calculated as the pre-compensation amount. Based on this pre-compensation amount, frequency fine-tuning or timestamp interpolation calibration is performed on the BeiDou satellite time source to eliminate the fixed deviation in the early stage of recovery.

[0064] After calibration is completed, a transition window is entered. Within the transition window, the weight of the BeiDou satellite time source is gradually increased according to the smoothing algorithm, while the weight of other time sources is decreased simultaneously. During this process, the single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism.

[0065] For example, suppose the weight of the BeiDou satellite time source is low in the initial stage of recovery. In the first sampling period of the transition window, the target weight increase of the BeiDou satellite time source is calculated to be large according to the smoothing algorithm. However, due to the constraint of the weight change rate limiting mechanism, the actual adjustment range is limited to a specified range. Only the weight of the BeiDou satellite time source is allowed to be increased by a limited amount, and the weights of other time sources are adjusted accordingly. The above process is repeated until the weight of the BeiDou satellite time source is restored to the highest weight.

[0066] As an optional implementation, step S104 involves quantitatively evaluating the availability status, time deviation accuracy, and historical stability of each time source, including: monitoring the status identifier bits carried by the standardized timestamps of each time source, extracting the signal lock status, network response status, or local clock operation status, and generating an initial score for the availability dimension; calculating the absolute value of the time deviation between the timestamps output by each time source and the reference time, and generating an initial score for the accuracy dimension; and calculating the deviation dispersion and frequency drift of the timestamps of each time source within a preset sliding window, and generating an initial score for the stability dimension.

[0067] In this embodiment, the assessment of availability involves: monitoring the status flags carried in the standardized timestamps of each time source; extracting the signal lock status of its radio frequency front-end for BeiDou satellite time sources; extracting the network round-trip time delay and response status for network time sources; and extracting the operating voltage and frequency lock status of its oscillator for local timekeeping sources. Based on the extracted status information, an initial score for availability is generated.

[0068] For example, if the signal lock status flag of the BeiDou satellite time source is detected as normally locked, the initial score for the availability dimension is set to a maximum of 100 points; if the network time source is detected to have a network response timeout or packet loss, the corresponding score is deducted based on the frequency of the timeout, and the corresponding initial score for the availability dimension is generated.

[0069] For the accuracy dimension evaluation: the absolute value of the time deviation between the timestamp output by each time source and the reference time is calculated; the smaller the absolute value of the time deviation, the higher the accuracy of the time source, and the higher the corresponding initial score.

[0070] For example, within a sampling period, the absolute time deviation of the BeiDou satellite time source is statistically obtained as 15 nanoseconds, and the absolute time deviation of the network time source is 10 milliseconds. According to the preset mapping relationship, the initial score of the accuracy dimension corresponding to the absolute time deviation of 15 nanoseconds is 95 points, and the initial score of the accuracy dimension corresponding to the absolute time deviation of 10 milliseconds is 85 points.

[0071] For the evaluation of the stability dimension: the degree of deviation dispersion and frequency drift of the timestamps of each time source within a pre-set sliding window (e.g., a window containing 200 consecutive sampling points) is statistically analyzed; the degree of deviation dispersion is usually characterized by the standard deviation of the time deviation sequence, and the degree of frequency drift is characterized by the rate of change of the time deviation between adjacent sampling points; an initial score for the stability dimension is generated based on these two statistics.

[0072] For example, within a preset sliding window, if the standard deviation of the time deviation sequence of the BeiDou satellite time source is 4 nanoseconds and the frequency drift between adjacent sampling points is less than 0.5 nanoseconds / second, exhibiting extremely high stability, then the initial score for the stability dimension is 95 points; while the standard deviation of the time deviation sequence of the network time source at the same time is 3 milliseconds and there is obvious frequency drift, then the initial score for the stability dimension is 80 points.

[0073] This invention discloses a timing device for seamless switching of multi-source time signals. The device includes an interface module, a time quality assessment module, a fusion decision module, a phase synchronization module, and a clock output module. The modules work together to achieve seamless switching and stable output of multi-source time signals.

[0074] The interface module, acting as the data input front end, acquires output signals from the BeiDou satellite time source, network time source, and local timekeeping source. Due to differences in the physical interfaces and data formats of each time source, the interface module encapsulates all output signals into a standardized timestamp. This timestamp records the specific time value corresponding to the time source for unified processing by subsequent modules. For example, the interface module parses and converts the serial data frames from the BeiDou satellite time source, the message data from the network time source, and the pulse signals from the local timekeeping source into a standard timestamp format containing second and nanosecond information.

[0075] The time quality assessment module is used to quantitatively score the health status of each time source. This module first performs a basic assessment, which quantitatively evaluates the availability, time deviation accuracy, and historical stability of each time source to obtain an initial score.

[0076] Building upon this foundation, the time quality assessment module simultaneously performs anomaly detection based on sliding window statistics, identifying abnormal situations such as continuous jumps, and introduces a penalty coefficient to dynamically correct the initial score. Finally, the module outputs the real-time time quality factor value for each time source. For example, if a continuous jump is detected in a BeiDou satellite time source, a penalty coefficient less than 1 is multiplied from the initial score, significantly reducing its output real-time time quality factor value and reflecting its current instability.

[0077] Figure 2 This is a schematic diagram of the time quality assessment process according to an embodiment of the present invention, such as... Figure 2The diagram illustrates the evaluation and generation logic of the time quality factor value. Raw multidimensional data from various time sources are input into the time quality evaluation module. This data includes, but is not limited to, core indicators such as availability (e.g., signal lock-in status, network connectivity), accuracy (e.g., instantaneous time deviation, frequency drift), and stability (e.g., historical deviation variance). Considering the differences in the units of measurement for different indicators (e.g., signal strength in dBm, while time deviation is in ns), a normalization compensation operation is performed. This step maps all heterogeneous indicators to a unified numerical range, eliminating unit barriers and making data from different dimensions directly comparable. A preliminary basic quality score is generated based on a preset weighting strategy. The final score is then integrated into the overall score fusion stage. After normalization, the basic scores are weighted and calculated to generate a preliminary total score, which represents the theoretical quality level of each time source at the current moment. To improve the model's anti-interference capability in complex environments, a historical bias filtering and anomaly window discrimination mechanism is introduced. This mechanism reviews the historical performance of the time sources, uses filtering algorithms to eliminate sudden abnormal interference (such as short-term instability caused by instantaneous electromagnetic pulses), and combines the continuity characteristics of the time axis to accurately identify the anomaly windows that truly represent the performance degradation of the time sources. Through this closed-loop feedback, the total score is finally dynamically corrected, thereby outputting a more robust and accurate Time Quality Factor (TQF) value, providing a reliable basis for subsequent dynamic weighted fusion.

[0078] The fusion decision module is responsible for the calculation and dynamic management of weights. First, it calculates the weights of each time source based on the real-time time quality factor value and normalizes these weights (ensuring the sum of all weights is 100%). Based on the normalized weights, it weights and synthesizes the timestamps output by each time source to generate the currently used reference time. To prevent output time jumps due to sudden weight changes, the fusion decision module introduces a weight change rate limiting mechanism to constrain the weight adjustment amplitude within adjacent periods. Furthermore, the fusion decision module specifically executes weight scheduling during the recovery period: within the transition window, it gradually increases the weight of the BeiDou satellite time source according to a smoothing algorithm, while simultaneously decreasing the weights of other time sources. The single-period amplitude of weight changes is strictly limited by the aforementioned weight change rate limiting mechanism until the weight of the BeiDou satellite time source recovers to its highest weight.

[0079] Figure 3 This is a schematic diagram of the dynamic weighted fusion process according to an embodiment of the present invention, such as... Figure 3The diagram illustrates the dynamic weighted fusion process based on time quality factor values. Using the real-time time quality factor (TQF) of each time source as input, to ensure that scores of different dimensions can directly participate in the calculation, the first step is normalization compensation. This step eliminates the numerical magnitude differences between different indicators, uniformly mapping the state of all time sources to the same scale, forming comparable basic weight values. Weight allocation is then performed based on the normalized values, initially calculating the proportion that each time source should occupy at the current moment. The core step is the logical prediction of the weight change rate, which compares the newly calculated weight with the old weight from the previous period to determine whether the magnitude of the weight change exceeds a preset safety range. Over-limit handling (smooth transition): If the weight change is too drastic (for example, a source weight changes from 10% to 90% instantly), a limiting protection mechanism will be triggered to prevent the output time from jumping. This mechanism will suppress the sudden change of weight and force the weight to slowly rise or fall according to the preset slope, thereby achieving a smooth transition of weight.

[0080] Normal processing (adaptive application): If the weight change is determined to be within the allowable normal range, proceed directly to the next step.

[0081] Whether the weights are smoothed or determined normally, they will be aggregated at the final weighted fusion output node. This node will weight and synthesize the standardized timestamps output by each time source based on their actual effective weights, and generate and output the final reference time.

[0082] The phase synchronization module is used to eliminate phase differences before a handover occurs. This module has two operating scenarios: For anticipated switching: During the gradual adjustment of weights, for the target time source whose weight is continuously rising and is expected to become the highest weight, extract the historical time deviation sequence between the timestamp of the target time source and the reference time, and calculate the pre-compensation amount; this pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed; based on this pre-compensation amount, perform frequency fine-tuning or timestamp interpolation calibration on the target time source.

[0083] For fault recovery: When the failed BeiDou satellite time source is restored to normal and its real-time time quality factor value is stable above the qualified threshold for several cycles, the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time is extracted, the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time is calculated, and based on the pre-compensation amount, frequency fine-tuning or timestamp interpolation calibration is performed on the BeiDou satellite time source.

[0084] For example, assuming that the historical time deviation sequence shows that the BeiDou satellite time source is 20 nanoseconds ahead of the reference time, the phase synchronization module calculates the pre-compensation amount as -20 nanoseconds, and before the BeiDou satellite time source participates in the synthesis, it deducts 20 nanoseconds from its timestamp, or fine-tunes its internal crystal oscillator frequency, so that its phase is aligned with the reference time in advance.

[0085] Figure 4 This is a schematic diagram of the phase prediction compensation process according to an embodiment of the present invention, as shown below. Figure 4 The diagram illustrates the pre-compensation process executed by the phase synchronization module. Through continuous monitoring, it detects a sustained decay in the time quality factor value of the currently used primary time source (e.g., the BeiDou satellite time source), indicating that the time source is about to fail or is already unstable. To prepare for the upcoming handover, based on the real-time evaluation scores of each time source, the second-highest rated "second-highest source" is selected as the future primary time source to ensure timing accuracy after the handover. To ensure a smooth handover, the historical time deviation sequence of this "second-highest source" over a past period is retrieved and collected, representing the actual phase offset between the timestamp of this time source and the current reference time. This historical deviation data is input into an autoregressive moving average (ARMA) prediction model. Utilizing the model's strong fitting ability to time series data, it can accurately predict the remaining phase deviation value between the second-highest source and the reference time at the moment of complete weight switching. Based on the prediction results, a "pre-compensation amount" is calculated. This pre-compensation amount is essentially the opposite of the predicted future phase deviation, its purpose being to ensure that the timestamp of the second-highest source perfectly aligns with the reference time at the moment of handover. The actual phase adjustment action is then executed. Within the transition window where the weights are gradually adjusted, the pre-compensation amount is superimposed on the timestamp of the second-highest source, or its frequency is fine-tuned, thereby eliminating potential phase jumps before the actual physical signal switching occurs, ensuring the absolute continuity of the output time.

[0086] The clock output module is responsible for the final time signal output. Within the transition window, based on real-time weight allocation, the clock output module continuously weights and synthesizes the timestamps output by each time source, and superimposes the pre-compensation amount calculated by the phase synchronization module during the synthesis process to generate the output time during the switching period. At the same time, the module uses a smoothing algorithm to constrain the trajectory of weight changes and control the weight ratio of each time source within the transition window, ultimately outputting a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching, for example, set to 50 sampling periods, to ensure the smoothness of the switching process.

[0087] Figure 5 This is a schematic diagram comparing the effects of traditional hard handover and seamless handover according to an embodiment of the present invention, as shown in the figure. Figure 5As shown, Figure 5 This figure compares the effects of traditional hard handover and the seamless handover of this invention. As shown, the upper layer illustrates the three-layer fusion noise reduction and seamless handover effect employed in this invention, while the lower layer demonstrates the effect of traditional hard handover. In the traditional handover scenario at the lower layer, a handover event occurs at time t0, with the time source instantly and hardly switching from "BeiDou-dominated" to "local-dominated." The weight change is a steep linear change, causing a significant step jump in the output time signal at the handover point, which can easily lead to time synchronization interruptions or sudden increases in error. In contrast, in the application scenario of this invention at the upper layer, a transition window and a weight change rate limiting mechanism are introduced. During the handover period from t0 to t1, the BeiDou... The weight of the BeiDou satellite time source smoothly decreases from 70% to 0%, the weight of the local time source smoothly increases from 25% to 80%, and the weight of the network time source fluctuates around 5%. After the BeiDou satellite time source returns to normal at time t1, its weight smoothly increases again from 0% to 95% through a transition window, and the weight of the local time source decreases to 0% accordingly. It can be seen that this invention transforms the step-like abrupt change in the traditional method into a gradual smooth adjustment, effectively eliminating the time discontinuity in the switching process and significantly improving the continuity and stability of the output time signal.

[0088] In this embodiment of the invention, output signals from BeiDou satellite time sources, NTP network time sources, and local timekeeping sources are acquired. These output signals are uniformly encapsulated into standardized timestamps. The availability, time deviation accuracy, and historical stability of each time source are quantitatively evaluated to obtain an initial score. Simultaneously, anomaly detection is performed based on sliding window statistics, and a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value for each time source. The weight of each time source is calculated based on the real-time time quality factor value, and the weights are normalized. Based on the normalized weights, the timestamps output by each time source are weighted and synthesized to generate the currently used reference time. A weight change rate constraint mechanism is introduced to constrain the weight adjustment range within adjacent periods. During the gradual weight adjustment process, for the target time source whose weight is continuously rising and is expected to become the highest weight, the historical time deviation sequence between the timestamp of the target time source and the reference time is extracted, the pre-compensation amount is calculated, and frequency fine-tuning or timestamp interpolation calibration is performed on the target time source based on the pre-compensation amount. Within the transition window, based on the real-time weight allocation, the timestamps output by each time source are continuously weighted and synthesized, and the pre-compensation amount is superimposed during the synthesis process to generate the output time of the switching period. A smoothing algorithm is used to constrain the weight change trajectory, control the weight ratio of each time source within the transition window, and output a continuous time signal.

[0089] This invention addresses the issues of phase jumps, time interruptions, and accuracy degradation during handover in multi-source time synchronization systems caused by time source failures or quality fluctuations. It constructs a dynamic time quality factor evaluation model that integrates availability, accuracy, and stability, combined with a sliding window anomaly detection and penalty correction mechanism, to achieve precise quantification of the health status of time sources. Furthermore, by utilizing a normalized weight allocation and rate-of-change limitation mechanism, the weight ratios of each time source are smoothly transitioned, effectively suppressing jitter caused by sudden weight changes. In particular, by extracting the historical deviation sequence of the target source before handover to predict the remaining phase difference and calculating pre-compensation amounts to perform frequency fine-tuning or interpolation calibration, potential phase deviations are eliminated in advance within the transition window. Ultimately, seamless and smooth handover between multiple time sources (BeiDou, NTP, and local timekeeping) is achieved, outputting high-precision, highly continuous time signals, significantly improving the reliability and stability of time synchronization in complex electromagnetic and network environments.

[0090] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0091] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0092] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.

[0093] 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 units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0094] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a first processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0095] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for seamless switching of multi-source time signals, characterized in that, include: The output signals of the BeiDou satellite time source, the NTP network time source and the local timekeeping time source are acquired, and the output signals are uniformly encapsulated into a standardized timestamp, wherein the timestamp is used to record the specific time value corresponding to the time source; The availability status, time deviation accuracy, and historical stability of each time source are quantitatively evaluated to obtain an initial score. At the same time, abnormal jump detection is performed based on sliding window statistics, and a penalty coefficient is introduced to dynamically correct the initial score, outputting the real-time time quality factor value of each time source. The weights of each time source are calculated based on the real-time time quality factor value. The weights are then normalized. Based on the normalized weights, the timestamps output by each time source are weighted and synthesized to generate the reference time currently in use. At the same time, a weight change rate limiting mechanism is introduced to constrain the weight adjustment range within adjacent periods. During the gradual adjustment of weights, for a target time source whose weight is continuously increasing and is expected to become the highest weight, the historical time deviation sequence between the timestamp of the target time source and the reference time is extracted, a pre-compensation amount is calculated, and frequency fine-tuning or timestamp interpolation calibration is performed on the target time source based on the pre-compensation amount. The pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed. Within the transition window, based on real-time weight allocation, the timestamps output by each time source are continuously weighted and synthesized. During the synthesis process, the pre-compensation amount is superimposed to generate the output time of the switching period. A smoothing algorithm is used to constrain the trajectory of weight changes, control the weight ratio of each time source within the transition window, and output a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching.

2. The method according to claim 1, characterized in that, The method of performing abnormal jump detection based on sliding window statistics introduces a penalty coefficient to dynamically correct the initial score, and outputs the real-time time quality factor values ​​for each time source, including: The mean and standard deviation of the time deviation sequence are calculated by acquiring a time deviation sequence containing multiple consecutive sampling points using a sliding window. If the jump amplitude of multiple consecutive sampling points in the time deviation sequence exceeds the normal range of fluctuation, it is determined to be an abnormal jump. Based on the jump amplitude, a penalty coefficient is introduced to dynamically correct the initial score, and the real-time time quality factor value of each time source is output.

3. The method according to claim 2, characterized in that, The initial score is dynamically corrected based on the jump amplitude by introducing a penalty coefficient, and the real-time time quality factor values ​​of each time source are output, including: When the jump amplitude is less than the first threshold, the initial score is reduced by the first ratio; When the jump amplitude is greater than or equal to the first threshold and less than the second threshold, the initial score is reduced by a second ratio, wherein the second threshold is greater than the first threshold; When the jump amplitude is greater than or equal to the second threshold and less than the third threshold, the initial score is reduced by a third ratio, wherein the second threshold is less than the third threshold; When the jump amplitude exceeds the allowable limit or a continuous jump occurs, the penalty coefficient is set to zero, the initial score corresponding to the penalty coefficient is lowered to zero, and the time source corresponding to the jump amplitude is determined to be invalid.

4. The method according to claim 3, characterized in that, The method further includes: When the failed BeiDou satellite time source is restored to normal, and the real-time time quality factor value of the BeiDou satellite time source is stable above the qualified threshold for several cycles, the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time is extracted, the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time is calculated, and based on the pre-compensation amount, the frequency fine-tuning or timestamp interpolation calibration is performed on the BeiDou satellite time source. Within the transition window, the weight of the BeiDou satellite time source is gradually increased according to the smoothing algorithm, while the weights of other time sources are reduced simultaneously. The single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism until the weight of the BeiDou satellite time source is restored to the highest weight.

5. The method according to claim 1, characterized in that, The quantitative evaluation of the availability status, time deviation accuracy, and historical stability of each time source includes: Monitor the status flag bits carried by the standardized timestamps of each time source, extract the signal lock status, network response status or local clock running status, and generate an initial score for the availability dimension accordingly. The absolute value of the time deviation between the timestamps output by each time source and the reference time is calculated to generate an initial score for the accuracy dimension. The deviation and frequency drift of timestamps from each time source within a preset sliding window are statistically analyzed to generate an initial score for the stability dimension.

6. A time synchronization device with seamless switching between multiple time signals, characterized in that, include: The interface module is used to acquire the output signals of the Beidou satellite time source, the NTP network time source and the local timekeeping time source, and encapsulate the output signals into a standardized timestamp, wherein the timestamp is used to record the specific time value corresponding to the time source; The time quality assessment module is used to quantitatively assess the availability status, time deviation accuracy, and historical stability of each time source to obtain an initial score; at the same time, it performs abnormal jump detection based on sliding window statistics, introduces a penalty coefficient to dynamically correct the initial score, and outputs the real-time time quality factor value of each time source. The fusion decision module is used to calculate the weight of each time source based on the real-time time quality factor value, normalize the weight, and weight and synthesize the timestamps output by each time source based on the normalized weight to generate the reference time in use; at the same time, a weight change rate limiting mechanism is introduced to constrain the weight adjustment range within adjacent periods. The phase synchronization module is used to extract the historical time deviation sequence between the timestamp of the target time source and the reference time for a target time source whose weight is continuously rising and is expected to become the highest weight during the gradual weight adjustment process, calculate the pre-compensation amount, and perform frequency fine-tuning or timestamp interpolation calibration on the target time source based on the pre-compensation amount. The pre-compensation amount is the correction value corresponding to the phase deviation between the timestamp of the target time source and the reference time when the weight adjustment is completed. The clock output module is used to continuously weight and synthesize the timestamps output by each time source based on real-time weight allocation within the transition window. During the synthesis process, the pre-compensation amount is superimposed to generate the output time of the switching period. A smoothing algorithm is used to constrain the change trajectory of the weights, control the weight ratio of each time source within the transition window, and output a continuous time signal. The transition window is a pre-configured time period for completing the smooth weight switching.

7. The apparatus according to claim 6, characterized in that, The timing device also includes: The phase synchronization module is also used to extract the historical time deviation sequence between the timestamp output by the BeiDou satellite time source and the reference time when the failed BeiDou satellite time source is restored to normal and the real-time time quality factor value of the BeiDou satellite time source is stable above the qualified threshold for several cycles, calculate the pre-compensation amount between the timestamp of the BeiDou satellite time source and the reference time, and perform frequency fine-tuning or timestamp interpolation calibration on the BeiDou satellite time source based on the pre-compensation amount. The fusion decision module is also used to gradually increase the weight of the BeiDou satellite time source within the transition window according to the smoothing algorithm, and simultaneously decrease the weight of other time sources. The single-cycle amplitude of the weight change is limited by the weight change rate limiting mechanism until the weight of the BeiDou satellite time source is restored to the highest weight.