Time synchronization method and device for power consumption information collection terminal
By obtaining the device address in the power consumption information collection system, determining the device type and selecting an appropriate time synchronization strategy, time synchronization is performed and through multiple optimizations, the problem of large time synchronization errors in the existing system is solved and higher accuracy is achieved. degree of time synchronization.
Patent Information
- Application Number
- CN202411449600.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2044-10-17
Smart Images

Figure CN118972935B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a time synchronization method and device for a power consumption information collection terminal. Background Art
[0002] The power data collection terminals and electric energy meters used in the power consumption information collection system are generally equipped with clocks. However, due to the influence of factors such as the error in the initial time value, the transmission delay of the communication between the master station and the collection terminal, the temperature drift of the quartz crystal, and the aging of the internal hardware equipment, the time synchronization in the power consumption information collection system deviates. Therefore, it is urgent to optimize the system using a more accurate time synchronization method.
[0003] At present, the solution to the time synchronization problem of the power consumption information collection system is mainly to realize the time synchronization process based on the daily frozen data items, and add compensation for the channel transmission delay. However, due to the instability of the communication channel, the delay time obtained in the first few times is not exactly the same as the delay time of the time synchronization command, and it is even possible that the delay time of issuing the command is greater than the normal delay time. In addition, the power consumption information collection terminal also needs a delay time to process the time synchronization command, and this delay time is unpredictable due to the different processing tasks itself, so the current time synchronization method still has large errors.
[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of the present invention is to provide a time synchronization method and device for an electricity consumption information collection terminal, aiming to solve the technical problem that the current time synchronization method still has large errors.
[0006] To achieve the above object, the present invention provides a time synchronization method for a power consumption information collection terminal, the time synchronization method for a power consumption information collection terminal comprising the following steps:
[0007] The power consumption information collection terminal obtains the address of the device to be time synchronized;
[0008] The power consumption information collection terminal determines the device type of the device to be time synchronized according to the acquired address;
[0009] The power consumption information collection terminal selects a corresponding time synchronization strategy based on the device type;
[0010] The power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy;
[0011] Detecting whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization;
[0012] If there is a synchronization time error, the step of returning to execute the step of performing time synchronization between the power consumption information collection terminal and the device to be time synchronized according to the time synchronization strategy, so as to optimize the synchronization time error through multiple time synchronizations.
[0013] In some embodiments, the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy, including:
[0014] When the device type is a master station server, the power consumption information collection terminal sends a time query request to the master station server, and records the sending time of the time query request as the first time;
[0015] The main station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, and records the time when the main station server receives the time query request as the second time, and the time when the time information packet is returned as the third time;
[0016] The power consumption information collection terminal receives the time information packet returned by the master station server, and records the corresponding receiving time as the fourth time;
[0017] Calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment;
[0018] The power consumption information collection terminal performs time synchronization with the main station server based on the time deviation.
[0019] In some embodiments, the calculating the time deviation according to the first moment, the second moment, the third moment, and the fourth moment includes:
[0020] If the network delay between the power consumption information collection terminal and the master station server is symmetrical, then the time deviation is calculated according to the first moment, the second moment, the third moment and the fourth moment;
[0021] If the network delay between the electricity consumption information collection terminal and the main station server is asymmetric, a first reference value is calculated according to the first moment and the second moment, and a second reference value is calculated according to the third moment and the fourth moment, an asymmetry coefficient is calculated based on the first reference value and the second reference value, and a time deviation is calculated according to the asymmetry coefficient, the first moment, the second moment, the third moment and the fourth moment.
[0022] In some embodiments, the method further comprises:
[0023] If the network delay between the power consumption information collection terminal and the master server is symmetrical, the time deviation
[0024] The calculation formula is , wherein t1 is the first moment, t2 is the second moment, t3 is the third moment and t4 is the fourth moment;
[0025] If the network delay between the power consumption information collection terminal and the main station server is asymmetric, the first reference
[0026] value , the second reference value , the asymmetry coefficient is , the calculation formula of time deviation is .
[0027] In some embodiments, the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy, including:
[0028] When the device type is a smart electric energy meter, the power consumption information collection terminal sends a message to the smart electric energy meter and records the time T1 of sending the message. The message is used to collect the time of the smart electric energy meter. The time required for the message to be sent from the power consumption information collection terminal to the smart electric energy meter is d1;
[0029] After receiving the message, the smart energy meter returns the message to the power consumption information collection terminal. The time required for the message to return from the smart energy meter to the power consumption information collection terminal is d2;
[0030] The power consumption information collection terminal receives the message returned by the smart power meter, records the time T2 when the returned message is received, and parses the time T3 from the returned message;
[0031] Determining whether the smart electric energy meter needs time synchronization;
[0032] If necessary, the time for the smart energy meter to process the message is determined to be d4=d3-d1-d2, where d3 represents the round-trip time from the power consumption information collection terminal sending the message to the smart energy meter until receiving the return message from the smart energy meter, and d3=T2-T1;
[0033] The power consumption information collection terminal sends a time message to the smart power meter and records the time T4 when the message is sent. The message is used to synchronize time with the smart power meter. The time required for the message to be sent from the power consumption information collection terminal to the smart power meter is d5, and the assembly time corresponding to the time message is d6;
[0034] The electricity consumption information collection terminal calculates the time T5=T4+d4+d5+d6 of the smart energy meter correction carried in the message, and performs time synchronization with the smart energy meter based on the time of the smart energy meter correction.
[0035] In some embodiments, determining whether the smart electric energy meter needs to be time synchronized includes:
[0036] Calculate the time deviation between the power consumption information collection terminal and the smart power meter, the time deviation d=T3+d2-T2;
[0037] comparing the time deviation with a preset deviation;
[0038] If the time deviation is less than or equal to the preset deviation, it is determined that the smart electric energy meter does not need to be time synchronized;
[0039] If the time deviation is greater than a preset deviation, it is determined that the smart electric energy meter needs to be time synchronized.
[0040] In some embodiments, the optimizing the synchronization time error through multiple time synchronizations includes:
[0041] Obtain multiple synchronization time errors corresponding to multiple time synchronizations;
[0042] A maximum likelihood function is constructed based on the number of time synchronizations corresponding to the multiple time synchronizations;
[0043] Filter out the minimum synchronization time error from multiple synchronization time errors;
[0044] Determining a maximum likelihood estimate corresponding to the minimum synchronization time error based on the maximum likelihood function;
[0045] Determining a time offset according to the maximum likelihood estimate;
[0046] The time offset is used to perform time compensation on the local clock corresponding to the power consumption information collection terminal to optimize the synchronization time error.
[0047] In addition, to achieve the above-mentioned purpose, the present invention also proposes a time synchronization device for a power consumption information collection terminal, the time synchronization device for a power consumption information collection terminal comprising:
[0048] An acquisition module, used by the power consumption information collection terminal to acquire the address of the device to be time synchronized;
[0049] A screening module, used for the power consumption information collection terminal to determine the device type of the device to be time synchronized according to the acquired address;
[0050] A selection module, used for the power consumption information collection terminal to select a corresponding time synchronization strategy based on the device type;
[0051] A synchronization module, used for the power consumption information collection terminal to perform time synchronization with the device to be time synchronized according to the time synchronization strategy;
[0052] A detection module, used to detect whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization;
[0053] The optimization module is used to return to the step of executing the time synchronization of the power consumption information collection terminal with the device to be time synchronized according to the time synchronization strategy if there is a synchronization time error, so as to optimize the synchronization time error through multiple time synchronizations.
[0054] In some embodiments, the synchronization module is used for, when the device type is a master station server, the power consumption information collection terminal sends a time query request to the master station server, and records the sending time of the time query request as the first time;
[0055] The main station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, and records the time when the main station server receives the time query request as the second time, and the time when the time information packet is returned as the third time;
[0056] The power consumption information collection terminal receives the time information packet returned by the master station server, and records the corresponding receiving time as the fourth time;
[0057] Calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment;
[0058] The power consumption information collection terminal performs time synchronization with the main station server based on the time deviation.
[0059] In some embodiments, the synchronization module is used to calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment if the network delay between the power consumption information collection terminal and the master station server is symmetrical;
[0060] If the network delay between the electricity consumption information collection terminal and the main station server is asymmetric, a first reference value is calculated according to the first moment and the second moment, and a second reference value is calculated according to the third moment and the fourth moment, an asymmetry coefficient is calculated based on the first reference value and the second reference value, and a time deviation is calculated according to the asymmetry coefficient, the first moment, the second moment, the third moment and the fourth moment.
[0061] The present invention obtains the address of the device to be time synchronized through the power consumption information collection terminal, and the power consumption information collection terminal determines the device type of the device to be time synchronized according to the obtained address; the power consumption information collection terminal selects the corresponding time synchronization strategy based on the device type; the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy; detects whether there is a synchronization time error between the power consumption information collection terminal and the device after the time synchronization is completed; if there is a synchronization time error, the synchronization time error is optimized through multiple time synchronizations. Through the above method, targeted time synchronization strategies are adopted for different device types, and optimization is performed through multiple time synchronizations, thereby reducing the error of time synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 This is a flow chart of a first embodiment of a method for synchronizing a power consumption information collection terminal;
[0063] Figure 2 This is a structural block diagram of the first embodiment of the time synchronization device for the power consumption information collection terminal of the present invention.
[0064] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0065] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0066] The embodiment of the present invention provides a method for synchronizing a power consumption information collection terminal time. Figure 1 , Figure 1 The present invention is a flowchart of a first embodiment of a method for synchronizing a power consumption information collection terminal.
[0067] In this embodiment, the time synchronization method of the power consumption information collection terminal includes the following steps:
[0068] Step S10: The power consumption information collection terminal obtains the address of the device to be time synchronized.
[0069] In this embodiment, the executor of this embodiment is a time synchronization device for a power consumption information collection terminal, wherein the time synchronization device for a power consumption information collection terminal has functions such as data processing, data communication, and program running. The time synchronization device for a power consumption information collection terminal can be a computer terminal device or other network device, and of course can also be other devices with similar functions, and this embodiment does not limit this.
[0070] It should be noted that the current solution to the time synchronization problem of the power consumption information collection system is mainly to implement the time synchronization process based on the daily frozen data items, and to add compensation for the channel transmission delay. However, due to the instability of the communication channel, the delay time obtained in the first few times is not exactly the same as the delay time of the time synchronization command, and it is even possible that the delay time of issuing the command is greater than the normal delay time. In addition, the power consumption information collection terminal also requires a delay time to process the time synchronization command, and this delay time is unpredictable due to the different processing tasks itself, so the current time synchronization method still has large errors.
[0071] In order to solve the above technical problems, this embodiment obtains the address of the device to be time synchronized through the power consumption information collection terminal, and the power consumption information collection terminal determines the device type of the device to be time synchronized according to the obtained address; the power consumption information collection terminal selects the corresponding time synchronization strategy based on the device type; the power consumption information collection terminal synchronizes the time with the device to be time synchronized according to the time synchronization strategy; detects whether there is a synchronization time error between the power consumption information collection terminal and the device after the time synchronization is completed; if there is a synchronization time error, the synchronization time error is optimized through multiple time synchronizations. Through the above method, targeted time synchronization strategies are adopted for different device types, and optimization is performed through multiple time synchronizations, thereby reducing the error of time synchronization. Specifically, it can be implemented in the following way.
[0072] In the specific implementation, in this embodiment, it is necessary to first obtain the address of the device to be time synchronized through the power consumption information collection terminal. The address can be a network address, that is, an IP address, or a media access control address, that is, a MAC address. In order to ensure the accuracy of device identification, the MAC address is used in this embodiment.
[0073] Step S20: the power consumption information collection terminal determines the device type of the device to be time synchronized according to the acquired address.
[0074] After obtaining the address, the electricity consumption information collection terminal can determine the device type of the device to be time synchronized. It should be noted that in this embodiment, the electricity consumption information collection terminal can perform time synchronization with the main station server and the smart power meter. The time synchronization strategy adopted in this embodiment is different for different devices. Therefore, it is necessary to determine the device type before performing time synchronization, that is, the main station server and the smart power meter.
[0075] Step S30: The power consumption information collection terminal selects a corresponding time synchronization strategy based on the device type.
[0076] Step S40: the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy.
[0077] It should be noted that after the device type is determined, a corresponding strategy is adopted in this embodiment to perform time synchronization.
[0078] Specifically, when the device type is a master station server, the specific process of time synchronization is that the power consumption information collection terminal sends a time query request to the master station server, the master station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, and the power consumption information collection terminal receives the time information packet returned by the master station server, and obtains corresponding moments for the above four processes respectively, that is, the time when the time query request is sent is the first moment, the time when the master station server receives the time query request is the second moment, and the time when the time information packet is returned is the third moment, and the time corresponding to the time when the power consumption information collection terminal receives the time information packet returned by the master station server is the fourth moment, and the time deviation can be obtained according to these recorded moments, and the power consumption information collection terminal synchronizes time with the master station server based on the time deviation. Specifically, the power consumption information collection terminal adjusts the clock of the master station server according to the local clock and the time deviation, and the power consumption information collection terminal can add or subtract the time deviation from the local clock to obtain the time corresponding to the clock of the master station server.
[0079] In some embodiments, the calculation of time deviation is divided into two cases. The first case is that the network delay between the power consumption information collection terminal and the master station server is symmetrical. In this case, the time deviation can be calculated according to the first moment, the second moment, the third moment and the fourth moment. The specific calculation formula of the time deviation is, for example:
[0080] ,
[0081] Wherein, t1 is the first moment, t2 is the second moment, t3 is the third moment, and t4 is the fourth moment. The second case is that the network delay between the power consumption information collection terminal and the master server is asymmetric. In this case, the first reference value is calculated according to the first moment and the second moment, and the second reference value is calculated according to the third moment and the fourth moment. For example, the first reference value , the second reference value , and then calculate the asymmetry coefficient based on the first reference value and the second reference value, for example , the specific calculation formula for the final time deviation is as follows:
[0082] .
[0083] Further, when the device type is a smart electric energy meter, in this embodiment, a message is first sent to the smart electric energy meter through the power consumption information collection terminal, and then the time T1 corresponding to the sent message is recorded. The message is used to collect the time of the smart electric energy meter. The time required for the message to be sent from the power consumption information collection terminal to the smart electric energy meter is d1. After receiving the message, the smart electric energy meter returns the message to the power consumption information collection terminal. The time required for the message to return from the smart electric energy meter to the power consumption information collection terminal is d2. The power consumption information collection terminal receives the message returned by the smart electric energy meter, records the time T2 when the returned message is received, and parses the time T3 from the returned message. According to the above time, the time for the smart electric energy meter to process the message can be determined as d4=d3-d1-d2, where d3 represents the round-trip time from the power consumption information collection terminal sending the message to the smart electric energy meter until receiving the return message from the smart electric energy meter, and d3=T2-T1. Then the electricity consumption information collection terminal sends a time message to the smart energy meter and records the time T4 when the message is sent. The message is used to synchronize time with the smart energy meter. The time required for the message to be sent from the electricity consumption information collection terminal to the smart energy meter is d5, and the assembly time corresponding to the time message is d6; the electricity consumption information collection terminal calculates the time T5=T4+d4+d5+d6 of the smart energy meter correction carried in the message, and synchronizes time with the smart energy meter based on the time of correction of the smart energy meter. Specifically, the smart energy meter adds or subtracts the time T5 of the smart energy meter correction based on the corresponding local clock. When the smart energy meter based on the corresponding local clock is faster than the local clock corresponding to the electricity consumption information collection terminal, the time T5 of the smart energy meter correction is subtracted, otherwise the time T5 of the smart energy meter correction is added.
[0084] In some embodiments, before performing time synchronization, it is necessary to first determine whether the smart electric energy meter needs time synchronization. Specifically, the time deviation between the electricity consumption information collection terminal and the smart electric energy meter is calculated, and the time deviation d=T3+d2-T2; the time deviation is compared with the preset deviation; if the time deviation is less than or equal to the preset deviation, it is determined that the smart electric energy meter does not need time synchronization; if the time deviation is greater than the preset deviation, it is determined that the smart electric energy meter needs time synchronization. The preset deviation can be set to 1, and of course it can be adjusted accordingly according to actual needs. This is not limited in this embodiment.
[0085] Step S50: Detect whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization.
[0086] It can be understood that in actual situations, errors exist in real time. In this embodiment, after obtaining the time deviation value between the electricity consumption information collection terminal and the device after completing time synchronization, the time deviation value is compared with the preset deviation threshold. If the time deviation value is less than the preset deviation threshold, it can be considered that the time synchronization has been completed. The preset deviation threshold is a very small value. The specific value can be set according to the actual synchronization accuracy requirements, and this is not limited in this embodiment.
[0087] Step S60: If there is a synchronization time error, return to the step of performing time synchronization between the power consumption information collection terminal and the device to be time synchronized according to the time synchronization strategy, so as to optimize the synchronization time error through multiple time synchronizations.
[0088] Through multiple time synchronizations, multiple synchronization time errors can be obtained, and then the minimum synchronization time error is screened out from the multiple synchronization time errors. Then, the maximum likelihood function is constructed based on the number of time synchronizations corresponding to the multiple time synchronizations, for example: ,in, Indicates the synchronization time error, and is the parameter value of Gaussian distribution, and the randomness of different synchronization time errors obeys ( , 2), the above parameter value can be obtained by using random Gaussian distribution, and the maximum likelihood estimate can be calculated by substituting the synchronization time error into the above functional relationship. The maximum likelihood estimate is also the variable value corresponding to the time offset. The time offset can be determined based on the maximum likelihood estimate. Finally, the time offset is used to perform time compensation on the local clock corresponding to the power consumption information collection terminal, that is, the local clock of the power consumption information collection terminal is adjusted by using the time offset. The local clock of the power consumption information collection terminal is optimized and adjusted here, and the local clock corresponding to the master station server or the smart electric energy meter is adjusted in the above time synchronization.
[0089] In this embodiment, the address of the device to be time synchronized is obtained through the power consumption information collection terminal, and the power consumption information collection terminal determines the device type of the device to be time synchronized according to the obtained address; the power consumption information collection terminal selects the corresponding time synchronization strategy based on the device type; the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy; it is detected whether there is a synchronization time error between the power consumption information collection terminal and the device after the time synchronization is completed; if there is a synchronization time error, the synchronization time error is optimized through multiple time synchronizations. In the above manner, targeted time synchronization strategies are adopted for different device types, and optimization is performed through multiple time synchronizations, thereby reducing the error of time synchronization.
[0090] Reference Figure 2 , Figure 2 This is a structural block diagram of the first embodiment of the time synchronization device for the power consumption information collection terminal of the present invention.
[0091] like Figure 2 As shown, the time synchronization device for the power consumption information collection terminal proposed in the embodiment of the present invention includes:
[0092] The acquisition module 10 is used for the power consumption information collection terminal to acquire the address of the device to be time synchronized.
[0093] The screening module 20 is used for the power consumption information collection terminal to determine the device type of the device to be time synchronized according to the acquired address.
[0094] The selection module 30 is used for the power consumption information collection terminal to select a corresponding time synchronization strategy based on the device type.
[0095] The synchronization module 40 is used for the power consumption information collection terminal to perform time synchronization with the device to be time synchronized according to the time synchronization strategy.
[0096] The detection module 50 is used to detect whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization.
[0097] The optimization module 60 is used to return to the step of performing time synchronization between the power consumption information collection terminal and the device to be time synchronized according to the time synchronization strategy if there is a synchronization time error, so as to optimize the synchronization time error through multiple time synchronizations.
[0098] In this embodiment, the address of the device to be time synchronized is obtained through the power consumption information collection terminal, and the power consumption information collection terminal determines the device type of the device to be time synchronized according to the obtained address; the power consumption information collection terminal selects the corresponding time synchronization strategy based on the device type; the power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy; it is detected whether there is a synchronization time error between the power consumption information collection terminal and the device after the time synchronization is completed; if there is a synchronization time error, the synchronization time error is optimized through multiple time synchronizations. In the above manner, targeted time synchronization strategies are adopted for different device types, and optimization is performed through multiple time synchronizations, thereby reducing the error of time synchronization.
[0099] In some embodiments, the synchronization module 40 is used for, when the device type is a master station server, the power consumption information collection terminal sends a time query request to the master station server, and records the sending time of the time query request as a first time; the master station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, records the time when the master station server receives the time query request as a second time, and the time when the time information packet is returned as a third time; the power consumption information collection terminal receives the time information packet returned by the master station server, and records the corresponding reception time as a fourth time; calculates the time deviation according to the first time, the second time, the third time and the fourth time; the power consumption information collection terminal performs time synchronization with the master station server based on the time deviation.
[0100] In some embodiments, the synchronization module 40 is used to calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment if the network delay between the power consumption information collection terminal and the main station server is symmetrical; if the network delay between the power consumption information collection terminal and the main station server is asymmetrical, calculate the first reference value according to the first moment and the second moment, and calculate the second reference value according to the third moment and the fourth moment, calculate the asymmetry coefficient based on the first reference value and the second reference value, and calculate the time deviation according to the asymmetry coefficient, the first moment, the second moment, the third moment and the fourth moment.
[0101] In some embodiments, the synchronization module 40 is used to calculate the time deviation if the network delay between the power consumption information collection terminal and the master server is symmetrical. , where t1 is the first moment, t2 is the second moment, t3 is the third moment, and t4 is the fourth moment; if the network delay between the power consumption information collection terminal and the master server is asymmetric, the first reference value , the second reference value , the asymmetry coefficient is , the calculation formula of time deviation is .
[0102] In some embodiments, the synchronization module 40 is used for, when the device type is a smart electric energy meter, the power consumption information collection terminal sends a message to the smart electric energy meter and records the time T1 of sending the message, the message is used to collect the time of the smart electric energy meter, and the time required for the message to be sent from the power consumption information collection terminal to the smart electric energy meter is d1; after receiving the message, the smart electric energy meter returns a message to the power consumption information collection terminal, and the time required for the message to return from the smart electric energy meter to the power consumption information collection terminal is d2; the power consumption information collection terminal receives the message returned by the smart electric energy meter, records the time T2 when the returned message is received, and parses the time T3 from the returned message; determines whether the smart electric energy meter needs to be time synchronized; if necessary, determines the required The time for the smart energy meter to process the message is d4=d3-d1-d2, wherein d3 represents the round-trip time from the power consumption information collection terminal sending the message to the smart energy meter until receiving the return message from the smart energy meter, and d3=T2-T1; the power consumption information collection terminal sends a time message to the smart energy meter and records the time T4 when the message is sent, the message is used to perform time synchronization with the smart energy meter, the time required for the message to be sent from the power consumption information collection terminal to the smart energy meter is d5, and the assembly time corresponding to the time message is d6; the power consumption information collection terminal calculates the time T5=T4+d4+d5+d6 of the smart energy meter correction carried in the message, and performs time synchronization with the smart energy meter based on the time of correction of the smart energy meter.
[0103] In some embodiments, the synchronization module 40 is used to calculate the time deviation between the electricity consumption information collection terminal and the smart electric energy meter, the time deviation d=T3+d2-T2; compare the time deviation with the preset deviation; if the time deviation is less than or equal to the preset deviation, it is determined that the smart electric energy meter does not need to be time synchronized; if the time deviation is greater than the preset deviation, it is determined that the smart electric energy meter needs to be time synchronized.
[0104] In some embodiments, the optimization module 60 is used to obtain multiple synchronization time errors corresponding to multiple time synchronizations; construct a maximum likelihood function based on the number of time synchronizations corresponding to the multiple time synchronizations; screen out the minimum synchronization time error from the multiple synchronization time errors; determine the maximum likelihood estimate corresponding to the minimum synchronization time error based on the maximum likelihood function; determine the time offset according to the maximum likelihood estimate; and use the time offset to perform time compensation on the local clock corresponding to the power consumption information collection terminal to optimize the synchronization time error.
[0105] An embodiment of the present application also provides a time synchronization device for an electricity consumption information collection terminal, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus, and the memory is used to store a time synchronization program for the electricity consumption information collection terminal; the processor is used to implement the above-mentioned time synchronization method for the electricity consumption information collection terminal when executing the program stored in the memory.
[0106] The communication bus mentioned in the above-mentioned power consumption information collection terminal time synchronization device can be a peripheral component interconnect standard (English: Peripheral Component Interconnect, referred to as: PCI) bus or an extended industry standard architecture (English: Extended Industry Standard Architecture, referred to as: EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0107] The communication interface is used for communication between the above-mentioned power consumption information collection terminal time synchronization device and other devices.
[0108] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0109] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0110] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0111] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0112] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0113] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0114] It should be understood that the above is only an example and does not constitute any limitation on the technical solution of the present invention. In specific applications, technicians in this field can make settings as needed, and the present invention does not limit this.
[0115] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of them according to actual needs to achieve the purpose of the present embodiment, and no limitation is made here.
[0116] In addition, for technical details not fully described in this embodiment, reference may be made to the time synchronization method for the power consumption information collection terminal provided in any embodiment of the present invention, and will not be repeated here.
[0117] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0118] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM) / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0119] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
[0120] It is understandable that the system provided by the embodiment of the present invention corresponds to the method provided by the embodiment of the present invention, and the explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the above method.
Claims
1. A time synchronization method for a power consumption information collection terminal, characterized in that: The time synchronization method of the power consumption information collection terminal includes: The power consumption information collection terminal obtains the address of the device to be time synchronized; The power consumption information collection terminal determines the device type of the device to be time synchronized according to the acquired address; The power consumption information collection terminal selects a corresponding time synchronization strategy based on the device type, and the device type includes a master station server and a smart energy meter; The power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy; The power consumption information collection terminal performs time synchronization with the device to be time synchronized according to the time synchronization strategy, further comprising: When the device type is a master station server, the power consumption information collection terminal sends a time query request to the master station server, and records the sending time of the time query request as the first time; The main station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, and records the time when the main station server receives the time query request as the second time, and the time when the time information packet is returned as the third time; The power consumption information collection terminal receives the time information packet returned by the master station server, and records the corresponding receiving time as the fourth time; Calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment; The power consumption information collection terminal performs time synchronization with the master station server based on the time deviation; and, when the device type is a smart electric energy meter, the power consumption information collection terminal sends a message to the smart electric energy meter and records the time T1 of sending the message, the message is used to collect the time of the smart electric energy meter, and the time required for the message to be sent from the power consumption information collection terminal to the smart electric energy meter is d1; After receiving the message, the smart energy meter returns the message to the power consumption information collection terminal. The time required for the message to return from the smart energy meter to the power consumption information collection terminal is d2; The power consumption information collection terminal receives the message returned by the smart power meter, records the time T2 when the returned message is received, and parses the time T3 from the returned message; Determining whether the smart electric energy meter needs time synchronization; If necessary, the time for the smart energy meter to process the message is determined to be d4=d3-d1-d2, where d3 represents the round-trip time from the power consumption information collection terminal sending the message to the smart energy meter until receiving the return message from the smart energy meter, and d3=T2-T1; The power consumption information collection terminal sends a time message to the smart power meter and records the time T4 when the time message is sent. The time message is used to synchronize time with the smart power meter. The time required for the time message to be sent from the power consumption information collection terminal to the smart power meter is d5, and the assembly time corresponding to the time message is d6; The power consumption information collection terminal calculates the time T5=T4+d4+d5+d6 of the smart energy meter correction carried in the time message, and performs time synchronization with the smart energy meter based on the time of the smart energy meter correction; Detecting whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization; If there is a synchronization time error, the step of returning to execute the step of performing time synchronization between the power consumption information collection terminal and the device to be time synchronized according to the time synchronization strategy, so as to optimize the synchronization time error through multiple time synchronizations.
2. The time synchronization method of the power consumption information collection terminal according to claim 1, characterized in that: The calculating the time deviation according to the first moment, the second moment, the third moment and the fourth moment includes: If the network delay between the power consumption information collection terminal and the master station server is symmetrical, then the time deviation is calculated according to the first moment, the second moment, the third moment and the fourth moment; If the network delay between the electricity consumption information collection terminal and the main station server is asymmetric, a first reference value is calculated according to the first moment and the second moment, and a second reference value is calculated according to the third moment and the fourth moment, an asymmetry coefficient is calculated based on the first reference value and the second reference value, and a time deviation is calculated according to the asymmetry coefficient, the first moment, the second moment, the third moment and the fourth moment.
3. The time synchronization method of the power consumption information collection terminal according to claim 2, characterized in that: The method further comprises: If the network delay between the power consumption information collection terminal and the master server is symmetrical, the time deviation The calculation formula is , wherein t1 is the first moment, t2 is the second moment, t3 is the third moment and t4 is the fourth moment; If the network delay between the power consumption information collection terminal and the main station server is asymmetric, the first reference value , the second reference value , the asymmetry coefficient is , the calculation formula of time deviation is .
4. The time synchronization method of the power consumption information collection terminal according to claim 1, characterized in that: The determining whether the smart electric energy meter needs to be time synchronized includes: Calculate the time deviation between the power consumption information collection terminal and the smart power meter, the time deviation d=T3+d2-T2; comparing the time deviation with a preset deviation; If the time deviation is less than or equal to the preset deviation, it is determined that the smart electric energy meter does not need to be time synchronized; If the time deviation is greater than a preset deviation, it is determined that the smart electric energy meter needs to be time synchronized.
5. The time synchronization method for a power consumption information collection terminal according to any one of claims 1 to 4, characterized in that: The optimizing the synchronization time error through multiple time synchronizations includes: Obtain multiple synchronization time errors corresponding to multiple time synchronizations; A maximum likelihood function is constructed based on the number of time synchronizations corresponding to the multiple time synchronizations; Filter out the minimum synchronization time error from multiple synchronization time errors; Determining a maximum likelihood estimate corresponding to the minimum synchronization time error based on the maximum likelihood function; determining a time offset according to the maximum likelihood estimate; The time offset is used to perform time compensation on the local clock corresponding to the power consumption information collection terminal, so as to optimize the synchronization time error.
6. A time synchronization device for a power consumption information collection terminal, characterized in that: The time synchronization device of the power consumption information collection terminal comprises: An acquisition module, used by the power consumption information collection terminal to acquire the address of the device to be time synchronized; A screening module, used for the power consumption information collection terminal to determine the device type of the device to be time synchronized according to the acquired address; A selection module, used for the power consumption information collection terminal to select a corresponding time synchronization strategy based on the device type, and the device type includes a master station server and a smart energy meter; A synchronization module, used for the power consumption information collection terminal to perform time synchronization with the device to be time synchronized according to the time synchronization strategy; Wherein, the synchronization module is further used for, when the device type is a master station server, the power consumption information collection terminal sends a time query request to the master station server, and records the sending time of the time query request as the first time; The main station server receives the time query request, and returns a time information packet to the power consumption information collection terminal based on the time query request, and records the time when the main station server receives the time query request as the second time, and the time when the time information packet is returned as the third time; The power consumption information collection terminal receives the time information packet returned by the master station server, and records the corresponding receiving time as the fourth time; Calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment; The power consumption information collection terminal performs time synchronization with the master station server based on the time deviation; and, when the device type is a smart electric energy meter, the power consumption information collection terminal sends a message to the smart electric energy meter and records the time T1 of sending the message, the message is used to collect the time of the smart electric energy meter, and the time required for the message to be sent from the power consumption information collection terminal to the smart electric energy meter is d1; After receiving the message, the smart energy meter returns the message to the power consumption information collection terminal. The time required for the message to return from the smart energy meter to the power consumption information collection terminal is d2; The power consumption information collection terminal receives the message returned by the smart power meter, records the time T2 when the returned message is received, and parses the time T3 from the returned message; Determining whether the smart electric energy meter needs time synchronization; If necessary, the time for the smart energy meter to process the message is determined to be d4=d3-d1-d2, where d3 represents the round-trip time from the power consumption information collection terminal sending the message to the smart energy meter until receiving the return message from the smart energy meter, and d3=T2-T1; The power consumption information collection terminal sends a time message to the smart power meter and records the time T4 when the time message is sent. The time message is used to synchronize time with the smart power meter. The time required for the time message to be sent from the power consumption information collection terminal to the smart power meter is d5, and the assembly time corresponding to the time message is d6; The power consumption information collection terminal calculates the time T5=T4+d4+d5+d6 of the smart energy meter correction carried in the time message, and performs time synchronization with the smart energy meter based on the time of the smart energy meter correction; A detection module, used to detect whether there is a synchronization time error between the power consumption information collection terminal and the device after completing time synchronization; The optimization module is used to return to the step of executing the time synchronization of the power consumption information collection terminal with the device to be time synchronized according to the time synchronization strategy if there is a synchronization time error, so as to optimize the synchronization time error through multiple time synchronizations.
7. The time synchronization device for power consumption information collection terminal according to claim 6, characterized in that: The synchronization module is used to calculate the time deviation according to the first moment, the second moment, the third moment and the fourth moment if the network delay between the power consumption information collection terminal and the master station server is symmetrical; If the network delay between the electricity consumption information collection terminal and the main station server is asymmetric, a first reference value is calculated according to the first moment and the second moment, and a second reference value is calculated according to the third moment and the fourth moment, an asymmetry coefficient is calculated based on the first reference value and the second reference value, and a time deviation is calculated according to the asymmetry coefficient, the first moment, the second moment, the third moment and the fourth moment.
Citation Information
Patent Citations
Electricity consumption information acquisition system clock management method and device
CN110320791A
Electric energy meter real-time data acquisition method based on service tunnel
CN115225429A