Summary of the invention
Based on this, it is necessary in view of the above technical problems, provide one kind and be able to solve existing clock synchronization mechanism and be unable to satisfy greatly
Clock synchronizing method, device, computer equipment and the storage medium of the electric energy meter of the problem of requirement that scale second grade synchronizes.
A kind of clock synchronizing method of electric energy meter, which comprises
Absolute time is obtained, according to the absolute time to internal clocking clock synchronization;
The first clock synchronization message, Yi Ji are sent to electric energy meter in first time by the electric energy meter communication protocol of physical link
Second time received the second clock synchronization message of electric energy meter feedback;The first time, the time that the second time was internal clocking;
According to the first time, second time and propagation delay time, the processing of the first clock synchronization message is obtained
Time delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking time,
Obtain prover time;
Message is calibrated to the electric energy meter sending time, includes the prover time in the time calibration message, with right
The local clock of the electric energy meter is synchronous;
Wherein, described according to the first time, second time and propagation delay time, obtain first pair of Times
The processing delay of text, comprising:
Obtain the first message length of the first clock synchronization message, the baud rate of the physical link and first pair described
When message code length in a communication link, according to first message length, the baud rate of the physical link and institute
The code length of the first clock synchronization message in a communication link is stated, the propagation delay time of the first clock synchronization message is obtained;
The second message length for obtaining the second clock synchronization message, according to second message length and the physics chain
The code length of the baud rate on road and the second clock synchronization message in a communication link, obtains the biography of the second clock synchronization message
Defeated time delay;
The calculation formula of the processing delay of the first clock synchronization message is as follows:
Dt3=T2-T1-dt1-dt2
Wherein, dt1 indicates the propagation delay time of the first clock synchronization message, and dt2 indicates the transmission of the second clock synchronization message
Time delay, T1 indicate the first time, and T2 indicates second time, and dt3 indicates the processing delay of the first clock synchronization message.
The clock synchronizing method of above-mentioned electric energy meter, by obtaining accurate absolute time, to internal clock counter clock synchronization,
To realize subsequent accurate timing, the first clock synchronization message, electricity are then sent in first time by pre-set communications protocol
Energy table feeds back the second clock synchronization message after receiving the first clock synchronization message, and record is received the second time of the second message, combined with this
The propagation delay time of message calculates electric energy meter to the processing delay of message, and then the local clock of electric energy meter can be calculated
Prover time, so that the local clock to realize electric energy meter is synchronous by calibrating message to electric energy meter sending time.The present invention
Embodiment enables the local clock of electric energy meter by accurate clock source and consideration message transmissions and the time delay of processing
Meet the requirement of second grade.
In one of the embodiments, further include: when decompression the second clock synchronization message obtains the local of the electric energy meter
The third time of clock;According to second time, third time and propagation delay time, obtain the electric energy meter local clock when
Between error;Judge that the time error whether in pre-set time range, judges whether the local to electric energy meter with this
Clock is synchronous.
In one of the embodiments, further include: the calculation formula of the time error of the electric energy meter local clock are as follows:
Dt0=T3+dt2-T2
Wherein, dt0 indicates the time error of the electric energy meter local clock, and T2 indicated for the second time, when T3 indicates third
Between, dt2 indicates propagation delay time.
In one of the embodiments, further include: by the electric energy meter communications protocol of physical link, in first time to electricity
Energy table sends the first clock synchronization message for meeting electric energy meter communications protocol and meets electricity in the second time reception electric energy meter feedback
It can table communications protocol the second clock synchronization message;The second clock synchronization message is handled, is obtained in the second clock synchronization message comprising described
The third time of the local clock of electric energy meter.
The calculation formula of the propagation delay time dt1 of the first clock synchronization message is as follows in one of the embodiments: dt1=
(baud rate of the physical link/code length of first clock synchronization message in a communication link)/first pair of Times
First message length of text;
The calculation formula of the propagation delay time dt2 of the second clock synchronization message is as follows: the dt1=(baud of the physical link
Rate/the code length of second clock synchronization message in a communication link)/the second clock synchronization message the second message length.
In one of the embodiments, further include: obtain the message built-up time and time calibration message in advance
Message length, according to the message length of the time calibration message, the baud rate of the physical link and time calibration message
Code length in a communication link obtains the propagation delay time of the time calibration message;The time calibration message alignment
The calculation formula of time are as follows:
T5=T4+dt3+dt4+dt5
Wherein, T5 indicates the prover time in the time calibration message, and T4 is that internal clocking record sends the time
It calibrates the time of message, the dt4 indicates the propagation delay time of the time calibration message, and dt5 indicates predetermined message group
ETL estimated time of loading.
In one of the embodiments, further include: obtain absolute time from a base station;Or, obtain multiple base stations when
Between, selected from the time of multiple base stations one as the absolute time;Or, being obtained by internal GPS module or Beidou module
Take absolute time.
A kind of clock synchronization apparatus of electric energy meter, described device include:
Internal clock synchronization module, for obtaining absolute time, according to the absolute time to internal clocking clock synchronization;
Packet sending and receiving module, for sending the to electric energy meter in first time by the electric energy meter communication protocol of physical link
Message when a pair of of, and the second clock synchronization message that electric energy meter is fed back is received in the second time;The first time, the second time is
The time of internal clocking;
Time-delay calculation module, for according to the first time, second time and propagation delay time, obtaining described the
The processing delay of message when a pair of of;According to the processing delay, propagation delay time, predetermined message built-up time and described
The time of internal clocking, obtain prover time;
Clock synchronization module is used to calibrate message to the electric energy meter sending time, includes in the time calibration message
The prover time, it is synchronous with the local clock to the electric energy meter;
The time-delay calculation module is also used to obtain the first message length of the first clock synchronization message, the physical link
Baud rate and the first clock synchronization message code length in a communication link, according to first message length, described
The code length of the baud rate of physical link and the first clock synchronization message in a communication link, obtains first pair of Times
The propagation delay time of text;The second message length for obtaining the second clock synchronization message, according to second message length and described
The code length of the baud rate of physical link and the second clock synchronization message in a communication link, obtains second pair of Times
The propagation delay time of text;The calculation formula of the processing delay of the first clock synchronization message is as follows:
Dt3=T2-T1-dt1-dt2
Wherein, dt1 indicates the propagation delay time of the first clock synchronization message, and dt2 indicates the transmission of the second clock synchronization message
Time delay, T1 indicate the first time, and T2 indicates second time, and dt3 indicates the processing delay of the first clock synchronization message.
A kind of computer equipment, including memory and processor, the memory are stored with computer program, the processing
Device performs the steps of when executing the computer program
Absolute time is obtained, according to the absolute time to internal clocking clock synchronization;
The first clock synchronization message is sent to electric energy meter in first time by pre-set communication protocol, and at second
Between receive electric energy meter feedback the second clock synchronization message;The first time, the time that the second time was internal clocking;
According to the first time, second time and propagation delay time, the processing of the first clock synchronization message is obtained
Time delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking time,
Obtain prover time;
Message is calibrated to the electric energy meter sending time, includes the prover time in the time calibration message, with right
The local clock of the electric energy meter is synchronous.
A kind of computer readable storage medium, is stored thereon with computer program, and the computer program is held by processor
It is performed the steps of when row
Absolute time is obtained, according to the absolute time to internal clocking clock synchronization;
The first clock synchronization message is sent to electric energy meter in first time by pre-set communication protocol, and at second
Between receive electric energy meter feedback the second clock synchronization message;The first time, the time that the second time was internal clocking;
According to the first time, second time and propagation delay time, the processing of the first clock synchronization message is obtained
Time delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking time,
Obtain prover time;
Message is calibrated to the electric energy meter sending time, includes the prover time in the time calibration message, with right
The local clock of the electric energy meter is synchronous.
Clock synchronizing method, device, computer equipment and the storage medium of above-mentioned electric energy meter, by accurate clock source with
And consider the time delay of message transmissions and processing, so that electric energy meter is can satisfy the requirement of second grade.
Specific embodiment
It is with reference to the accompanying drawings and embodiments, right in order to which the objects, technical solutions and advantages of the application are more clearly understood
The application is further elaborated.It should be appreciated that specific embodiment described herein is only used to explain the application, not
For limiting the application.
The clock synchronizing method of electric energy meter provided by the present application can be applied in application environment as shown in Figure 1.Its
In, electric energy meter 102 is communicated by presetting communications protocol interface with clock synchronization terminal 104.Wherein, electric energy meter 102 can be with
Electronic electric energy meter, electric card prepayment meter etc., clock synchronization terminal 104 can have the intelligence for presetting communications protocol interface
Mobile phone, laptop etc..
Wherein, it is integrated with local clock in electric energy meter 102, for the record of the time of itself, the time of electric energy meter business
Demand is provided by the local clock.
Further, clock synchronization terminal 104 includes that perhaps Beidou module is used to obtain absolutely from Beidou or GPS GPS module
Time, if in addition, clock synchronization terminal 104 without GPS module or Beidou module, can also be by communication module from neighbouring one
A base station or multiple base stations obtain absolute time.
In one embodiment, it as shown in Fig. 2, providing a kind of clock synchronizing method of electric energy meter, applies in this way
It is illustrated for clock synchronization terminal in Fig. 1, comprising the following steps:
Step 202, absolute time is obtained, according to the absolute time to internal clocking clock synchronization.
Wherein, absolute time may be considered correct time, it is however generally that, it is stored in GPS system and dipper system
Absolute time.
Specifically, being internal clocking clock synchronization using absolute time, to guarantee clock synchronization after clock synchronization terminal obtains absolute time
The accuracy of terminal inner time.
Step 204, the first clock synchronization message is sent to electric energy meter in first time by pre-set communication protocol, and
The second clock synchronization message of electric energy meter feedback is received in the second time;The first time, the time that the second time was internal clocking.
Wherein, communications protocol can be determined by the connection relationship of electric energy meter and clock synchronization terminal, for example, electric energy meter and clock synchronization are whole
End is connected by RS485 communication interface, then communications protocol can be DL/T645 communications protocol, the present embodiment is not limited to this
Connection type.
Step 206, according to the first time, second time and propagation delay time, first pair of Times is obtained
The processing delay of text;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking
Time, obtain prover time.
Wherein, propagation delay time is transmission time of the message in communication line, in the company for determining electric energy meter and clock synchronization terminal
After connecing mode, the baud rate and message length that can be transmitted according to data are calculated.In addition, processing delay be electric energy meter or
Person's clock synchronization terminal required time when decompressing message.
Step 208, Xiang Suoshu electric energy meter sending time calibrates message, when including the calibration in the time calibration message
Between, it is synchronous with the local clock to the electric energy meter.
In the clock synchronizing method of above-mentioned electric energy meter, by obtaining accurate absolute time, to internal counter pair always
When, to realize subsequent accurate timing, the first clock synchronization message is then sent in first time by pre-set communications protocol,
Electric energy meter feeds back the second clock synchronization message after receiving the first clock synchronization message, and record is received the second time of the second message, tied with this
The propagation delay time for closing message, calculates electric energy meter to the processing delay of message, and then electric energy meter local clock can be calculated
Prover time, thus by electric energy meter sending time calibrate message, to realize the clock synchronization of electric energy meter.The embodiment of the present invention,
By accurate clock source and consideration message transmissions and the time delay of processing, electric energy meter is made to can satisfy the requirement of second grade.
In one embodiment, as shown in figure 3, the method that the clock for providing another electric energy meter synchronizes, this method specifically:
S301 obtains absolute time, according to the absolute time to internal clocking clock synchronization.
In one embodiment, as shown in figure 4, clock synchronization terminal can obtain absolute time from a base station, it is however generally that, base
There are GPS module or Beidou module in standing, therefore, clock synchronization terminal passes through absolute with a base station communication both available base station
Time.
In another embodiment, as shown in figure 5, clock synchronization terminal can obtain absolute time from multiple base stations, then more
One is selected in the time of a base station as absolute time, it is inaccurate when leading to school when thus can be to avoid single base station fault
True problem, specifically, it is whether consistent by comparing multiple base station times, judge the time of most accurate base station, is made with this
For absolute time.
In another embodiment, as shown in fig. 6, including GPS module or Beidou module in clock synchronization terminal, this can be passed through
The GPS module or Beidou module on ground obtain absolute time.
In addition, in one embodiment, internal clocking can be clock counter, the benchmark that clock counter counts is clock synchronization
Terminal CPU internal clocking, to guarantee the accuracy of clock counter timing, by absolute time to clock counter clock synchronization,
Realize the accurate record of time.
S302 sends the first clock synchronization message to electric energy meter in first time by pre-set communication protocol, second
Time receives the second clock synchronization message of electric energy meter feedback, decompresses the second clock synchronization message and obtains the local clock of the electric energy meter
The third time.
In the embodiment of the present invention, at the first time, the second time be to be recorded by internal clocking, the third time is
The time of electric energy meter local clock.
S303, according to the second time, third time and propagation delay time, the time for obtaining the electric energy meter local clock is missed
Difference;Time error is judged whether in pre-set time range, judges whether that carrying out clock to electric energy meter synchronizes with this.
In one embodiment, by third time and propagation delay time, available electric energy meter local clock is at second
Between real time, therefore the real time error of electric energy meter local clock can be calculated, pass through the corresponding clock synchronization plan of setting
Slightly, such as: setting real time error be greater than 1s execute time tick operation, can also according to it is actual without ask selection other
Time range, in embodiments of the present invention, the calculation formula of the time error of electric energy meter local clock are as follows:
Dt0=T3+dt2-T2
Wherein, dt0 indicates the time error of the electric energy meter local clock, and T3 indicates the third time, when T2 indicates second
Between, dt2 indicates propagation delay time.
If time range is > 1s, then, without executing clock synchronization to electric energy meter, terminating this clock synchronization in dt0≤1s
Operation needs the step of executing clock synchronization to electric energy meter, executing S304 in dt0 > 1s.
S304 obtains the first clock synchronization message according to the first time, second time and propagation delay time
Processing delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking when
Between, obtain prover time.
In the present embodiment, it is necessary first to calculate the processing delay of electric energy list processing message, then determine electric energy meter assembly report
The message built-up time of text, and determine the propagation delay time of message, so that it may determine the prover time in time calibration message.
S305, Xiang Suoshu electric energy meter sending time calibrate message, include the prover time in the time calibration message,
With synchronous with regard to the local clock of scale to the electric energy.
The embodiment of the present invention can construct time calibration according to pre-set communications protocol by calculating prover time
Message, clock synchronization terminal calibrate message to electric energy meter sending time, the clock synchronization of electric energy meter both may be implemented.
In one embodiment, as shown in fig. 7, clock synchronization terminal with electric energy meter is connected by physical link, clock synchronization terminal and
The message received and dispatched between electric energy meter needs to meet electric energy meter communications protocol.A kind of clock synchronizing method of electric energy meter is provided, at this
Method is specific as follows:
S401 obtains absolute time, according to the absolute time to internal clock timing in clock synchronization terminal side.
In one embodiment, clock synchronization terminal can obtain absolute time from a base station, it is however generally that, there is GPS in base station
Module or Beidou module, therefore, clock synchronization terminal pass through the absolute time with a base station communication both available base station.
In another embodiment, clock synchronization terminal can from multiple base stations obtain absolute time, then multiple base stations when
Between it is middle select one as absolute time, when thus can be to avoid single base station fault, the problem of inaccuracy, tool when leading to school
Body, it is whether consistent by comparing multiple base station times, the time of most accurate base station is judged, in this, as absolute time.
In another embodiment, include GPS module or Beidou module in clock synchronization terminal, local GPS mould can be passed through
Block or Beidou module obtain absolute time.
In addition, in one embodiment, internal clocking can be clock counter, the benchmark that clock counter counts is clock synchronization
Terminal CPU internal clocking, to guarantee the accuracy of clock counter timing, by absolute time to clock counter clock synchronization,
Realize the accurate record of time.
S402 meets electric energy meter communication to electric energy meter transmission in first time by physical link in clock synchronization terminal side
First clock synchronization message of agreement.
S403 receives the first clock synchronization message in electric energy meter side, handles the first clock synchronization message, by physical link to right
When terminal feedback meet the second clock synchronization message of electric energy meter communications protocol, wherein include that electric energy meter is local in the second clock synchronization message
The third time of clock.
S404 receives the second clock synchronization message in clock synchronization terminal side, and record was the second time this moment;The second report of processing
Text obtains the third time in the second clock synchronization message comprising electric energy meter local clock.
In one embodiment, the baud rate of physical link is S, the second message length of available second clock synchronization message
L2, the code length of the second clock synchronization message in a communication link are m, therefore, calculate the second clock synchronization message and are sent to from electric energy meter
Propagation delay time dt2=(S/m)/L2 of clock synchronization terminal, then in the second time T2, the estimation time T4=T3+dt2 of electric energy meter,
Therefore, the time error of electric energy meter local clock is dt0=T3+dt2-T2.
In another embodiment, it is also necessary to judge whether dt0 meets the synchronous requirement of second grade, if so, not needing additional
Clock synchronization, entire clock synchronization process stops, if it is not, then also needing the step of carrying out S405.
S405 obtains institute according to the first time, second time and propagation delay time in clock synchronization terminal side
State the processing delay of the first clock synchronization message.
In one embodiment, obtain the first message length L1 of the first clock synchronization message, the physical link baud rate S with
And the first clock synchronization message code length m in a communication link, according to the first message length L1, the RS485 interface
The code length m of baud rate S and the first clock synchronization message in a communication link, obtains the propagation delay time of the first clock synchronization message
dt1.The propagation delay time dt1 of first clock synchronization message can be indicated with following formula:
Dt1=(S/m)/L1
The propagation delay time dt2 of second clock synchronization message can be indicated with following formula:
Dt2=(S/m)/L2
The processing delay dt3 of so the first message can be indicated with following formula:
Dt3=T2-T1-dt1-dt2
It is worth noting that physical link can be RS485 interface link, RS232 interface link, Ethernet interface link
Deng electric energy meter communication protocol can be DL/T645 communications protocol, and in the communication link of RS485 interface, communication baud rate can be with
It is set as 2400bps, the code length m of the first clock synchronization message and the second clock synchronization message in a communication link indicates the first clock synchronization
The code length of message and the second each byte of clock synchronization message.For example, the message length of the first clock synchronization message is 8 bytes, that
In a communication link, code length m=10.
S406, in clock synchronization terminal side, according to the processing delay, propagation delay time, predetermined message built-up time
And the time of the internal clocking, obtain prover time.
The embodiment of the present invention, influence clock synchronization error is the time delay of message transmissions, then, after calculating each time delay,
The time that message can be calibrated according to sending time, obtain prover time.
In one embodiment, prover time T5 can be indicated with following formula:
T5=T4+dt3+dt4+dt5
Wherein, T5 indicates the prover time in the time calibration message, and T4 internal clocking record sends the time school
The time of quasi- message, the dt4 indicate the propagation delay time of the time calibration message, and dt5 indicates predetermined message assembling
Time.
Specifically, message is calibrated to electric energy meter sending time at the T4 moment, then practical in time calibration message included
Prover time be that with this accurate clock synchronization of electric energy meter just may be implemented in T5.
S407, in clock synchronization terminal side, Xiang Suoshu electric energy meter sending time calibrates message, wraps in the time calibration message
It is synchronous with the local clock to the electric energy meter containing the prover time.
S408, in electric energy meter side, receiving time calibrates message, calibrates to local clock.
S409 waits preset duration in clock synchronization terminal side, when sending request electric energy meter local clock to electric energy meter again
Between third clock synchronization message.
S410 receives third clock synchronization message in electric energy meter side, generates the 4th pair comprising electric energy meter local clock time
When message, and be sent to clock synchronization terminal.
S411 receives and processes the 4th clock synchronization message in clock synchronization terminal side, and the time for calculating electric energy meter local clock is
It is no accurate, if accurately, stopping time tick operation.
It should be understood that although each step in the flow chart of Fig. 2 and 3 is successively shown according to the instruction of arrow,
It is these steps is not that the inevitable sequence according to arrow instruction successively executes.Unless expressly stating otherwise herein, these steps
There is no stringent sequences to limit for rapid execution, these steps can execute in other order.Moreover, in Fig. 2 and 3 at least
A part of step may include that perhaps these sub-steps of multiple stages or stage are not necessarily in same a period of time to multiple sub-steps
Quarter executes completion, but can execute at different times, the execution in these sub-steps or stage be sequentially also not necessarily according to
Secondary progress, but in turn or can replace at least part of the sub-step or stage of other steps or other steps
Ground executes.
In one embodiment, as shown in figure 8, providing a kind of clock synchronization apparatus of electric energy meter, comprising: internal clock synchronization
Module 502, packet sending and receiving module 504, time-delay calculation module 506 and clock synchronization module 508, in which:
Internal clock synchronization module 502, for obtaining absolute time, according to the absolute time to internal clocking clock synchronization.
Packet sending and receiving module 504, for sending first to electric energy meter in first time by pre-set communication protocol
Clock synchronization message, and the second clock synchronization message that electric energy meter is fed back is received in the second time;The first time, the second time are interior
The time of portion's clock.
Time-delay calculation module 506, for obtaining institute according to the first time, second time and propagation delay time
State the processing delay of the first clock synchronization message;According to the processing delay, propagation delay time, predetermined message built-up time and
The time of the internal clocking, obtain prover time.
Clock synchronization module 508 wraps in the time calibration message for calibrating message to the electric energy meter sending time
It is synchronous with the local clock to the electric energy meter containing the prover time.
In one of the embodiments, further include: calibration judgment module obtains institute for decompressing the second clock synchronization message
State the third time of the local clock of electric energy meter;According to second time, third time and propagation delay time, the electricity is obtained
The time error of energy table local clock;Judge the time error whether in pre-set time range, judged with this be
The no local clock to electric energy meter is synchronous.
Calibration judgment module is also used to the meter of the time error of the electric energy meter local clock in one of the embodiments,
Calculate formula are as follows:
Dt0=T3+dt2-T2
Wherein, dt0 indicates the time error of the electric energy meter local clock, and T2 indicated for the second time, when T3 indicates third
Between, dt2 indicates propagation delay time.
Packet sending and receiving module 504 is also used to the electric energy meter communication protocol by physical link in one of the embodiments,
It is sent in first time to electric energy meter and meets the first clock synchronization message of electric energy meter communications protocol and in the second time reception electric energy
Table feedback meets electric energy meter communications protocol the second clock synchronization message.
In one of the embodiments, time-delay calculation module 506 be also used to obtain the first clock synchronization message the first message it is long
Degree, the code length of the baud rate of the physical link and the first clock synchronization message in a communication link, according to first report
Literary length, the code length of the baud rate of the physical link and the first clock synchronization message in a communication link obtain described
The propagation delay time of message when a pair of of;The second message length for obtaining the second clock synchronization message, according to second message length and
The code length of the baud rate of the physical link and the second clock synchronization message in a communication link, obtains the second clock synchronization message
Propagation delay time;The calculation formula of the processing delay of the first clock synchronization message is as follows:
Dt3=T2-T1-dt1-dt2
Wherein, dt1 indicates the propagation delay time of the first clock synchronization message, and dt2 indicates the propagation delay time of the second clock synchronization message, T1 table
Show at the first time, T2 indicated for the second time, and dt3 indicates the processing delay of the first clock synchronization message.
In one of the embodiments, time-delay calculation module 506 be also used to obtain in advance the message built-up time and
The message length of time calibration message, according to the baud rate of the message length of the time calibration message, the RS485 interface with
And the code length of time calibration message in a communication link, obtain the propagation delay time of the time calibration message;The time
Calibrate the calculation formula of message alignment time are as follows:
T5=T4+dt3+dt4+dt5
Wherein, T5 indicates the prover time in the time calibration message, when T4 indicates that internal clocking record sends described
Between calibrate time of message, the dt4 indicates the propagation delay time of the time calibration message, and dt5 indicates predetermined message
Built-up time.
Absolute time is obtained from a base station in one of the embodiments,;Or, obtain the time of multiple base stations, from more
Selected in the time of a base station one as the absolute time;Or, obtaining absolute time by internal GPS module or Beidou module
Between.
Specific limit of clock synchronization apparatus about electric energy meter may refer to synchronize above for the clock of electric energy meter
The restriction of method, details are not described herein.Modules in the clock synchronization apparatus of above-mentioned electric energy meter can be fully or partially through
Software, hardware and combinations thereof are realized.Above-mentioned each module can be embedded in the form of hardware or independently of the place in computer equipment
It manages in device, can also be stored in a software form in the memory in computer equipment, in order to which processor calls execution or more
The corresponding operation of modules.
In one embodiment, a kind of computer equipment is provided, which can be server, internal junction
Composition can be as shown in Figure 9.The computer equipment include by system bus connect processor, memory, network interface and
Database.Wherein, the processor of the computer equipment is for providing calculating and control ability.The memory packet of the computer equipment
Include non-volatile memory medium, built-in storage.The non-volatile memory medium is stored with operating system, computer program and data
Library.The built-in storage provides environment for the operation of operating system and computer program in non-volatile memory medium.The calculating
The database of machine equipment is used to store the data that the clock of electric energy meter synchronizes.The network interface of the computer equipment is used for and outside
Terminal by network connection communication.A kind of clock side of synchronization of electric energy meter is realized when the computer program is executed by processor
Method.
It will be understood by those skilled in the art that structure shown in Fig. 9, only part relevant to application scheme is tied
The block diagram of structure does not constitute the restriction for the computer equipment being applied thereon to application scheme, specific computer equipment
It may include perhaps combining certain components or with different component layouts than more or fewer components as shown in the figure.
In one embodiment, a kind of computer equipment, including memory and processor are provided, is stored in memory
Computer program, the processor perform the steps of when executing computer program
Absolute time is obtained, according to the absolute time to internal clocking clock synchronization;
The first clock synchronization message is sent to electric energy meter in first time by pre-set communication protocol, and at second
Between receive electric energy meter feedback the second clock synchronization message;The first time, the time that the second time was internal clocking;
According to the first time, second time and propagation delay time, the processing of the first clock synchronization message is obtained
Time delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking time,
Obtain prover time;
Message is calibrated to the electric energy meter sending time, includes the prover time in the time calibration message, with right
The local clock of the electric energy meter is synchronous.
In one embodiment, decompression second clock synchronization is also performed the steps of when processor executes computer program
Message obtains the third time of the local clock of the electric energy meter;According to second time, third time and propagation delay time,
Obtain the time error of the electric energy meter local clock;Judge the time error whether in pre-set time range,
Judged whether with this synchronous to the local clock of electric energy meter.
In one embodiment, when also performing the steps of the electric energy meter local when processor executes computer program
The calculation formula of the time error of clock are as follows:
Dt0=T3+dt2-T2
Wherein, dt0 indicates the time error of the electric energy meter, and T2 indicated for the second time, and T3 indicates third time, dt2 table
Show propagation delay time.
In one embodiment, the electricity by physical link is also performed the steps of when processor executes computer program
Energy table communication protocol meets the first clock synchronization message of electric energy meter communications protocol and second to electric energy meter transmission in first time
Time reception electric energy meter feedback meets electric energy meter communications protocol the second clock synchronization message.
In one embodiment, it is also performed the steps of when processor executes computer program and obtains the first clock synchronization message
The first message length, the physical link baud rate and the first clock synchronization message code length in a communication link, root
It is long according to first message length, the coding of the baud rate of the physical link and the first clock synchronization message in a communication link
Degree, obtains the propagation delay time of the first clock synchronization message;The second message length for obtaining the second clock synchronization message, according to described second
The code length of the baud rate and the second clock synchronization message of message length and the physical link in a communication link obtains
The propagation delay time of two clock synchronization messages;The calculation formula of the processing delay of the first clock synchronization message is as follows:
Dt3=T2-T1-dt1-dt2
Wherein, dt1 indicates the propagation delay time of the first clock synchronization message, and dt2 indicates the propagation delay time of the second clock synchronization message, T1 table
Show at the first time, T2 indicated for the second time, and dt3 indicates the processing delay of the first clock synchronization message.
In one embodiment, it is also performed the steps of when processor executes computer program and obtains the message in advance
The message length of built-up time and time calibration message, according to the message length of the time calibration message, the physics chain
The code length of the baud rate and time calibration message on road in a communication link, when obtaining the transmission of the time calibration message
Prolong;The calculation formula of the time calibration message alignment time are as follows:
T5=T4+dt3+dt4+dt5
Wherein, T5 indicates the prover time in the time calibration message, when T4 indicates that internal clocking record sends described
Between calibrate time of message, the dt4 indicates the propagation delay time of the time calibration message, and dt5 indicates predetermined message
Built-up time.
In one embodiment, it also performs the steps of when processor executes computer program and is obtained absolutely from a base station
To the time;Or, obtain the time of multiple base stations, selected from the time of multiple base stations one as the absolute time;Or, logical
It crosses internal GPS module or Beidou module obtains absolute time.
In one embodiment, a kind of computer readable storage medium is provided, computer program is stored thereon with, is calculated
Machine program performs the steps of when being executed by processor
Absolute time is obtained, according to the absolute time to internal clocking clock synchronization;
The first clock synchronization message is sent to electric energy meter in first time by pre-set communication protocol, and at second
Between receive electric energy meter feedback the second clock synchronization message;The first time, the time that the second time was internal clocking;
According to the first time, second time and propagation delay time, the processing of the first clock synchronization message is obtained
Time delay;According to the processing delay, propagation delay time, predetermined message built-up time and the internal clocking time,
Obtain prover time;
Message is calibrated to the electric energy meter sending time, includes the prover time in the time calibration message, with right
The local clock of the electric energy meter is synchronous.
In one embodiment, described second pair of decompression is also performed the steps of when computer program is executed by processor
When message obtain the electric energy meter local clock the third time;When according to second time, third time and transmission
Prolong, obtains the time error of the electric energy meter local clock;Judge the time error whether in pre-set time range
It is interior, judged whether with this synchronous to the local clock of electric energy meter.
In one embodiment, it is local that the electric energy meter is also performed the steps of when computer program is executed by processor
The calculation formula of the time error of clock are as follows:
Dt0=T3+dt2-T2
Wherein, dt0 indicates the time error of the electric energy meter local clock, and T2 indicated for the second time, when T3 indicates third
Between, dt2 indicates propagation delay time.
In one embodiment, it also performs the steps of when computer program is executed by processor through physical link
Electric energy meter communication protocol sends to electric energy meter in first time and meets the first clock synchronization message of electric energy meter communications protocol and the
Two times reception electric energy meter feedback meets electric energy meter communications protocol the second clock synchronization message.
In one embodiment, it is also performed the steps of when computer program is executed by processor and obtains first pair of Times
The code length of the baud rate and the first clock synchronization message of literary the first message length, the physical link in a communication link,
It is long according to first message length, the coding of the baud rate of the physical link and the first clock synchronization message in a communication link
Degree, obtains the propagation delay time of the first clock synchronization message;The second message length for obtaining the second clock synchronization message, according to described second
The code length of the baud rate and the second clock synchronization message of message length and the physical link in a communication link obtains
The propagation delay time of two clock synchronization messages;The calculation formula of the processing delay of the first clock synchronization message is as follows:
Dt3=T2-T1-dt1-dt2
Wherein, dt1 indicates the propagation delay time of the first clock synchronization message, and dt2 indicates the propagation delay time of the second clock synchronization message, T1 table
Show at the first time, T2 indicated for the second time, and dt3 indicates the processing delay of the first clock synchronization message.
In one embodiment, it is also performed the steps of when computer program is executed by processor and obtains the report in advance
The message length of literary built-up time and time calibration message, according to the message length of the time calibration message, the physics
The code length of the baud rate and time calibration message of link in a communication link, obtains the transmission of the time calibration message
Time delay;The calculation formula of the time calibration message alignment time are as follows:
T5=T4+dt3+dt4+dt5
Wherein, T5 indicates the prover time in the time calibration message, when T4 indicates that internal clocking record sends described
Between calibrate time of message, the dt4 indicates the propagation delay time of the time calibration message, and dt5 indicates predetermined message
Built-up time.
In one embodiment, it also performs the steps of when computer program is executed by processor and is obtained from a base station
Absolute time;Or, obtain the time of multiple base stations, selected from the time of multiple base stations one as the absolute time;Or,
Absolute time is obtained by internal GPS module or Beidou module.
Those of ordinary skill in the art will appreciate that realizing all or part of the process in above-described embodiment method, being can be with
Relevant hardware is instructed to complete by computer program, the computer program can be stored in a non-volatile computer
In read/write memory medium, the computer program is when being executed, it may include such as the process of the embodiment of above-mentioned each method.Wherein,
To any reference of memory, storage, database or other media used in each embodiment provided herein,
Including non-volatile and/or volatile memory.Nonvolatile memory may include read-only memory (ROM), programming ROM
(PROM), electrically programmable ROM (EPROM), electrically erasable ROM (EEPROM) or flash memory.Volatile memory may include
Random access memory (RAM) or external cache.By way of illustration and not limitation, RAM is available in many forms,
Such as static state RAM (SRAM), dynamic ram (DRAM), synchronous dram (SDRAM), double data rate sdram (DDRSDRAM), enhancing
Type SDRAM (ESDRAM), synchronization link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM
(RDRAM), direct memory bus dynamic ram (DRDRAM) and memory bus dynamic ram (RDRAM) etc..
Each technical characteristic of above embodiments can be combined arbitrarily, for simplicity of description, not to above-described embodiment
In each technical characteristic it is all possible combination be all described, as long as however, the combination of these technical characteristics be not present lance
Shield all should be considered as described in this specification.
The several embodiments of the application above described embodiment only expresses, the description thereof is more specific and detailed, but simultaneously
It cannot therefore be construed as limiting the scope of the patent.It should be pointed out that coming for those of ordinary skill in the art
It says, without departing from the concept of this application, various modifications and improvements can be made, these belong to the protection of the application
Range.Therefore, the scope of protection shall be subject to the appended claims for the application patent.