A reference time determination method and apparatus, electronic device, and storage medium

By combining the determination of satellite count and local system time in the NTP server, the reference time offset problem caused by GPS module instability was solved, achieving stable and accurate time synchronization.

CN116131984BActive Publication Date: 2026-03-03INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-06
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

The GPS module of the NTP server obtains satellite system time unstably, resulting in abnormal time offset and jitter, which affects the accuracy of time synchronization.

Method used

By obtaining the update cycle, the system uses the GPS module to acquire satellite time and local system time, and determines whether the number of satellites has reached a preset value. If it has, the satellite time is used as the reference time; otherwise, the local system time is used, and the local system time is adjusted as necessary to ensure accuracy.

Benefits of technology

It provides a stable and accurate reference time, ensuring continuous and efficient time synchronization for NTP servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116131984B_ABST
    Figure CN116131984B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a reference time determination method and device, electronic equipment and storage medium. The method is applied to a network time protocol (NTP) server. The NTP server is configured with a GPS module. The method comprises: obtaining an update period for a reference time; obtaining satellite time and a current number of searched satellites by the GPS module according to the update period, and obtaining a local system time; determining whether the number of satellites is greater than or equal to a preset value; if the number of satellites is greater than or equal to the preset value, using the satellite time as the reference time; and if the number of satellites is less than the preset value, using the local system time as the reference time. The method can continuously provide stable and accurate reference time for the NTP server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network time synchronization technology, and in particular to a reference time determination method, apparatus, electronic device, and storage medium. Background Technology

[0002] NTP (Network Time Protocol) is a protocol used to synchronize computer time. An NTP server, based on the NTP protocol, is used to synchronize time between a distributed time server and clients. An NTP server is equipped with a GPS (Global Positioning System) module, which obtains satellite system time and uses it as the NTP server's reference time. However, the GPS time acquisition is affected by many factors and is unstable, resulting in abnormal offsets and jitter in the acquired satellite system time. This leads to inaccurate reference time obtained by the NTP server, thus preventing the NTP server from accurately synchronizing time with terminal devices. Summary of the Invention

[0003] In view of the above problems, embodiments of the present invention are proposed to provide a reference time determination method, apparatus, electronic device and storage medium that overcomes or at least partially solves the above problems.

[0004] To address the aforementioned problems, in a first aspect, embodiments of the present invention disclose a reference time determination method applied to a Network Time Protocol (NTP) server, wherein the NTP server is configured with a GPS module, and the method includes:

[0005] Obtain the update cycle for a reference time; the reference time is the time used for time synchronization.

[0006] According to the update cycle, the GPS module obtains the satellite time, the number of currently searched satellites, and the local system time.

[0007] Determine whether the number of satellites is greater than or equal to a preset value;

[0008] If the number of satellites is greater than or equal to the preset value, the satellite time is used as the reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time.

[0009] Optionally, using the local system time as a reference time includes:

[0010] Obtain the deviation between the local system time and the satellite time each time the reference time is updated within a first preset time period;

[0011] The local system time is adjusted based on the average of the deviation values;

[0012] Use the adjusted local system time as the reference time.

[0013] Optionally, adjusting the local system time based on the average of the deviation values ​​includes:

[0014] Obtain the deviation value between the local system time and the satellite time when the reference time of the NTP server switches from the local system time to the satellite time within the second preset time period, and use the deviation value as the fault deviation value;

[0015] The time adjustment value is obtained by subtracting the most recent fault deviation value in the second preset time period from the average value of the deviation values ​​in the first preset time period.

[0016] Adjust the local system time according to the time adjustment value.

[0017] Optionally, the step of using the satellite time as a reference time if the number of satellites is greater than or equal to the preset value includes:

[0018] If the number of satellites is greater than or equal to the preset value, and the deviation between the satellite time and the local system time is less than or equal to the average value of the deviation, then the satellite time is used as the reference time.

[0019] Optionally, the method further includes:

[0020] If the number of satellites is greater than or equal to the preset value, the deviation between the local system time and the satellite time is recorded, and the satellite time is synchronized to the local system time.

[0021] Optionally, the method further includes:

[0022] Before updating the reference time, the satellite time and the number of satellites are acquired once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0023] If the satellite time and the number of satellites cannot be obtained, record the number of times the satellite time and the number of satellites cannot be obtained;

[0024] If the satellite time and the number of satellites cannot be obtained within a preset number of attempts before updating the reference time, then the local system time will be used as the reference time when updating the reference time.

[0025] Optionally, the method further includes:

[0026] Before updating the reference time, the satellite time and the number of satellites are acquired once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0027] If the satellite time and the number of satellites cannot be obtained when updating the reference time, then it is determined whether the number of satellites obtained before updating the reference time is greater than or equal to the preset value.

[0028] If the number of satellites is greater than or equal to the preset value, then the satellite time acquired simultaneously with the number of satellites is used as the reference time.

[0029] Secondly, embodiments of the present invention disclose a reference time determination device applied to a Network Time Protocol (NTP) server, wherein the NTP server is configured with a GPS module, and the device includes:

[0030] The update cycle acquisition module is used to acquire the update cycle for a reference time; the reference time is the time used for time synchronization.

[0031] The reference time acquisition module is used to acquire satellite time and the number of currently searched satellites through the GPS module according to the update cycle, as well as to acquire the local system time;

[0032] The reference time determination module is used to determine whether the number of satellites is greater than or equal to a preset value;

[0033] The reference time determination module is used to use the satellite time as the reference time if the number of satellites is greater than or equal to the preset value; and to use the local system time as the reference time if the number of satellites is less than the preset value.

[0034] Optionally, the reference time determination module includes: a local system time adjustment module and a local system time synchronization module. The local system time adjustment module is used to obtain the deviation value between the local system time and the satellite time each time the reference time is updated within a first preset time period.

[0035] The local system time is adjusted based on the average of the deviation values;

[0036] The local system time synchronization module is used to use the adjusted local system time as a reference time.

[0037] Optionally, the local system time adjustment module is further used for:

[0038] Obtain the deviation value between the local system time and the satellite time when the reference time of the NTP server switches from the local system time to the satellite time within the second preset time period, and use the deviation value as the fault deviation value;

[0039] The time adjustment value is obtained by subtracting the most recent fault deviation value in the second preset time period from the average value of the deviation values ​​in the first preset time period.

[0040] Adjust the local system time according to the time adjustment value.

[0041] Optionally, the reference time determination module includes a satellite time synchronization module, which is used for:

[0042] If the number of satellites is greater than or equal to the preset value, and the deviation between the satellite time and the local system time is less than or equal to the average value of the deviation, then the satellite time is used as the reference time.

[0043] Optionally, the reference time determination module includes a deviation value recording module and a satellite time synchronization module, wherein the deviation value recording module is used for:

[0044] If the number of satellites is greater than or equal to the preset value, the deviation between the local system time and the satellite time is recorded, and the satellite time synchronization module is used to synchronize the satellite time to the local system time.

[0045] Optionally, the reference time determination device includes a satellite time monitoring module and a satellite time synchronization module, wherein the satellite time monitoring module is used for:

[0046] Before updating the reference time, the satellite time and the number of satellites are acquired once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0047] If the satellite time and the number of satellites cannot be obtained, record the number of times the satellite time and the number of satellites cannot be obtained;

[0048] The satellite time synchronization module is configured to use the local system time as the reference time when updating the reference time if the satellite time and the number of satellites cannot be obtained after a preset number of attempts before updating the reference time.

[0049] Optionally, the reference time determination device includes a satellite time monitoring module and a satellite time synchronization module, wherein the satellite time monitoring module is used for:

[0050] Before updating the reference time, the satellite time and the number of satellites are acquired once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0051] The satellite time synchronization module is used to determine, if the satellite time and the number of satellites cannot be obtained when updating the reference time, whether the number of satellites obtained before updating the reference time is greater than or equal to the preset value.

[0052] If the number of satellites is greater than or equal to the preset value, then the satellite time acquired simultaneously with the number of satellites is used as the reference time.

[0053] Thirdly, the present invention discloses an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the reference time determination method as described in the first aspect.

[0054] Fourthly, the present invention discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the reference time determination method as described in the first aspect.

[0055] The embodiments of the present invention have the following advantages:

[0056] The system obtains the update cycle for the reference time; based on the update cycle, it obtains the satellite time, the number of currently searched satellites, and the local system time; it determines whether the number of satellites is greater than or equal to a preset value; if the number of satellites is greater than or equal to the preset value, the satellite time is used as the reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time. This invention provides a stable and accurate reference time continuously for the NTP server. Attached Figure Description

[0057] Figure 1 This is a flowchart of the steps of a reference time determination method provided in an embodiment of the present invention;

[0058] Figure 2 This is a flowchart of a reference time determination method provided in an embodiment of the present invention;

[0059] Figure 3 This is a structural block diagram of a reference time determination device provided in an embodiment of the present invention;

[0060] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of the present invention;

[0061] Figure 5 This is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present invention. Detailed Implementation

[0062] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0063] To address the issues of unavailable, unidentifiable, or non-existent reference time for NTP servers, this invention proposes a method for providing multiple selectable reference times for NTP servers. The selectable reference times include satellite time and local system time. Simultaneously, the satellite time is monitored, and the local system time is corrected, thereby achieving a continuous and stable provision of accurate reference time for terminal devices.

[0064] Reference Figure 1 The diagram illustrates a flowchart of a reference time determination method provided by an embodiment of the present invention. The method is applied to a Network Time Protocol (NTP) server, which is configured with a GPS module. The method may specifically include the following steps:

[0065] Step 101: Obtain the update cycle for the reference time; the reference time is the time used for time synchronization.

[0066] NTP servers can be used for time synchronization. When used for time synchronization, NTP servers are divided into client NTP servers and server NTP servers. Client NTP servers obtain time information sent by the server NTP server through the existing network environment, functioning as a slave clock. Server NTP servers primarily provide a time synchronization function for network devices such as servers and computers, functioning as a master clock. The time provided by the server NTP server to the client NTP server for time synchronization is the reference time.

[0067] The NTP server updates the reference time every preset period. The update period can be set by the user. For example, the update period can be set to 20 minutes, that is, the reference time is updated every 20 minutes, or the update period can be set to 30 minutes, that is, the reference time is updated every 30 minutes, etc.

[0068] Step 102: According to the update cycle, obtain the satellite time and the number of currently searched satellites through the GPS module, as well as the local system time.

[0069] Once the update cycle for the reference time is obtained, the local system time, satellite time, and the number of currently searched satellites can be retrieved according to the update cycle, as well as through the GPS module configured on the NTP server. For example, if the update cycle is 20 minutes, the satellite time, the number of satellites, and the local system time can be retrieved every 20 minutes.

[0070] Local system time can be obtained through system commands. For example, you can press Windows+R to open the "Run" dialog box, then type "cmd" in the "Run" input box to open the cmd command prompt. With your computer connected to the internet, type "net time \\local IP address" in the command prompt and press Enter to get the local system time. There are many other methods for obtaining local system time, which will not be detailed here.

[0071] GPS navigation satellites typically carry high-precision anchor atomic clocks and hydrogen atomic clocks, providing accurate and highly precise time. The GPS module configured on the NTP server can receive satellite signals transmitted by GPS navigation satellites. These signals contain time information provided by the GPS navigation satellites; parsing this time information yields the satellite time. The number of satellites refers to the number of satellites that can be searched when obtaining satellite time.

[0072] Step 103: Determine whether the number of satellites is greater than or equal to a preset value.

[0073] The signal quality of a GPS module can be determined by the number of satellites it receives. Generally, a GPS module can simultaneously receive signals from 4 to 8 satellites within its field of view at any given time. The more satellite signals received, i.e., the larger the number of satellites detected, the better the signal quality. Therefore, after obtaining the number of satellites from the GPS module, the accuracy of the satellite time can be determined by comparing this number with a preset value. The preset value can be set according to the maximum number of satellites the GPS module can detect. For example, a preset value of 6 can be set, and after each satellite count, it can be checked whether the number of satellites is greater than or equal to 6.

[0074] Step 104: If the number of satellites is greater than or equal to the preset value, the satellite time is used as the reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time.

[0075] If the number of satellites is greater than or equal to the preset value, it proves that the satellite time obtained simultaneously with the number of satellites is relatively accurate. Therefore, the satellite time is used as the reference time for the NTP server. If the number of satellites is less than the preset value, it proves that the satellite time obtained simultaneously with the number of satellites may not be accurate enough. Therefore, the local system time can be used as the reference time for the NTP server.

[0076] In this embodiment of the invention, an update cycle for the reference time is obtained; based on the update cycle, the satellite time and the number of currently searched satellites, as well as the local system time, are obtained; it is determined whether the number of satellites is greater than or equal to a preset value; if the number of satellites is greater than or equal to the preset value, the satellite time is used as the reference time; if the number of satellites is less than the preset value, the local system time is used as the reference time. This can continuously provide a stable and accurate reference time for the NTP server.

[0077] In one embodiment, if the number of acquired satellites is greater than or equal to a preset value, the deviation between the local system time and the satellite time is recorded, and the satellite time is synchronized to the local system time. The deviation between the local system time and the satellite time refers to the difference in time between the two. For example, if the local system time is 19:00:00 on January 1, 2022, and the satellite time is 19:01:00 on January 1, 2022, then the deviation between the local system time and the satellite time is 1 minute. Each time the NTP server's reference time is updated to the satellite time, the acquired local system time, satellite time, and the deviation between the local system time and the satellite time are recorded before synchronizing the satellite time to the local system time.

[0078] In one embodiment, if satellite time cannot be obtained, or the obtained satellite time is inaccurate, the local system time can be used as the reference time for the NTP server. Before using the local system time as the reference time for the NTP server, the local system time can be adjusted, and the adjusted local system time can be used as the reference time for the NTP server to improve the accuracy of the local system time. The method for adjusting the local system time can be as follows: obtaining the deviation value between the local system time and the satellite time each time the reference time is updated within a first preset time period; and adjusting the local system time based on the average value of the deviation value.

[0079] The first preset time period is a user-defined time period, such as 12 hours or 24 hours. Assuming the first preset time period is 12 hours and the update cycle for the reference time is 20 minutes, before using the local system time as the reference time for the NTP server, the deviation between the local system time and the satellite time can be obtained for each update of the reference time within the previous 12 hours, resulting in 36 deviation values. Then, based on these 36 deviation values, the average deviation value is calculated, and the local system time is adjusted accordingly. For example, if the calculated average deviation value is 40 seconds, it means that the local system time was on average 40 seconds ahead of the satellite time within the previous 12 hours. Therefore, after obtaining the local system time, 40 seconds can be subtracted, and the adjusted local system time can be used as the reference time for the NTP server.

[0080] The deviation value and its average value can also be negative. A negative deviation value indicates that the local system time is slower than the satellite time, and a negative average deviation value indicates that the local system time is on average slower than the satellite time. The meaning of positive and negative deviation values ​​and their average value can be defined by those skilled in the art according to their needs. For example, a positive deviation value can be set to indicate that the satellite time is faster than the local system time, or the deviation value can be set to only be positive, and so on.

[0081] In one embodiment, adjusting the local system time based on the average deviation value may further include: obtaining the deviation value between the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time within a second preset time period, and using the deviation value as a fault deviation value; subtracting the most recent fault deviation value within the second preset time period from the average deviation value within the first preset time period to obtain a time adjustment value; and adjusting the local system time based on the time adjustment value.

[0082] The second preset time period is a user-defined time range. Generally, the second preset time period should not be set too large, because if the range is too large, the obtained fault deviation value will not be of much reference value. Therefore, the second preset time period can be set to within 3 days. The fault deviation value refers to the deviation between the local system time and the satellite time when the NTP server uses the local system time as the reference time and then reverts to using the satellite time as the reference time.

[0083] Assuming the first preset time period is 12 hours and the second preset time period is 72 hours, the local system time adjustment method can be as follows: Obtain the deviation between the local system time and the satellite time each time the reference time is updated within the previous 12 hours; obtain the fault deviation between the local system time and the satellite time when the NTP server's reference time is switched from the local system time to the satellite time within the past 3 days; subtract the most recent fault deviation value within the second preset time period from the average deviation value within the first preset time period to obtain the time adjustment value; adjust the local system time according to the time adjustment value. For example, assuming the average deviation value within the first preset time period is 1 minute and the most recent fault deviation value within the second preset time period is 10 seconds, the time adjustment value is 50 seconds, indicating that the local system time is on average 50 seconds ahead of the satellite time. Therefore, after obtaining the local system time, subtract 50 seconds from the local system time and use the adjusted local system time as the reference time for the NTP server.

[0084] If multiple fault deviation values ​​are obtained within the second preset time period, either the most recent fault deviation value or the average of the multiple fault deviation values ​​can be used for calculation. For example, the average of the deviation values ​​within the first preset time period can be subtracted from the average of the fault deviation values ​​within the second preset time period to obtain the time adjustment value; the local system time can then be adjusted based on this time adjustment value. If no fault deviation value is obtained within the second preset time period, the fault deviation value can be directly set to 0.

[0085] After adjusting the local system time, using the adjusted local system time as the reference time for the NTP server can improve the accuracy of the local system time and reduce the problem of large reference time deviations caused by the inability to obtain accurate satellite time for extended periods.

[0086] In one embodiment, if the number of satellites obtained is greater than or equal to a preset value, then the satellite time is used as the reference time, including: if the number of satellites is greater than or equal to the preset value, and the deviation between the satellite time and the local system time is less than or equal to the average value of the deviation, then the satellite time is used as the reference time.

[0087] When satellite time cannot be obtained, or the obtained satellite time is not accurate enough, the NTP server can use the local system time as a reference time. However, when the NTP server can obtain satellite time and satellite quantity normally, and the obtained satellite quantity is greater than or equal to a preset value, and the deviation between the obtained satellite time and the local system time is less than or equal to the average deviation value within a first preset time period, that is, when the GPS module obtains the preset number of satellites and the comparison between the satellite time and the local system time meets expectations, it indicates that the GPS module is working normally and the obtained satellite time is accurate. At this time, the NTP server can switch the reference time from the local system time to the satellite time.

[0088] In one embodiment, the reference time determination method further includes:

[0089] Before updating the reference time, the satellite time and number of satellites are obtained once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0090] If the satellite time and the number of satellites cannot be obtained, record the number of times the satellite time and number of satellites cannot be obtained;

[0091] If the satellite time and number of satellites cannot be obtained after a preset number of attempts before updating the reference time, the local system time will be used as the reference time when updating the reference time.

[0092] The third preset time period is a user-defined time period, which can be set to a period shorter than the update cycle. For example, if the update cycle is 20 minutes, the third preset time period can be set to 1 minute, meaning that satellite time and satellite count are obtained every minute. Within 20 minutes, 19 satellite time and satellite counts can be obtained. If the satellite time and satellite count are obtained successfully each time, it indicates that the GPS module is working stably. If the preset number of times is reached but satellite time and satellite count cannot be obtained, it indicates that the GPS module is not working stably. The preset number of times can be set according to the third preset cycle. For example, in this case, the preset number of times can be set to any number less than or equal to 19. Therefore, if the preset number of times is reached before the reference time is updated, and satellite time and satellite count cannot be obtained, the local system time can be used as the reference time when updating the reference time to the NTP server at the 20-minute mark.

[0093] This invention monitors the stability of satellite time acquired by the GPS module. When the GPS module experiences abnormal jitter and offset, the NTP server can use the local system time as a reference time to avoid situations where the NTP server has no reference time available.

[0094] In one embodiment, the reference time determination method further includes:

[0095] Before updating the reference time, the satellite time and number of satellites are obtained once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0096] If satellite time and satellite count cannot be obtained when updating the reference time, then check whether the number of satellites obtained before updating the reference time is greater than or equal to a preset value.

[0097] If the number of satellites is greater than or equal to the preset value, the satellite time acquired at the same time as the number of satellites will be used as the reference time.

[0098] Before updating the reference time, satellite time and satellite count can be obtained every third preset time interval. If satellite time and count cannot be obtained when updating the reference time, one of the satellite times obtained before the update can be selected as the reference time. For example, if the update cycle is set to 20 minutes and the third preset time interval is 1 minute, then satellite time and count can be obtained every minute, resulting in 19 satellite time and count data points within 20 minutes. If an NTP server reference time update is needed at the 20th minute, but satellite time and count cannot be obtained, the satellite counts obtained at the 19th, 18th, 17th, and up to the 1st minute can be checked sequentially. First, check if the satellite count obtained at the 19th minute is greater than or equal to a preset value. If the satellite count is greater than or equal to the preset value, then the satellite time obtained at the 19th minute is used as the reference time. If the number of satellites acquired in the 19th minute is less than the preset value, the system continues to check if the number of satellites acquired in the 18th minute is greater than or equal to the preset value. If the number of satellites acquired in the 18th minute is greater than or equal to the preset value, the satellite time acquired in the 18th minute is used as the reference time, and so on. If the number of satellites acquired up to the 1st minute does not reach the preset value, the local system time acquired in the 20th minute is used as the reference time for the NTP server.

[0099] Reference Figure 2The diagram illustrates a flowchart of a reference time determination method provided by an embodiment of the present invention. The NTP server obtains satellite time and the number of satellites through a GPS module. The NTP server determines whether the information obtained by the GPS module is normal. This determination can be made by checking whether the number of satellites reaches a preset value, or whether the deviation between the satellite time and the local system time is less than or equal to the average of the deviation values. If the information obtained by the GPS module is normal, the satellite time is synchronized to the NTP server and also to the local system time. If the information obtained by the GPS module is abnormal, automatic time correction is initiated for the local system time, and the corrected local system time is synchronized to the NTP server.

[0100] This invention monitors the stability of satellite time acquired by the GPS module. When abnormal jitter and offset occur in the GPS module, the NTP service can use the local system time as the reference time. At the same time, it enables the automatic correction process of the local system time to improve the high accuracy of the local system time, thus comprehensively ensuring the continuous, stable and highly accurate reference time of the NTP server.

[0101] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0102] Reference Figure 3 The diagram illustrates a structural block diagram of a reference time determination device provided in an embodiment of the present invention. This device is applied to a Network Time Protocol (NTP) server, which is equipped with a GPS module. Specifically, the device may include the following modules:

[0103] The update cycle acquisition module is used to obtain the update cycle for a reference time; the reference time is the time used for time synchronization.

[0104] The reference time acquisition module is used to obtain satellite time and the number of currently searched satellites through the GPS module according to the update cycle, as well as to obtain the local system time;

[0105] The reference time judgment module is used to determine whether the number of satellites is greater than or equal to a preset value;

[0106] The reference time determination module is used to use the satellite time as the reference time if the number of satellites is greater than or equal to a preset value; if the number of satellites is less than the preset value, the local system time is used as the reference time.

[0107] Optionally, the reference time determination module includes: a local system time adjustment module and a local system time synchronization module. The local system time adjustment module is used to obtain the deviation value between the local system time and the satellite time each time the reference time is updated within the first preset time period.

[0108] Adjust the local system time based on the average of the deviation values;

[0109] The local system time synchronization module is used to use the adjusted local system time as a reference time.

[0110] Optionally, the local system time adjustment module is also used for:

[0111] Obtain the deviation between the local system time and the satellite time when the reference time of the NTP server switches from the local system time to the satellite time within the second preset time period, and use the deviation value as the fault deviation value;

[0112] The time adjustment value is obtained by subtracting the average deviation value within the first preset time period from the most recent fault deviation value within the second preset time period.

[0113] Adjust the local system time according to the time adjustment value.

[0114] Optionally, the reference time determination module includes a satellite time synchronization module, which is used for:

[0115] If the number of satellites is greater than or equal to the preset value, and the deviation between the satellite time and the local system time is less than or equal to the average of the deviation values, then the satellite time will be used as the reference time.

[0116] Optionally, the reference time determination module includes a deviation value recording module and a satellite time synchronization module. The deviation value recording module is used for:

[0117] If the number of satellites is greater than or equal to the preset value, the deviation between the local system time and the satellite time is recorded. The satellite time synchronization module is used to synchronize the satellite time to the local system time.

[0118] Optionally, the reference time determination device includes a satellite time monitoring module and a satellite time synchronization module. The satellite time monitoring module is used for:

[0119] Before updating the reference time, the satellite time and number of satellites are obtained once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0120] If satellite time and satellite count cannot be obtained, record the number of times satellite time and satellite count cannot be obtained;

[0121] The satellite time synchronization module is used to use the local system time as the reference time when updating the reference time if the satellite time and number of satellites cannot be obtained after a preset number of attempts before updating the reference time.

[0122] Optionally, the reference time determination device includes a satellite time monitoring module and a satellite time synchronization module. The satellite time monitoring module is used for:

[0123] Before updating the reference time, the satellite time and number of satellites are obtained once every third preset time period; the third preset time period is shorter than the update cycle for the reference time.

[0124] The satellite time synchronization module is used to determine whether the number of satellites obtained before the reference time update is greater than or equal to a preset value if the satellite time and number of satellites cannot be obtained when updating the reference time.

[0125] If the number of satellites is greater than or equal to the preset value, the satellite time acquired at the same time as the number of satellites will be used as the reference time.

[0126] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0127] Reference Figure 4 The diagram shows a structural block diagram of an electronic device 30 provided in an embodiment of the present invention. The electronic device 30 includes:

[0128] The processor 301, the memory 302, and the computer program 3021 stored in the memory 302 and capable of running on the processor 301, when the computer program 3021 is executed by the processor 301, implement the various processes of the above-described reference time determination method embodiment and achieve the same technical effect. To avoid repetition, they will not be described again here.

[0129] Reference Figure 5 The diagram shows a structural block diagram of a computer-readable storage medium 40 provided in an embodiment of the present invention. The computer-readable storage medium 40 stores a computer program 401. When the computer program 401 is executed by a processor, it implements the various processes of the above-described reference time determination method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0130] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0131] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0132] Embodiments of the present invention are described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0133] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0134] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0135] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.

[0136] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.

[0137] The foregoing has provided a detailed description of the reference time determination method, apparatus, electronic device, and storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A reference time determination method, characterized by, The method is applied to a network time protocol (NTP) server configured with a GPS module, and comprises the following steps: acquiring an update period for a reference time; the reference time is a time used for time synchronization; acquiring a satellite time and a current number of searched satellites by the GPS module according to the update period, and acquiring a local system time; judging whether the number of satellites is greater than or equal to a preset value; if the number of satellites is greater than or equal to the preset value, using the satellite time as the reference time; if the number of satellites is less than the preset value, using the local system time as the reference time; the method further comprises: subtracting a latest fault deviation value in a second preset time period from an average value of deviation values in a first preset time period to obtain a time adjustment value; the deviation value is a deviation value between the local system time and the satellite time each time the reference time is updated; the fault deviation value is a deviation value between the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time; adjusting the local system time according to the time adjustment value.

2. The reference time determination method according to claim 1, characterized by, the using of the local system time as the reference time comprises: acquiring a deviation value between the local system time and the satellite time each time the reference time is updated in a first preset time period; adjusting the local system time according to an average value of the deviation values; using the adjusted local system time as the reference time.

3. The reference time determination method according to claim 2, characterized by, the using of the satellite time as the reference time if the number of satellites is greater than or equal to the preset value comprises: if the number of satellites is greater than or equal to the preset value, and a deviation value between the satellite time and the local system time is less than or equal to the average value of the deviation values, using the satellite time as the reference time.

4. The reference time determination method according to claim 1, characterized by, the method further comprises: if the number of satellites is greater than or equal to the preset value, recording the deviation value between the local system time and the satellite time, and synchronizing the satellite time to the local system time.

5. The reference time determination method according to claim 1, characterized by, the method further comprises: before updating the reference time, acquiring the satellite time and the number of satellites every third preset time period; the third preset time period is less than the update period for the reference time; if the satellite time and the number of satellites cannot be acquired, recording a number of times when the satellite time and the number of satellites cannot be acquired; if the satellite time and the number of satellites cannot be acquired for greater than or equal to a preset number of times before updating the reference time, using the local system time as the reference time when the reference time is updated.

6. The reference time determination method of claim 1, wherein, the method further comprises: before updating the reference time, acquiring the satellite time and the number of satellites every third preset time period; the third preset time period is less than the update period for the reference time; if the satellite time and the number of satellites cannot be acquired when the reference time is updated, judging whether the number of satellites acquired before updating the reference time is greater than or equal to the preset value in sequence. If the number of satellites is greater than or equal to the preset value, the satellite time acquired at the same time as the number of satellites is used as the reference time.

7. A reference time determination apparatus characterized by comprising: The application is applied to a network time protocol (NTP) server, and the NTP server is configured with a GPS module. An update period acquisition module is configured to acquire an update period for a reference time, wherein the reference time is a time used for time synchronization. A reference time acquisition module is configured to acquire a satellite time and a number of currently searched satellites by the GPS module according to the update period, and acquire a local system time. A reference time judgment module is configured to judge whether the number of satellites is greater than or equal to a preset value. A reference time determination module is configured to use the satellite time as the reference time if the number of satellites is greater than or equal to the preset value, and use the local system time as the reference time if the number of satellites is less than the preset value. The reference time determination module comprises a local system time adjustment module. The local system time adjustment module is configured to subtract a latest fault deviation value in a second preset time period from an average value of deviation values in a first preset time period to obtain a time adjustment value, wherein the deviation value is a deviation value between the local system time and the satellite time each time the reference time is updated, and the fault deviation value is a deviation value between the local system time and the satellite time when the reference time of the NTP server is switched from the local system time to the satellite time, and adjust the local system time according to the time adjustment value.

8. An electronic device, comprising: The application comprises: A processor, a memory, and a computer program stored on the memory and capable of running on the processor, wherein the computer program is executed by the processor to implement the steps of the reference time determination method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, A computer program is stored on the computer readable storage medium, and the computer program is executed by the processor to implement the steps of the reference time determination method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Automatic driving domain controller navigation satellite clock taming method and device

    CN114019782A

  • Time synchronization method and device of vehicle controller, electronic equipment and storage medium

    CN114545449A