Automatic clock calibration method and system for acquisition terminal

Through the automatic clock calibration method of the acquisition terminal, the virtual task scheme and meter reading function are used to realize automatic calibration of clock abnormalities caused by clock battery undervoltage, solving the passiveness and untimely problems of the clock calibration method in the prior art, and improving the timeliness and stability of calibration.

CN119987177APending Publication Date: 2025-05-13QINGDAO ITECHENE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510379480.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The existing clock calibration methods of acquisition terminals have problems such as high passivity, untimely, limited application range and poor stability. Especially in the case of clock abnormalities caused by undervoltage of clock batteries, there is a lack of effective calibration solutions.

Method used

It provides an automatic clock calibration method for the acquisition terminal. By independently detecting the voltage and time of the clock battery, creating and initializing a virtual task scheme, multiplexing the original meter reading function for virtual meter reading tasks, calculating the reference time and setting the system time, realizing automatic clock calibration.

Benefits of technology

After the power is powered off and restarted, this method can detect and calibrate the clock automatically, reduce the problem of missing metering data caused by clock abnormalities, improve the timeliness and initiative of clock calibration, have high stability, and have a small impact on the original business functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119987177A_ABST
    Figure CN119987177A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of power utilization information acquisition systems, and discloses an automatic clock calibration method and system for an acquisition terminal, and the method comprises the steps: S1, judging whether the acquisition terminal is restarted after being restarted; if power-off restarting is carried out, the step S2 is executed; s2, judging that the current time of the clock or the voltage of the clock battery is out of a preset range, executing S3, and otherwise, executing S9; s3, closing an original clock calibration program of the acquisition terminal; s4, creating and initializing a virtual task scheme, and writing the virtual task scheme into a file and a database; s5, acquiring the total number of the electricity meters, and determining the number threshold value of the electricity meters needing to be read successfully; s6, executing a virtual meter reading task; s7, calculating reference time according to the time data of the electric meter acquired by the virtual meter reading task; s8, setting the reference time as system time; and S9, running a task initialization process. The clock automatic calibration method has strong timeliness and initiative, and is high in stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of power consumption information collection systems, and in particular to a clock automatic calibration method and system for a collection terminal. Background Art

[0002] The electric energy information acquisition terminal is a vital device in the power system, which realizes the real-time acquisition, storage, processing and remote transmission of electric energy. Through various sensors and communication interfaces, the acquisition terminal can centrally manage the key power parameter data such as current, voltage, power, etc. collected in real time, which is helpful for the load management and demand response of power companies.

[0003] The clock acquisition of the acquisition terminal depends on its internal clock management module, and some hardware circuits of the acquisition terminal are powered by the clock battery first. In the scenario of frequent power outages and power restorations, the acquisition terminal has the hidden danger of clock battery undervoltage. Clock battery undervoltage will cause the internal clock management module to be paralyzed, and the acquisition terminal time will be abnormal, affecting the accuracy of the acquisition of the acquisition terminal time, resulting in a decrease in the success rate of data collection in the low-voltage area. In severe cases, it will cause data to stop reading in the low-voltage area, seriously affecting the measurement indicators of the low-voltage area. Therefore, it is necessary to calibrate the clock of the acquisition terminal in time.

[0004] At present, there are three commonly used clock calibration methods for acquisition terminals, namely master station timing, heartbeat timing and satellite timing. Master station timing is the time when the acquisition master station sends a message to the acquisition terminal to complete the clock calibration of the acquisition terminal. This method is completely dependent on the operation of the acquisition master station, which is relatively passive and does not have the timeliness of timing. If there are a large number of stations with this problem, the processing method of master station timing will be difficult to implement. Heartbeat timing is to calculate the time error through the communication interaction between the acquisition master station and the terminal. If the error exceeds the set threshold, the acquisition terminal time is calibrated to the terminal time. This method depends on the interaction between the acquisition terminal and the acquisition master station, and has extremely high requirements on the communication conditions between the acquisition master station and the acquisition terminal. It is not suitable for use in remote areas. Satellite timing is currently less used. This method is greatly limited by weather conditions and the spatial location of the acquisition terminal. It has poor stability and poor actual application effect.

[0005] It can be seen that the above existing time calibration methods have the problems of being too passive, untimely, limited in scope of application, or unstable, and are not designed for calibrating clock anomalies caused by clock battery undervoltage.

[0006] Therefore, the prior art needs to be further improved. Summary of the invention

[0007] In response to the problems existing in the clock calibration method of the above-mentioned existing acquisition terminals, the present application provides a method and system for automatic clock calibration of an acquisition terminal. The method is designed for calibration of clock abnormalities caused by undervoltage of the clock battery. The method of autonomously detecting and calibrating the clock is highly proactive, reducing problems such as missing measurement data due to clock abnormalities.

[0008] To solve the above problems, this application provides the following technical solutions: The present application provides a method for automatically calibrating a clock of an acquisition terminal, which comprises the following steps: S1. After the acquisition terminal is restarted, determine whether it is a power-on restart; if it is a power-off restart, execute step S2; if it is a non-power-off restart, execute step S9; S2, reading the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and determining whether the current time of the clock is within a preset clock range or determining whether the current voltage of the clock battery is lower than a preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, executing S3; if the current time of the clock or the current voltage of the clock battery are both within the preset range, executing S9; S3, close the original clock calibration program of the acquisition terminal, and execute S4; S4, create and initialize a virtual task plan, and write the virtual task plan into a file and a database; obtain the sequence number of the virtual task plan, set the type of data collected by the virtual task plan to real-time data, the data item to be collected is time, the collection object is all electric meters, and execute according to the preset frequency; S5. Obtain the total number of electric meters stored in the database, and determine the threshold value of the number of electric meters that need to be successfully read for the virtual task plan based on the obtained electric meter data; S6, execute the virtual meter reading task, reuse the original meter reading function of the acquisition terminal to read the meter; Determine whether the execution time of the virtual meter reading task reaches the preset time threshold. If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the termination condition is met, and step S7 is executed; the termination condition is: the number of meters successfully read within the time threshold is not less than the preset meter number threshold; If the execution time reaches the preset time threshold and the number of successfully read meters is less than the meter number threshold, the original clock calibration procedure is restarted; S7, calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task, if the reference time is legal and valid, executing S8, if the reference time is illegal and valid, starting the original clock calibration program; S8, setting the reference time to the system time of the acquisition terminal; S9, running the task initialization process of the acquisition terminal after power-on.

[0009] Preferably, in the automatic clock calibration method of the acquisition terminal, step S8 further includes the following steps: clearing all data of the virtual task plan in the file and database.

[0010] Preferably, in the automatic clock calibration method of the acquisition terminal, the following steps are further included in step S1, S2 or S3: Determine whether there is a file storing the virtual task plan. If so, clear the content of the file and all data of the corresponding task in the database and execute the next step. If the file does not exist, directly execute the next step.

[0011] Preferably, in the automatic clock calibration method of the acquisition terminal, in step S4, the method for obtaining the serial number of the virtual task plan is: starting from the task plan with the largest serial number, traversing forward all the task plans stored in the database in order of serial numbers from large to small, and setting the first unused serial number queried as the serial number of the virtual task plan.

[0012] Preferably, in the automatic clock calibration method of the acquisition terminal, step S4 further includes: pausing all other tasks of the acquisition terminal except the virtual task plan.

[0013] This step is set to improve the efficiency of the time calibration method. After completing the automatic calibration procedure, all programs of the acquisition terminal will be restored.

[0014] Preferably, in the automatic clock calibration method of the acquisition terminal, in step S6, the method of reusing the original meter reading function of the acquisition terminal to perform meter reading is specifically: according to the port number obtained in the meter file, the meter reading task of the channel corresponding to the port number is executed, the meter clock is read according to the meter type group protocol, and according to the collection cycle, collection frequency and collection object configured in the virtual task plan, the virtual meter reading task is autonomously executed at the set frequency, and the collection reply data is stored in the collection terminal database.

[0015] Preferably, in the automatic clock calibration method of the acquisition terminal, the original clock calibration procedure is heartbeat time calibration or satellite time calibration.

[0016] Preferably, in the automatic clock calibration method of the acquisition terminal, in step S2, the preset clock range is 1970~2060; the preset voltage range is 2.5~3V.

[0017] Preferably, in the automatic clock calibration method of the acquisition terminal, step S6 further comprises: During the execution of the virtual meter reading task, check in real time whether there are any changes in the meter files; If there is a change in the meter file, execute step S4, recreate and initialize the virtual task plan, write the virtual task plan into the file and database, and update the meter reading information; If there is no change in the meter file, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold reaches the meter quantity threshold or the execution time reaches the time threshold.

[0018] Preferably, in the automatic clock calibration method of the acquisition terminal, in step S7, the method for calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task is: the reference time is calculated by removing the average value or taking the median according to the time data of the electric meter collected by the virtual meter reading task.

[0019] In a second aspect, the present invention further provides a clock automatic calibration system applied to an acquisition terminal, comprising: The first judgment module is used to judge whether it is a power-on restart after the acquisition terminal is restarted; if it is a power-off restart, the second judgment module is triggered; if it is a non-power-off restart, the initialization operation module is triggered to work; The second reading and judging module is used to read the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and then judge whether the current time of the clock is within the preset clock range or whether the current voltage of the clock battery is within the preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, the shutdown module is triggered to work; if the current time of the clock or the current voltage of the clock battery are both within the preset range, the initialization operation module is triggered to work; A closing module is used to close the original clock calibration program of the acquisition terminal; A virtual scheme creation module is used to create and initialize a virtual task scheme, and write the virtual task scheme into a file and a database; it is specifically used to obtain the sequence number of the virtual task scheme, set the type of virtual task scheme collection to real-time data, the collection data item to time, the collection object to all electric meters, and execute according to a preset frequency; An acquisition module is used to acquire the total number of electric meters stored in the database, and determine the threshold value of the number of electric meters that need to be successfully read according to the acquired electric meter data; A virtual meter reading task execution module is used to execute virtual meter reading tasks by reusing the original meter reading function of the acquisition terminal; The virtual meter reading task execution module includes the following units: A time threshold judgment unit is used to judge whether the execution time of the virtual meter reading task reaches a preset time threshold. If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold is not less than the preset meter number threshold, and the collected time data of the meters is sent to the reference time calculation module; It is also used to restart the original clock calibration procedure if the execution time reaches a preset time threshold and the number of successfully read meters is less than the meter number threshold; The benchmark time calculation module includes: A reference time calculation unit, used to calculate the reference time according to the time data of the electric meter collected by the virtual meter reading task; A reference time judgment unit is used to judge whether the reference time is legal and valid. If the reference time is legal and valid, the system time setting module is triggered to work. If the reference time is illegal and valid, the original clock calibration program is started; A system time setting module, used to set the reference time sent by the reference time judgment unit as the system time of the acquisition terminal; The initialization operation module is used to run the task initialization process of the acquisition terminal after power-on.

[0020] The present invention has the following beneficial effects: 1. The clock automatic calibration method provided by the present invention can perform self-detection on the clock battery after power failure and restart to determine whether the clock is under-voltage. The processing of clock under-voltage and other clock abnormality problems is highly timely and proactive, and has high stability.

[0021] 2. The automatic clock calibration method of the acquisition terminal of the present invention adopts the method of creating and initializing a virtual task plan to obtain the meter clock information for calibration of the acquisition terminal with abnormal clock. The original meter reading process in the program can be reused, the program changes are small, the stability is high, the impact on the original business functions of the acquisition terminal is small, and it will not cause a major impact on the data collection of the actual on-site substation. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a flowchart of the clock automatic calibration method of the acquisition terminal of Example 1; Figure 2 This is a flow chart of the automatic clock calibration method of the acquisition terminal of Example 3. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0024] It should be noted that when an element is described as being "fixed to" another element, it can be directly on the other element, or one or more centered elements can exist between them. When an element is described as being "connected" to another element, it can be directly connected to the other element, or one or more centered elements can exist between them. The terms "vertical", "horizontal", "left", "right", "upper", "lower", "inner", "outer", "bottom", etc. used in this specification indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0025] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used in this specification and in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used in this specification includes any and all combinations of one or more related listed items. In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0026] Example 1 This embodiment provides a clock automatic calibration method applied to an acquisition terminal, such as Figure 1 As shown, the clock automatic calibration method includes the following steps: S1. After the acquisition terminal is restarted, determine whether it is a power-on restart; if it is a power-off restart, execute step S2; if it is a non-power-off restart, execute step S9.

[0027] This method is to calibrate the clock time due to the clock battery undervoltage of the acquisition terminal caused by frequent power outages and power restorations. Therefore, first check whether it is a power-on restart. If it is a power-on restart, this is the situation where the subsequent clock calibration method needs to be executed, and then proceed to the next step.

[0028] If it is found that the current state of the system is not a power-off restart, such as a normal startup, there is no need for clock calibration caused by clock battery undervoltage. Therefore, it is possible to directly enter step S9 and directly run the task initialization process of the acquisition terminal after power-on.

[0029] The setting of this step can quickly identify and check whether there are prerequisites that cause clock undervoltage and clock abnormality. If there are no such prerequisites, the system can quickly run the task initialization process of the acquisition terminal after power-on to improve the speed of system restart tasks.

[0030] S2. Read the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and determine whether the current time of the clock is within the preset clock range or whether the current voltage of the clock battery is within the preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, execute S3; if the current time of the clock or the current voltage of the clock battery are both within the preset range, execute S9.

[0031] On the one hand, it is determined whether the current voltage of the clock battery is within a preset voltage range (for example, the preset voltage range is 2.5~3V), specifically, it is determined whether the current voltage of the clock battery is lower than the lowest threshold of the preset voltage range (for example, whether it is lower than 2.5~3V). This method directly determines that the state is a clock battery undervoltage caused by power outage based on the voltage value.

[0032] Preferably, the preset voltage range is 2.5-3V, which can accurately identify the clock battery undervoltage caused by power outage.

[0033] On the other hand, another manifestation of clock battery undervoltage caused by power outage is that the deviation between the abnormal clock time and the actual time is extremely large, while the deviation between the abnormal clock time and the actual time caused by other non-clock battery undervoltage conditions is smaller.

[0034] Therefore, by setting a time range that is far away from the actual time as the preset clock range, and judging whether the current clock time is outside the preset clock range, it is possible to quickly identify that the current time anomaly is caused by clock undervoltage due to power outage, which is a situation where the scheme requires time calibration, and thus execute S3.

[0035] Preferably, the preset clock range is from 1970 to 2060.

[0036] S3. Close the original clock calibration program of the acquisition terminal and execute S4.

[0037] The original clock calibration procedure is heartbeat calibration or satellite calibration.

[0038] S4. Create and initialize a virtual task plan, and write the virtual task plan into a file and a database; obtain the serial number of the virtual task plan, set the type of data collected by the virtual task plan to real-time data, the collected data item to time, the collection object to all electric meters, and execute according to the preset frequency.

[0039] By self-checking the clock battery through power-off restart and under-voltage, this method is timely and proactive in calibrating the clock of the acquisition terminal, and well solves the problems existing in the existing time calibration method.

[0040] S5. Obtain the total number of electric meters stored in the database, and determine a threshold value of the number of electric meters that needs to be successfully read for the virtual task solution based on the obtained electric meter data.

[0041] Since the workload of reading the time data of all the meters connected to the collection terminal is large, which greatly affects the effect of time calibration, reading the meter time of a part of all the meters can take into account both the efficiency of reading and the accuracy of time calibration.

[0042] Therefore, the total number of electric meters stored in the database can be first obtained, so as to calculate and determine the threshold value X of the number of electric meters that need to be successfully read in the virtual task scheme according to the set specifications.

[0043] The set specification may be a preset certain ratio, such as 60% or 50% or other more complex setting methods. For example, if the set specification is 60%, and the total number of electric meters is 10, the threshold number of electric meters that need to be successfully read is 6.

[0044] Preferably, segmented settings can be performed according to the size of the number of electric meters, and different specifications are set for each number segment to determine the threshold value of the number of electric meters that need to be successfully read.

[0045] For example, when the total number of electricity meters S ≥ 10, the threshold value of the number of electricity meters successfully read is set to X = 5; When 5≤total number of meters S<10, set the threshold of the number of meters successfully read X=3; When the total number of electric meters S is less than 5, the threshold value of the number of electric meters successfully read is set to X=1.

[0046] S6. Execute a virtual meter reading task, reuse the original meter reading function of the acquisition terminal to read the meter, and obtain real-time time data of multiple meters.

[0047] During the execution process, it is determined whether the execution time of the virtual meter reading task reaches a preset time threshold (e.g., 2 hours); If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the termination condition is met, and step S7 is executed; the termination condition is: the number of meters successfully read within the time threshold is not less than the preset meter number threshold.

[0048] If the execution time reaches the preset time threshold, but the number of successfully read meters is less than the meter number threshold, the reading fails, and the original clock calibration program is restarted.

[0049] The setting of the above time threshold can ensure the overall efficiency of the time calibration method. When the execution time of the above virtual meter reading task exceeds the time threshold and continues to be executed, it will lead to a long cycle of the time calibration method, low efficiency, and affect the speed of restarting the acquisition terminal. Therefore, when the execution time of the above virtual meter reading task reaches the time threshold and fails, it is selected to restart the original clock calibration program.

[0050] Optionally, the original clock calibration procedure is heartbeat calibration or satellite calibration.

[0051] S7, calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task, if the reference time is legal and valid, executing S8, if the reference time is illegal and valid, starting the original clock calibration program.

[0052] Optionally, the method for determining whether the reference time is legal and valid is: determining whether the reference time is within a preset legal time threshold; if so, the reference time is legal and valid; if not, the reference time is illegal and invalid.

[0053] The legal time threshold may be set to a time interval that is relatively close to the actual time (year or year-month or year-month-day, etc.), and may be reasonably set according to actual conditions, such as 2010 to 2030.

[0054] S8. Set the reference time to the system time of the acquisition terminal.

[0055] S9, running the task initialization process of the acquisition terminal after power-on.

[0056] The automatic clock calibration method of this embodiment will perform a self-test on the clock battery after power failure and restart. After determining that the clock is undervoltage, a new virtual task method is created in a timely and autonomous manner to collect the real-time time of multiple connected electricity meters to quickly calibrate the clock of the collection terminal. This method has strong timeliness, initiative and stability.

[0057] This embodiment also provides a clock automatic calibration system applied to an acquisition terminal, which includes the following modules: The first judgment module is used to judge whether it is a power-on restart after the acquisition terminal is restarted; if it is a power-off restart, the second judgment module is triggered; if it is a non-power-off restart, the initialization operation module is triggered to work; The second reading and judging module is used to read the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and then judge whether the current time of the clock is within the preset clock range or whether the current voltage of the clock battery is within the preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, the shutdown module is triggered to work; if the current time of the clock or the current voltage of the clock battery are both within the preset range, the initialization operation module is triggered to work; A closing module is used to close the original clock calibration program of the acquisition terminal; A virtual scheme creation module is used to create and initialize a virtual task scheme, and write the virtual task scheme into a file and a database; it is specifically used to obtain the sequence number of the virtual task scheme, set the type of virtual task scheme collection to real-time data, the collection data item to time, the collection object to all electric meters, and execute according to a preset frequency; An acquisition module is used to acquire the total number of electric meters stored in the database, and determine the threshold value of the number of electric meters that need to be successfully read according to the acquired electric meter data; A virtual meter reading task execution module is used to execute virtual meter reading tasks by reusing the original meter reading function of the acquisition terminal; The virtual meter reading task execution module includes the following units: A time threshold judgment unit is used to judge whether the execution time of the virtual meter reading task reaches a preset time threshold. If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold is not less than the preset meter number threshold, and the collected time data of the meters is sent to the reference time calculation module; It is also used to restart the original clock calibration procedure if the execution time reaches a preset time threshold and the number of successfully read meters is less than the meter number threshold; The benchmark time calculation module includes: A reference time calculation unit, used to calculate the reference time according to the time data of the electric meter collected by the virtual meter reading task; A reference time judgment unit is used to judge whether the reference time is legal and valid. If the reference time is legal and valid, the system time setting module is triggered to work. If the reference time is illegal and valid, the original clock calibration program is started; A system time setting module, used to set the reference time sent by the reference time judgment unit as the system time of the acquisition terminal; The initialization operation module is used to run the task initialization process of the acquisition terminal after power-on.

[0058] Example 2 On the basis of Example 1, in order to further optimize the solution, this embodiment provides a method for automatically calibrating a clock of an acquisition terminal, the method comprising the following steps: S1. After the acquisition terminal is restarted, determine whether it is a power-on restart; if it is a power-off restart, execute step S2; if it is a non-power-off restart, execute step S9.

[0059] S2. Read the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and determine whether the current time of the clock is within the preset clock range or whether the current voltage of the clock battery is within the preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, execute S3; if the current time of the clock or the current voltage of the clock battery are both within the preset range, execute S9.

[0060] Optionally, the preset clock range is 1970~2060; the preset voltage range is 2.5~3V.

[0061] S3. Close the original clock calibration program of the acquisition terminal and execute S4.

[0062] The original clock calibration procedure is heartbeat calibration or satellite calibration.

[0063] S31, check whether there is a file storing the virtual task plan. If so, clear the content of the file and all data of the corresponding task in the database and execute the next step. If the file does not exist, directly execute the next step.

[0064] This step is set to prevent the existing historical virtual task solution from interfering with the execution of the newly created virtual task solution. In other embodiments, this step can also be adjusted to step S2 or step S1.

[0065] S4. Create and initialize a virtual task plan, and write the virtual task plan into a file and a database; obtain the serial number of the virtual task plan, set the type of data collected by the virtual task plan to real-time data, the collected data item to time, the collection object to all electric meters, and execute according to the preset frequency.

[0066] Among them, the method for obtaining the serial number of the virtual task plan is: starting from the task plan with the largest serial number, traverse all the task plans stored in the database in order from large to small serial numbers (such as serial number 255), and set the first unused serial number queried as the serial number of the virtual task plan.

[0067] The above setting is to quickly find unused serial numbers in the existing task methods, which can improve the speed of obtaining the serial numbers of the virtual task plan.

[0068] Step S4 also includes: suspending all other tasks of the acquisition terminal except the virtual task plan. This step is set to improve the implementation efficiency of the time calibration method.

[0069] Since other running tasks will greatly affect the execution efficiency of the virtual task plan, in order to improve the time calibration efficiency, all other tasks of the acquisition terminal except the virtual task plan can be suspended. After completing the automatic calibration program, all programs of the acquisition terminal will be restored.

[0070] S5. Obtain the total number of electric meters stored in the database, and determine the threshold of the number of electric meters that need to be successfully read for the virtual task plan based on the obtained electric meter data. At the same time, obtain the database port number and protocol type.

[0071] The total number of electric meters stored in the database can be first obtained, so as to calculate and determine the threshold value X of the number of electric meters that need to be successfully read in the virtual task scheme according to the set specifications.

[0072] Preferably, segmented settings can be performed according to the size of the number of electric meters, and different specifications are set for each number segment to determine the threshold value of the number of electric meters that need to be successfully read.

[0073] For example, first determine whether the total number of meters S is ≥ 10. If so, set the threshold value of the number of meters successfully read X = 5; If the total number of electric meters S is less than 10, it is further determined whether the total number of electric meters S meets the condition when 5≤S<10. If the condition is met, the threshold value of the number of electric meters successfully read is set to X=3; If the total number of meters does not satisfy the condition 5≤S<10, it is further determined whether the total number of meters is less than 5. If so, the threshold value X of the number of meters successfully read is set to 1.

[0074] S6. Execute a virtual meter reading task, reuse the original meter reading function of the acquisition terminal to read the meter, and obtain real-time time data of multiple meters.

[0075] The method for multiplexing the original meter reading function of the acquisition terminal to perform meter reading is specifically as follows: According to the port number obtained from the meter file, execute the meter reading task of the channel corresponding to the port number, read the meter clock according to the meter type group protocol (such as 698 protocol or 645 protocol), and execute the virtual meter reading task autonomously at the set frequency according to the collection cycle, collection frequency and collection object configured in the virtual task plan, and store the collected reply data in the collection terminal database to facilitate the calculation and acquisition of the benchmark time in the subsequent steps.

[0076] Further, preferably, the method for multiplexing the original meter reading function of the acquisition terminal to perform meter reading comprises the following steps: S61, judging whether the meter port is a carrier port according to the port number obtained from the meter file; S62: If the meter port is a non-carrier port, start the 485 meter reading process; If the meter port is a carrier port, start the carrier meter reading process.

[0077] S63, determining whether the electric meter adopts the DLT698 protocol (a communication protocol adopted by a smart electric energy meter): If it is DLT698 protocol, perform DLT698 protocol framing and store the collected reply data into the collection terminal database; If the electric meter does not use the DLT698 protocol, the DLT645 protocol is framed and the collected reply data is stored in the collection terminal database.

[0078] The above-mentioned method of performing meter reading in the virtual meter reading task by reusing the original meter reading process of the collection terminal fully utilizes the existing meter reading process in the program, has small program changes, low cost, high stability, little impact on the original business functions of the collection terminal, and will not cause a major impact on the data collection of the actual on-site substation.

[0079] S64. During the execution of the virtual meter reading task, check whether the execution time of the virtual meter reading task reaches a preset time threshold: If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the termination condition is met, and step S7 is executed; the termination condition is: the number of meters successfully read within the time threshold is not less than the preset meter number threshold; If the execution time reaches a preset time threshold and the number of successfully read meters is less than the meter number threshold, the original clock calibration procedure is restarted.

[0080] Furthermore, in order to avoid meter reading anomalies caused by meter file changes and ensure the normal operation of the virtual meter reading task process, step S6 also includes: S65. During the execution of the virtual meter reading task, checking in real time whether there is any change in the meter file; If there is a change in the meter file, execute step S4, recreate and initialize the virtual task plan, write the virtual task plan into the file and database, and update the meter reading information; If there is no change in the meter file, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold reaches the meter quantity threshold or the execution time reaches the time threshold.

[0081] Steps S64 and S65 are not a sequential process, but are performed simultaneously.

[0082] S7, calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task, if the reference time is legal and valid, executing S8, if the reference time is illegal and valid, starting the original clock calibration program.

[0083] Preferably, the method for calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task is: the reference time is calculated by removing the average value according to the time data of the electric meter collected by the virtual meter reading task.

[0084] In other embodiments, the method for calculating the reference time based on the time data of the electric meter collected by the virtual meter reading task can also adopt a median method, in which the collected data is sorted and then the median is taken to avoid the influence of extreme values ​​on the results.

[0085] S8. Set the reference time to the system time of the acquisition terminal.

[0086] It also includes: clearing all data of virtual task plans in files and databases.

[0087] S9, running the task initialization process of the acquisition terminal after power-on.

[0088] Example 3 In order to facilitate the understanding of the solution of the present invention, this embodiment provides a specific implementation method for illustration: A method for automatically calibrating a clock of an acquisition terminal, the method comprising the following steps: S1. After the acquisition terminal is restarted, determine whether it is a power-on restart; if it is a power-off restart, execute step S2; if it is a non-power-off restart, execute step S9.

[0089] At the same time, check whether there is a file storing the virtual task plan. If so, clear the file content and all data of the virtual task plan in the database and execute the next step.

[0090] S2, read the current time of the clock of the acquisition terminal or the current voltage of the clock battery, and if it is determined that the current time of the clock (such as 1965) is outside the preset clock range (1970~2060), then execute S3; or if it is determined that the current voltage of the clock battery is 1.5V, which is lower than the preset voltage range of 2.5V, then execute S3.

[0091] S3. Turn off the original heartbeat calibration of the acquisition terminal and execute S4.

[0092] S4. Create and initialize a virtual task plan, and write the virtual task plan into a file and a database.

[0093] S41. First, obtain the serial number of the virtual task plan by: starting from the task plan with the largest serial number, traverse all the task plans stored in the database from serial number 255 in descending order, and set the first unused serial number 250 found as the serial number of the virtual task plan.

[0094] S42, set the type of virtual task plan collection to "real-time data", the collection data item to "time (4000)", the collection object to "all meters", execute according to the preset frequency (5min), and write the virtual task plan into files and databases.

[0095] At the same time, all other tasks of the acquisition terminal except the virtual task plan are suspended. This step is set to improve the implementation efficiency of the time calibration method.

[0096] S5. Obtain the total number of electric meters stored in the database, the database port number, and the protocol type. Determine the threshold value of the number of electric meters that the virtual task solution needs to read successfully based on the acquired electric meter data.

[0097] The rules set are: Determine whether the total number of meters S is ≥10. If so, set the threshold value of the number of successfully read meters X=5; if not, further determine whether the total number of meters S meets the condition when 5≤S<10. If so, set the threshold value of the number of successfully read meters X=3; if not, further determine whether the total number of meters is less than 5. If so, set the threshold value of the number of successfully read meters X=1.

[0098] In this embodiment, the total number of electricity meters obtained is 12, so the threshold value X of the number of electricity meters successfully read is set to 5.

[0099] S6. Execute the virtual meter reading task and reuse the original meter reading function of the acquisition terminal to read the meter: S61, judging whether the meter port is a carrier port according to the port number obtained from the meter file; S62: If the meter port is a non-carrier port, start the 485 meter reading process; if the meter port is a carrier port, start the carrier meter reading process.

[0100] S63, determine whether the electric meter adopts the DLT698 protocol. If it adopts the DLT698 protocol, perform framing of the DLT698 protocol and store the collected reply data in the collection terminal database; if the electric meter does not adopt the DLT698 protocol, perform framing of the DLT645 protocol and store the collected reply data in the collection terminal database.

[0101] S64: During the execution of the virtual meter reading task, check whether the execution time of the virtual meter reading task reaches a preset time threshold, where the preset time threshold is 2 hours: If the number of meters successfully read is less than 5 within 2 hours, continue to execute the virtual meter reading task until the termination condition is met and proceed to the next step.

[0102] At the same time, whether there is any change in the meter file is checked in real time. Once the change in the meter file is found, step S4 is executed to recreate and initialize the virtual task plan, write the virtual task plan into the file and the database, and update the meter reading information.

[0103] The virtual meter reading task is executed until the number of meters successfully read within the time threshold reaches the meter quantity threshold of 5 or the execution time reaches 2 hours.

[0104] S7. Calculate the reference time according to the time data of the electric meter collected by the virtual meter reading task by removing the average value. If the obtained reference time is legal and valid, execute S8. If the reference time is illegal and valid, start the original heartbeat time calibration.

[0105] S8, the reference time is set to the system time of the acquisition terminal. At the same time, all data of the virtual task plan in the file and database are cleared.

[0106] S9, running the task initialization process of the acquisition terminal after power-on.

[0107] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0108] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for automatically calibrating the clock of an acquisition terminal, characterized in that: The following steps are involved: S1. After the acquisition terminal is restarted, determine whether it is a power-on restart; if it is a power-off restart, execute step S2; if it is a non-power-off restart, execute step S9; S2, reading the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and determining whether the current time of the clock is within a preset clock range or determining whether the current voltage of the clock battery is within a preset voltage range; If the current time of the clock or the current voltage of the clock battery is outside the preset range, then execute S3; if the current time of the clock or the current voltage of the clock battery are both within the preset range, then execute S9; S3, close the original clock calibration program of the acquisition terminal, and execute S4; S4, create and initialize a virtual task plan, and write the virtual task plan into a file and a database; obtain the sequence number of the virtual task plan, set the type of data collected by the virtual task plan to real-time data, the data item to be collected is time, the collection object is all electric meters, and execute according to the preset frequency; S5. Obtain the total number of electric meters stored in the database, and determine the threshold value of the number of electric meters that need to be successfully read for the virtual task plan based on the obtained electric meter data; S6, execute the virtual meter reading task, reuse the original meter reading function of the acquisition terminal to read the meter; Determine whether the execution time of the virtual meter reading task reaches the preset time threshold. If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the termination condition is met, and step S7 is executed; the termination condition is: the number of meters successfully read within the time threshold is not less than the preset meter number threshold; If the execution time reaches the preset time threshold and the number of successfully read meters is less than the meter number threshold, the original clock calibration procedure is restarted; S7, calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task, if the reference time is legal and valid, executing S8, if the reference time is illegal and valid, starting the original clock calibration program; S8, setting the reference time to the system time of the acquisition terminal; S9, running the task initialization process of the acquisition terminal after power-on.

2. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: The step of S8 also includes the following steps: clearing all data of the virtual task plan in the file and database.

3. The clock automatic calibration method of the acquisition terminal according to claim 1, characterized in that: The step S1, S2 or S3 also includes the following steps: Determine whether there is a file storing the virtual task plan. If so, clear the content of the file and all data of the corresponding task in the database and execute the next step. If the file does not exist, directly execute the next step.

4. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: In step S4, the method for obtaining the serial number of the virtual task plan is: starting from the task plan with the largest serial number, traverse all the task plans stored in the database in order from large to small, and set the first unused serial number found as the serial number of the virtual task plan.

5. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: Step S4 also includes: suspending all other tasks of the acquisition terminal except the virtual task plan.

6. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: In step S6, the method of reusing the original meter reading function of the collection terminal to perform meter reading is specifically as follows: according to the port number obtained from the meter file, the meter reading task of the channel corresponding to the port number is executed, the meter clock is read according to the meter type group protocol, and according to the collection cycle, collection frequency and collection object configured in the virtual task plan, the virtual meter reading task is executed autonomously at the set frequency, and the collection reply data is stored in the collection terminal database.

7. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: In step S2, the preset clock range is 1970-2060; the preset voltage range is 2.5-3V.

8. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: Step S6 also includes: During the execution of the virtual meter reading task, check in real time whether there are any changes in the meter files; If there is a change in the meter file, execute step S4, recreate and initialize the virtual task plan, write the virtual task plan into the file and database, and update the meter reading information; If there is no change in the meter file, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold reaches the meter quantity threshold or the execution time reaches the time threshold.

9. The automatic clock calibration method of the acquisition terminal according to claim 1, characterized in that: In step S7, the method for calculating the reference time according to the time data of the electric meter collected by the virtual meter reading task is: the reference time is calculated by removing the average value or taking the median according to the time data of the electric meter collected by the virtual meter reading task.

10. A clock automatic calibration system applied to an acquisition terminal, characterized in that: include: The first judgment module is used to judge whether it is a power-on restart after the acquisition terminal is restarted; If it is a power-off restart, the second judgment module is triggered; if it is a non-power-off restart, the initialization operation module is triggered to work; The second reading and judging module is used to read the current time of the clock of the acquisition terminal and the current voltage of the clock battery, and then judge whether the current time of the clock is within the preset clock range or whether the current voltage of the clock battery is within the preset voltage range; if the current time of the clock or the current voltage of the clock battery is outside the preset range, the shutdown module is triggered to work; if the current time of the clock or the current voltage of the clock battery are both within the preset range, the initialization operation module is triggered to work; A closing module is used to close the original clock calibration program of the acquisition terminal; A virtual scheme creation module is used to create and initialize a virtual task scheme, and write the virtual task scheme into a file and a database; it is specifically used to obtain the sequence number of the virtual task scheme, set the type of virtual task scheme collection to real-time data, the collection data item to time, the collection object to all electric meters, and execute according to a preset frequency; An acquisition module is used to acquire the total number of electric meters stored in the database, and determine the threshold value of the number of electric meters that need to be successfully read according to the acquired electric meter data; A virtual meter reading task execution module is used to execute virtual meter reading tasks by reusing the original meter reading function of the acquisition terminal; The virtual meter reading task execution module includes the following units: A time threshold judgment unit is used to judge whether the execution time of the virtual meter reading task reaches a preset time threshold. If the execution time does not reach the time threshold, the virtual meter reading task continues to be executed until the number of meters successfully read within the time threshold is not less than the preset meter number threshold, and the collected time data of the meters is sent to the reference time calculation module; It is also used to restart the original clock calibration procedure if the execution time reaches a preset time threshold and the number of successfully read meters is less than the meter number threshold; The benchmark time calculation module includes: A reference time calculation unit, used to calculate the reference time according to the time data of the electric meter collected by the virtual meter reading task; A reference time judgment unit is used to judge whether the reference time is legal and valid. If the reference time is legal and valid, the system time setting module is triggered to work. If the reference time is illegal and valid, the original clock calibration program is started; A system time setting module, used to set the reference time sent by the reference time judgment unit as the system time of the acquisition terminal; The initialization operation module is used to run the task initialization process of the acquisition terminal after power-on.