A method of device time calibration and related devices

CN122554040APending Publication Date: 2026-08-11ZKTECO CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0005]本发明提供了一种设备时间校准方法和相关设备,解决了级联偏差累积、授时精度低、属地适配性差的问题

Benefits of technology

[0041]从以上技术方案可以看出,本发明具有以下优点:本发明提供的一种设备时间校准方法和相关设备,其通过部署独立的主时间源设备接收属地标准时间服务器的授时信号获得基准时间,实现高精度时间同步,适配不同地域使用规范;通过主时间源设备将基准时间经由与各下级设备之间的一对一校准链路,下发至各下级设备,摒弃了传统级联下发方式,彻底消除了时间偏差逐级累积的问题;同时,下级设备基于接收到的基准时间校准自身的当前设备时间,避免了终端设备异常时间戳对服务器时间的篡改风险,从根源上解决了因时间跳变导致的设备掉线、命令下发失败等问题,显著提升了系统的时间稳定性与运行可靠性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122554040A_ABST
    Figure CN122554040A_ABST
Patent Text Reader

Abstract

The application discloses a device time calibration method and related equipment, applied to a system comprising a main time source device and multiple subordinate devices, comprising: the main time source device receives a time service signal of a local standard time server, performs time calibration based on the time service signal, and obtains a reference time; the main time source device transmits the reference time to each subordinate device via a calibration link between the main time source device and each subordinate device according to a preset calibration period; and each subordinate device synchronously calibrates the current device time based on the received reference time. The application realizes high-precision time synchronization, adapts to different regional use specifications, discards the traditional cascading transmission mode, completely eliminates the problem of time deviation accumulation, fundamentally solves the problems of device disconnection, command transmission failure and the like caused by time jump, significantly improves the time stability and operation reliability of the system, and can be widely applied to the technical field of time synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of time synchronization technology, and more particularly to a device time calibration method and related equipment. Background Technology

[0002] In large-scale distributed access control systems such as subways and industrial parks, various devices such as turnstiles, access control terminals, and servers are deployed. The operation of these devices, such as access records and instruction issuance, is highly dependent on a unified and stable time base. The accuracy and stability of time synchronization are crucial to the normal operation of the system.

[0003] In existing technologies, time synchronization of multi-level devices often adopts a cascading distribution method of "upper-level device → intermediate-level device → lower-level device", with time being transmitted level by level along the link; at the same time, the terminal device will periodically push its own timestamp to the server, and the server will update the system time based on the received terminal timestamps.

[0004] However, the cascading delivery method causes time deviations to accumulate at each level, and abnormal timestamps on terminal devices can easily cause server time jumps, resulting in device disconnection and command delivery failure. At the same time, existing technologies lack a unified high-precision time reference and cannot be adapted to the standard time specifications of the project location. Summary of the Invention

[0005] This invention provides a device time calibration method and related equipment, which solves the problems of cascade deviation accumulation, low time synchronization accuracy, and poor local adaptability.

[0006] In a first aspect, the present invention provides a device time calibration method, applied to a system including a main time source device and multiple subordinate devices, characterized in that the method includes:

[0007] The main time source device receives the time signal from the local standard time server, performs time calibration based on the time signal, and obtains the reference time.

[0008] The master time source device transmits the reference time to each of the lower-level devices via the calibration link between the master time source device and each of the lower-level devices according to a preset calibration cycle.

[0009] Each of the lower-level devices performs time synchronization calibration on the current device based on the received reference time.

[0010] In some embodiments, each of the lower-level devices performs synchronization calibration of the current device time based on the received reference time, including:

[0011] Each of the lower-level devices receives the reference time and calculates a first deviation between the reference time and the current device time;

[0012] If the first deviation is less than a preset first threshold, the lower-level device sets the current device time to the reference time;

[0013] If the first deviation is equal to or greater than a preset first threshold, the lower-level device triggers immediate calibration.

[0014] In some embodiments, the plurality of subordinate devices include at least one terminal device and at least one master server, and the method further includes:

[0015] If the master server receives a communication request from the terminal device, it obtains the server system time and the current calibration identifier, calculates the second deviation between the timestamp bound in the communication request and the server system time, and compares the current calibration identifier with the calibration identifier to be tested in the timestamp.

[0016] If the second deviation is equal to or exceeds a preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, then the master server rejects the communication request;

[0017] If the second deviation is less than a preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the main server receives the communication data corresponding to the communication request.

[0018] In some embodiments, before the master time source device sends the reference time to each of the lower-level devices via calibration links according to a preset calibration cycle, the process includes:

[0019] The main time source device acquires the target communication protocol;

[0020] The master time source device establishes calibration links with each of the subordinate devices based on the target communication protocol.

[0021] In some embodiments, triggering instantaneous calibration includes:

[0022] The lower-level device generates and records an abnormal jump event based on the first deviation and the current device time;

[0023] The lower-level device sends a time calibration request to the main time source device;

[0024] The lower-level device receives a first reference time corresponding to the time calibration request returned by the main time source device, and sets the current device time to the first reference time.

[0025] In some embodiments, the method further includes:

[0026] Within a preset time monitoring window, the main server counts the number of terminal devices that report target abnormal error codes.

[0027] If the number of terminal devices exceeds a preset threshold, the main server determines that the devices are in batch anomaly and triggers an anomaly calibration.

[0028] In some embodiments, triggering abnormal calibration includes:

[0029] The master server detects the calibration link with the master time source device according to the preset link detection rules and determines the link operation status;

[0030] If the link is in normal operation, the master server initiates an abnormal calibration request to the master time source device, receives a second reference time corresponding to the abnormal calibration request from the master time source device, and sets the current device time to the second reference time.

[0031] If the link is in an abnormal operating state, the master server generates a link alarm message and triggers a manual adjustment operation.

[0032] Secondly, the present invention provides a device time calibration apparatus, comprising a main time source device and multiple subordinate devices;

[0033] The main time source device is used to receive the time signal from the local standard time server, perform time calibration based on the time signal, and obtain the reference time.

[0034] The main time source device is also used to send the reference time to each of the lower-level devices via the calibration link between the device and each lower-level device according to a preset calibration cycle.

[0035] The lower-level device is used to synchronize and calibrate the current device time based on the received reference time.

[0036] In some embodiments, the plurality of subordinate devices include at least one terminal device and at least one master server;

[0037] The master server is configured to: if it receives a communication request from the terminal device, obtain the server system time and the current calibration identifier, calculate the second deviation between the timestamp bound in the communication request and the server system time, and compare the current calibration identifier with the calibration identifier to be tested in the timestamp;

[0038] If the second deviation is equal to or exceeds a preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, then the communication request is rejected.

[0039] If the second deviation is less than a preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the communication data corresponding to the communication request is received.

[0040] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the above-described device time calibration method.

[0041] As can be seen from the above technical solutions, the present invention has the following advantages: The device time calibration method and related equipment provided by the present invention obtain a reference time by deploying an independent master time source device to receive the time signal from the local standard time server, thereby achieving high-precision time synchronization and adapting to different regional usage standards; the master time source device distributes the reference time to each lower-level device through a one-to-one calibration link, abandoning the traditional cascading distribution method and completely eliminating the problem of time deviation accumulating at each level; at the same time, the lower-level devices calibrate their own current device time based on the received reference time, avoiding the risk of abnormal timestamps of terminal devices tampering with the server time, fundamentally solving the problems of device disconnection and command failure caused by time jumps, and significantly improving the time stability and operational reliability of the system. Attached Figure Description

[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0043] Figure 1 A flowchart of a device time calibration method provided in an embodiment of the present invention;

[0044] Figure 2 This is a schematic diagram of the structure of a device time calibration apparatus provided in an embodiment of the present invention;

[0045] Figure 3 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0046] This invention provides a device time calibration method and related equipment to solve the technical problems of cascaded deviation accumulation, low time synchronization accuracy, and poor local adaptability.

[0047] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0048] Please see Figure 1 , Figure 1 An optional flowchart of a device time calibration method provided in an embodiment of the present invention includes steps 101 to 103.

[0049] Step 101: The main time source device receives the time signal from the local standard time server, performs time calibration based on the time signal, and obtains the reference time.

[0050] The primary time source device refers to a dedicated time server independently deployed in the system. As the sole top-level time reference for the entire system, it is responsible for receiving external standard time signals and providing a unified time reference to all subordinate devices.

[0051] A local standard time server refers to a time server deployed at the project location that can provide local standard time services. In this embodiment, an NTP (Network Time Protocol) server is used. NTP is a standardized protocol used to synchronize computer clocks in a distributed system, and its time transmission accuracy can reach the millisecond level or even higher.

[0052] UTC (Coordinated Universal Time) is the internationally recognized time standard and the benchmark for global time measurement. Local NTP servers typically trace back to UTC via satellite time synchronization or synchronization with the national time service center and automatically convert it to the local time zone.

[0053] Optionally, the master time source device establishes a network connection with the local NTP server at the project site via an Ethernet interface. At a preset synchronization interval (e.g., every 30 seconds), the master time source device actively sends a time synchronization request message to the NTP server. Upon receiving the request, the NTP server returns a timestamp data packet containing the current standard time. This data packet carries the server's time information and network latency estimation parameters. After receiving the response, the master time source device uses NTP's built-in clock filtering and selection algorithms to calculate the network transmission latency and clock offset, thereby correcting its own system clock. After multiple consecutive synchronizations, the master time source device's system time can accurately follow the standard time of the local NTP server, ultimately obtaining a reference time with millisecond-level accuracy, providing a unified and high-precision time source for subsequent synchronization of all system devices.

[0054] Step 102: The main time source device sends the reference time to each lower-level device via the calibration link between the main time source device and each lower-level device according to the preset calibration cycle.

[0055] The calibration period refers to the fixed time interval at which the master time source device sends the reference time to each subordinate device. In this embodiment, the default period is 60 seconds, which can be adjusted according to the actual needs of the system (e.g., 30 seconds, 120 seconds). The shorter the period, the higher the synchronization accuracy, but it will slightly increase the network load.

[0056] A calibration link refers to a logical communication channel established between the primary time source device and a single subordinate device for transmitting time information. This link is a one-to-one direct calibration link, that is, a point-to-point logical connection without any intermediate devices (such as switches that only perform transparent transmission and do not involve cascading forwarding), so that the time signal is not buffered or modified by intermediate nodes during transmission.

[0057] Specifically, the master time source device maintains a timer internally, which triggers the time distribution task according to a preset calibration cycle (e.g., 60 seconds). At the arrival of each cycle, the master time source device obtains the reference time it currently maintains (which has been synchronized with the local NTP server through step 101), encapsulates the time into an NTP protocol message, and sends it to each subordinate device through the established calibration link. To avoid network congestion, multi-threaded or asynchronous methods can be used for parallel transmission.

[0058] In some embodiments, the following sub-steps may be included before performing step 102:

[0059] The main time source device acquires the target communication protocol;

[0060] The master time source device establishes calibration links with each subordinate device based on the target communication protocol.

[0061] The target communication protocol refers to the general communication protocol used by the primary time source device and its subordinate devices for time data exchange, providing communication rules to support link establishment and data transmission. In this embodiment, NTP (Network Time Protocol) is used as the standard protocol for time synchronization. NTP is based on UDP transmission and features timestamp exchange and delay compensation mechanisms, achieving millisecond-level synchronization accuracy. Optionally, SNTP (Simple Network Time Protocol) or PTP (Precise Time Protocol) can also be used.

[0062] Before step 102 is executed, the master time source device establishes a one-to-one direct calibration link with each subordinate device. Specifically, the master time source device acquires the target communication protocol (e.g., NTP) and initiates a connection request to the IP address of each subordinate device in the network based on this protocol. The subordinate devices listen and respond on a designated port (e.g., UDP 123). After the two parties complete the handshake, a dedicated time synchronization channel is established. This link does not rely on cascading forwarding; the master time source device communicates directly with each subordinate device.

[0063] Step 103: Each lower-level device performs time synchronization calibration on the current device based on the received reference time;

[0064] After receiving the reference time message from the master time source device, the lower-level device parses out the standard time value and immediately performs time calibration. Since the link is a one-to-one direct communication, there is no additional delay or error accumulation introduced by intermediate devices. Therefore, the time reference received by each lower-level device is highly consistent with the master time source, and the deviation is only affected by network transmission delay (usually less than 1 millisecond).

[0065] In some embodiments, step 103 may include the following sub-steps:

[0066] Each subordinate device receives the reference time and calculates the first deviation between the reference time and the current device time;

[0067] If the first deviation is less than the preset first threshold, the lower-level device will set the current device time as the reference time.

[0068] If the first deviation is equal to or greater than the preset first threshold, the downstream device will trigger immediate calibration.

[0069] The first deviation refers to the absolute value of the difference between the reference time received by the lower-level device and the device's current time. This deviation is used to determine whether the device's time has experienced abnormal jumps.

[0070] The preset first threshold is a critical deviation value used to distinguish between normal drift and abnormal jumps. In this embodiment, it is set to 10 seconds by default. When the deviation is less than this threshold, the device time is considered to be basically accurate or has only a slight drift, and a routine calibration is performed; when the deviation reaches or exceeds this threshold, it is determined that the device time has experienced an abnormal jump (such as hardware failure or human tampering), and an immediate calibration is required.

[0071] Routine calibration refers to the downstream device unconditionally setting its own time to the received reference time to eliminate minor errors caused by crystal oscillator drift. This operation is performed every time a reference time is received, regardless of the magnitude of the deviation.

[0072] Real-time calibration refers to a special calibration process in which a downstream device proactively sends a time request to the main time source and resets its own time after detecting an abnormal time jump. Compared with conventional calibration, real-time calibration adds the actions of abnormal event logging and proactive request.

[0073] After receiving the reference time from the master time source, the downstream devices need to perform different calibration strategies based on the degree of deviation between their own time and the reference time. The calibration strategies include routine calibration and on-the-spot calibration, as detailed below:

[0074] Routine calibration: If the first deviation is less than the preset first threshold (e.g., 10 seconds), it indicates that the device time is normal (only a slight drift exists). The downstream device sets its own current time (the aforementioned current device time) to the received reference time. This operation immediately aligns the current device time with the main time source, eliminating accumulated errors.

[0075] Instant calibration: If the first deviation reaches or exceeds 10 seconds, it indicates that the device time has experienced an abnormal abrupt change between two calibration cycles (e.g., a 50-second time jump due to battery failure). In this case, the abnormal event is recorded, and a calibration request is actively initiated to the main time source device to reacquire the standard time and complete the update.

[0076] In some embodiments, triggering instant calibration includes:

[0077] The downstream device generates and records an abnormal jump event based on the first deviation and the current device time;

[0078] The lower-level device sends a time calibration request to the main time source device;

[0079] The lower-level device receives the first reference time corresponding to the time calibration request returned by the master time source device and sets the current device time as the first reference time.

[0080] Abnormal jump event: refers to a log message recorded by a downstream device, which includes at least the first deviation value and the current time of the device when the jump occurred, and is used by operation and maintenance personnel for fault tracing and analysis.

[0081] For example, after a lower-level device triggers an instant calibration, it performs the following operations:

[0082] Generate and record abnormal jump events, including the first deviation value and the current time of the device when the deviation is detected (i.e. the current time of the device after the jump but before calibration).

[0083] Actively initiate a dedicated time calibration request to the main time source device to obtain the latest reference time (to prevent secondary deviations caused by network latency or the main time source's own fine-tuning).

[0084] It receives the current reference time returned by the main time source and sets its own current device time back to that reference time (equivalent to double confirmation).

[0085] Through real-time calibration, the system can not only quickly correct abnormal jumps, but also record the fault scene, which facilitates subsequent location of the problematic equipment.

[0086] In some embodiments, the plurality of subordinate devices include at least one terminal device and at least one master server, and the device time calibration method may further include the following steps:

[0087] If the master server receives a communication request from the terminal device, it obtains the server system time and the current calibration identifier, calculates the second deviation between the timestamp bound in the communication request and the server system time, and compares the current calibration identifier with the calibration identifier to be tested in the timestamp.

[0088] If the second deviation is equal to or exceeds the preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, the master server will reject the communication request.

[0089] If the second deviation is less than the preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the main server receives the communication data corresponding to the communication request.

[0090] The server-side system time refers to the system time currently maintained by the main server itself. This time has been synchronized with the main time source device through steps 101-103, traced back to UTC international standard time, with millisecond-level accuracy.

[0091] The current calibration identifier is an identifier (such as a calibration version number or timestamp hash value) generated or updated by the master server after each successful time calibration with the master time source device. This identifier is used to mark the freshness of the server's current time. By comparing it with the calibration identifier reported by the terminal device, it can be determined whether the terminal has completed the latest calibration.

[0092] The calibration flag to be tested refers to the flag value obtained and saved by the terminal device (such as a turnstile or access control system) after each calibration with the main time source, and synchronized with the current calibration flag of the main server. When the terminal initiates a communication request to the main server, it carries this flag in the request (e.g., in the extended bits of the timestamp field or in a custom header).

[0093] The second deviation refers to the absolute value of the difference between the terminal timestamp bound in the communication request and the current server-side system time of the master server.

[0094] The preset second threshold is a critical deviation value used to determine whether the terminal timestamp is abnormal. When the second deviation is less than the threshold, the terminal time is considered basically reliable; if the second deviation reaches or exceeds the threshold, it is determined that the terminal time may have an abnormal jump, and communication is rejected.

[0095] The communication request is deemed valid only when the second deviation is less than the preset second threshold and the calibration identifier to be tested is completely consistent with the current calibration identifier. The main server receives and processes the communication data corresponding to the communication request. If any condition is not met (the second deviation exceeds the limit or the identifier does not match), the main server immediately rejects the communication request and may return a specific error code (e.g., -1111) to the terminal, triggering the terminal to actively recalibrate with the main time source.

[0096] Specifically, in a distributed system, terminal devices (such as turnstiles and access control systems) report access records, heartbeat status, and other data to the main server at preset intervals. If a terminal device malfunctions or is attacked, causing its local time to become abnormal (e.g., jumping to a future time), data packets carrying incorrect timestamps may cause incorrect server time updates (in unprotected older systems) or lead to business logic errors (such as abnormal access record times or invalid permission checks).

[0097] Therefore, abnormal requests are effectively intercepted through a dual verification mechanism (including time deviation verification and calibration mark verification), as follows:

[0098] Time Deviation Verification: The master server extracts the timestamp bound to the terminal communication request (usually the local time when the terminal generated the request) and compares it with the server's own high-precision server-side system time to calculate the second deviation. Since the server time is synchronized with the master time source and is highly accurate, if the terminal time fluctuates significantly (e.g., more than 60 seconds faster or slower), the second deviation will exceed a preset second threshold. In this case, the master server determines that the terminal's request is untrustworthy and rejects it directly.

[0099] Calibration Identifier Verification: Simple deviation verification cannot detect situations where the terminal's time deviation is less than a threshold but the terminal has not completed the latest calibration (e.g., the terminal missed multiple calibrations due to network disconnection, but its local crystal oscillator drifts slowly, with a deviation of only 5 seconds). Therefore, a calibration identifier is introduced. The master server updates the current calibration identifier (e.g., an auto-incrementing sequence number) after each successful calibration with the master time source. The terminal device also acquires and stores the same identifier after each calibration with the master time source. When the terminal initiates a request, it attaches its own calibration identifier to the request. The master server compares this identifier with the current calibration identifier. If they match, it indicates that the terminal has successfully synchronized at least in the most recent calibration cycle; if they do not match, it means the terminal may be offline or calibration failed. Even if the time deviation is small, communication should be rejected, and the terminal should be prompted to recalibrate.

[0100] Through the aforementioned dual verification mechanism, the main server avoids being contaminated by abnormal timestamps, maintains normal interaction with legitimate terminals, and provides clear fault recovery guidance for terminals.

[0101] In some embodiments, the above-described device time calibration method may further include the following steps:

[0102] Within a preset time monitoring window, the main server counts the number of terminal devices that report target abnormal error codes.

[0103] If the number of terminal devices exceeds a preset threshold, the main server determines that the devices are abnormal in batches and triggers an abnormal calibration.

[0104] The preset time monitoring window refers to a fixed time interval during which the main server continuously observes the error codes reported by the terminal devices. In this embodiment, the default window is 5 minutes, which can be dynamically adjusted according to the system size.

[0105] The target error code refers to a specific error code that reflects a time synchronization failure of the terminal device, such as -1111 (indicating that the device time is not synchronized with the master time source or there is a jump). Other related error codes can be extended according to system definitions.

[0106] Batch device anomaly refers to a situation where, within the monitoring window, the number of terminal devices reporting target anomaly error codes exceeds a preset threshold (e.g., 10% of the total number of devices or a fixed value such as 10 units), at which point the system determines that a batch failure has occurred.

[0107] Anomaly calibration refers to the process initiated by the master server to resynchronize time with the master time source after detecting a batch of anomalies. The purpose is to eliminate misjudgments caused by time drift of the server itself.

[0108] Optionally, in a distributed system, when a large number of terminal devices simultaneously report time synchronization error codes such as -1111 within a short period of time, possible reasons include:

[0109] The server time itself jumps: The main server causes its own system time to change suddenly due to software errors, human error, or hardware failure, causing all terminal devices communicating with it to fail the verification.

[0110] Master time source device failure: The master time source device is disconnected from the local NTP server or its own clock is out of sync, resulting in incorrect reference time sent to each terminal;

[0111] Network partition: The network between the master server and the master time source device is interrupted, but the network between the server and the terminal is normal, which causes the terminal to be able to report errors but unable to calibrate.

[0112] Relying solely on real-time calibration of a single terminal cannot resolve the aforementioned systemic failures. Therefore, this embodiment introduces a batch anomaly detection and calibration mechanism on the main server side. The batch anomaly detection is as follows:

[0113] The main server starts a scheduled task that monitors the number of terminal devices receiving the target error code (e.g., -1111) every 5-minute interval. If this number exceeds a preset threshold (e.g., 10% of the total number of devices in the system or an absolute value of 10), the main server determines that a batch anomaly has occurred and triggers the anomaly calibration process.

[0114] In some embodiments, triggering abnormal calibration includes:

[0115] The master server detects the calibration link with the master time source device according to the preset link detection rules to determine the link's operating status.

[0116] If the link is in normal operation, the master server sends an abnormal calibration request to the master time source device, receives the second reference time corresponding to the abnormal calibration request from the master time source device, and sets the current device time to the second reference time.

[0117] If the link is in an abnormal state, the master server will generate a link alarm message and trigger manual adjustment.

[0118] Link operation status refers to the health status of the direct calibration link between the master server and the master time source device, including normal (network connectivity, successful protocol handshake) and abnormal (network disconnection, timeout without response, etc.).

[0119] The link detection rules include comprehensive judgment logic for communication connectivity verification, message response verification, and transmission delay verification, which is used to identify whether the calibration link is in a normal or abnormal state.

[0120] Link alarm information refers to an alarm record generated by the master server when the link status is abnormal. The content includes the time of the abnormality, the type of fault (such as ping timeout, NTP request no response), and a prompt to suggest manual intervention.

[0121] Optionally, the specific process of the abnormal calibration mechanism is as follows:

[0122] The master server detects the calibration link status between itself and the master time source device according to the preset link detection rules. It can determine whether the link is normal by sending an NTP request and setting a short timeout (such as 2 seconds).

[0123] If the link is normal, it means the primary time source is accessible. The primary server proactively initiates an abnormal calibration request to the primary time source device to obtain the latest reference time and sets its own system time to that reference time. After calibration, the primary server's local time returns to accuracy. Subsequently, when the terminal device re-reports, the time deviation check should pass, and the error code will disappear naturally.

[0124] If the link fails, the master server will be unable to obtain the correct time from the master time source. In this case, a link alarm message (containing details of the link failure) will be generated, triggering manual intervention (e.g., displaying an alarm in the management interface to notify maintenance personnel to check the network or master time source device). After manual intervention to repair the link, the system can return to normal.

[0125] Through the above-mentioned abnormal calibration mechanism, the master server can quickly self-heal when its own time deviates, while identifying the main time source link failure and guiding manual repair, thus avoiding the serious consequences of a batch of devices going offline.

[0126] The present invention will be further described in detail below with reference to specific embodiments.

[0127] Example: Application in a subway project in a certain area. The specific steps are as follows:

[0128] Step 1: In the subway project in this region, deploy a master time source device and configure it to connect to the local standard time server in real time for calibration. The local standard time server can achieve millisecond-level high-precision synchronization with UTC and automatically adapt to local time zones and time difference rules, ensuring that the master time source device has both high accuracy and regional compliance. Establish a one-to-one calibration link between the master time source device and the turnstiles, access control terminals, and the master server, complete the device communication configuration, and deploy the master server in a dual-system environment of Windows and Linux, enabling the master time source device to communicate independently with each subordinate device and provide real-time time synchronization.

[0129] Step 2: Configure the preset second threshold to 60 seconds and the calibration cycle to 60 seconds. Enable the abnormal timestamp verification function, and at the same time restrict the permissions of terminal devices such as turnstiles and access control systems, prohibiting terminal devices from actively modifying the main server time, thereby avoiding time jump problems caused by abnormal time tampering from the permission level;

[0130] Step 3: The main time source device continuously receives time signals from the local standard time server and completes self-calibration to obtain a high-precision reference time. Following a preset calibration cycle of 60 seconds, the main time source device distributes the reference time to each subordinate device via an independent calibration link. After receiving the reference time, each subordinate device calculates the first deviation between its local time and the reference time. When the first deviation exceeds a preset first threshold of 10 seconds, it immediately performs real-time calibration to ensure that the time of all devices in the system is consistent with the reference time.

[0131] Step 4: After receiving the communication request and corresponding timestamp uploaded by the terminal device, the main server retrieves its own system time and the current calibration identifier, calculates the second deviation between the timestamp and the system time, and compares the identifier information. If the second deviation corresponding to the terminal timestamp is 70 seconds, exceeding the preset second threshold of 60 seconds, it is determined to be an abnormal timestamp and discarded, and the communication interaction is rejected. If the second deviation is 20 seconds, within the threshold range and the calibration identifier to be tested matches the current calibration identifier, the timestamp is determined to be valid, and communication data is received normally. The main server only updates its local time based on the reference time sent by the main time source device to ensure system time consistency.

[0132] Step 5: When a time jump occurs on the main server or a disconnection occurs when the terminal device reports an abnormal error code, check the calibration link between the main server and the main time source device. If the link is normal, restart the calibration process, the server time will stabilize, and the terminal device will be able to connect to the network normally. If the link is abnormal or the calibration fails to restart multiple times, generate a link alarm message and notify the maintenance personnel to manually correct the local time of the main server and restart the business service.

[0133] Step 6: Conduct full-process functional testing of this method, verifying functions such as one-to-one direct calibration, deviation verification, abnormal timestamp filtering, and dual-system adaptation. Test results show that the system does not have the problem of deviation accumulation caused by cascading transmission, the time synchronization accuracy of each device reaches the millisecond level, the server time does not jump, there are no batch disconnections of terminal devices, and the command issuance is normal. It not only meets the timing control requirements of the subway project in this region, but also complies with the UTC-based distributed reliable time synchronization technical specifications.

[0134] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0135] The device time calibration apparatus provided in the embodiments of this application is described below. The device time calibration apparatus described below and the device time calibration method described above can be referred to in correspondence.

[0136] Reference Figure 2 , Figure 2 This is an optional structural diagram of a device time calibration apparatus provided in an embodiment of the present invention. The apparatus is used to implement the above-mentioned intelligent robot garbage collection method. The apparatus may include a main time source device 200 and multiple subordinate devices 300.

[0137] The main time source device 200 is used to receive the time signal from the local standard time server, perform time calibration based on the time signal, and obtain the reference time.

[0138] The main time source device 200 is also used to send the reference time to each lower-level device via the calibration link between the device and the lower-level device according to the preset calibration cycle.

[0139] The lower-level device 300 is used to synchronize and calibrate the current device time based on the received reference time.

[0140] In some embodiments, the plurality of subordinate devices 300 include at least one terminal device and at least one master server;

[0141] The main server is configured as follows: if a communication request is received from a terminal device, the server system time and the current calibration identifier are obtained, the second deviation between the timestamp bound in the communication request and the server system time is calculated, and the current calibration identifier is compared with the calibration identifier to be tested in the timestamp.

[0142] If the second deviation is equal to or exceeds the preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, the communication request is rejected.

[0143] If the second deviation is less than the preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the communication data corresponding to the communication request is received.

[0144] In some embodiments, the master server is configured as follows:

[0145] Within the preset time monitoring window, count the number of terminal devices that report target abnormal error codes;

[0146] If the number of terminal devices exceeds a preset threshold, it is determined to be a batch device anomaly and an abnormal calibration is triggered.

[0147] In some embodiments, the master server triggers an abnormal calibration, including:

[0148] According to the preset link detection rules, the calibration link between the device and the main time source device 200 is detected to determine the link's operating status.

[0149] If the link is in normal operation, an abnormal calibration request is sent to the main time source device 200, the second reference time corresponding to the abnormal calibration request is returned by the main time source device 200, and the current device time is set as the second reference time.

[0150] If the link is in an abnormal state, a link alarm message will be generated and a manual adjustment operation will be triggered.

[0151] In some embodiments, the primary time source device 200 is configured as follows:

[0152] Obtain the target communication protocol;

[0153] Based on the target communication protocol, calibration links are established with each of the lower-level devices 300.

[0154] In some embodiments, each subordinate device 300 is configured as follows:

[0155] Receive the reference time and calculate the first deviation between the reference time and the current device time;

[0156] If the first deviation is less than the preset first threshold, then the current device time is set as the reference time;

[0157] If the first deviation is equal to or greater than the preset first threshold, then instant calibration is triggered.

[0158] In some embodiments, the lower-level device 300 triggers instantaneous calibration, including:

[0159] Based on the first deviation and the current device time, an abnormal jump event is generated and recorded;

[0160] Initiate a time calibration request to the primary time source device;

[0161] The device receives the first reference time returned by the master time source device 200 corresponding to the time calibration request, and sets the current device time as the first reference time.

[0162] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0163] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0164] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.

[0165] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0166] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0167] This invention also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned device time calibration method. This electronic device can be any smart terminal, including a tablet computer.

[0168] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0169] Please see Figure 3 , Figure 3 The hardware structure of an electronic device according to another embodiment is illustrated, including:

[0170] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention.

[0171] The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called by the processor 901 to execute the device time calibration method of the embodiments of this invention.

[0172] The input / output interface 903 is used to implement information input and output;

[0173] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0174] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);

[0175] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.

[0176] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned device time calibration method.

[0177] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0178] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0179] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A device time calibration method, applied to a system including a master time source device and multiple subordinate devices, characterized in that, The method includes: The main time source device receives the time signal from the local standard time server, performs time calibration based on the time signal, and obtains the reference time. The master time source device transmits the reference time to each of the lower-level devices via the calibration link between the master time source device and each of the lower-level devices according to a preset calibration cycle. Each of the lower-level devices performs time synchronization calibration on the current device based on the received reference time.

2. The apparatus time calibration method of claim 1, wherein, Each of the lower-level devices performs time synchronization calibration on the current device based on the received reference time, including: Each of the lower-level devices receives the reference time and calculates a first deviation between the reference time and the current device time; If the first deviation is less than a preset first threshold, the lower-level device sets the current device time to the reference time; If the first deviation is equal to or greater than a preset first threshold, the lower-level device triggers immediate calibration.

3. The method of claim 1, wherein, The plurality of subordinate devices include at least one terminal device and at least one master server, and the method further includes: If the master server receives a communication request from the terminal device, it obtains the server system time and the current calibration identifier, calculates the second deviation between the timestamp bound in the communication request and the server system time, and compares the current calibration identifier with the calibration identifier to be tested in the timestamp. If the second deviation is equal to or exceeds a preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, then the master server rejects the communication request; If the second deviation is less than a preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the main server receives the communication data corresponding to the communication request.

4. The apparatus time calibration method of claim 1, wherein, Before the master time source device sends the reference time to each of the lower-level devices via the calibration link according to the preset calibration cycle, the process includes: The main time source device acquires the target communication protocol; The master time source device establishes calibration links with each of the subordinate devices based on the target communication protocol.

5. The apparatus time calibration method of claim 2, wherein, The triggered instant calibration includes: The lower-level device generates and records an abnormal jump event based on the first deviation and the current device time; The lower-level device sends a time calibration request to the main time source device; The lower-level device receives a first reference time corresponding to the time calibration request returned by the main time source device, and sets the current device time to the first reference time.

6. The apparatus time calibration method of claim 3, wherein, Also includes: Within a preset time monitoring window, the main server counts the number of terminal devices that report target abnormal error codes. If the number of terminal devices exceeds a preset threshold, the main server determines that the devices are in batch anomaly and triggers an anomaly calibration.

7. The apparatus time calibration method of claim 6, wherein, The triggered anomaly calibration includes: The master server detects the calibration link with the master time source device according to the preset link detection rules and determines the link operation status; If the link is in normal operation, the master server initiates an abnormal calibration request to the master time source device, receives a second reference time corresponding to the abnormal calibration request from the master time source device, and sets the current device time to the second reference time. If the link is in an abnormal operating state, the master server generates a link alarm message and triggers a manual adjustment operation.

8. An apparatus time calibration device, characterized by Includes a main time source device and multiple subordinate devices; The main time source device is used to receive the time signal from the local standard time server, perform time calibration based on the time signal, and obtain the reference time. The main time source device is also used to send the reference time to each of the lower-level devices via the calibration link between the device and each lower-level device according to a preset calibration cycle. The lower-level device is used to synchronize and calibrate the current device time based on the received reference time.

9. The apparatus time calibration device of claim 8, wherein, The plurality of subordinate devices include at least one terminal device and at least one master server; The master server is configured to: if it receives a communication request from the terminal device, obtain the server system time and the current calibration identifier, calculate the second deviation between the timestamp bound in the communication request and the server system time, and compare the current calibration identifier with the calibration identifier to be tested in the timestamp; If the second deviation is equal to or exceeds a preset second threshold, or if the calibration identifier to be tested is inconsistent with the current calibration identifier, then the communication request is rejected. If the second deviation is less than a preset second threshold and the calibration identifier to be tested is consistent with the current calibration identifier, then the communication data corresponding to the communication request is received.

10. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed, it implements the device time calibration method as described in any one of claims 1 to 7.