CN113014349A - Time calibration method, device, electronic equipment, storage medium and program product - Google Patents

Time calibration method, device, electronic equipment, storage medium and program product Download PDF

Info

Publication number
CN113014349A
CN113014349A CN202110223985.4A CN202110223985A CN113014349A CN 113014349 A CN113014349 A CN 113014349A CN 202110223985 A CN202110223985 A CN 202110223985A CN 113014349 A CN113014349 A CN 113014349A
Authority
CN
China
Prior art keywords
time
difference
time difference
calibration
effective
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110223985.4A
Other languages
Chinese (zh)
Other versions
CN113014349B (en
Inventor
王熙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Didi Infinity Technology and Development Co Ltd
Original Assignee
Beijing Didi Infinity Technology and Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Didi Infinity Technology and Development Co Ltd filed Critical Beijing Didi Infinity Technology and Development Co Ltd
Priority to CN202110223985.4A priority Critical patent/CN113014349B/en
Publication of CN113014349A publication Critical patent/CN113014349A/en
Application granted granted Critical
Publication of CN113014349B publication Critical patent/CN113014349B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04JMULTIPLEX COMMUNICATION
    • H04J3/00Time-division multiplex systems
    • H04J3/02Details
    • H04J3/06Synchronising arrangements
    • H04J3/0635Clock or time synchronisation in a network
    • H04J3/0638Clock or time synchronisation among nodes; Internode synchronisation
    • H04J3/0644External master-clock

Abstract

The application relates to a time calibration method, a time calibration device, an electronic device, a storage medium and a program product. The method comprises the following steps: acquiring a first reference time; wherein the first reference time is a time determined by other equipment except a time server; determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to a second reference time sent by the time server and the system time of the current device; determining an effective time difference according to the intermediate time difference and a corresponding time difference threshold; and calibrating the system time of the current equipment according to the effective time difference to obtain calibration time. By adopting the method, the strong dependence of the whole time calibration method on the time server can be reduced, the influence on the calibration of the system time when the time server is unstable or abnormal is avoided, and the accuracy of the time calibration is further improved.

Description

Time calibration method, device, electronic equipment, storage medium and program product
Technical Field
The present application relates to the field of computer technologies, and in particular, to a time calibration method, apparatus, electronic device, storage medium, and program product.
Background
The system time of the device is key information for providing time-related services such as timing and charging for the device.
In order to accurately acquire the system Time of a system clock in a device, the device communicates with a Time server through an NTP (Network Time Protocol), sends a Time calibration request to the Time server, and the Time server responds to the Time calibration request and feeds back UTC (Universal Time Coordinated, Universal standard Time) to the device.
However, the time calibration method strongly depends on the time server, and if the time server is abnormal, calibration of the system time is affected, and accuracy of time calibration is reduced.
Disclosure of Invention
In view of the above, it is necessary to provide a time calibration method, apparatus, electronic device, storage medium, and program product for solving the above technical problems.
In a first aspect, an embodiment of the present disclosure provides a time calibration method, including:
acquiring a first reference time; the first reference time is the time determined by other equipment except the time server;
determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment;
determining an effective time difference according to the intermediate time difference and the corresponding time difference threshold;
and calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
In a second aspect, an embodiment of the present disclosure provides a time calibration apparatus, including:
the time acquisition module is used for acquiring first reference time; the first reference time is the time determined by other equipment except the time server;
the effective checking module is used for determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment;
the threshold comparison module is used for determining an effective time difference according to the intermediate time difference and the corresponding time difference threshold;
and the time calibration module is used for calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method of the first aspect when executing the computer program.
In a fourth aspect, the present disclosure provides a storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the method of the first aspect.
In a fifth aspect, the embodiments of the present disclosure provide a program product, which includes a computer program, and when the computer program is executed by a processor, the method of the first aspect is implemented.
According to the time calibration method, the time calibration device, the electronic equipment, the storage medium and the program product provided by the embodiment of the disclosure, the first reference time determined by other equipment except the time server is obtained, the intermediate time difference is determined according to the first reference time, the current system time of the current equipment and the initial time difference, the effective time difference is determined according to the intermediate time difference and the corresponding time difference threshold, the effective time difference is further adopted to calibrate the system time of the current equipment, the calibration time is obtained, and the time calibration of the system time of the current equipment is completed. The initial time difference is determined by the current equipment according to the UTC provided by the time server, the current equipment cannot directly adopt the UTC provided by the time server to carry out the time calibration, but an intermediate time difference is determined according to the first reference time provided by other equipment and the current system time of the current equipment and the initial time difference, and then an effective time difference is determined according to the intermediate time difference and a corresponding time difference threshold value, so that the validity check of the initial time difference is realized, the strong dependence of the whole time calibration method on the time server is reduced, the influence on the calibration of the system time is avoided when the time server is unstable or abnormal, and the accuracy of the time calibration is further improved.
Drawings
FIG. 1 is a diagram of an exemplary implementation of a time alignment method;
FIG. 2 is a flow diagram illustrating a method for time alignment in one embodiment;
FIG. 3 is a flow diagram illustrating the determination of an intermediate time difference in one embodiment;
FIG. 4 is a schematic diagram of a process for determining an effective time difference in one embodiment;
FIG. 5 is a schematic flow chart illustrating the determination of an intermediate time difference in another embodiment;
FIG. 6 is a schematic flow chart illustrating the determination of the effective time difference in another embodiment;
FIG. 7 is a flow chart illustrating the determination of an intermediate time difference in another embodiment;
FIG. 8 is a schematic flow chart illustrating the determination of the effective time difference in another embodiment;
FIG. 9 is a schematic flow chart illustrating the determination of the effective time difference in another embodiment;
FIG. 10 is a flow diagram illustrating a process for determining whether a valid time difference is valid in one embodiment;
FIG. 11 is a flow chart illustrating the process of determining whether the valid time difference is valid in another embodiment;
FIG. 12 is a flow chart illustrating the process of determining whether the valid time difference is valid in another embodiment;
FIG. 13 is a block diagram showing the structure of a time alignment apparatus according to an embodiment;
FIG. 14 is a diagram illustrating the internal architecture of an electronic device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
First, before specifically describing the technical solution of the embodiment of the present disclosure, a technical background or a technical evolution context on which the embodiment of the present disclosure is based is described. In general, in the field of time alignment, the current technical background is: the system time of the electronic device is affected by the performance of the electronic device and the environment, and the system time may deviate from the UTC with the increase of the service time, so the electronic device needs to perform time calibration irregularly to improve the accuracy of the system time of the electronic device. In the prior art, the electronic device is generally time-calibrated in two ways: in the first mode, an electronic device currently requiring calibration (hereinafter referred to as "current device") sends a time calibration request to a time server for multiple times, multiple time differences are calculated based on UTC returned by the time server in response to the multiple time calibration requests, an accurate time difference is further determined among the multiple time differences, and then the system time of the current device is calibrated by using the accurate time difference. In the second mode, the current device sends time calibration requests to a plurality of time servers, a plurality of time differences are obtained, an accurate time difference is further determined from the time differences, and the system time of the current device is calibrated by using the accurate time difference. Based on the background, the applicant finds that the time server is influenced by the network environment and the running stability of the time server through long-term calibration experiment simulation and experimental data statistics and verification, so that the access success rate of the current equipment to the time server is not high, the success rate of time calibration is reduced, and the accuracy of time calibration is also reduced. How to reduce the strong dependence on the time server and improve the accuracy of time calibration becomes a difficult problem to be solved urgently at present. In addition, it should be noted that the technical solutions introduced in the following embodiments are all provided by a great deal of creative work for the applicant.
The time calibration method provided by the application can be applied to the application environment shown in fig. 1. Where the current device 102 communicates with other devices 104 and with a time server 106 over a network. The current device 102 initiates a time calibration request to the time server 106, the time server 106 sends a second reference time to the current device 102 in response to the time calibration request, and the current device 102 obtains an initial time difference between the current device 102 and the time server 106 according to the system time and the received second reference time. The terminal device 102 obtains the first reference time from the other device 104, determines an intermediate time difference according to the first reference time, the system time of the current device, and the initial time difference, and determines an effective time difference by using the intermediate time difference and a corresponding time difference threshold, so as to implement validity check on the initial time difference, and further calibrate the system time of the current device 102 by using the effective time difference, so as to obtain calibration time. The current device 102 may be, but is not limited to, various electronic devices with a timing function, such as a personal computer, a notebook computer, a smart phone, a tablet computer, and a portable wearable device.
In one embodiment, as shown in fig. 2, a time calibration method is provided, which is exemplified by the method applied to the current device in fig. 1, and includes the following steps:
and S210, acquiring a first reference time.
Wherein the first reference time is a time determined by other devices except the time server.
Optionally, the other device is other device capable of performing time positioning besides the time server, such as another time-calibrated terminal device, a beidou positioning system, a GPS positioning satellite, and the like.
In this embodiment, the current device may obtain the reference time from the time server, and may also obtain the reference time from other devices, for example, the current device interacts with another terminal device after time calibration, and takes the system time sent by the terminal device after time calibration as the first reference time, or takes the time sent by the beidou positioning system, the GPS positioning satellite, and the like as the first reference time, which is not limited in this embodiment of the application.
S220, determining an intermediate time difference according to the first reference time, the current system time of the current device and the initial time difference.
And the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment. The intermediate time difference is used for validity check whether the initial time difference is valid or not so as to determine whether the initial time difference has failure caused by instability of the time server or not.
Optionally, before performing the step S210, the user triggers a time calibration instruction by operating the current device, the current device sends a time calibration request to the time server based on the time calibration instruction, and further determines an initial time difference between the current device and the time server according to a second reference time sent by the time server. Specifically, the system time when the current device sends the time calibration request to the time server is m0, the UTC when the time server receives the time calibration request is m1, the UTC when the time server returns a response message to the current device in response to the time calibration request is m2, the system time when the current device receives the response message is m3, and the initial time difference between the current device and the time server is Δ T0. The response message returned by the time server to the current device in response to the time alignment request includes the second reference time, and the second reference time includes UTC m1 of the time server receiving the time alignment request and UTC m2 of the response message returned by the time server to the current device in response to the time alignment request. And the current equipment utilizes the fact that the network time consumption Treq of the time calibration request sent by the current equipment to the time server is equal to the network time consumption Tres of the response message returned by the time server to the current equipment, and the initial time difference delta T0 between the current equipment and the time server is obtained through calculation. Among them, Treq ═ m1- (m0 +. DELTA.T 0) ═ Tres ═ m3 +. DELTA.T 0) -m2, and Δ T0 ═ m1-m0) + (m2-m3))/2 was obtained.
Optionally, the time calibration instruction may be triggered by an operation of selecting a time calibration task on the current device by the user, may be triggered by selecting a power-on or restarting the current device by the user, and may also be triggered according to a preset polling period.
In this embodiment, the current device receives a first reference time sent by another terminal device after time calibration, calculates a time difference between the first reference time and the current system time of the current device, and obtains a difference between the time difference and the initial time difference as the intermediate time difference.
And S230, determining the effective time difference according to the intermediate time difference and the corresponding time difference threshold value.
Optionally, the current device further determines whether the intermediate time difference is equal to or smaller than a corresponding preset time difference threshold, if so, the current device determines that the initial time difference is valid, and stores the initial time difference as a valid time difference, that is, determines that the initial time difference is the valid time difference; if not, the current device determines that the initial time difference is invalid, and returns to the step S210 to obtain a new first reference time to obtain a new initial time difference until the new initial time difference is valid. Or, the current device may also directly receive the first reference time sent by the satellite, similarly calculate a time difference between the first reference time and the current system time of the current device, and use a difference between the time difference and the initial time difference as the intermediate time difference, further determine whether the intermediate time difference is equal to or smaller than a corresponding preset time difference threshold, if so, the current device determines that the initial time difference is valid, and stores the initial time difference as a valid time difference, that is, determines that the initial time difference is the valid time difference; if not, the current device determines that the initial time difference is invalid, and returns to the step S210 to obtain a new first reference time to obtain a new initial time difference until the new initial time difference is valid.
And S240, calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
Specifically, when the current device calibrates its own system time, the stored effective time difference may be directly used to obtain the calibrated calibration time. For example, the effective time difference Δ T — the current system time T1 is 3s, that is, the current system time T1 is 3s slower than the UTC of the time server, and the current device calibrates its own system time T0 by using the effective time difference Δ T3 s, so as to obtain a calibrated time T0+ Δ T0+3 s. Optionally, the valid time difference Δ T is the current system time-UTC, for example, Δ T is T1-UTC is 5s, that is, the current system time T1 is 5s faster than the UTC of the time server, and the current device calibrates its own system time T0 using the valid time difference Δ T is 5s, so as to obtain the calibrated time T is T0- Δ T is T0-5 s.
In this embodiment, the current device obtains a first reference time determined by other devices except the time server, determines an intermediate time difference according to the first reference time, the system time of the current device, and the initial time difference, obtains an effective time difference according to the intermediate time difference and a corresponding time difference threshold value, and then calibrates the system time of the current device by using the effective time difference to obtain a calibration time, thereby completing time calibration of the system time of the current device. The initial time difference is determined by the current equipment according to the UTC provided by the time server, the current equipment does not directly adopt the UTC provided by the time server to carry out time calibration, but an intermediate time difference is determined according to the first reference time provided by other equipment and the system time of the current equipment and the initial time difference, and then an effective time difference is determined according to the intermediate time difference and a corresponding time difference threshold value, so that the validity check of the initial time difference is realized, the strong dependence of the whole time calibration method on the time server is reduced, the calibration of the system time is prevented from being influenced when the time server is unstable or abnormal, and the accuracy of the time calibration is further improved.
In one embodiment, to simplify the process of determining the effective time difference, the first reference time includes a local time, as shown in fig. 3, and the step S220 includes:
and S310, calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time.
The local time is the known time stored in the current device, and the corresponding other devices are the current devices. Specifically, the current device calibrates the current system time of the current device by using the initial time difference, so as to obtain initial calibration time. For example, the initial calibration time T1 ═ the current system time T1+ the initial time difference Δ T0.
S320, acquiring a first difference value between the local time and the initial calibration time as an intermediate time difference.
Wherein the local time is stored in the current device. Alternatively, the local time may be a past time, a current time, or a future time. For example, the current time is 13:30 at 1/2021, the local time may be 13:28 at 1/2021, and may also be 13:32 at 1/2021.
Specifically, the current device acquires a first difference value between a local time stored in the current device and an initial calibration time as an intermediate time difference. For example, the local time to is the current time 2021 year 1 month 1 day 13:30, and the initial calibration time T1' is 2021 year 1 month 1 day 13: 35. The current device obtains the first difference Δ T1 between to and T1' as the intermediate time difference. The first difference Δ T1 is the local time to — the initial calibration time T1'.
Accordingly, as shown in fig. 4, the step S230 includes:
s410, judging whether the first difference value is smaller than a first time difference threshold value.
Specifically, the current device determines whether the initial time difference is an effective time difference by comparing the magnitude relationship between the first difference and the first time difference threshold, and implements validity check on the initial time difference.
And S420, if the first difference value is smaller than the first time difference threshold value, determining the initial time difference as an effective time difference.
And S430, if the first difference is not smaller than the first time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new first difference is smaller than the first time difference threshold, so as to obtain an effective time difference.
Specifically, the present apparatus further determines whether the first difference Δ t1 is smaller than a first time difference threshold t 1. If the first difference value Δ T1 is smaller than the first time difference threshold value T1, the current device determines that the initial time difference Δ T0 is an effective time difference Δ T; if the first difference Δ T1 is not less than the first time difference threshold T1, the current device determines that the initial time difference Δ T0 is invalid, and returns to perform the above S210 until the new first difference is less than the first time difference threshold to obtain the valid time difference Δ T.
In this embodiment, the first reference time may be a local time pre-stored in the current device, and the current device determines whether the initial calibration time calibrated by using the initial time difference is accurate according to the local time, that is, whether an intermediate time difference, which is a difference between the initial calibration time and the local time, satisfies a corresponding time difference threshold, that is, an error range, and obtains a check result whether the initial time difference is an effective time difference, so as to simplify a process of determining the effective time difference, thereby simplifying an overall time calibration process, reducing calibration time consumption, and improving calibration efficiency. Meanwhile, the process of verifying the effectiveness of the initial time difference by adopting the local time does not need a network, so that the strong dependence on the network is reduced, and the influence of the instability of the network environment on the time calibration is further reduced.
In an alternative embodiment, to improve the accuracy of the effective time difference, the first reference time includes a satellite time, as shown in fig. 5, and the step S220 includes:
and S510, acquiring a reference time difference between the satellite time transmitted by the satellite and the system time of the current equipment.
Specifically, the current device acquires a reference time difference between a satellite time transmitted by the satellite and a current system time of the current device. For example, the reference time difference Δ T1 is the satellite time W — the current system time T1.
And S520, acquiring a second difference value between the reference time difference and the initial time difference as an intermediate time difference.
Specifically, the current device acquires a second difference Δ T2 between the reference time difference Δ T1 and the initial time difference Δ T0 as an intermediate time difference. Wherein the second difference Δ T2 is the reference time difference Δ T1 — the initial time difference Δ T0.
Accordingly, as shown in fig. 6, the step S230 includes:
s610, judging whether the second difference value is smaller than a second time difference threshold value;
specifically, the current device determines whether the initial time difference is an effective time difference by comparing the magnitude relationship between the second difference and the second time difference threshold, so as to verify the effectiveness of the initial time difference.
S620, if the second difference value is smaller than the second time difference threshold value, determining the initial time difference as an effective time difference;
s630, if the second difference is not smaller than the second time difference threshold, determining that the initial time difference is invalid, and returning to the step of obtaining the first reference time until the new second difference is smaller than the second time difference threshold, so as to obtain the effective time difference.
Specifically, the present apparatus further determines whether the second difference Δ t2 is smaller than a second time difference threshold t 2. If the second difference value Δ T2 is smaller than a second time difference threshold value T2, the current device determines that the initial time difference Δ T0 is an effective time difference Δ T; if the second difference Δ T2 is not less than the second time difference threshold T2, the current device determines that the initial time difference Δ T0 is invalid, and returns to perform the above S210 until the new second difference is less than the second time difference threshold to obtain the valid time difference Δ T.
In this embodiment, the first reference time may be satellite time transmitted by a satellite, the current device determines a reference time difference according to the satellite time and the current system time, and obtains a check result of whether the initial time difference is an effective time difference according to whether an intermediate time difference, which is a difference between the reference time difference and the initial time difference, satisfies a corresponding time difference threshold, that is, an error range, the satellite operates stably, the satellite time is accurate and reliable, and the reference time difference determined by using the satellite time is compared with the initial time difference, so that whether the initial time difference is accurate can be accurately reflected, the accurate effective time difference is obtained, accuracy of determining the effective time difference is improved, and accuracy of overall time calibration is improved.
In one embodiment, the first reference time includes both the local time and the satellite time, as shown in fig. 7, at S220 above includes:
s710, calibrating the system time of the current equipment by adopting the initial time difference to obtain initial calibration time; and acquiring a first difference between the initial calibration time and a local time stored in the current device as a first intermediate time difference.
Specifically, the current device calibrates the current system time of the current device with the initial time difference, and obtains an initial calibration time, such as the initial calibration time T1 ═ the current system time T1+ the initial time difference Δ T0. The current device again obtains a first difference between the initial calibration time and the local time stored in the current device as a first intermediate time difference, such as the local time to — the initial calibration time T1' described above as the first difference Δ T1.
S720, acquiring a reference time difference between the satellite time sent by the satellite and the system time of the current equipment; and a second difference between the reference time difference and the initial time difference is obtained as a second intermediate time difference.
Specifically, the current device further obtains a reference time difference between the satellite time transmitted by the satellite and the current system time of the current device, such as the reference time difference Δ T1-the satellite time W-the current system time T1. Meanwhile, a second difference between the reference time difference and the initial time difference is obtained as a second intermediate time difference, such as the second difference Δ T2 being the reference time difference Δ T1 — the initial time difference Δ T0.
Accordingly, as shown in fig. 8, the step S230 includes:
s810, comparing the first difference value with a first time difference threshold value to obtain a first check result indicating whether the initial time difference is valid.
S820, comparing the second difference value with a second time difference threshold value to obtain a second check result indicating whether the initial time difference is valid.
Specifically, the current device determines a first check result indicating whether the initial time difference is valid or not by using the first difference value, and determines a second check result indicating whether the initial time difference is valid or not by using the second difference value. If the first difference is smaller than the first time difference threshold, the first verification result is determined to be that the initial time difference is valid, and if the first difference is not smaller than the first time difference threshold, the first verification result is determined to be that the initial time difference is invalid. Similarly, if the second difference is smaller than the second time difference threshold, the second check result is determined to be that the initial time difference is valid, and if the second difference is not smaller than the second time difference threshold, the second check result is determined to be that the initial time difference is invalid.
And S830, if the first check result and the second check result are both valid, determining that the initial time difference is a valid time difference.
S840, if the first check result and/or the second check result is/are the initial time difference failure, determining that the initial time difference is the failure, and returning to execute the step of obtaining the first reference time until the new first check result and the new second check result are both the initial time difference validity, so as to obtain the valid time difference.
Specifically, the current device further obtains a check result of whether the initial time difference is the valid time difference according to the first check result and the second check result. If the first check result and the second check result are both valid in the initial time difference, the current device determines that the initial time difference is a valid time difference; if the first check result and/or the second check result is/are that the initial time difference is invalid, the current device determines that the initial time difference is invalid, and returns to execute the step S210 until the new first check result and the new second check result are both valid, so as to obtain a valid time difference Δ T.
In this embodiment, when multiple verification results of whether the initial time difference is the valid time difference or not are obtained in multiple ways (not less than 2), if the initial time difference is invalid in the multiple verification results, the current device determines that the initial time difference is invalid; if the multiple verification results are all valid initial time differences, the current equipment determines the initial time differences to be valid time differences so as to improve the verification conditions of the valid time differences and correspondingly improve the accuracy of valid verification.
In an alternative embodiment, the current device performs a weighted summation on the first difference and the second difference, and determines whether the initial time difference is a valid time difference according to a result of the weighted summation, and accordingly, as shown in fig. 9, the step S230 includes:
s910, determining the weight of the first difference value and the weight of the second difference value;
s920, according to the weight of the first difference value and the weight of the second difference value, carrying out weighted summation on the first difference value and the second difference value to obtain a verification value of the initial time difference;
s930, if the verification value is smaller than a third time difference threshold value, determining the initial time difference as an effective time difference;
and S940, if the verification value is not smaller than the third time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new verification value is smaller than the third time difference threshold to obtain the effective time difference.
Specifically, the current device determines a preset weight corresponding to the first difference and a preset weight corresponding to the second difference, and performs weighted summation on the first difference and the second difference according to the weight of the first difference and the weight of the second difference to obtain a verification value of the initial time difference. For example, the first difference Δ t1 corresponds to the weight α, and the second difference Δ t2 corresponds to the weight β, where α + β is 1, and the verification value a is Δ t1 α + Δ t2 β. And the current equipment further determines whether the initial time difference is valid according to the verification value. If the verification value is smaller than the third time difference threshold value, the current equipment determines that the initial time difference is an effective time difference; if the verification value is not smaller than the third time difference threshold, the current device determines that the initial time difference is invalid, and returns to execute the step S210 until the new verification value is smaller than the third time difference threshold, so as to obtain an effective time difference Δ T.
In this embodiment, after the multiple difference values are obtained in multiple ways (not less than 2), the current device obtains preset weights corresponding to the different ways, performs weighted summation on the multiple difference values obtained in multiple ways to obtain a check value, and finally determines whether the initial time difference is the valid time difference according to the check value, so that the multiple ways are comprehensively considered, the influence degree of a single way on the check result is reduced, and the accuracy of valid check is improved.
In this embodiment, the current device performs validity check on the initial time difference by using the local time and the satellite time together, obtains a first difference between the local time and the initial calibration time after the initial time difference calibration, and a second difference between a reference time difference determined by the satellite time and the initial time difference, and then determines whether the initial time difference is a check result of the valid time difference according to the first difference and the second difference, determines the check result in two ways, and improves accuracy of checking the initial time difference.
In some scenarios, in order to ensure the accuracy of time calibration, the valid time difference determined in the above embodiments may be checked again, that is, the process of determining whether the initial time difference is the valid time difference in the embodiments of fig. 3 to 9 is a primary validity check, and after the valid time difference is obtained, the process of further determining whether the valid time difference is valid is a secondary validity check.
Further, the first reference time may include at least one of a local time, a satellite time, and a system reference time of the current device, the system reference time being different from a current system time of the current device. To further improve the accuracy of time calibration, the current device may perform a second validity check on the valid time difference to ensure that the valid time difference is valid, and therefore, the method further includes:
determining whether the valid time is valid according to at least one of the local time, the satellite time and the system reference time. The system reference time is another time different from the current system time in the system time of the current device. For example, the current system time T1 of the current device is 14:00, and the system reference time may be 18:00 at T2 or 7:00 at T3.
Optionally, the current device may perform secondary validity check on the valid time difference according to the local time stored in the current device to obtain a check result, or may receive satellite time sent by a satellite through communication with the satellite, perform secondary validity check on the valid time difference according to the satellite time to obtain a check result, or perform secondary validity check on the valid time difference according to a system reference time different from the current system time to obtain a check result, or perform secondary validity check on the valid time difference by using any two of the local time, the satellite time, and the system reference time to obtain a check result, or perform secondary validity check on the valid time difference by using the local time, the satellite time, and the system reference time at the same time to obtain a check result, which is not limited in the embodiment of the present application.
In an optional embodiment, the current device performs secondary validity check on the valid time difference by using local time and/or satellite time, for a specific process, refer to the embodiments in fig. 3 to 9, and the initial time difference may be replaced by the valid time difference, which is not described herein again.
The following description focuses on a specific implementation manner of performing secondary validity check on the valid time difference by the current device according to the system reference time, as shown in fig. 10, including:
and S1010, calibrating the current system time by adopting the effective time difference to obtain first calibration time.
And S1020, calibrating the system reference time by adopting the effective time difference to obtain second calibration time.
Specifically, the current device respectively calibrates the current system time and the system reference time of the current device by using the effective time difference, and correspondingly obtains a first calibration time and a second calibration time. For example, the first calibration time T1 ═ the current system time T1+ the effective time difference Δ T, and the second calibration time T2 ═ the system reference time T2+ the effective time difference Δ T. Wherein the system reference time may be some historical time prior to the current system time.
S1030, acquiring a first system startup duration corresponding to the current system time and a second system startup duration corresponding to the system reference time.
The first system startup duration and the second system startup duration refer to the startup duration of the current device, and the startup durations corresponding to different system times are different.
Specifically, the current device obtains system boot durations corresponding to the current system time and the system reference time, respectively, that is, a first boot duration corresponding to the current system time and a second system start duration corresponding to the system reference time. For example, the first power-on duration E1 corresponding to the current system time T1 and the second system start duration E2 corresponding to the system reference time T2.
S1040, determining whether the effective time difference is effective according to the first calibration time, the second calibration time, the first system startup time and the second system startup time.
In this embodiment, the current device may perform a second validity check on the valid time difference according to whether a difference between the first calibration time and the second calibration time is the same as a difference between the first system boot-up time and the second system boot-up time or meets an error range, as shown in fig. 11, where the step S1040 includes:
s1110, acquiring a first time difference between the first calibration time and the second calibration time;
s1120, acquiring a second time difference between the starting time of the first system and the starting time of the second system;
s1130, judging whether a third difference value between the first time difference and the second time difference is smaller than a fourth time difference threshold value or not;
and S1140, if the third difference value is smaller than the fourth time difference threshold value, determining that the effective time difference is effective.
Specifically, the current device acquires a first time difference between the first calibration time and the second calibration time, that is, a first time difference Q1 ═ a first calibration time T1 '-a second calibration time T2'. The current device further obtains a second time difference between the first system startup duration and the second system startup duration, that is, the second time difference Q2 is the first system startup duration E1 — the first system startup duration E2. The current device determines whether the effective time difference is effective according to the first time difference and the second time difference. For example, a third difference between the first time difference Q1 and the second time difference Q2 is calculated, and it is determined whether the third difference is less than a fourth time difference threshold. And if the third difference value is smaller than the fourth time difference threshold value, the current equipment determines that the effective time difference is effective.
Optionally, if the third difference is not less than the fourth time difference threshold, the current device determines that the valid time difference is invalid, deletes the valid time difference in the current device, and sends a time calibration request to the time server again, determines a new initial time difference based on a new UTC sent by the time server, performs a validity check on the new initial time difference to obtain a new valid time difference, and performs a secondary validity check on the new valid time difference until the new valid time difference is valid.
Optionally, when the current device performs secondary validity check on the valid time difference by using any two of the local time, the satellite time, and the system reference time, it may be determined whether the valid time difference is valid by referring to the manners in the embodiments in fig. 8 and fig. 9, which is not described herein again.
In an optional embodiment, when the current device performs secondary validity check on the valid time difference by using the local time, the satellite time, and the system reference time at the same time, a first difference, a second difference, and a third difference corresponding to the valid time difference are obtained, and the current device determines a check result according to the first difference, the second difference, and the third difference. For example, if any one of the first difference, the second difference, and the third difference is valid, it is determined that the valid time difference is invalid, or the first difference, the second difference, and the third difference are weighted and summed, and whether the valid time difference is valid is determined according to a result of the weighted summation, and so on.
In an optional embodiment, the current device determines whether the valid time difference is valid using a first check result, a second check result, and a third check result, which are determined according to the first difference, the second difference, and the third difference, respectively, to indicate whether the valid time difference is valid. If the first check result, the second check result and the third check result are all valid initial time differences, the current device determines that the valid time differences are valid; and if any one of the first check result, the second check result and the third check result indicates that the effective time difference is invalid, the current equipment determines that the effective time difference is invalid.
In an optional embodiment, the current device performs weighted summation on the first difference, the second difference, and the third difference, and determines whether the effective time difference is effective according to a result of the weighted summation, as shown in fig. 12, the method specifically includes the following steps:
s1210, determining the weight of the first difference, the weight of the second difference and the weight of the third difference;
s1220, carrying out weighted summation on the first difference, the second difference and the third difference according to the weight of the first difference, the weight of the second difference and the weight of the third difference to obtain a verification value of the effective time difference;
s1230, if the verification value of the effective time difference is smaller than a fifth time difference threshold value, determining that the effective time difference is effective;
and S1240, if the verification value of the effective time difference is not less than the fifth time difference threshold value, determining that the effective time difference is invalid.
Specifically, the current device determines that the first difference corresponds to a preset weight and the second difference corresponds to a preset weight, and the third difference corresponds to a weight, for example, the first difference Δ t1 corresponds to a weight α, the second difference Δ t2 corresponds to a weight β, and the third difference Δ t3 corresponds to a weight γ, where α + β + γ is 1. And the current equipment performs weighted summation on the first difference, the second difference and the third difference according to the weight of the first difference, the weight of the second difference and the weight corresponding to the third difference to obtain a verification value of the effective time difference. For example, the validation value B ═ Δ t1 ═ Δ t2 ═ Δ t3 ═ Δ t. The current device then determines whether the valid time difference is valid based on the validation value of the valid time difference. If the verification value of the effective time difference is smaller than a fifth time difference threshold value, the current equipment determines that the effective time difference is effective; and if the verification value of the effective time difference is not less than the fifth time difference threshold value, the current equipment determines that the effective time difference is invalid.
Optionally, if the validation value of the valid time difference is not less than the fifth time difference threshold, the current device determines that the valid time difference is invalid, deletes the valid time difference in the current device, and initiates a time calibration request to the time server again, determines a new initial time difference based on a new UTC sent by the time server, performs a validity check on the new initial time difference to obtain a new valid time difference, and performs a secondary validity check on the new valid time difference until the new valid time difference is valid.
In this embodiment, the current device performs secondary validity check on the effective time difference by introducing a first system startup duration corresponding to the current system time and a second system startup duration corresponding to the system reference time, so as to ensure validity of the effective time difference and further improve accuracy of time calibration. The current device specifically obtains a first calibration time and a second calibration time which are respectively obtained by correspondingly calibrating the current system time and the system reference time by the effective time difference, and determines whether the effective time difference is effective or not according to whether a first time difference between the first calibration time and the second calibration time is equal to a second time difference between the first system startup time and the second system startup time or whether a third difference between the first time difference and the second time difference is smaller than a fourth time difference threshold. The starting-up time length of the current equipment is independently timed and is not influenced by the system time of the current equipment, and whether the effective time difference is effective or not can be accurately verified by adopting the difference between the system starting-up time lengths corresponding to different system times and the difference between the calibration time after the effective time difference calibration corresponding to different system times, so that the accuracy of verifying the effective time difference is improved.
It should be understood that although the various steps in the flow charts of fig. 2-12 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-12 may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed in turn or alternately with other steps or at least some of the other steps.
In one embodiment, as shown in fig. 13, there is provided a time calibration apparatus including: a time acquisition module 1301, a validity check module 1302, a threshold comparison module 1303, and a time calibration module 1304, wherein:
the time obtaining module 1301 is configured to obtain a first reference time; the first reference time is the time determined by other equipment except the time server;
the validity check module 1302 is configured to determine an intermediate time difference according to the first reference time, the current system time of the current device, and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment;
a threshold comparison module 1303, configured to determine an effective time difference according to the intermediate time difference and the corresponding time difference threshold;
the time calibration module 1304 is configured to calibrate the system time of the current device according to the effective time difference, so as to obtain a calibration time.
In one embodiment, the first reference time comprises a local time; the validity check module 1302 is specifically configured to:
calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time; acquiring a first difference value between the local time and the initial calibration time as an intermediate time difference; wherein the local time is stored in the current device.
In one embodiment, the threshold comparing module 1303 is specifically configured to:
judging whether the first difference value is smaller than a first threshold value; if the first difference value is smaller than the first time difference threshold value, determining the initial time difference as an effective time difference; and if the first difference is not smaller than the first time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new first difference is smaller than the first time difference threshold so as to obtain the effective time difference.
In one embodiment, the first reference time includes a satellite time, and the validity check module 1302 is specifically configured to:
acquiring a reference time difference between satellite time transmitted by a satellite and current system time of current equipment; and acquiring a second difference value between the reference time difference and the initial time difference as the intermediate time difference.
In one embodiment, the threshold comparing module 1303 is specifically configured to:
judging whether the second difference value is smaller than a second time difference threshold value; if the second difference value is smaller than the second time difference threshold value, determining the initial time difference as an effective time difference; and if the second difference is not smaller than the second time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new second difference is smaller than the second time difference threshold so as to obtain the effective time difference.
In one embodiment, the first reference time includes a local time and a satellite time, and the validity check module 1302 is specifically configured to:
calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time; acquiring a first difference value between the initial calibration time and local time stored in the current equipment as a first intermediate time difference; acquiring a reference time difference between satellite time transmitted by a satellite and current system time of current equipment; and a second difference between the reference time difference and the initial time difference is obtained as a second intermediate time difference.
In one embodiment, the threshold comparing module 1303 is specifically configured to:
comparing the first difference value with a first time difference threshold value to obtain a first check result indicating whether the initial time difference is valid; comparing the second difference value with a second time difference threshold value to obtain a second check result indicating whether the initial time difference is valid; if the first check result and the second check result are both valid in the initial time difference, determining the initial time difference as a valid time difference; and if the first check result and/or the second check result is/are the initial time difference failure, determining that the initial time difference failure occurs, and returning to the step of acquiring the first reference time until the new first check result and the new second check result are both the initial time difference validity, so as to obtain the valid time difference.
In one embodiment, the threshold comparing module 1303 is specifically configured to:
determining a weight of the first difference and a weight of the second difference; according to the weight of the first difference value and the weight of the second difference value, carrying out weighted summation on the first difference value and the second difference value to obtain a verification value of the initial time difference; if the verification value is smaller than the third time difference threshold value, determining the initial time difference as an effective time difference; and if the verification value is not smaller than the third time difference threshold value, determining that the verification result is that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new verification value is smaller than the third time difference threshold value to obtain the effective time difference.
In one embodiment, the first reference time includes at least one of a local time, a satellite time, and a system reference time of the current device, the system reference time is different from the current system time of the current device, and the validity check module 1302 is further configured to:
determining whether the valid time difference is valid according to at least one of the local time, the satellite time and the system reference time.
In one embodiment, the validity check module 1302 is specifically configured to:
calibrating the current system time by adopting the effective time difference to obtain first calibration time; calibrating the system reference time by adopting the effective time difference to obtain second calibration time; acquiring a first system startup duration corresponding to the current system time and a second system startup duration corresponding to the system reference time; and determining whether the effective time difference is effective or not according to the first calibration time, the second calibration time, the first system startup time and the second system startup time.
In one embodiment, the validity check module 1302 is specifically configured to:
acquiring a first time difference between a first calibration time and a second calibration time; acquiring a second time difference between the starting time of the first system and the starting time of the second system; judging whether a third difference value between the first time difference and the second time difference is smaller than a fourth time difference threshold value or not; and if the third difference is smaller than the fourth time difference threshold, determining that the effective time difference is effective.
For the specific definition of the time calibration device, reference may be made to the above definition of the time calibration method, which is not described herein again. The modules in the time calibration device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent of a processor in the electronic device, or can be stored in a memory in the electronic device in a software form, so that the processor can call and execute operations corresponding to the modules.
Fig. 14 is a block diagram illustrating an electronic device 1300 according to an example embodiment. For example, the electronic device 1300 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and so forth.
Referring to fig. 14, electronic device 1300 may include one or more of the following components: a processing component 1302, a memory 1304, a power component 1306, a multimedia component 1308, an audio component 1310, an input/output (I/O) interface 1312, a sensor component 1314, and a communication component 1316. Wherein the memory has stored thereon a computer program or instructions for execution on the processor.
The processing component 1302 generally controls overall operation of the electronic device 1300, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 1302 may include one or more processors 1320 to execute instructions to perform all or part of the steps of the method described above. Further, the processing component 1302 can include one or more modules that facilitate interaction between the processing component 1302 and other components. For example, the processing component 1302 may include a multimedia module to facilitate interaction between the multimedia component 1308 and the processing component 1302.
The memory 1304 is configured to store various types of data to support operation at the electronic device 1300. Examples of such data include instructions for any application or method operating on the electronic device 1300, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 1304 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 1306 provides power to the various components of the electronic device 1300. Power components 1306 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for electronic device 1300.
The multimedia component 1308 includes a touch-sensitive display screen that provides an output interface between the electronic device 1300 and a user. In some embodiments, the touch display screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1308 includes a front facing camera and/or a rear facing camera. The front-facing camera and/or the rear-facing camera may receive external multimedia data when the electronic device 1300 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 1310 is configured to output and/or input audio signals. For example, the audio component 1310 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 1300 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 1304 or transmitted via the communication component 1316. In some embodiments, the audio component 1310 also includes a speaker for outputting audio signals.
The I/O interface 1312 provides an interface between the processing component 1302 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 1314 includes one or more sensors for providing various aspects of state assessment for the electronic device 1300. For example, the sensor assembly 1314 may detect an open/closed state of the electronic device 1300, the relative positioning of components, such as a display and keypad of the electronic device 1300, the sensor assembly 1314 may also detect a change in the position of the electronic device 1300 or a component of the electronic device 1300, the presence or absence of user contact with the electronic device 1300, orientation or acceleration/deceleration of the electronic device 1300, and a change in the temperature of the electronic device 1300. The sensor assembly 1314 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1314 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1314 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 1316 is configured to facilitate communications between the electronic device 1300 and other devices in a wired or wireless manner. The electronic device 1300 may access a wireless network based on a communication standard, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 1316 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communications component 1316 also includes a Near Field Communications (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the electronic device 1300 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic components for performing the above-described time alignment methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 1304 comprising instructions, executable by the processor 1320 of the electronic device 1300 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a program product is also provided, which computer program, when being executed by a processor, is adapted to carry out the above-mentioned method. The program product includes one or more computer instructions. When loaded and executed on a computer, may implement some or all of the above-described methods, in whole or in part, according to the procedures or functions described in the embodiments of the disclosure.
By way of example, the embodiments of the present application disclose:
TS1, a method of time calibration, comprising:
acquiring a first reference time; the first reference time is the time determined by other equipment except the time server; determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment; determining an effective time difference according to the intermediate time difference and the corresponding time difference threshold; and calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
TS2, the method of TS1, wherein the first reference time comprises a local time; determining an intermediate time difference according to the first reference time, the current system time of the current device and the initial time difference, including:
calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time; acquiring a first difference value between local time and initial calibration time as the intermediate time difference; wherein the local time is stored in the current device.
TS3, the method of TS2, determining an effective time difference based on the intermediate time difference and a corresponding time difference threshold, comprising:
judging whether the first difference value is smaller than a first time difference threshold value or not; if the first difference value is smaller than the first time difference threshold value, determining the initial time difference as an effective time difference; and if the first difference is not smaller than the first time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new first difference is smaller than the first time difference threshold so as to obtain the effective time difference.
TS4, the method of TS1, wherein the first reference time comprises a satellite time, and determining an intermediate time difference based on the first reference time, a current system time of the current device, and the initial time difference comprises:
acquiring a reference time difference between satellite time transmitted by a satellite and current system time of current equipment; and acquiring a second difference value between the reference time difference and the initial time difference as the intermediate time difference.
TS5, the method of TS4, determining an effective time difference based on the intermediate time difference and a corresponding time difference threshold, comprising:
judging whether the second difference value is smaller than a second time difference threshold value; if the second difference value is smaller than the second time difference threshold value, determining the initial time difference as an effective time difference; and if the second difference is not smaller than the second time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new second difference is smaller than the second time difference threshold so as to obtain the effective time difference.
TS6, the method of TS1, wherein the first reference time includes a local time and a satellite time, and determining an intermediate time difference based on the first reference time, a current system time of the current device, and the initial time difference comprises:
calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time; acquiring a first difference value between the initial calibration time and local time stored in the current equipment as a first intermediate time difference; acquiring a reference time difference between satellite time transmitted by a satellite and current system time of current equipment; and a second difference between the reference time difference and the initial time difference is obtained as a second intermediate time difference.
TS7, the method of TS6, determining an effective time difference based on the intermediate time difference and a corresponding time difference threshold, comprising:
comparing the first difference value with a first time difference threshold value to obtain a first check result indicating whether the initial time difference is valid; comparing the second difference value with a second time difference threshold value to obtain a second check result indicating whether the initial time difference is valid; if the first check result and the second check result are both valid in the initial time difference, determining the initial time difference as a valid time difference; and if the first check result and/or the second check result is/are the initial time difference failure, determining that the initial time difference failure occurs, and returning to the step of acquiring the first reference time until the new first check result and the new second check result are both the initial time difference validity, so as to obtain the valid time difference.
TS8, the method of TS6, determining an effective time difference based on the intermediate time difference and a corresponding time difference threshold, comprising:
determining a weight of the first difference and a weight of the second difference; according to the weight of the first difference value and the weight of the second difference value, carrying out weighted summation on the first difference value and the second difference value to obtain a verification value of the initial time difference; if the verification value is smaller than the third time difference threshold value, determining the initial time difference as an effective time difference; and if the verification value is not smaller than the third time difference threshold value, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until the new verification value is smaller than the third time difference threshold value to obtain the effective time difference.
TS9, the method as in TS1, wherein the first reference time includes at least one of a local time, a satellite time, and a system reference time of the current device, the system reference time being different from a current system time of the current device, the method further comprising:
determining whether the valid time difference is valid according to at least one of the local time, the satellite time and the system reference time.
TS10, the method of TS9, wherein determining whether the validity time difference is valid based on the system reference time comprises:
calibrating the current system time by adopting the effective time difference to obtain first calibration time; calibrating the system reference time by adopting the effective time difference to obtain second calibration time; acquiring a first system startup duration corresponding to the current system time and a second system startup duration corresponding to the system reference time; and determining whether the effective time difference is effective or not according to the first calibration time, the second calibration time, the first system startup time and the second system startup time.
TS11, the method of TS10, determining whether the validity time difference is valid according to the first calibration time, the second calibration time, the first system power-on duration, and the second system power-on duration, comprising:
acquiring a first time difference between a first calibration time and a second calibration time; acquiring a second time difference between the starting time of the first system and the starting time of the second system; judging whether a third difference value between the first time difference and the second time difference is smaller than a fourth time difference threshold value or not; and if the third difference is smaller than the fourth time difference threshold, determining that the effective time difference is effective.
TS12, a time alignment apparatus, comprising:
the time acquisition module is used for acquiring first reference time; the first reference time is the time determined by other equipment except the time server;
the effective checking module is used for determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment;
the threshold comparison module is used for determining an effective time difference according to the intermediate time difference and the corresponding time difference threshold;
and the time calibration module is used for calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
TS13, an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the method of any one of TS1 to TS11 when executing the computer program.
TS14, a storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of any one of TS1 to TS 11.
TS15, a program product having a computer program stored thereon, which computer program, when being executed by a processor, carries out the steps of the method of any one of TS1 to TS 11.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database or other medium used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical storage, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method of time calibration, the method comprising:
acquiring a first reference time; wherein the first reference time is a time determined by other equipment except a time server;
determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to a second reference time sent by the time server and the system time of the current device;
determining an effective time difference according to the intermediate time difference and a corresponding time difference threshold;
and calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
2. The method of claim 1, wherein the first reference time comprises a local time;
determining an intermediate time difference according to the first reference time, the current system time of the current device, and the initial time difference, including:
calibrating the current system time of the current equipment by adopting the initial time difference to obtain initial calibration time;
acquiring a first difference value between the local time and the initial calibration time as the intermediate time difference; wherein the local time is stored in the current device.
3. The method of claim 2, wherein determining the effective time difference based on the intermediate time difference and a corresponding time difference threshold comprises:
judging whether the first difference value is smaller than a first time difference threshold value or not;
if the first difference value is smaller than the first time difference threshold value, determining the initial time difference as the effective time difference;
and if the first difference is not smaller than the first time difference threshold, determining that the initial time difference is invalid, and returning to the step of acquiring the first reference time until a new first difference is smaller than the first time difference threshold so as to obtain the effective time difference.
4. The method of claim 1, wherein the first reference time comprises at least one of a local time, a satellite time, and a system reference time of the current device, the system reference time being different from a current system time of the current device, the method further comprising:
determining whether the effective time difference is effective according to at least one of the local time, the satellite time and the system reference time.
5. The method of claim 4, wherein determining whether the effective time difference is effective based on the system reference time comprises:
calibrating the current system time by adopting the effective time difference to obtain first calibration time;
calibrating the system reference time by adopting the effective time difference to obtain second calibration time;
acquiring a first system startup duration corresponding to the current system time and a second system startup duration corresponding to the system reference time;
and determining whether the effective time difference is effective according to the first calibration time, the second calibration time, the first system startup time and the second system startup time.
6. The method of claim 5, wherein determining whether the valid time difference is valid based on the first calibration time, the second calibration time, the first system on time, and the second system on time comprises:
obtaining a first time difference between the first calibration time and the second calibration time;
acquiring a second time difference between the first system startup time and the second system startup time;
judging whether a third difference value between the first time difference and the second time difference is smaller than a fourth time difference threshold value or not;
and if the third difference value is smaller than the fourth time difference threshold value, determining that the effective time difference is effective.
7. A time alignment apparatus, comprising:
the time acquisition module is used for acquiring first reference time; wherein the first reference time is a time determined by other equipment except a time server;
the effective checking module is used for determining an intermediate time difference according to the first reference time, the current system time of the current equipment and the initial time difference; the initial time difference is determined according to the second reference time sent by the time server and the system time of the current equipment;
a threshold comparison module for determining an effective time difference according to the intermediate time difference and a corresponding time difference threshold;
and the time calibration module is used for calibrating the system time of the current equipment according to the effective time difference to obtain calibration time.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 6 are implemented when the computer program is executed by the processor.
9. A storage medium having a computer program stored thereon, the computer program, when being executed by a processor, realizing the steps of the method of any one of claims 1 to 6.
10. A program product comprising a computer program, characterized in that the computer program realizes the steps of the method of any one of claims 1-6 when executed by a processor.
CN202110223985.4A 2021-03-01 2021-03-01 Time calibration method, device, electronic equipment, storage medium and program product Active CN113014349B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110223985.4A CN113014349B (en) 2021-03-01 2021-03-01 Time calibration method, device, electronic equipment, storage medium and program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110223985.4A CN113014349B (en) 2021-03-01 2021-03-01 Time calibration method, device, electronic equipment, storage medium and program product

Publications (2)

Publication Number Publication Date
CN113014349A true CN113014349A (en) 2021-06-22
CN113014349B CN113014349B (en) 2022-12-16

Family

ID=76386898

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110223985.4A Active CN113014349B (en) 2021-03-01 2021-03-01 Time calibration method, device, electronic equipment, storage medium and program product

Country Status (1)

Country Link
CN (1) CN113014349B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114006674A (en) * 2021-12-31 2022-02-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment
CN114115673A (en) * 2021-11-25 2022-03-01 海信集团控股股份有限公司 Control method of vehicle-mounted screen
CN114401065A (en) * 2021-12-06 2022-04-26 深圳市亚略特科技股份有限公司 Local time calibration method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030123491A1 (en) * 2000-12-13 2003-07-03 Bruno Couillard Method and system for time synchronization
CN107395312A (en) * 2017-09-19 2017-11-24 电信科学技术第五研究所有限公司 A kind of secure network method for synchronizing time and device
CN107430414A (en) * 2015-03-25 2017-12-01 西门子公司 Equipment, method and system for the temporal information that detects and differentiate different management domains
CN111092688A (en) * 2019-12-30 2020-05-01 海信集团有限公司 Time calibration method and device and terminal equipment
CN111224733A (en) * 2020-01-09 2020-06-02 珠海格力电器股份有限公司 Time calibration method, device, computer equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030123491A1 (en) * 2000-12-13 2003-07-03 Bruno Couillard Method and system for time synchronization
CN107430414A (en) * 2015-03-25 2017-12-01 西门子公司 Equipment, method and system for the temporal information that detects and differentiate different management domains
CN107395312A (en) * 2017-09-19 2017-11-24 电信科学技术第五研究所有限公司 A kind of secure network method for synchronizing time and device
CN111092688A (en) * 2019-12-30 2020-05-01 海信集团有限公司 Time calibration method and device and terminal equipment
CN111224733A (en) * 2020-01-09 2020-06-02 珠海格力电器股份有限公司 Time calibration method, device, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
邱淳: "专业数字电声设备的时钟以及系统的同步(下)", 《现代电视技术》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114115673A (en) * 2021-11-25 2022-03-01 海信集团控股股份有限公司 Control method of vehicle-mounted screen
CN114115673B (en) * 2021-11-25 2023-10-27 海信集团控股股份有限公司 Control method of vehicle-mounted screen
CN114401065A (en) * 2021-12-06 2022-04-26 深圳市亚略特科技股份有限公司 Local time calibration method, device, equipment and storage medium
CN114006674A (en) * 2021-12-31 2022-02-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment
CN114006674B (en) * 2021-12-31 2022-04-01 深圳市海清视讯科技有限公司 Time correction method, device, equipment and storage medium for attendance equipment

Also Published As

Publication number Publication date
CN113014349B (en) 2022-12-16

Similar Documents

Publication Publication Date Title
CN113014349B (en) Time calibration method, device, electronic equipment, storage medium and program product
EP3133528B1 (en) Method and apparatus for fingerprint identification
US20180365004A1 (en) Method and device for calling software development kit
EP2978265B1 (en) Method and apparatus for automatically connecting to a wireless network
EP3076716A1 (en) Method and apparatus for network access
US11864241B2 (en) Random access method and apparatus, and storage medium
CN110634488B (en) Information processing method, device and system and storage medium
JP2017524212A (en) Application installation package processing method, apparatus, program, and recording medium
EP2961148A1 (en) Method and device for obtaining voice service
EP4203604A1 (en) Ranging capacity request method and apparatus, ranging capacity sending method and apparatus, and ranging capacity receiving method and apparatus
US10083346B2 (en) Method and apparatus for providing contact card
US20150339016A1 (en) Tab creation method, device, and terminal
US20140380292A1 (en) Method, device, and storage medium for upgrading operating system
CN115185717B (en) Interface calling method and device, electronic equipment and storage medium
CN112042239A (en) Offset indication determination method and device and offset determination method and device
JP2017503289A (en) Terminal verification method, apparatus, program, and recording medium
CN109076595B (en) Random access control method and random access control device
CN108153540B (en) System upgrading method, device, terminal and storage medium
CN109885360B (en) Data processing method, device and storage medium
CN109194639B (en) Message receiving and processing method, device, terminal and readable storage medium
CN111049943A (en) Method, device, equipment and medium for analyzing domain name
CN111221559B (en) Application updating method, device, storage medium, terminal and server
CN108833673B (en) Method, apparatus, hardware apparatus and medium for restricting user operation
CN113138036B (en) Temperature detection method and device and electronic equipment
CN113961839A (en) Time acquisition method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant