Local end time synchronization method, local end and computer readable storage medium
By calculating the time quality and comparing the time quality of the local end and the server, the time synchronization interval is controlled, which solves the problem of difficult time synchronization error judgment in the local area network and improves the accuracy of time synchronization and system stability.
Patent Information
- Application Number
- CN202310370273.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-07
- Publication Date
- 2024-10-15
AI Technical Summary
In local area network systems, existing local time synchronization methods cannot accurately determine the time error, which may lead to the possibility of using untrusted server time to update the local time, resulting in a problem of reduced time accuracy.
By calculating the time quality, based on the allowable error, error rate and time interval, the time quality of the local end and the server is compared to determine whether to perform time synchronization, and the synchronization interval is controlled according to the time quality threshold to ensure the accuracy of time synchronization.
It effectively prevents the reduction of local time accuracy caused by inaccurate server time, improves the accuracy and reliability of time synchronization, and ensures the normal operation of the local area network system.
Smart Images

Figure CN118784122A_ABST
Abstract
Description
Technical Field
[0001] The present invention generally relates to the field of local area network technology, and in particular to a local end time synchronization method, a local end and a computer-readable storage medium. Background Art
[0002] In a local area network system, due to the accuracy of software and hardware, there is a time error on the local side. Therefore, it is necessary to update the local time after a certain period of time. The usual method is that the local side sends a time synchronization request to the server, obtains the current time of the server, and updates the local time according to the current time of the server.
[0003] However, in actual applications, the server is also affected by the accuracy of software and hardware. Therefore, in some cases, such as an unexpected power outage on the server, or the server's own time accuracy is lower than the local time accuracy, the server time may not be trustworthy. Using the server time to update the local time may cause errors. In addition, in the existing local time synchronization method, it is impossible to accurately obtain the time error generated by the local end, and thus it is impossible to determine whether an unacceptable time error has occurred, affecting the normal operation of the local end.
[0004] The contents of the background technology section are merely the technologies known to the inventors and do not necessarily represent the prior art in the field. Summary of the invention
[0005] In view of one or more defects in the prior art, the present invention provides a local time synchronization method, comprising:
[0006] The local end sends a time synchronization request to the server at a preset time interval, and the server can update the server time according to the upper network;
[0007] Generate server time quality and local time quality;
[0008] Compare the local time quality with the server time quality;
[0009] Determine whether the local end performs time synchronization according to the server time based on the comparison result of the local end time quality and the server time instruction;
[0010] The time quality decreases as the time interval from the last time synchronization increases.
[0011] According to one aspect of the present invention, the time quality is calculated based on the allowable error, the error rate and the time interval from the last time synchronization.
[0012] According to one aspect of the present invention, the step of determining whether the local terminal performs time synchronization according to the server time based on the comparison result of the time quality of the local terminal and the time quality of the server comprises:
[0013] Determine whether the local time quality is greater than the server time quality;
[0014] When the time quality of the local terminal is greater than the time quality of the server, the local terminal sends a time synchronization request to the server at a first preset interval and does not update the time of the local terminal.
[0015] According to one aspect of the present invention, when the time quality of the local end is not greater than the time quality of the server, the local end sends a time synchronization request to the server at a second preset interval, uses the server time to update the time of the local end, and updates the time quality of the local end; wherein the second preset interval is not greater than the first preset interval.
[0016] According to one aspect of the present invention, the local time synchronization method further includes:
[0017] When the time quality of the local end is not greater than the time quality of the server, and the time quality of the server is less than a first threshold;
[0018] The local end sends a time synchronization request to the server at a third preset interval, and does not update the time of the local end.
[0019] According to one aspect of the present invention, the local time synchronization method further includes:
[0020] When the time quality of the server is not less than the first threshold and not greater than the second threshold, the local end sends a time synchronization request to the server at a fourth preset interval, updates the time of the local end with the time of the server, and updates the time quality of the local end;
[0021] When the time quality of the server is greater than the second threshold, the local end sends a time synchronization request to the server at a fifth preset interval, updates the time of the local end using the time of the server, and updates the time quality of the local end;
[0022] The fifth preset interval is greater than the fourth preset interval, and the fifth preset interval is not greater than the first preset interval.
[0023] According to one aspect of the present invention, the value range of the time quality is adjusted to a closed interval [0, N], where N is a preset value greater than 0. After the time synchronization between the local end and the server is completed, the time quality of the local end is N; when the time quality of the local end is 0, the time quality of the local end remains 0 until the local end is synchronized with the server.
[0024] According to one aspect of the present invention, when the time quality of the local terminal and the time quality of the server are both 0, the local terminal does not perform time synchronization.
[0025] According to one aspect of the present invention, the error rate of the local terminal and the error rate of the server are independent of each other, and the error rate is caused by software and / or hardware errors and can be obtained through calibration measurements.
[0026] According to one aspect of the present invention, the local time synchronization method further includes:
[0027] Determine whether the server has received a time synchronization request; and / or
[0028] Determines whether the server time quality is received.
[0029] According to one aspect of the present invention, the present invention also includes a local end, which communicates with a server and can send a time synchronization request to the server, the local end has a local end time, the server has a server time, the server communicates with an upper-level network, and can use the upper-level network to update the server time; the local end is configured to be able to execute the local end time synchronization method as described above.
[0030] According to one aspect of the present invention, the local terminal comprises:
[0031] a motherboard, the motherboard comprising a processor; and
[0032] A communication board, wherein the communication board comprises a communication interface and a communication chip for signal connection, the communication chip and the processor are connected via a connector, and the communication interface communicates with the server.
[0033] According to one aspect of the present invention, the communication interface is connected to the server via a network connector, the network connector supports the ZigBee communication protocol, and the communication interface is a ZigBee antenna.
[0034] According to one aspect of the present invention, the present invention also includes a computer-readable storage medium, including computer executable commands stored thereon, and when the executable commands are executed by a processor, the local time synchronization method as described above is implemented.
[0035] Compared with the prior art, the embodiment of the present invention provides a local time synchronization method, proposes to use time quality as a standard to measure the accuracy of the local and server time, and controls the time interval for the local and server time synchronization according to the time quality standard. The time quality quantified by the allowable error, error rate and time interval from the last time synchronization can reflect the accuracy of the local time and server time at the current moment, prevent the local time from being affected by the server time, resulting in reduced accuracy, and can evaluate the accuracy of the local time by setting the allowable threshold of the time quality. The present invention also includes an embodiment of a local terminal and a computer-readable storage medium, which can implement the aforementioned local time synchronization method. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0037] Figure 1 is a flow chart of a local time synchronization method in one embodiment of the present invention;
[0038] Figure 2 is a flow chart of a process of determining the time quality of a local terminal and a server in one embodiment of the present invention;
[0039] Figure 3 is a flow chart of a process of sending a time synchronization request according to a server time quality value in one embodiment of the present invention;
[0040] Figure 4 is a flow chart of a process for determining information reception in one embodiment of the present invention;
[0041] Figure 5 is a structural block diagram of a network system in one embodiment of the present invention;
[0042] Figure 6 It is a structural block diagram of the local end in one embodiment of the present invention. DETAILED DESCRIPTION
[0043] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0044] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0045] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or can communicate with each other; it can be directly connected, or indirectly connected through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0046] In the present invention, unless otherwise clearly specified and limited, a first feature being "above" or "below" a second feature may include that the first and second features are in direct contact, or may include that the first and second features are not in direct contact but are in contact through another feature between them. Moreover, a first feature being "above", "above" and "above" a second feature includes that the first feature is directly above and obliquely above the second feature, or simply means that the first feature is higher in level than the second feature. A first feature being "below", "below" and "below" a second feature includes that the first feature is directly below and obliquely below the second feature, or simply means that the first feature is lower in level than the second feature.
[0047] The disclosure below provides many different embodiments or examples to realize different structures of the present invention. In order to simplify the disclosure of the present invention, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present invention. In addition, the present invention can repeat reference numbers and / or reference letters in different examples, and this repetition is for the purpose of simplicity and clarity, which itself does not indicate the relationship between the various embodiments and / or settings discussed. In addition, the present invention provides various specific examples of processes and materials, but those of ordinary skill in the art can be aware of the application of other processes and / or the use of other materials.
[0048] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0049] The local end time synchronization method in the embodiment of the present invention is applied in a local area network system, in which the local area network system includes at least one local end and a server, the local end is connected to the server through a network connector, and the local end can communicate with the server, for example, to send a time synchronization request. Specifically, the local end in the local area network system can be an ACB (frame circuit breaker), and the circuit breaker is connected to the server via a network connector in a wired or wireless manner. For example, a ZigBee (a low-power local area network communication protocol) antenna is integrated in the ACB, and a connection is established with the network connector, for example, the network connector is a ZigBee gateway. The server is also connected to a superior network and can update the server time according to the superior network. In the following specific embodiments, the local end time synchronization method is described in detail.
[0050] Figure 1 The specific process of the local time synchronization method 100 according to the preferred embodiment of the present invention is shown below. Figure 1 The local time synchronization method 100 is described.
[0051] like Figure 1As shown, in step S101, the local end sends a time synchronization request to the server at a preset time interval. The server in this embodiment can update the server time according to the superior network. Specifically, the server is connected to the superior network through a network device, and can update the server time using the superior network time at a preset frequency or the time synchronization method in this embodiment. In practical applications, the local end is limited by the accuracy of software and hardware, and time errors will occur. Taking the local end using the crystal oscillator timing principle as an example, since the accuracy of the crystal itself cannot be completely accurate, for example, when the accuracy of the crystal is 32768Hz±20ppm (partspermillion), taking 1 year as an example, the expected time after 1 year is 365.24*60*60=31536000s. Within 1 year, due to the existence of crystal error, the actual time error may range from ±315s=±5.25min. Here, 5.25min is only an error range, and does not mean that an error of 5.25min will definitely occur. Hardware using other timing methods, as well as the control software system in the local end, will also produce different errors. To ensure that the local time is within the allowed range, it is necessary to calibrate the local time after a certain period of time. In the local area network, the local end sends a time synchronization request to the server. Specifically, the local area network composed of the local end and the server is as follows: Figure 5 As shown, it may include multiple local terminals that do not affect each other and communicate with the server, and can send time synchronization requests to the server.
[0052] In step S102, the time quality of the server and the time quality of the local end are generated. Specifically, the local end may receive the time quality of the server sent by the server, that is, the server time quality is calculated and transmitted to the local end, or the local end may receive the operating parameters of the server and obtain the time quality of the server according to a preset calculation formula. Correspondingly, the local end generates the time quality of the local end. In this embodiment, the time quality decreases as the time interval from the last time synchronization increases. For example, for the local end, its time quality is negatively correlated with the time interval of the last time the local end was corrected according to the server time; for the server, its time quality is negatively correlated with the time interval of the last time the server was corrected according to the time of the upper network. Specifically, according to a preferred embodiment of the present invention, the time quality can be calculated according to the following formula,
[0053] Q=Te-t,
[0054] In the above formula, Q represents the time quality. The time quality of the local terminal and the time quality of the server can be the same or different. t represents the time interval from the last time synchronization. Within the preset range, the time quality is negatively correlated with the time interval from the last time synchronization, that is, the longer the time interval from the last time synchronization, the lower the time quality. For example, a value range is set for the time quality. Within the value range, the value of the time quality Q decreases as the time interval t from the last time synchronization increases. Outside the value range of the time quality Q, for example, after the time quality Q decreases to 0, it no longer decreases and remains at 0. In this embodiment, the server updates the server time according to the time of the upper network, such as the Internet. Specifically, it can be updated at a preset frequency, or the server can be regarded as a local terminal in a local area network, and the time of the server (the local terminal in the upper network) can be updated according to the local terminal time synchronization method 100 in this embodiment. In the time quality of the server, the time interval from the last time synchronization is the time interval between the server and the upper network for the last time synchronization.
[0055] According to a preferred embodiment of the present invention, the time quality is calculated based on the allowable error, the error rate, and the time interval from the last time synchronization. Specifically, for example, Te in the above formula represents the time taken for the time quality Q to decrease to the minimum value, which is a set value, and Te satisfies the following formula, that is, Te determines the value range through the following formula, and selects a set value within the value range,
[0056] Te≤Tc / e.
[0057] Wherein Tc represents the allowable error, which is a setting value of the network system including the local end and the server, such as the maximum error value of the time in the network system that meets the use requirements; e represents the error rate caused by the local end or the server due to software and / or hardware limitations, which can be obtained through calibration measurement, for example, when the supplier provides the corresponding product, the error rate of the product will be provided at the same time. In different embodiments of the present invention, the error rate of the local end and the error rate of the server are independent of each other, and can be the same or different, which leads to different results of the time quality calculation of the local end and the server.
[0058] In the above formula, Tc carries a time unit, such as 60s, e is a known fixed value, such as expressed in million ratios, and t also carries a time unit, which is determined according to the specific application scenario of the local end. For example, in application scenarios with high requirements for time accuracy, the time unit of t can be unified as seconds. In application scenarios with low requirements for time accuracy, t can also choose other time units and unify the time units through conversion.
[0059] The above formula is only one embodiment of the present invention. In different embodiments of the present invention, the allowable error, error rate and time interval from the last time synchronization can also be substituted into other calculation formulas to calculate the time quality, which will be specifically described in subsequent embodiments. According to the above formula, the lower the error rate of the local terminal and the server, the higher the time quality of the local terminal and the server.
[0060] After respectively obtaining the time quality of the local end and the time quality of the server, in step S103, the time quality of the local end and the time quality of the server are compared, and in step S104, based on the comparison result, it is determined whether the local end is synchronized according to the server time.
[0061] At present, in a local area network, the process of time synchronization between the local end and the server is simple. Usually, a fixed frequency is set, and the local end directly obtains the current time of the server and replaces it with the local end time. However, this method does not fully consider the situation that the server time may have errors. In special cases, the server time error may be greater than the local end time error, such as an unexpected power outage on the server, or after updating the local end device, the error rate of the local end device is less than the error rate of the server, etc. In this case, if the server time is still used to replace the local end time, it may cause the local end time error to increase, and in the process of this time synchronization, the time error generated cannot be accurately evaluated and measured, and even if a time error beyond the allowable range is generated, it cannot be confirmed in time. This embodiment provides the concept of time quality, points out the fixed values and variables related to time quality, and uses time quality to evaluate the time accuracy of the local end and the time accuracy of the server, and guides the subsequent time synchronization process based on the comparison results.
[0062] Figure 2 The specific process of the local time synchronization method 200 according to the preferred embodiment of the present invention is shown, including a flow chart of the process of judging the local and server time quality. Specifically, in the local time synchronization method 200, steps S201 and S202 are basically the same as steps S101 and S102 in the local time synchronization method 100 in the aforementioned embodiment, and are not repeated here.
[0063] In step S203, it is determined whether the time quality of the local terminal is greater than the time quality of the server. In this embodiment, the time quality decreases as the time interval from the last time synchronization increases. For example, the time quality is calculated by applying the calculation formula in the above embodiment. Preferably, within a preset time range, as the time without time synchronization increases, the time quality gradually decreases. When the preset time range is exceeded, the time quality remains unchanged. For example, when the time quality decreases to a preset minimum value, the time quality remains unchanged at the minimum value. In this step, the time quality of the local terminal and the server is compared to determine the time accuracy of the local terminal and the server.
[0064] When the time quality of the local terminal is greater than the time quality of the server, it means that the time accuracy of the local terminal is greater than the time accuracy of the server. In step S204, the local terminal sends a time synchronization request to the server at a first preset interval, and because the time quality of the local terminal is higher than the time quality of the server, the local terminal time is not updated, that is, the timing of the local terminal is retained. Of course, the time quality of the local terminal will also decrease as time continues to extend. Then return to step S202, the local terminal sends a time synchronization request to the server at a first preset interval, reconfirms the time quality of the server and the time quality of the local terminal, and repeats the subsequent steps.
[0065] The first preset interval can be set according to the application scenario of the local terminal and the network system. When the time quality of the local terminal is greater than the time quality of the server, the time of the local terminal is more reliable than the time of the server. Therefore, the local terminal can send time synchronization requests to the server at longer time intervals, such as 24 hours.
[0066] Further, according to a preferred embodiment of the present invention, when the time quality of the local terminal is not greater than the time quality of the server, it indicates that the time accuracy of the server is the same as or higher than that of the local terminal. In step S205, the local terminal sends a time synchronization request to the server at a second preset interval, and uses the server's time to update the time of the local terminal. After the local terminal time synchronization is completed, the time quality of the local terminal is updated. For the local terminal, the time interval from the last time synchronization is reduced to 0, the time quality of the local terminal reaches the maximum value, and the timing is restarted. Wherein the second preset interval is not greater than the aforementioned first preset interval, the time quality of the server is greater than the time quality of the local terminal, and the local terminal can be controlled to send a time synchronization request at a shorter time interval. Similarly, after determining in step S205 that the local terminal sends a time synchronization request to the server at the second preset interval, return to step S202, reconfirm the time quality of the server and the time quality of the local terminal, and continue to execute subsequent steps.
[0067] In this embodiment, the time quality is used to indicate the time accuracy. For example, if the time quality of the local terminal is greater than the time quality of the server, it indicates that the time accuracy of the local terminal is greater than the time accuracy of the server. When the time quality of the local terminal is not greater than the time quality of the server, it indicates that the time of the server is trustworthy, and a time synchronization request can be sent to the server at a shorter time interval.
[0068] Specifically, the larger the server's time quality value is, the higher the server's time accuracy is. According to the calculation formula that the time quality is negatively correlated with the time interval from the last time synchronization, the time quality decreases as the time interval of time synchronization increases. When the server's time quality value is high, the server's time quality will remain at a high value for a longer time, and a longer time interval can be selected to send a time synchronization request. When the server's time quality value is low, the corresponding server's time accuracy is low, and a shorter time interval can be selected to send a time synchronization request.
[0069] Specifically, according to a preferred embodiment of the present invention, Figure 3 A local time synchronization method 300 is shown, which specifically includes a process of controlling the local end to issue a time synchronization request according to the time quality value of the server, wherein different steps are performed when the time quality of the server is within different value ranges. In the local time synchronization method 300, steps S301, S302, S303 and S304 are basically the same as steps S201, S202, S203 and S204 in the local time synchronization method 200 in the aforementioned embodiment, and are not described in detail.
[0070] In this embodiment, the server time quality can be divided into three ranges using a first threshold and a second threshold, wherein the second threshold is greater than the first threshold, such as a single range from the minimum value or infinitesimal of the server time quality to the first threshold, from the first threshold to the second threshold, and from the second threshold to the maximum value or infinity of the server time quality.
[0071] When the time quality of the local terminal is not greater than the time quality of the server, it is determined whether the time quality value of the server is less than the first threshold value. When the time quality of the server is less than the first threshold value, in step S305, the local terminal sends a time synchronization request to the server at a third preset interval, and does not update the time of the local terminal, and then returns to step S302, and reconfirms the time quality of the server and the time quality of the local terminal after the third preset interval. In this case, although the time quality of the server is higher than the time quality of the local terminal, when the time quality value of the server is low, it is considered that the time accuracy of the server is insufficient. In this embodiment, the time of the server is not used to update the time of the local terminal, and a time synchronization request is sent to the server at a shorter time interval to complete the time synchronization of the local terminal as soon as possible. Specifically, the third preset interval is, for example, 5 minutes.
[0072] According to a preferred embodiment of the present invention, when the time quality of the server is not less than the first threshold value and not greater than the second threshold value, in step S306, the local end sends a time synchronization request to the server at a fourth preset interval, and uses the server time to update the time of the local end, and updates the time quality of the local end, that is, recalculates the time interval between the local end and the last time synchronization. After the fourth preset interval, return to step S302, re-determine the time quality of the server and the time quality of the local end, and continue to execute subsequent steps. In this case, the time quality of the server is greater than the time quality of the local end, and the time quality of the server is maintained within a relatively high range, which can extend the time for the local end to send a time synchronization request to the server and reduce the occupation of communication resources, that is, the fourth preset interval is greater than the third preset interval. Specifically, the fourth preset interval is, for example, 12 hours.
[0073] When the time quality of the server is greater than the second threshold, in step S307, the local end sends a time synchronization request to the server at the fifth preset interval, and uses the server's time to update the local end's time, and updates the time quality of the local end. After the fifth preset interval, return to step S302, re-determine the time quality of the server and the time quality of the local end, and continue to execute subsequent steps. In this case, the time quality of the server has a high value, and the time quality of the server can be in a higher range for a period of time. The local end can be controlled to send a time synchronization request to the server at a longer time interval. Specifically, for example, the fifth preset interval is 24 hours. In this embodiment, the third preset interval, the fourth preset interval and the fifth preset interval increase in sequence.
[0074] According to a preferred embodiment of the present invention, the time quality of the local end and the time quality value of the server are set within a closed interval, that is, the value range of the time quality has a maximum value and a minimum value, for example, [0, N], where N can be any number greater than 0, by adjusting the calculation formula of the time quality, or setting conditions, so that the value range of the time quality is within the closed interval [0, N].
[0075] In a specific embodiment of the present invention, for example, N is 100, and the calculation formula of time quality is:
[0076] Q = 100*(1-t / Te),
[0077] The meanings of the letters are the same as those in the calculation formula in the above embodiment. The time units in the above formula are unified, where Te can be understood as the time when the time quality decreases to 0. The value range of Te is determined according to the following formula, and a set value is selected within the range. When Q=0, Q is fixed to 0 and no longer decreases with the increase of t, avoiding the occurrence of negative Q.
[0078] Te≤Tc / e.
[0079] According to the above formula, when the local end has just completed time synchronization with the server, t = 0, Q = 100, and 100 is the maximum value of time quality. When t = Te, Q = 0, and the minimum value of time quality is 0. When t continues to increase and t> Te, Q is set to remain at 0 until the local end and the server synchronize time and reset the value of t, so as to output the time quality result and subsequent calculations.
[0080] Furthermore, when the time quality of the local terminal and the time quality of the server are both 0, the local terminal is set not to perform time synchronization. The time quality of the local terminal and the server is both 0, which means that the accuracy of the time calculated by the local terminal and the server through methods such as crystal oscillator timing is extremely low and cannot be trusted. In actual production, time synchronization may not be performed for a long time, or the equipment line may be damaged. In this case, time synchronization is not performed on the local terminal. Preferably, an error indication signal can also be issued, and the technicians will perform time synchronization after troubleshooting.
[0081] like Figure 4 As shown, in a preferred embodiment of the present invention, the local time synchronization method 400 also includes a process of determining the quality of signal transmission between the local end and the server. Specifically, Figure 4The specific process of the local time synchronization method 400 according to the preferred embodiment of the present invention is shown, wherein steps S401, S403, S405, S406 and S407 are respectively substantially the same as steps S201, S202, S203, S204 and S205 in the local time synchronization method 200 in the aforementioned embodiment, and are not described in detail.
[0082] In step S402, it is determined whether the server has received the time synchronization request. In step S404, it is determined whether the time quality of the server has been received, so as to check the communication quality between the local end and the server. Further, according to a preferred embodiment of the present invention, a threshold for disconnection of communication between the local end and the server can be set. For example, in step S402, if the server has not received the time synchronization request, it returns to step S401 and controls the local end to reissue the time synchronization request. When the number of cycles of step S401 and step S402 exceeds 3 times, that is, the time synchronization request is sent to the server for 3 consecutive times and the server has not received it, the cycle is stopped and it is considered that the communication between the local end and the server has failed. Similarly, in step S404, it is determined whether the time quality of the server has been received. When the time quality of the server has not been received, it returns to step S403. Similarly, when the cycle of step S403 and step S404 exceeds a certain number of times, for example, 3 times, the cycle is stopped and an error is reported. In different embodiments of the present invention, only one of step S402 and step S404 can be executed, or both can be executed. Figure 4 As shown, step S402 and step S404 are executed.
[0083] like Figure 5 As shown, the present invention also includes an embodiment of a local terminal 10, the local terminal 10 communicates with the server 20, for example, the local terminal 10 establishes a connection with the server 20 through various means such as Bluetooth, WLAN, etc., and can send a time synchronization request to the server 20, wherein the local terminal 10 has a local terminal time, and the local terminal 10 can be a device with a time display function, or a device that does not display a specific time but needs to record the time, such as a device that needs to output content with time information, etc., specifically, a circuit breaker in a power distribution system, etc.
[0084] The server 20 also has server time, and the server 20 communicates with the upper network (not shown in the figure), and can adjust and calibrate the time of the server 20 according to the time of the upper network, or synchronize the server time using the local end time synchronization method in the above-mentioned embodiment, for example, the server is regarded as the local end in the upper network. The time of the server 20 can be updated at a preset frequency, and the time calibration conditions can also be set. When the conditions are met, the time of the server 20 is updated.
[0085] Further, according to a preferred embodiment of the present invention, the local terminal 10 and the server 20 are connected via a network connector 30, and the local terminal 10 can send a time synchronization request to the server 20 via the network connector 30. Specifically, the network connector 30 can be a gateway, a router, a switch, etc. In a network system 1, one or more local terminals 10 can be included, and the multiple local terminals 10 can be directly connected to the server, or connected to the server 20 via the network connector 30, and the time and time quality between the multiple local terminals 10 and the time of requesting time synchronization do not affect each other.
[0086] In this embodiment, the local terminal 10 can execute the local terminal time synchronization method as described in the above embodiment to determine the time interval for the local terminal 10 to send a time synchronization request to the server 20. Since the timing accuracy of the local terminal 10 is limited, errors will inevitably occur, and as time goes on, the errors may accumulate and continue to increase, affecting the normal use of the functions of the local terminal 10. Therefore, after a period of time, the local terminal 10 sends a time synchronization request to the server 20, and performs time synchronization according to the local terminal time synchronization method in the above embodiment. The device that specifically executes the local terminal time synchronization method in the above embodiment can be the local terminal 10 itself, or it can be the network connector 30.
[0087] like Figure 6 As shown, according to a preferred embodiment of the present invention, the local end 10 includes a mainboard 11 and a communication board 12, wherein the mainboard 11 includes a processor 111, for example, for realizing the functions of the local end 10, or executing the local end time synchronization method in the aforementioned embodiment. The communication board 12 includes a communication interface 121 and a communication chip 122, and the communication interface 121 and the communication chip 122 are connected by signal, and the communication chip 122 is connected to the processor 111 through a connector 13, for example, the connector 13 is a pin interface of standard specifications. The communication interface 121 is connected to the server 20 by signal.
[0088] In this embodiment, the mainboard 11 and the communication board 12 are separately provided to improve the application scope of the communication board 12, avoid binding the mainboard 11 and the communication protocol, and the communication board 12 can be integrated with chips of different communication protocols to improve the application scope of the local end 10. Specifically, the network connector 30 supports the ZigBee communication protocol, for example, the network connector 30 can be a ZigBee gateway, and correspondingly, the communication interface 121 can be a ZigBee antenna. The traditional frame-type circuit breaker as the local end 10 realizes data exchange based on ASCII (American Standard Information Interchange Code), does not have the ZigBee communication function, and has poor compatibility. The circuit breaker can communicate with the ZigBee device through the ZigBee antenna and the ZigBee gateway.
[0089] The present invention also includes a computer-readable storage medium, including computer executable commands stored thereon. When the executable commands are executed by a processor, the local time synchronization method described in the aforementioned embodiment is implemented. Specifically, the computer-readable storage medium is, for example, a hard disk, a disk, a tape, etc.
[0090] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A local time synchronization method, include: The local end sends a time synchronization request to the server at a preset time interval, and the server can update the server time according to the upper network; Generate server time quality and local time quality; Compare the local time quality with the server time quality; According to the comparison result of the time quality of the local end and the time quality of the server, determine whether the local end is synchronized with the time of the server; The time quality decreases as the time interval from the last time synchronization increases.
2. The local time synchronization method according to claim 1, wherein the time quality is calculated based on the allowable error, the error rate and the time interval from the last time synchronization.
3. The local time synchronization method according to claim 2, wherein the step of determining whether the local end is to be synchronized with the server time according to the comparison result of the local time quality and the server time quality is include: Determine whether the local time quality is greater than the server time quality; When the time quality of the local terminal is greater than the time quality of the server, the local terminal sends a time synchronization request to the server at a first preset interval and does not update the time of the local terminal.
4. According to the local time synchronization method described in claim 3, when the time quality of the local end is not greater than the time quality of the server, the local end sends a time synchronization request to the server at a second preset interval, uses the server time to update the local time, and updates the local time quality; wherein the second preset interval is not greater than the first preset interval.
5. The local time synchronization method according to claim 3, further comprising: include: When the time quality of the local end is not greater than the time quality of the server, and the time quality of the server is less than a first threshold; The local end sends a time synchronization request to the server at a third preset interval, and does not update the time of the local end.
6. The local time synchronization method according to claim 5, further comprising: include: When the time quality of the server is not less than the first threshold and not greater than the second threshold, the local end sends a time synchronization request to the server at a fourth preset interval, updates the time of the local end with the time of the server, and updates the time quality of the local end; When the time quality of the server is greater than the second threshold, the local end sends a time synchronization request to the server at a fifth preset interval, updates the time of the local end using the time of the server, and updates the time quality of the local end; The fifth preset interval is greater than the fourth preset interval, and the fifth preset interval is not greater than the first preset interval.
7. According to the local time synchronization method described in claim 2, the value range of the time quality is adjusted to a closed interval [0, N], wherein N is a preset value greater than 0, and after the local time synchronization with the server is completed, the time quality of the local end is N; when the time quality of the local end is 0, the time quality of the local end remains 0 until the local end is synchronized with the server.
8. The local time synchronization method according to claim 7, wherein when the time quality of the local terminal and the time quality of the server are both 0, the local terminal does not perform time synchronization.
9. The local time synchronization method according to any one of claims 1-8, wherein the error rate of the local end and the error rate of the server are independent of each other, and the error rate is caused by software and / or hardware errors and can be obtained through calibration measurements.
10. The local time synchronization method according to any one of claims 1 to 8, further comprising: include: Determine whether the server receives a time synchronization request; and / or Determines whether the server time quality is received.
11. A local terminal that communicates with a server and can send a time synchronization request to the server, the local terminal has a local terminal time, the server has a server time, the server communicates with an upper-level network and can update the server time using the upper-level network; the local terminal is configured to be able to execute the local terminal time synchronization method described in any one of claims 1-10.
12. The local terminal according to claim 11, include: a motherboard, the motherboard comprising a processor; and A communication board, wherein the communication board comprises a communication interface and a communication chip for signal connection, the communication chip and the processor are connected via a connector, and the communication interface communicates with the server.
13. The local terminal according to claim 12, wherein the communication interface is connected to the server via a network connector, the network connector supports ZigBee communication protocol, and the communication interface is a ZigBee antenna.
14. A computer-readable storage medium, comprising computer executable commands stored thereon, wherein the executable commands, when executed by a processor, implement the local time synchronization method according to any one of claims 1 to 10.
