Clock delay compensation method based on equipment heartbeat signal automatic verification

By calculating the heartbeat message timestamps on the terminal and main station side of the device, the clock deviation and network delay are dynamically calculated, clock timing and compensation are realized, and the problem of insufficient clock delay compensation in the existing technology is solved, and the accuracy of the clock is improved Sex and management refinement.

CN119030648APending Publication Date: 2024-11-26STATE GRID SHANGHAI MUNICIPAL ELECTRIC POWER CO +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410973648.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

The existing clock management method cannot effectively compensate clock delays when channel congestion, resulting in unnecessary deviations in the device clock, and the compensation method is fixed, making it impossible to adapt to the real-time changing channel network situation.

Method used

By obtaining the time stamps of heartbeat messages on the terminal side of the device and the main station side, calculating network delay and clock deviation, using dynamic compensation method for clock calibration, the filtering algorithm is used to select the most accurate clock synchronization from multiple sets of data to achieve real-time Clock delay calculation and compensation.

Benefits of technology

It improves the accuracy of the clock, is suitable for various types of measurement terminals, reduces costs, realizes dynamic supplementation of real-time channel delays, and improves the refinement of clock management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119030648A_ABST
    Figure CN119030648A_ABST
Patent Text Reader

Abstract

The invention relates to the field of power equipment inspection, in particular to a clock delay compensation method based on equipment heartbeat signal automatic verification, which comprises the following steps of: acquiring time information of a clock module of an equipment terminal side, and recording real time when the equipment terminal side sends a heartbeat message to a master station side; recording the time when the master station side receives the heartbeat message of the equipment terminal, immediately writing the local time of the master station side into the heartbeat message, and recording the time when the heartbeat message is sent to the equipment terminal side; recording the time when the equipment terminal side receives the heartbeat message; performing clock delay calculation on the equipment terminal according to the time for receiving and sending the heartbeat message to obtain a delay result; and carrying out a heartbeat timing function according to the time delay result, and carrying out dynamic compensation on the equipment terminal with the delay. Compared with the prior art, the method has the advantages that the channel time delay condition can be calculated in real time, time delay supplement is dynamically completed, and the clock accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of power equipment inspection, and in particular to a clock delay compensation method based on automatic verification of equipment heartbeat signals. Background Art

[0002] Clock synchronization is an important part of the power measurement terminal, which aims to ensure the time synchronization between the device and the master station clock source and provide accurate time information. At present, the master station manages the terminal clock by monitoring and patrolling the terminal clock through the heartbeat mechanism and issuing instructions. The master station uses the heartbeat mechanism to regularly patrol the clock of the terminal device, regularly obtain the terminal clock information, and promptly discover and solve the clock deviation problem, thereby ensuring the accuracy of the terminal clock. The commonly used clock management steps are summarized as regular time synchronization, timeout judgment and automatic time calibration.

[0003] 1. Regular inspections: According to the usage of the equipment and the working environment, a reasonable inspection cycle is formulated to conduct regular inspections of the terminal clocks. The master station analyzes the terminal clock through the heartbeat message and automatically batch-measures the clocks of other terminals on a daily basis. The master station automatically determines the clock deviation and puts the terminal with the clock deviation into the time calibration list.

[0004] 2. Timeout judgment: After the master station times out on the terminal clock patrol task, the master station initiates a command. If the master station does not receive feedback from the terminal within 2 minutes, it is considered that the collection has failed. The message returned after the timeout is not parsed or stored.

[0005] 3. Automatic time calibration: the master station automatically calibrates the terminals in the calibration list and completes the calibration on the same day. After the master station completes the terminal calibration, it needs to confirm whether the calibration is successful. If the calibration fails, repeat the calibration. Terminals that fail to calibrate for three consecutive times and need to be calibrated for two consecutive days will be identified as abnormal terminals, and work orders will be automatically generated for on-site processing.

[0006] However, this method will inevitably include the time that the master station and the device occupy in the channel, resulting in clock delays, especially when the uplink and downlink channels are congested, which will cause unnecessary deviations in the device clock. Although the master station can make certain delay compensation through some parameters, the compensation method relies on expert experience and is often relatively fixed. It cannot be applied to real-time changing channel network conditions or various types of measurement terminals. Summary of the invention

[0007] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a clock delay compensation method based on automatic verification of device heartbeat signal.

[0008] The purpose of the present invention can be achieved by the following technical solutions:

[0009] The present invention provides a clock delay compensation method based on automatic verification of a device heartbeat signal, comprising the following steps:

[0010] S1: Obtain the time information of the clock module of the device terminal side, and record the real time when the device terminal side sends the heartbeat message to the master station side as T1;

[0011] S2: Record the time when the master station receives the heartbeat message from the device terminal as T2, immediately write the local time of the master station into the heartbeat message, and record the time when the heartbeat message is sent to the device terminal as T3;

[0012] S3: Record the time when the device terminal receives the heartbeat message as T4;

[0013] S4: Calculate the clock delay of the device terminal according to the time of receiving and sending the heartbeat message, and obtain the network delay, time deviation and delay result;

[0014] S5: Perform a heartbeat timing function according to the delay result, and dynamically compensate for the device terminal with delay.

[0015] According to the time intervals between T1, T2, T3 and T4, the clock deviation and network delay between the master station and the device terminal are calculated, which can be obtained by the following formula:

[0016] T2-T1 = Offset + Delay1;

[0017] T4-T3 = Delay2-Offset;

[0018] Delay1 = Delay2 = Delay;

[0019] Offset=[(T2—T1)—(T4—T3)] / 2;

[0020] Delay=[(T2-T1)+(T4-T3)] / 2;

[0021] Among them, Delay1 is the network delay in the T1-T2 stage, Delay2 is the network delay in the T3-T4 stage, Offset is the clock deviation, and Delay is the network delay.

[0022] The delay result is obtained according to the sum of the network delay and the time deviation, and is expressed by the following formula:

[0023] K = Delay + Offset;

[0024] Among them, K is the delay result.

[0025] The device terminal side uses a filtering algorithm to select the most accurate set of network delays and clock deviations from multiple sets to synchronize the local clock.

[0026] The heartbeat calibration process includes the following steps:

[0027] S51, after the communication connection is established between the device terminal side and the master station side, heartbeat calibration is performed according to a set period;

[0028] S52, determine whether the clock deviation between the device terminal side and the master station side is less than 10 seconds; if less than, do not start the heartbeat calibration; if not less than, start the heartbeat calibration and proceed to the next step;

[0029] S53, determine whether the clock deviation between the device terminal side and the master station side is less than 5 minutes; if so, proceed to step S53A1; if not, proceed to step S53B1;

[0030] S53A1, accumulating the number of heartbeats through the device terminal side; determining whether the number of heartbeat records is greater than the total number of heartbeat times X1; if greater, proceeding to the next step; if not greater, re-running this step;

[0031] S53A2, read X1 heartbeat times, filter out valid heartbeats that meet the clock deviation and network delay below the threshold, and calculate the delay result K1 of a single heartbeat of the valid heartbeat and the average value K2 of the delay result;

[0032] S53A3, determine whether X1 heartbeats meet the number of valid heartbeats; if not, return to the time synchronization failure, continue to accumulate the number of heartbeats through the device terminal side, and re-run step S53A2; if satisfied, calculate the precise time through the device terminal side time and the average value K2 of the delay result, and synchronize the device terminal side;

[0033] Step S53B1, accumulate 1 frame heartbeat and determine whether the network delay is less than 10 seconds; if not, restart step S51; if less, calculate the precise time through the time on the device terminal side and the average value K2 of the delay result, and synchronize the time on the device terminal side.

[0034] The effective number of heartbeats X5 that must be guaranteed at least after being screened by X2, X3, and X4 is expressed by the following formula:

[0035] X5 = X1-X2-X3-X4;

[0036] Among them, X5 is the number of valid heartbeats, X1 is the total number of heartbeat times, X2 is the number of K1 delay results of the largest single heartbeat that need to be eliminated; X3 is the number of K1 delay results of the smallest single heartbeat that need to be eliminated; X4 is the number of clock deviations and network delays between the terminal side and the master station side that are below the threshold.

[0037] The delay result average value K2 is calculated using the following formula:

[0038]

[0039] Among them, K2 is the average value of the delay result, X5 is the number of valid heartbeats, and K1 is the delay result of a single heartbeat.

[0040] In a second aspect, the present invention provides a computer program product, comprising a computer program / instruction, which implements any of the above-mentioned methods when executed by a processor.

[0041] In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a program stored in the memory, wherein the processor implements any of the above-described methods when executing the program.

[0042] In a fourth aspect, the present invention provides a storage medium having a program stored thereon, wherein the program implements any of the above-described methods when executed.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] 1) The present invention utilizes a dynamic compensation method of a heartbeat clock to achieve real-time calculation of channel delay, dynamically complete delay compensation, and improve clock accuracy.

[0045] 2) After the present invention is expanded, it can be combined with services to calculate the delay of different devices respectively, thereby improving the degree of refined clock management.

[0046] 3) The present invention is completely implemented through program algorithms, does not rely on other hardware, reduces costs, has high portability, and is applicable to various measurement system scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 It is a schematic diagram of the steps of the present invention;

[0048] Figure 2 This is a communication flow chart of the main station server of this embodiment;

[0049] Figure 3 This is a program flow chart of the master station end of this embodiment;

[0050] Figure 4 This is a schematic diagram of network delay and time deviation;

[0051] Figure 5 This is a heartbeat timing logic flow chart of this embodiment;

[0052] Figure 6 This is a diagram of the evaluation index system of the delay optimization solution of this embodiment. DETAILED DESCRIPTION

[0053] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0054] Example 1

[0055] The delay improvement of the clock synchronization of the power collection master station equipment can be mainly started from three aspects, namely the terminal aspect, the channel aspect, and the master station aspect. The present invention selects the optimal solution by constructing a delay improvement solution evaluation index system.

[0056] The key point of establishing the evaluation index of the delay improvement plan is to select appropriate evaluation indicators to ensure the comprehensiveness, scientificity and rationality of the improvement strategy decision. In the process of selecting indicators, it is necessary to meet the basic principles of building an indicator system and the specific requirements for making decisions on the time delay optimization plan. In order to understand the relevant key points of time delay optimization, equipment experts from various equipment manufacturers were consulted, and combined with historical documents and construction plans, the indicator system was divided into effectiveness, operability and reliability.

[0057] Effectiveness is the most intuitive measurement standard. It is mainly measured by four parts: processing speed, link complexity, concurrency and clock source accuracy. Effectiveness starts from basic performance and comprehensively considers various performance indicators that need to be considered in the optimization process. Among them, processing speed mainly considers the performance level and computing speed of the system hardware itself, and link complexity refers to the steps and processes that the system needs to complete in the process of processing information. Concurrency mainly considers the maximum number of processes that the system supports to be executed asynchronously at the same time when the acquisition device reports the message. The clock source accuracy mainly considers the quality of the system's own clock source and whether it can meet the accuracy requirements of the system.

[0058] Operability mainly considers the difficulty of the optimization process itself. An optimization plan with good operability can effectively help save internal and external communication costs and better achieve optimization goals. Operability is mainly composed of four parts: scalability, transformation difficulty, maintenance difficulty, and economic cost. Among them, scalability refers to whether it has scalability in the later stage and is compatible with other types of signals or equipment access. Transformation difficulty refers to the technical difficulty and learning cost involved in the optimization process. Maintenance difficulty refers to the difficulty of operation and maintenance involved after the optimization is completed. Economic cost starts from the basic cost and comprehensively considers various expenses that need to be consumed during the construction process, including labor costs, transformation costs, and operation and maintenance costs.

[0059] Reliability mainly considers the results and feedback after the optimization and improvement. It is mainly considered by four factors: anti-interference ability, equipment failure rate, signal strength, and business busyness. Signal strength and stability directly affect the data collection rate of the collection index; the equipment failure rate mainly considers the equipment stability of the improvement measures; anti-interference ability refers to external factors such as external signal interference, electromagnetic interference, and other carrier frequency interference. The improvement strategy needs to consider these external interference factors and try to minimize or offset various interferences. Business busyness refers to the time-consuming impact caused by busy business periods.

[0060] Step 1: Determine the index weights using the improved AHP method

[0061] (1) Establishing a hierarchical model

[0062] The first layer is set as the target layer, and the second layer can define the decision-making goal and the purpose of solving the problem; the second and third layers are the criterion layer and the sub-criterion layer, which are the first-level evaluation indicators and the second-level evaluation indicators. The sub-criterion layer is the detailed indicator of the criterion layer, and the criterion layer represents a series of judgment criteria established to achieve the goal; the last is the solution layer, which is the alternative delay optimization solution. This paper constructs a delay optimization solution evaluation indicator system from the three dimensions of effectiveness, operability, and reliability, with a total of 12 second-level indicators, and takes the three commonly used alternative solutions as the solution layer, such as Figure 6 shown.

[0063] (2) Establish a three-scale comparison matrix

[0064] The comparison matrix is ​​similar to the judgment matrix. For a certain element of the criterion layer, the relative importance of this layer and its associated lower layer elements is compared. For example, there are four elements under the element B1 effectiveness of the criterion layer, namely C1 processing speed, C2 link complexity, C3 concurrency, and C4 clock source accuracy. A comparison matrix is ​​established for these four elements, as shown in Table 1. Among them, rij represents the importance of Ci and Cj compared with B1. To quantify the data, the 3-scale method is used to establish a comparison matrix, as shown in Table 1.

[0065] Table 1 Comparison matrix

[0066] B1 C1 C2 C3 C4 C1 <![CDATA[r 11 ]]> <![CDATA[r 12 ]]> <![CDATA[r 13 ]]> <![CDATA[r 14 ]]> C2 <![CDATA[r 21 ]]> <![CDATA[r 22 ]]> <![CDATA[r 23 ]]> <![CDATA[r 24 ]]> C3 <![CDATA[r 31 ]]> <![CDATA[r 32 ]]> <![CDATA[r 33 ]]> <![CDATA[r 34 ]]> C4 <![CDATA[r 41 ]]> <![CDATA[r 42 ]]> <![CDATA[r 43 ]]> <![CDATA[r 44 ]]>

[0067] The comparison matrix scale and description

[0068] r ij Represents the importance of the comparison between two factors, where rii is 1. The comparison results are obtained by odd-numbered business experts discussing, evaluating and scoring the indicators. The comparison matrix of C1 to C4 relative to B1 is:

[0069]

[0070] (3) Establish judgment matrix B

[0071] Assumption b ij is the element of the judgment matrix, then define in The judgment matrix can be calculated

[0072] (4) Establish the optimal transfer matrix C

[0073] Given the judgment matrix B, the optimal transfer matrix C can be established through the judgment matrix, and the definition The calculation can be obtained:

[0074] (5) Calculate the weight of each factor

[0075] Given the quasi-optimal consistent matrix D, calculate the eigenvector corresponding to its maximum eigenvalue, and then normalize it to get the weight w of each secondary indicator. The Python tool np.linalg.eig() function can be used to calculate the maximum eigenvalue λ1=4.0000, and the corresponding eigenvector is T1=(0.1233, 0.6684, 0.6684, 0.3020)T. After normalizing the eigenvector, w1=(0.0700, 0.3793, 0.3793, 0.1714) is obtained. According to the same algorithm, C5~C8 are calculated, and the weights of C5~C8 relative to B2 are w2=(0.0772, 0.4017, 0.1194, 0.4017). Similarly, the weights of C9~C12 relative to B3 are w3=(0.1091, 0.4571, 0.3247, 0.1091). The weights of B1, B2, and B3 relative to the target layer A are w=(0.2583, 0.1047, 0.6370).

[0076] Therefore, the weight of each secondary indicator relative to A is obtained, W 1×12=(0.0181, 0.0980, 0.0980, 0.0443, 0.0081, 0.0421, 0.0125, 0.0421, 0.0695, 0.2912, 0.2068, 0.0695), the corresponding weights of the secondary indicators are shown in Table 2:

[0077] Table 2 Secondary index weights

[0078]

[0079] Step 2: Index processing based on TOPSIS

[0080] (6) Calculation of the positive and negative ideal solutions of the indicators

[0081] Use the expert scoring method to score each secondary indicator of each alternative plan, substitute the score into the decision matrix, process it in the same trend, and perform weighted calculation according to the required weight to obtain the ideal solution S+ and the negative ideal solution S-, as shown in Table 3:

[0082] Table 3 Ideal solution and negative ideal solution

[0083] index C1 C2 C3 C4 C5 C6 Ideal solution 0.57735 0.57734 0.63959 0.77458 0.78445 0.68823 Negative ideal solution 0.00005773 0.00001924 0.00002132 0.00002582 0.00001961 0.00002294 index C7 C8 C9 C10 C11 C12 Ideal solution 0.71841 0.63244 0.89441 0.74998 0.60301 0.94867 Negative ideal solution 0.00001796 0.00003162 0.00004472 0.000025 0.00003015 0.00003162

[0084] (7) Calculate the comprehensive score of each solution

[0085] Calculate the positive ideal solution distance D+ and negative ideal solution distance D- of each delay improvement solution. The distance from the solution to the positive ideal solution is

[0086]

[0087] The distance from the solution to the negative ideal solution is

[0088]

[0089] Calculate the relative closeness index m,

[0090]

[0091] According to m i The calculation shows that the examples of each scheme to positive and negative ideal solutions are shown in Table 4:

[0092] Table 4 Distances of each solution to positive and negative ideal solutions

[0093] plan Positive ideal solution distance (D+) Negative ideal solution distance (D-) Comprehensive score index Sorting Channel Enhancement 0.12554563 0.67645052 0.84345857 1 Terminal promotion 0.47398675 0.45197633 0.48811485 2 Main station upgrade 0.47967138 0.34612718 0.41914238 3

[0094] According to the size of mi, the optimal channel enhancement scheme is selected. In terms of comprehensive evaluation, channel enhancement is the best scheme, and the priority of the schemes adopted on site is "channel enhancement scheme - terminal enhancement scheme - master station enhancement scheme".

[0095] Based on the calculation results, this embodiment provides a clock delay compensation method based on automatic verification of device heartbeat signals, such as Figure 1 As shown, the method comprises the following steps:

[0096] S1: The device terminal obtains time information based on its own clock module, packages the heartbeat signal message and sends it to the acquisition master station. The actual time when the terminal sends the heartbeat message to the master station is recorded as T1.

[0097] S2: Record the time when the master station receives the heartbeat message from the device terminal as T2, immediately write the local time of the master station into the heartbeat message, and record the time when the heartbeat message is sent to the device terminal as T3.

[0098] S3: Record the time when the device terminal receives the heartbeat message as T4.

[0099] S4: Calculate the clock delay of the device terminal according to the time of receiving and sending the heartbeat message, and obtain the network delay, time deviation and delay results.

[0100] Specifically, the principle of calculating network delay and time deviation is as follows Figure 4 As shown:

[0101] Assume that the time difference between the master station side and the device terminal side is Offset, then

[0102] T2—T1=Offset+Delay1.............(1)

[0103] T3—Offset+Delay2=T4.............(2)

[0104] T4—T3=Delay2–Offset.............(3)

[0105] Wherein, Delay1 is the network delay in the offset measurement phase, and Delay2 is the network delay in the delay measurement phase.

[0106] Assuming that the network delay Delay1 in the offset measurement phase is equal to Delay2 in the delay measurement phase, formula (4) is obtained:

[0107] Delay1=Delay2=Delay.............(4)

[0108] The network delay Delay and time offset Offset can be obtained as shown in formulas (5) and (6):

[0109] Delay=[(T2—T1)+(T4—T3)] / 2......(5)

[0110] Offset=[(T2—T1)—(T4—T3)] / 2......(6)

[0111] The overall delay is K, as shown in formula (7):

[0112] K=Delay+Offset.........(7)

[0113] S5: Carry out the heartbeat timing process according to the delay result, and dynamically compensate the device terminal with delay. In the specific heartbeat timing process, the overall delay K on the device terminal side can be obtained by the average value K2 of the delay result of a single heartbeat, that is, K2 can be used as the overall delay K on the device terminal side.

[0114] Specifically, the main responsibility of the terminal side is to send a heartbeat message to the master station side, and the master station side calculates the heartbeat message, obtains the local clock deviation and network delay, and adjusts the local clock. In this embodiment, the terminal side is also referred to as the client. Each returned message contains four timestamps, and the time deviation and network delay are calculated based on the four timestamps. Each synchronization process requires multiple heartbeat message exchanges, and each time a set of network delay and clock deviation can be obtained. The client uses a filtering algorithm to select the most accurate set from multiple sets of network delays and clock deviations to synchronize the local clock.

[0115] The master station service includes five parts: serial port data processing, local clock update, time data processing, request reception and response sending. Therefore, the master station side is also called the server. The serial port data processing part is used to communicate with the external time source through the serial port and the network time server to obtain the standard time information of the external standard time source. The local clock update part updates the local clock of the network time server according to the standard time data of the external time source. The time data processing part processes the time data based on the network time protocol. The request reception part is used to receive the time calibration request of the user device. The response sending part is used to send the standard time information to the terminal side.

[0116] like Figure 2 As shown in FIG. 1 , the communication process of the master station side of this embodiment includes the following processes:

[0117] 1. Establish a server Socket connection.

[0118] 2. Determine whether the request from the device terminal has arrived. If not, continue to monitor and wait for the device request, and re-determine whether the user device request has arrived.

[0119] 3. If it arrives, when the client device sends a clock request, the latest clock information is packaged according to the clock source information.

[0120] 4. Establish a connection with the device terminal side and determine whether the communication is completed. If not, then determine whether there is a waiting timeout. If there is a communication delay, the communication fails and the process ends. If not, re-determine whether the communication is completed.

[0121] 5. If the communication is completed, the latest clock packaging information is fed back and the socket is closed, and the process ends.

[0122] 6. Feedback the clock packaging information to the device terminal side.

[0123] The main responsibility of the master station is to read the standard time pulse from the atomic clock group and provide accurate time services to the terminal side. In order to ensure the accuracy of time, the master station needs to write the local time into the message immediately when receiving and sending the message. Figure 3 As shown, the program flow of the master station of this embodiment includes the following processes:

[0124] 1. After the server completes network initialization, it searches for the clock source signal;

[0125] 2. Complete the local clock setting according to the clock source signal;

[0126] 3. Wait for the request message from the user equipment terminal side;

[0127] 4. When receiving a message request, record the time when the message is received;

[0128] 5. The server assembles the return message;

[0129] 6. Encapsulate the return message and send it back to the user equipment terminal to complete the request interaction.

[0130] S3: Use the device heartbeat signal to calculate the clock delay of the terminal and obtain the delay result;

[0131] S4: Use the clock delay calculation result to dynamically compensate the terminal device under test.

[0132] Specifically, the terminal turns on the heartbeat time calibration function. The terminal calculates the deviation from the master station clock through heartbeat interaction with the master station, thereby calibrating its own clock. Figure 5 The figure shows the process of heartbeat calibration, which includes the following steps:

[0133] W1. Establish a communication connection between the terminal side and the main station side, and carry out the heartbeat timing interaction process according to the default cycle; in this embodiment, the default cycle is set to 5 minutes.

[0134] W2. When the clock error between the terminal side and the master side is less than 10 seconds, the default heartbeat time synchronization is not enabled. When the clock error between the terminal side and the master side is greater than 10 seconds, the subsequent heartbeat time synchronization mechanism is enabled.

[0135] W3. Determine whether the clock error between the terminal side and the master station side is less than 5 minutes. If so, proceed to step W3A1; if not, proceed to step W3B1;

[0136] W3A1. Accumulate the number of heartbeats through the device terminal side; determine whether the number of heartbeat records is greater than the total number of heartbeat times X1; if greater, proceed to the next step; if not, re-run this step;

[0137] W3A2, read X1 heartbeat times, filter out valid heartbeats that meet the clock deviation and network delay thresholds, and calculate the delay result K1 of a single heartbeat of the valid heartbeat and the average delay result K2;

[0138] W3A3, determine whether X1 heartbeats meet the number of valid heartbeats X5; if not, return to the time synchronization failure, continue to accumulate the number of heartbeats through the device terminal side, and re-run step W3A2; if satisfied, calculate the precise time through the device terminal side time and the average value of the delay result K2, and synchronize the device terminal side; (the total number of heartbeat times X1 is configurable. In this embodiment, the total number is not less than 3, the valid number is not less than 1, and the synchronization cycle is guaranteed to be at least once a day. When the valid heartbeat is met, the average value of the delay result K2 is taken for clock compensation calculation.)

[0139] W3B1. If it is not less than, accumulate 1 frame heartbeat to determine whether the network delay is less than 10 seconds; if it is not less than, restart step W1; if it is less than, calculate the precise time through the time on the device terminal side and the average value K2 of the delay result, and synchronize the time on the device terminal side.

[0140] Among them, X1 is the total number of heartbeat times to be selected; X2 is the number of K1 delay results of the largest single heartbeat to be eliminated; X3 is the number of K1 delay results of the smallest single heartbeat to be eliminated; X4 is the number of clock deviations and network delays between the terminal side and the master side that are below the threshold. X5 is the minimum number of valid times to be guaranteed after screening by X2, X3, and X4. Only when it is greater than this number can it be counted, otherwise it returns failure.

[0141] X5=X1-X2-X3-X4

[0142] Furthermore, the average value K2 of the delay result is obtained by the following formula:

[0143]

[0144] Among them, K2 is the average value of the delay result, X5 is the number of valid heartbeats, and K1 is the delay result of a single heartbeat.

[0145] Example 2

[0146] This embodiment provides a computer program product, including a computer program / instruction, which implements the method mentioned in the above embodiment when executed by a processor.

[0147] This embodiment provides an electronic device, including a memory, a processor, and a program stored in the memory, and the processor implements the method mentioned in the above embodiment when executing the program.

[0148] This embodiment provides a storage medium on which a program is stored, and when the program is executed, the method mentioned in the above embodiment is implemented. The same content as in Example 1 is not repeated here. The difference from Example 1 is that this embodiment provides a hardware device, which is an important carrier for implementing the method of Example 1, wherein the storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.

[0149] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A clock delay compensation method based on automatic verification of device heartbeat signal, characterized in that: The following steps are involved: S1: Obtain the time information of the clock module of the device terminal side, and record the real time when the device terminal side sends the heartbeat message to the master station side as T1; S2: Record the time when the master station receives the heartbeat message from the device terminal as T2, immediately write the local time of the master station into the heartbeat message, and record the time when the heartbeat message is sent to the device terminal as T3; S3: Record the time when the device terminal receives the heartbeat message as T4; S4: Calculate the clock delay of the device terminal according to the time of receiving and sending the heartbeat message, and obtain network delay, time deviation and delay results; S5: Perform a heartbeat timing function according to the delay result, and dynamically compensate for the device terminal with delay.

2. According to claim 1, a clock delay compensation method based on automatic verification of device heartbeat signal is characterized in that: According to the time intervals between T1, T2, T3 and T4, the clock deviation and network delay between the master station and the device terminal are calculated, which can be obtained by the following formula: T2-T1 = Offset + Delay1; T4-T3 = Delay2-Offset; Delay1 = Delay2 = Delay; Offset=[(T2—T1)—(T4—T3)] / 2; Delay=[(T2-T1)+(T4-T3)] / 2; Among them, Delay1 is the network delay in the T1-T2 stage, Delay2 is the network delay in the T3-T4 stage, Offset is the clock deviation, and Delay is the network delay.

3. The method for detecting anomalies of clock delay automatic verification based on device heartbeat signal according to claim 2, characterized in that: The delay result is obtained according to the sum of the network delay and the time deviation, and is expressed by the following formula: K = Delay + Offset; Among them, K is the delay result.

4. A clock delay compensation method based on automatic verification of device heartbeat signal according to claim 2, characterized in that: The device terminal side uses a filtering algorithm to select the most accurate set of network delays and clock deviations from multiple sets to synchronize the local clock.

5. A clock delay compensation method based on automatic verification of device heartbeat signal according to claim 1, characterized in that: The heartbeat calibration process includes the following steps: S51, after the communication connection is established between the device terminal side and the master station side, heartbeat calibration is performed according to a set period; S52, determining whether the clock deviation between the device terminal side and the master station side is less than 10 seconds; If it is less than, the heartbeat calibration will not be started; if it is not less than, the heartbeat calibration will be started and the next step will be performed; S53, determine whether the clock deviation between the device terminal side and the master station side is less than 5 minutes; if so, proceed to step S53A1; if not, proceed to step S53B1; S53A1, accumulating the number of heartbeats through the device terminal side; determining whether the number of heartbeat records is greater than the total number of heartbeat times X1; if greater, proceeding to the next step; If not, rerun the step; S53A2, read X1 heartbeat times, filter out valid heartbeats that meet the clock deviation and network delay below the threshold, and calculate the delay result K1 of a single heartbeat of the valid heartbeat and the average value K2 of the delay result; S53A3, determine whether X1 heartbeats meet the number of valid heartbeats; if not, return to the time synchronization failure, continue to accumulate the number of heartbeats through the device terminal side, and re-run step S53A2; if satisfied, calculate the precise time through the device terminal side time and the average value K2 of the delay result, and synchronize the device terminal side; Step S53B1, accumulate one heartbeat frame and determine whether the network delay is less than 10 seconds; If it is not less than, restart step S51; if it is less than, calculate the precise time through the time on the device terminal side and the average value K2 of the delay result, and synchronize the time on the device terminal side.

6. A clock delay compensation method based on automatic verification of device heartbeat signal according to claim 5, characterized in that: The effective number of heartbeats X5 that must be guaranteed at least after being screened by X2, X3, and X4 is expressed by the following formula: X5 = X1-X2-X3-X4; Among them, X5 is the number of valid heartbeats, X1 is the total number of heartbeat times, X2 is the number of K1 delay results of the largest single heartbeat that need to be eliminated; X3 is the number of K1 delay results of the smallest single heartbeat that need to be eliminated; X4 is the number of clock deviations and network delays between the terminal side and the master station side that are below the threshold.

7. A clock delay compensation method based on automatic verification of device heartbeat signal according to claim 6, characterized in that: The delay result average value K2 is calculated using the following formula: Among them, K2 is the average value of the delay result, X5 is the number of valid heartbeats, and K1 is the delay result of a single heartbeat.

8. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.

9. An electronic device comprising a memory, a processor, and a program stored in the memory, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A storage medium having a program stored thereon, characterized in that: When the program is executed, the method according to any one of claims 1 to 7 is implemented.