A data processing method and system of time window

CN122621272APending Publication Date: 2026-08-21NANJING GUODIAN NANZI POWER GRID AUTOMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610689211.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-19
Publication Date
2026-08-21

AI Technical Summary

Technical Problem

这种偏差可能表现为两种形式:一是时间突变,如主站进行NTP同步或人工调整时系统时间发生跳变;二是缓慢漂移,如子站设备晶振老化导致时钟逐渐偏离标准时间

Benefits of technology

[0066] This application achieves efficient synchronous caching and processing of data between the master station and substations in a wide-area measurement system through a series of technical means, including time window initialization, system time change detection, data reception and window adaptation, time drift adaptive adjustment, data extraction and window sliding, and window information diagnosis. Compared with existing technologies, by dynamically expanding the window to accommodate future data within a reasonable range, its adaptability is significantly improved compared to the fixed window method; data is processed preferentially based on its age to ensure that processing latency is controlled within the allowable network latency range, and expired data is specially marked; the window is automatically rebuilt when there is a sudden change in system time to ensure rapid recovery of data processing capabilities; various threshold parameters can be flexibly configured according to application scenarios, covering a variety of typical application scenarios for the master station of the wide-area measurement system; at the same time, a window status monitoring interface and health indicators are provided to intuitively reflect the window's operating status, making it easy for maintenance personnel to understand the system's operating status. This invention comprehensively improves the adaptability, completeness, timeliness, robustness, configurability, and maintainability of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122621272A_ABST
    Figure CN122621272A_ABST
Patent Text Reader

Abstract

The application provides a time window data processing method and system, and relates to the technical field of power systems. The method comprises the following steps: establishing a time window comprising a plurality of continuous second-level time slots; monitoring the time change of a master station system, and initializing the time window if a time mutation of the master station system is monitored; performing data processing on data according to the relationship between the data time tag of the data and the time window; accumulating the system time drift amount, and performing overall translation or partial reconstruction of the time window when the system time drift amount reaches a preset threshold; after extracting the data to be processed, removing the time slot corresponding to the data from the time window, and sliding the time window to maintain the window timeliness of the time window; and calculating the health degree index of the time window according to the state information. Through the time window initialization, time mutation detection, data receiving window adaptation, time drift adjustment, data extraction and window sliding, and window information diagnosis, the application realizes efficient synchronous caching and processing of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power system technology, and in particular to a data processing method and system for time windows. Background Technology

[0002] The wide-area measurement system consists of phasor measurement units (PMUs) deployed at various nodes of the power grid, phasor data concentrators (PDCs) at substations, and a master station system. After collecting data from the PMUs, the substation PDCs upload the data to the master station via a communication network, providing real-time data support for the master station's power grid monitoring, analysis, and control.

[0003] In actual operation, the main station of the wide-area measurement system faces the following technical problems when receiving data from the substations:

[0004] (1) Time asynchrony

[0005] There is a discrepancy between the time stamp carried in the data frames of the substation and the system time of the master station. This discrepancy may manifest in two forms: one is a sudden time change, such as a jump in system time when the master station performs NTP synchronization or manual adjustment; the other is a slow drift, such as the gradual deviation of the clock from the standard time due to the aging of the crystal oscillator in the substation equipment. When the time discrepancy exceeds a certain range, the data will not be correctly aligned, affecting the accuracy of subsequent analysis.

[0006] (2) Data disorder

[0007] Due to random fluctuations in communication network latency, data uploaded by substations may arrive at the main station out of order. Network congestion, routing switching, and retransmissions can all cause data latency fluctuations, resulting in data sent earlier arriving later. Using a simple first-in, first-out (FIFO) queue will lead to incorrect data ordering, making it impossible to accurately reconstruct the actual time sequence.

[0008] (3) Window Management

[0009] The main station needs to maintain a dynamic time window to ensure data timeliness, promptly processing the latest arriving data, while also accommodating a certain range of delayed data to prevent data loss due to network fluctuations. The size and position of the time window need to be dynamically adjusted based on network conditions and clock deviations, as a fixed window is difficult to adapt to the complex changes in actual operation.

[0010] (4) System time mutation

[0011] The main system time may change abruptly due to various reasons, such as network time protocol synchronization, leap second adjustments, and manual corrections. Such abrupt changes can render existing time windows completely invalid, causing cached data within those windows to become incompatible with the new system time. Therefore, it is necessary to quickly rebuild the windows to avoid data processing interruptions.

[0012] In existing technologies, fixed time windows or simple FIFO queues are typically used to address the aforementioned problems. Fixed-window methods, with their fixed window parameters, cannot adapt to changes in network latency and clock drift; FIFO queues, on the other hand, cannot handle out-of-order data, leading to data sequence errors. Therefore, there is an urgent need for a time-window data synchronization caching and processing method that can adaptively handle issues such as time discrepancies between master and slave stations, out-of-order data arrival, and sudden changes in system time. Summary of the Invention

[0013] This application provides a data processing method and system for time windows, which enables efficient synchronous caching and processing of data through time window initialization, time change detection, data receiving window adaptation, time drift adjustment, data extraction and window sliding, and window information diagnosis.

[0014] Firstly, this application provides a data processing method for time windows, which is executed by a computing device. The computing device can be understood as a computer or similar device, and is not limited thereto in this application. The method includes:

[0015] Based on the main station system time, a time window containing multiple consecutive second-level time slots is established; changes in the main station system time are monitored, and if a time abrupt change is detected, the time window is initialized; incoming data is received, and data processing is performed on the data according to the relationship between the data timescale and the time window; wherein, the data processing includes one of storage, window expansion, or discarding; when a slow drift in system time is detected, the system time drift is accumulated, and when the system time drift reaches a preset threshold, the time window is shifted as a whole or partially reconstructed; data to be processed is periodically extracted according to the data age, and after the data to be processed is extracted, the time slot of the corresponding data is removed from the time window, and the time window is slid to maintain the timeliness of the time window; the status information of the time window is obtained, and the health index of the time window is calculated based on the status information.

[0016] Through the aforementioned methods, this application achieves efficient synchronous caching and processing of data between the master station and substations in a wide-area measurement system via a series of technical means, including time window initialization, system time abrupt change detection, data reception and window adaptation, time drift adaptive adjustment, data extraction and window sliding, and window information diagnosis. By dynamically expanding the window to accommodate future data within a reasonable range, its adaptability is significantly improved compared to the fixed window method. Data is processed preferentially based on its age to ensure processing latency is controlled within the allowable network latency range, and expired data is specially marked. The window is automatically rebuilt when there are sudden changes in system time to ensure rapid recovery of data processing capabilities. Each threshold parameter can be flexibly configured according to the application scenario, covering various typical application scenarios of the master station in the wide-area measurement system. Simultaneously, a window status monitoring interface and health indicators are provided to intuitively reflect the window's operating status, facilitating maintenance personnel to understand the system's operational status. This invention comprehensively improves the adaptability, completeness, timeliness, robustness, configurability, and maintainability of data processing.

[0017] In the aforementioned data processing method for time windows, a time window containing multiple consecutive second-level time slots is established based on the main station system time, including:

[0018] When the system starts up or detects a serious anomaly, a time window initialization is performed. A time window is established based on the main station system time, and the start and end times of the window are represented as follows:

[0019] Tstart = Tmaster - CACHE_DATA_BEFORE;

[0020] Tend = Tstart + CACHE_DATA_SIZE - 1;

[0021] Where Tmaster is the master station system time, Tstart is the window start time, Tend is the window end time, CACHE_DATA_BEFORE is the preset cache pre-emption amount, representing the length of historical data covered by the window; CACHE_DATA_SIZE is the preset cache size, representing the total time length covered by the window; all time slots are pre-created within the time window range, each time slot contains 100 frame data slots, and each frame data slot contains a 10ms data frame; the frame index calculation formula for the data frame is:

[0022] frameIdx = floor(msec / 10);

[0023] Where frameIdx represents the frame index formula, msec is the number of milliseconds in a frame, and floor is the floor function.

[0024] By using the above method, this application initializes the time window based on the main station system time, avoiding time deviations that could lead to time window misalignment and data time slot misalignment, thereby achieving uniformity of the data time dimension within the system and ensuring the accuracy of time series data processing, statistics, and comparison.

[0025] In the aforementioned data processing method for the time window, monitoring changes in the main station system's time, and if a sudden time change is detected in the main station system, initializing the time window includes:

[0026] Before adding data each time, obtain the current system time of the main site and calculate the difference ΔT between it and the previously recorded system time. ΔT can be expressed as:

[0027] ΔT = Tcurrent - Tlast;

[0028] Where Tcurrent represents the current main station system time, and Tlast represents the last recorded system time; if the difference exceeds a preset mutation threshold, it is determined to be a time mutation, the current time window is cleared and reinitialized; the mutation detection function is defined as:

[0029] ;

[0030] Among them, MAX_TIME_JUMP_THRESHOLD represents the preset mutation threshold; Used to determine whether the difference exceeds the preset mutation threshold. When f_jump(ΔT) is 1, a window reconstruction operation is performed and an alarm log is recorded.

[0031] In the above manner, this application monitors the time changes of the main station system. If a time change is detected in the main station system, the time window is initialized to avoid the time window boundary disorder caused by the time change, ensure the accuracy of the timing logic, and prevent data errors caused by time jumps.

[0032] In the aforementioned data processing method for time windows, receiving arriving data and processing the data according to the relationship between the data's time index and the time window includes:

[0033] For an arriving data frame, let its timestamp be tSOC; use a window containment function to determine the relationship between the timestamp tSOC of the data and the time window. The window containment function is defined as follows:

[0034] ;

[0035] like =1, indicating the data is within the window, perform normal data storage, store the data in the corresponding position according to the frame index and mark the reception flag; if inWindow(tSOC)=0, indicating the data exceeds the window, calculate the timeout ΔTfuture and the timeout ΔTpast, expressed as:

[0036] ΔTfuture = tSOC - Tend;

[0037] ΔTpast = Tstart - tSOC;

[0038] When the time exceeding the end time is less than or equal to the maximum future tolerance of the preset offset and greater than 0, a window expansion operation is performed, updating the end time of the expanded window to Tend_new = tSOC, and deleting the oldest ΔTfuture second data in the window to keep the total window size not exceeding maxWindowSize; when the time exceeding the end time is greater than the maximum future tolerance of the preset offset, the data is discarded and a warning is recorded; when the past data is greater than 0, the data is discarded.

[0039] Through the above methods, this application is compatible with small time deviations, avoids the accidental loss of normal data, ensures data integrity, and at the same time ensures the timeliness of window data, improves analysis accuracy, eliminates outdated and redundant data, and reduces invalid calculations.

[0040] In the aforementioned data processing method for time windows, when a slow drift in system time is detected, the system time drift is accumulated. When the system time drift reaches a preset threshold, the time window is shifted entirely or partially reconstructed, including:

[0041] The cumulative system time drift is expressed as:

[0042] ;

[0043] Where D_total represents the system time drift, and ΔTi is the amount of time change detected each time data is added; when the absolute value of the system time drift is greater than or equal to the drift adjustment threshold, the drift amount δ = D_total; if the absolute value of the drift is less than or equal to the preset maximum drift adjustment, the keywords of all time slots in the window are shifted as a whole, and the start and end times of the window are updated at the same time; if the absolute value of the drift is greater than the preset maximum drift adjustment, the window is rebuilt based on the current system time, retaining the data in the original window that falls within the range of the new window, and supplementing the missing time slots.

[0044] By employing the above methods, this application reduces window misalignment and timing failure caused by significant time jumps, ensuring the accuracy of the time base. At the same time, it reduces the impact of data anomalies and subsequent data errors caused by system time drift.

[0045] In the aforementioned data processing method using time windows, data to be processed is periodically extracted based on its age. After extraction, the corresponding time slots are removed from the time window, and the time window is slid to maintain its timeliness. This includes:

[0046] The age(t) of the data to be processed is defined as:

[0047] age(t) = Tcurrent - t;

[0048] Where Tcurrent is the current main station system time; data with age(t) ≥ 1 second is searched as data to be processed; if no corresponding data is found, the oldest data is selected as data to be processed; after finding the best candidate time tbest, the corresponding second data stCacheSecond is extracted, and the timeout status of the corresponding second data is checked. The timeout status judgment function isTimeout is defined as:

[0049] ;

[0050] After extracting the data, remove the corresponding time slot from the window corresponding to the time window, slide the time window, and establish a new window start time Tstart_new and window end time Tend_new:

[0051] Tstart_new = Tstart + 1;

[0052] Tend_new = Tstart_new + CACHE_DATA_SIZE - 1;

[0053] New time slots are added based on the new window start time and window end time.

[0054] Through the above methods, this application ensures data timeliness and improves analysis accuracy. At the same time, it removes outdated time slot data in a timely manner to prevent data from accumulating indefinitely within the time window, effectively reducing the scale of data to be processed, reducing memory usage, and improving processing efficiency.

[0055] In the aforementioned data processing method for time windows, obtaining the status information of the time window and calculating the health index of the time window based on the status information includes:

[0056] The status information includes at least the window start time Tstart, end time Tend, current size size, expected start time Texpected, start time drift ΔTstart, end time drift ΔTend, and cumulative drift amount D_total; the health index H is calculated using the following formula:

[0057] ;

[0058] Where H∈[0,1], the closer to 1, the healthier the window state.

[0059] By using the above methods, the health indicators of the time window are quantified and visualized, ensuring that maintenance personnel can intuitively grasp the system's operating status and promptly identify potential problems through the window status diagnosis interface.

[0060] Secondly, this application provides a time window data processing system for executing the aforementioned time window data processing method. The system includes: a time window establishment module, a mutation monitoring module, a data processing module, a drift detection module, a data extraction module, and a status acquisition module.

[0061] The system includes the following modules: a time window establishment module, used to establish a time window containing multiple consecutive second-level time slots based on the main station system time; a mutation monitoring module, used to monitor changes in the main station system time, and initialize the time window if a time mutation is detected; a data processing module, used to receive arriving data and process the data according to the relationship between the data timescale and the time window, wherein the data processing includes one of storage, window expansion, or discarding; a drift detection module, used to accumulate the system time drift when a slow drift is detected, and perform overall translation or partial reconstruction of the time window when the system time drift reaches a preset threshold; a data extraction module, used to periodically extract the data to be processed according to the data age, remove the corresponding time slot from the time window after extraction, and slide the time window to maintain its timeliness; and a status acquisition module, used to obtain the status information of the time window and calculate the health index of the time window based on the status information.

[0062] Thirdly, this application also provides a computing device, comprising: a memory for storing program instructions; and a processor for calling the program instructions stored in the memory and executing the method described in the first aspect according to the obtained program instructions.

[0063] Fourthly, this application also provides a computer-readable storage medium storing computer-readable instructions that, when read and executed by a computer, implement the method of the first aspect described above.

[0064] Fifthly, this application provides a computer program product including a computer program executable by a computer device, which, when run on the computer device, causes the computer device to perform the method described in the first aspect.

[0065] Beneficial effects:

[0066] This application achieves efficient synchronous caching and processing of data between the master station and substations in a wide-area measurement system through a series of technical means, including time window initialization, system time change detection, data reception and window adaptation, time drift adaptive adjustment, data extraction and window sliding, and window information diagnosis. Compared with existing technologies, by dynamically expanding the window to accommodate future data within a reasonable range, its adaptability is significantly improved compared to the fixed window method; data is processed preferentially based on its age to ensure that processing latency is controlled within the allowable network latency range, and expired data is specially marked; the window is automatically rebuilt when there is a sudden change in system time to ensure rapid recovery of data processing capabilities; various threshold parameters can be flexibly configured according to application scenarios, covering a variety of typical application scenarios for the master station of the wide-area measurement system; at the same time, a window status monitoring interface and health indicators are provided to intuitively reflect the window's operating status, making it easy for maintenance personnel to understand the system's operating status. This invention comprehensively improves the adaptability, completeness, timeliness, robustness, configurability, and maintainability of data processing. Attached Figure Description

[0067] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0068] Figure 1 A flowchart illustrating a time window data processing method provided in an embodiment of this application;

[0069] Figure 2 A flowchart illustrating a time window data processing method provided in an embodiment of this application;

[0070] Figure 3 A schematic diagram of the time window data processing flow of a time window data processing method provided in this application embodiment;

[0071] Figure 4 A schematic diagram of the time window initialization process of a time window data processing method provided in this application embodiment;

[0072] Figure 5Schematic diagram of the system time mutation detection process for a data processing method of a time window provided by an embodiment of the present application;

[0073] Figure 6 Schematic diagram of the data reception and window adaptation process for a data processing method of a time window provided by an embodiment of the present application;

[0074] Figure 7 Schematic diagram of the time window extension operation for a data processing method of a time window provided by an embodiment of the present application;

[0075] Figure 8 Schematic diagram of the time drift adaptive adjustment process for a data processing method of a time window provided by an embodiment of the present application;

[0076] Figure 9 Schematic diagram of the data extraction and window sliding process for a data processing method of a time window provided by an embodiment of the present application;

[0077] Figure 10 Schematic diagram of the structure of a data processing system of a time window provided by an embodiment of the present application;

[0078] Figure 11 Schematic diagram of the structure of a computing device provided by an embodiment of the present application. Detailed implementation manners

[0079] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.

[0080] In the following embodiments of the present application, "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B may be singular or plural. The character " / " generally represents that the associated objects before and after are in an "or" relationship. "At least one (item) below" or similar expressions refer to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b or c may represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, c may be single or multiple. The singular expression forms "a", "one kind", "the", "above-mentioned", "this" and "this one" are also intended to include expressions such as "one or more", unless there is a clear opposite indication in the context. And, unless otherwise stated, the ordinal numbers such as "first", "second" mentioned in the embodiments of the present application are used to distinguish multiple objects and are not used to limit the order, time sequence, priority or importance of multiple objects.

[0081] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0082] Example 1

[0083] Embodiment 1 of this application provides a data processing method for time windows. This method is executed by a computing device, which can be understood as a computer or other similar device, but is not limited thereto in this application. The method flow is as follows: Figure 1 As shown, it includes:

[0084] Step 101: Based on the main station system time, establish a time window containing multiple consecutive second-level time slots.

[0085] In one possible implementation, when the system starts up or detects a serious anomaly, a time window initialization is performed. A time window is established based on the main station system time, and the window start time and window end time are represented as follows:

[0086] Tstart = Tmaster - CACHE_DATA_BEFORE;

[0087] Tend = Tstart + CACHE_DATA_SIZE - 1;

[0088] Where Tmaster is the master station system time, Tstart is the window start time, Tend is the window end time, CACHE_DATA_BEFORE is the preset cache size, representing the length of historical data covered by the window; and CACHE_DATA_SIZE is the preset cache size, representing the total time length covered by the window.

[0089] All time slots are pre-created within the time window. Each time slot contains 100 frame data slots, and each frame data slot contains a 10ms data frame. The frame index of the data frame is calculated using the following formula:

[0090] frameIdx = floor(msec / 10);

[0091] Where frameIdx represents the frame index formula, msec is the number of milliseconds in a frame, and floor is the floor function.

[0092] Step 102: Monitor the time changes of the main station system. If a sudden time change is detected in the main station system, initialize the time window.

[0093] Specifically, before adding data each time, the current system time of the main site is obtained, and the difference ΔT between the current system time and the previously recorded system time is calculated. ΔT can be expressed as:

[0094] ΔT = Tcurrent - Tlast;

[0095] Where Tcurrent represents the current system time of the main station, and Tlast represents the system time recorded last time;

[0096] If the difference exceeds a preset mutation threshold, it is determined to be a time mutation, the current time window is cleared and reinitialized; wherein, the mutation detection function is defined as:

[0097] ;

[0098] Among them, MAX_TIME_JUMP_THRESHOLD represents the preset mutation threshold; Used to determine whether the difference exceeds the preset mutation threshold. When f_jump(ΔT) is 1, a window reconstruction operation is performed and an alarm log is recorded.

[0099] Step 103: Receive the arriving data and process the data according to the relationship between the data time stamp and the time window.

[0100] The data processing includes one of storage, window expansion, or discarding.

[0101] In one possible implementation, the timestamp of an arriving data frame is tSOC;

[0102] The window containment function is used to determine the relationship between the time scale tSOC and the time window of the data. The window containment function is defined as follows:

[0103] ;

[0104] like =1, determine if the data is within the window, perform normal data storage, store it in the corresponding position according to the frame index and mark the receiving flag;

[0105] If inWindow(tSOC) = 0, determine if the data exceeds the window, calculate the amount of time exceeded (ΔTfuture) and the amount of time exceeded (ΔTpast), expressed as:

[0106] ΔTfuture = tSOC - Tend;

[0107] ΔTpast = Tstart - tSOC;

[0108] When the amount of time exceeding the end time is less than or equal to the maximum future tolerance of the preset offset and greater than 0, a window expansion operation is performed, the end time of the expanded window is updated to Tend_new = tSOC, and the oldest ΔTfuture second data in the window is deleted to keep the total window size from exceeding maxWindowSize.

[0109] When the time exceeds the maximum future tolerance of the preset offset, discard the data and log a warning.

[0110] If the past data is greater than 0, discard the data.

[0111] Step 104: When a slow drift in system time is detected, the system time drift is accumulated. When the system time drift reaches a preset threshold, the time window is shifted as a whole or partially reconstructed.

[0112] In one possible implementation, the cumulative system time drift is expressed as:

[0113] ;

[0114] Where D_total represents the system time drift, and ΔTi is the amount of time change detected each time data is added;

[0115] When the absolute value of the system time drift is greater than or equal to the drift adjustment threshold, let the drift amount δ = D_total;

[0116] If the absolute value of the drift is less than or equal to the preset maximum drift adjustment, the keywords of all time slots in the window are shifted as a whole, and the start and end times of the window are updated at the same time.

[0117] If the absolute value of the drift is greater than the preset maximum drift adjustment, the window is rebuilt based on the current system time, retaining the data in the original window that falls within the range of the new window, and supplementing the missing time slots.

[0118] Step 105: Periodically extract the data to be processed according to the data age. After extracting the data to be processed, remove the time slot of the corresponding data from the time window and slide the time window to maintain the window timeliness of the time window.

[0119] In one possible implementation, the age(t) of the data to be processed is defined as:

[0120] age(t) = Tcurrent - t;

[0121] Where Tcurrent is the current main station system time;

[0122] Find data with age(t) ≥ 1 second as the data to be processed. If no corresponding data is found, select the oldest data as the data to be processed.

[0123] After finding the best candidate time tbest, extract the corresponding second data stCacheSecond, and check the timeout status of the corresponding second data. The timeout status judgment function isTimeout is defined as follows:

[0124] ;

[0125] After extracting the data, remove the corresponding time slot from the window corresponding to the time window, slide the time window, and establish a new window start time Tstart_new and window end time Tend_new:

[0126] Tstart_new = Tstart + 1;

[0127] Tend_new = Tstart_new + CACHE_DATA_SIZE - 1;

[0128] New time slots are added based on the new window start time and window end time.

[0129] Step 106: Obtain the status information of the time window, and calculate the health index of the time window based on the status information.

[0130] In one possible implementation, the time window uses std::map.<uint64_t, StructCacheSecond> The data structure implementation uses a red-black tree to achieve O(log n) search, insertion, and deletion operations.

[0131] In one possible implementation, the preset parameters are dynamically configured according to the application scenario as follows: the preset cache pre-set amount (CACHE_DATA_BEFORE) is set according to the maximum expected network latency, with a value range of 3-5 seconds; the preset cache size (CACHE_DATA_SIZE) is set according to the application's real-time requirements, with a value range of 10-30 seconds; the preset maximum future tolerance (MAX_FUTURE_TOLERANCE) is set according to the maximum clock drift rate, with a value range of 2-3 seconds; the preset mutation threshold (MAX_TIME_JUMP_THRESHOLD) is set according to the system time synchronization accuracy, with a value range of 1-2 seconds; and the drift adjustment threshold (DRIFT_ADJUST_THRESHOLD) is set according to the maximum allowable cumulative error, with a value range of 0.5-1 seconds.

[0132] Specifically, the overall process of Embodiment 1 of this application is as follows: Figure 2 As shown, after receiving data from the substation, it checks whether the time window has been initialized. If the time window has not been initialized, the time window initialization step is executed. If the time window has been initialized, a system time change detection is performed to determine whether a change has occurred in the system time. If so, the window is cleared and re-initialized. If not, it checks whether the data is still within the time window. If the data is still within the time window, the data is stored normally. If the data is not within the time window, the time exceeding the end time ΔTfuture and the time exceeding the start time ΔTpast are calculated. If ΔTpast is greater than 0, past data is discarded. If not, it checks whether ΔTfuture is less than or equal to 0. If ΔTfuture is less than or equal to 0, future data is discarded and recorded. If not, the window is expanded and the window state is updated, waiting for the next frame of data.

[0133] In the above technical solution, each preset parameter can be dynamically configured according to the application scenario:

[0134] The cache pre-set value (CACHE_DATA_BEFORE) is set based on the maximum expected network latency, typically ranging from 3 to 5 seconds. The cache size (CACHE_DATA_SIZE) is set based on the application's real-time requirements, typically ranging from 10 to 30 seconds. The future tolerance (MAX_FUTURE_TOLERANCE) is set based on the maximum clock drift rate, typically ranging from 2 to 3 seconds. The mutation threshold (MAX_TIME_JUMP_THRESHOLD) is set based on the system's time synchronization accuracy, typically ranging from 1 to 2 seconds. The drift adjustment threshold (DRIFT_ADJUST_THRESHOLD) is set based on the maximum allowable cumulative error, typically ranging from 0.5 to 1 second.

[0135] Example 2

[0136] Embodiment 2 of this application provides a data processing method for time windows based on Embodiment 1. This method is executed by a computing device, which can be understood as a computer or similar device; however, this application does not limit the scope of the method. This embodiment uses the main station of a city power grid wide-area measurement system as an example to describe the specific implementation process of this method in detail. The system configuration parameters are as follows:

[0137] The default cache pre-buffer size is 5 seconds.

[0138] The default cache size is CACHE_DATA_SIZE = 10 seconds.

[0139] The preset future tolerance is MAX_FUTURE_TOLERANCE = 3 seconds;

[0140] The preset mutation threshold MAX_TIME_JUMP_THRESHOLD = 2 seconds;

[0141] The preset drift adjustment threshold is DRIFT_ADJUST_THRESHOLD = 1 second;

[0142] The preset maximum drift adjustment is MAX_DRIFT_ADJUSTMENT = 2 seconds.

[0143] The method flow is as follows: Figure 3 As shown, it includes:

[0144] Step 201: Time initialization. Establish a dynamic time window containing multiple consecutive second-level time slots based on the main station system time.

[0145] Specifically, at system startup, the master station system time Tmaster = 1000 seconds. When the system starts or a serious anomaly is detected, time window initialization is performed. A time window is established based on the master station system time Tmaster, and the window start time Tstart and window end time Tend can be represented as:

[0146] Tstart = Tmaster - CACHE_DATA_BEFORE;

[0147] Tend = Tstart + CACHE_DATA_SIZE - 1;

[0148] Wherein, CACHE_DATA_BEFORE is the preset cache front amount, representing the length of historical data covered by the window; CACHE_DATA_SIZE is the preset cache size, representing the total time length covered by the window.

[0149] For example, when the main system time is 1000 seconds, the window start time can be expressed as: Tstart = Tmaster - CACHE_DATA_BEFORE = 1000 - 5 = 995 seconds; the window end time can be expressed as: Tend = Tstart + CACHE_DATA_SIZE - 1 = 995 + 10 - 1 = 1004 seconds; it should be noted that the above is just one example, and this application does not limit it.

[0150] as follows Figure 4 As shown, all time slots are pre-created within the time window range [Tstart, Tend]. Each time slot contains 100 frame data slots, corresponding to a data frame of 10ms. The frame index frameIdx is calculated using the following formula:

[0151] frameIdx = floor(msec / 10);

[0152] Where msec is the number of milliseconds in a frame.

[0153] For example, 10 time slots are pre-created within the time window range [995, 1004], each time slot corresponding to a second-level data buffer unit. The time slot set S = {s(995), s(996), s(997), s(998), s(999), s(1000), s(1001), s(1002), s(1003), s(1004)}. Each time slot s(t) contains 100 frame data slots stFrameArray[0] to stFrameArray

[99] , corresponding to a PMU data frame (0ms, 10ms, 20ms, ..., 990ms) every 10ms. It should be noted that the above is only an example, and this application does not limit it.

[0154] Preferably, the time window uses std::map<uint64_t, StructCacheSecond> The data structure uses a red-black tree to achieve O(log n) search, insertion, and deletion operations.

[0155] Preferably, object pooling technology is used to pre-allocate StructCacheSecond objects to avoid frequent memory allocation and deallocation. The object pool size can be set as follows:

[0156] CACHE_DATA_SIZE + MAX_FUTURE_TOLERANCE + SAFE_MARGIN;

[0157] MAX_FUTURE_TOLERANCE is the maximum future tolerance, and SAFE_MARGIN is the safety boundary.

[0158] For example, the object pool size is calculated as 10 + 3 + 2 = 15 objects to avoid frequent memory allocation and deallocation, thus improving system performance. After initialization, the last system time Tlast = 1000 seconds, the window start time Tstart = 995 seconds, the window end time Tend = 1004 seconds are recorded, and the initialization status m_initialized is set to true.

[0159] Step 202: System time change detection. Monitor the time changes of the main station system. When a time change exceeding the preset threshold is detected, clear the current time window and reinitialize the time window.

[0160] Specifically, during system operation, a system time abrupt change detection is performed before each data addition. (See below.) Figure 5 As shown, after receiving data, the last system time Tlast is recorded, the current system time Tcurrent is obtained, and the time difference ΔT is calculated. If the absolute value of ΔT exceeds the preset mutation threshold, it is determined to be a time mutation, triggering time mutation processing, clearing the current time window and resetting the initialization state, re-initializing based on the new system time, recording alarm logs, and determining whether the program has ended. If the absolute value of ΔT does not exceed the preset mutation threshold, Tlast=Tcurrent is updated, the normal processing flow continues, and it is determined whether the program has ended. If the program has not ended, data is received again and the above operations are repeated.

[0161] Specifically, before adding data each time, the current main site system time Tcurrent is obtained, and the difference ΔT between it and the previously recorded system time Tlast is calculated. ΔT can be expressed as:

[0162] ΔT = Tcurrent - Tlast;

[0163] If the time exceeds the preset mutation threshold MAX_TIME_JUMP_THRESHOLD, it is determined to be a time mutation, the current time window is cleared and reinitialized. The mutation detection function is defined as follows:

[0164] ;

[0165] When f_jump(ΔT) is 1, a window reconstruction operation is performed and an alarm log is recorded.

[0166] Preferably, the mutation threshold MAX_TIME_JUMP_THRESHOLD is set according to the system time synchronization accuracy, with a typical value range of 1-2 seconds.

[0167] For example, at time t=1002, the current main station system time Tcurrent = 1002 seconds is obtained. The difference between this and the previously recorded system time Tlast is calculated as ΔT = Tcurrent - Tlast = 1002 - 1000 = 2 seconds. Since |ΔT| = 2 seconds ≤ MAX_TIME_JUMP_THRESHOLD = 2 seconds, it is determined that no time abrupt change has occurred. Tlast is updated to 1002 seconds, and normal processing continues.

[0168] At this time, a data frame with substation timestamp tSOC=1002 and milliseconds msec=1230ms is received. Check if the data is within the current time window: the current window range is [995,1004]. Since Tstart=995 ≤ tSOC=1002 ≤ Tend=1004, the data is within the window range.

[0169] Perform normal data storage: locate the corresponding time slot s(1002); calculate the frame index frameIdx = floor(msec / 10) = floor(1230 / 10) = 123 based on the number of milliseconds; store the data frame in the stFrameArray

[123] position.

[0170] Step 203: Data reception and window adaptation. Based on the inclusion relationship between the data timestamp and the time window, the data is stored, the window is expanded, or the data is discarded.

[0171] Specifically, as follows: Figure 6 As shown, for an arriving data frame, let its timescale be tSOC. Based on the relationship between the data timescale tSOC and the time window, a window containment function is used for determination. The window containment function is defined as follows:

[0172] ;

[0173] Scenario 1: Data is within the window (inWindow(tSOC)=1)

[0174] Perform normal data storage. Locate the corresponding time slot s(tSOC) and calculate the frame index based on the number of milliseconds msec:

[0175] frameIdx = floor(msec / 10);

[0176] Store the data frame in the stFrameArray[frameIdx] location.

[0177] Scenario 2: Data exceeds window limit (inWindow(tSOC)=0)

[0178] Calculate the deviation of the data from the window boundary. The amount of time exceeding the end time ΔTfuture and the amount of time exceeding the start time ΔTpast can be expressed as:

[0179] ΔTfuture = tSOC - Tend;

[0180] ΔTpast = Tstart - tSOC;

[0181] Different strategies are adopted based on the amount of deviation:

[0182] a) Slightly future data (0 < ΔTfuture ≤ MAX_FUTURE_TOLERANCE)

[0183] Perform a window expansion operation. The window expansion operation is as follows: Figure 7 As shown. The extended window end time is updated to Tend_new = tSOC, while the oldest ΔTfuture second data in the window is deleted, keeping the total window size no more than maxWindowSize.

[0184] b) Large future data (ΔTfuture > MAX_FUTURE_TOLERANCE)

[0185] Discard the data and log a warning. This type of data may be caused by equipment malfunction or a serious network anomaly.

[0186] c) Past data (ΔTpast > 0)

[0187] Discard it directly. This type of data has exceeded its processing time limit; retaining it will consume window resources.

[0188] Preferably, the future tolerance MAX_FUTURE_TOLERANCE is set according to the maximum clock drift rate, with a typical value range of 2-3 seconds.

[0189] For example, at a certain moment, network jitter occurs, and a data frame with substation timestamp tSOC=1006 and milliseconds msec=450ms is received. The current window range is still [995,1004]. To determine if the data is within the window: tSOC=1006 > Tend=1004, the data is outside the window.

[0190] Calculate the time exceeding the end time ΔTfuture = tSOC - Tend = 1006 - 1004 = 2 seconds. Since 0 < ΔTfuture = 2 seconds ≤ MAX_FUTURE_TOLERANCE = 3 seconds, it is determined to be slightly future data, and a window expansion operation is performed:

[0191] First, delete the oldest 2-second data in the window, that is, delete time slots s(995) and s(996);

[0192] Then, add new time slots s(1005) and s(1006);

[0193] Finally, the window range is updated to [997, 1006], and the window end time is updated to Tend_new = tSOC = 1006 seconds.

[0194] After expansion, the current data frame is stored in the newly added time slot s(1006), and the frame index frameIdx = floor(450 / 10) = 45 is stored in the stFrameArray

[45] . The total size of the window after expansion is still 10 seconds, which is as expected.

[0195] Step 204: Time drift adaptive adjustment, accumulate the system time drift amount, and when the threshold is reached, perform overall translation or partial reconstruction of the time window.

[0196] Specifically, as follows: Figure 8 As shown, the system time may drift slowly. The cumulative system time drift D_total is defined as:

[0197] ;

[0198] Where ΔTi is the amount of time change detected each time data is added;

[0199] When |D_total|≥DRIFT_ADJUST_THRESHOLD, set the drift amount δ=D_total, and execute the window adjustment strategy:

[0200] Strategy 1: Small drift (|δ| ≤ MAX_DRIFT_ADJUSTMENT)

[0201] The keywords for all time slots within the window are shifted as a whole. The relationship between the new keyword `newKey` and the old keyword `oldKey` can be represented as follows:

[0202] newKey = oldKey + δ;

[0203] Simultaneously update the window start time Tstart_new and end time Tstart_new, represented as:

[0204] Tstart_new = Tstart + δ;

[0205] Tend_new = Tend + δ;

[0206] Strategy 2: Large drift (|δ| > MAX_DRIFT_ADJUSTMENT)

[0207] Retain the most recent data and reconstruct the time window. Recalculate the expected window range using the current system time as the baseline. The expected start time Tstart_expected and the expected end time Tend_expected can be represented as:

[0208] Tstart_expected = Tcurrent - CACHE_DATA_BEFORE;

[0209] Tend_expected = Tstart_expected + CACHE_DATA_SIZE - 1;

[0210] Where Tcurrent is the current main station system time.

[0211] Retain the data in the original window that falls within the range of [Tstart_expected, Tend_expected], and fill in the missing time slots.

[0212] Preferably, the drift adjustment threshold DRIFT_ADJUST_THRESHOLD is set according to the maximum allowed cumulative error, with a typical value range of 0.5-1 seconds.

[0213] For example, in case 1 (past data): At a certain moment, due to network retransmission, a data frame with a substation timestamp of tSOC=998 and a millisecond count of msec=230ms is received. The current window range is [997, 1006]. Since tSOC=998 seconds < Tstart=997 seconds, it belongs to past data and is discarded. A warning log is recorded: "Past data discarded: tSOC=998, earlier than the window start time of 997 seconds".

[0214] Scenario 2 (Large Future Data): Due to a device malfunction, a data frame with a substation timestamp of tSOC=1015 and a millisecond count of msec=780ms is received. The current window range is [997, 1006]. ΔTfuture = tSOC - Tend = 1015 - 1006 = 9 seconds is calculated. Since ΔTfuture=9 seconds > MAX_FUTURE_TOLERANCE=3 seconds, this is considered large future data and is therefore discarded. A warning log is recorded: "Large future data discarded: tSOC=1015, exceeding the window by 9 seconds".

[0215] In one possible implementation, during system operation, the crystal oscillator of a certain substation device ages, causing the clock to drift slowly. The system records and accumulates the time change each time data is added.

[0216] First time: ΔT1 = +0.3 seconds, cumulative drift D_total = +0.3 seconds

[0217] Second time: ΔT2 = +0.4 seconds, cumulative drift D_total = +0.7 seconds

[0218] Third time: ΔT3 = +0.4 seconds, cumulative drift D_total = +1.1 seconds

[0219] Drift adjustment is triggered when D_total reaches 1.1 seconds, exceeding the preset drift adjustment threshold DRIFT_ADJUST_THRESHOLD = 1 second. Let the drift amount δ = D_total = 1.1 seconds.

[0220] Since |δ| = 1.1 seconds ≤ the preset maximum drift adjustment MAX_DRIFT_ADJUSTMENT = 2 seconds, it is a small drift, so a global translation operation is performed: the keywords of all time slots within the window are translated as follows: newKey = oldKey + δ; the window start time is updated to Tstart_new = Tstart + δ = 997 + 1.1 = 998.1 seconds; the window end time is updated to Tend_new = Tend + δ = 1006 + 1.1 = 1007.1 seconds.

[0221] In practice, the shifted time slot is processed in whole seconds, and the remaining decimal part is accumulated for the next adjustment. After adjustment, the accumulated drift is reset to zero.

[0222] If a significant drift occurs where |δ| > MAX_DRIFT_ADJUSTMENT, a partial reconstruction operation is performed: based on the current system time, the expected window range Tstart_expected = Tcurrent - CACHE_DATA_BEFORE and Tend_expected = Tstart_expected + CACHE_DATA_SIZE - 1 are recalculated; data in the original window that falls within the new window range are retained, and missing time slots are supplemented.

[0223] Step 205, Data Extraction and Window Sliding: Extract complete data to be processed based on data age and slide the time window to maintain the timeliness of the window.

[0224] Specifically, as follows: Figure 9As shown, the system periodically extracts data to be processed from a time window. The data age (t) is defined as:

[0225] age(t) = Tcurrent - t;

[0226] To find the most suitable data for processing, the following priority strategy should be adopted:

[0227] Prioritize processing data where age(t) ≥ 1 second (i.e., data that has been received completely for more than 1 second);

[0228] If no data meets the criteria, return the oldest data in the window.

[0229] After finding the best candidate time tbest, extract the corresponding second data stCacheSecond, check the timeout status, and the timeout status judgment function isTimeout is defined as follows:

[0230] ;

[0231] After extracting the data, remove the corresponding time slot from the window, slide the window, and create a new window start time Tstart_new and a new window end time Tend_new:

[0232] Tstart_new = Tstart + 1;

[0233] Tend_new = Tstart_new + CACHE_DATA_SIZE - 1;

[0234] At the same time, add a new time slot s(Tend_new) to ensure that the window size is maintained at around CACHE_DATA_SIZE.

[0235] Preferably, a read-write lock mechanism is adopted to support a multi-producer, single-consumer model. Data writing is protected by a mutex lock, while data reading can use a shared lock to improve concurrency performance.

[0236] For example, in the early morning of a certain day, the master station performs NTP time synchronization, and the system time jumps from 1002 seconds to 1100 seconds. When the next data arrives, the current master station system time Tcurrent = 1100 seconds is obtained, and the time difference ΔT = Tcurrent - Tlast = 1100 - 1002 = 98 seconds is calculated. Since |ΔT| = 98 seconds > MAX_TIME_JUMP_THRESHOLD = 2 seconds, it is determined that a sudden change in system time has occurred.

[0237] Triggering a sudden change in time window processing: Clear the current time window data using `m_timeWindow.clear()`; reset the initialization state to `m_initialized = false`; re-execute the time window initialization step 1 based on the new system time of 1100 seconds, calculating `Tstart = 1100 - 5 = 1095 seconds` and `Tend = 1095 + 10 - 1 = 1104 seconds`; record the alarm log "System time sudden change detection: jump from 1002 to 1100, window has been rebuilt". The entire process takes 8ms, after which the system resumes normal data processing.

[0238] The system periodically extracts data from a time window for analysis by upper-layer applications. At a certain moment, the main station system time Tcurrent = 1010 seconds, and the current window range is [1005, 1014] (the window state after multiple slides). The data extraction process is as follows:

[0239] First, iterate through all time slots within the window and calculate the data age (t) for each time slot: age(t) = Tcurrent -t.

[0240] t=1005: age=1010-1005=5 seconds;

[0241] t=1006:age=1010-1006=4 seconds;

[0242] t=1007: age=1010-1007=3 seconds;

[0243] t=1008:age=1010-1008=2 seconds;

[0244] t=1009:age=1010-1009=1 second;

[0245] t=1010:age=1010-1010=0 seconds;

[0246] When t=1011, 1012, 1013, and 1014, the age is negative, indicating future data.

[0247] Then, the most suitable data to process is found, prioritizing data where age(t) ≥ 1 second. The oldest data found that satisfies age ≥ 1 second is t = 1005 seconds (age = 5 seconds).

[0248] Next, check the timeout status. Since age(tbest) = 5 seconds > 2 seconds, the data is determined to have timed out, and isTimeout = true is set.

[0249] Next, extract the StructCacheSecond data stCacheSecond corresponding to t=1005 seconds from the time window, which contains the complete data of 100 frame data slots within that second. Remove the time slot s(1005) from the window using m_timeWindow.erase(1005).

[0250] Finally, for the sliding window: update the window start time Tstart_new = Tstart + 1 = 1005 + 1 = 1006 seconds; calculate the new window end time Tend_new = Tstart_new + CACHE_DATA_SIZE - 1 = 1006 + 10 - 1 = 1015 seconds; and add a new time slot s(1015) to the window.

[0251] The extracted stCacheSecond data is passed to the upper-layer application, which determines whether to use the data (e.g., for historical analysis rather than real-time control) based on the isTimeout=true flag. Throughout the process, a read-write lock mechanism is used to support a multi-producer, single-consumer model: data writing is protected by a mutex lock, allowing multiple data receiving threads to write concurrently; data retrieval uses a shared lock to ensure the stability of the window state during retrieval.

[0252] Step 206: Window information diagnosis, output time window status information and calculate health index.

[0253] Specifically, a window diagnostic interface is provided, which outputs the following status information:

[0254] Window start time: Tstart;

[0255] Window end time: Tend;

[0256] Current window size: size = |S|;

[0257] Expected start time: Texpected = Tcurrent - CACHE_DATA_BEFORE;

[0258] Start time drift: ΔTstart = Tstart - Texpected;

[0259] End-time drift: ΔTend = Tend - (Texpected + CACHE_DATA_SIZE - 1);

[0260] Cumulative drift: D_total;

[0261] The formula for calculating the health index H is as follows:

[0262] ;

[0263] Where H∈[0,1], the closer to 1, the healthier the window state.

[0264] For example, the system provides a window diagnostic interface for operations and maintenance personnel to monitor the system's operational status. At a certain point in time, the following status information is output:

[0265] The current system time, Tcurrent, is 1020 seconds.

[0266] Window start time Tstart = 1015 seconds;

[0267] Window end time Tend = 1024 seconds;

[0268] The current window size is 10 seconds.

[0269] Expected start time Texpected = Tcurrent - CACHE_DATA_BEFORE = 1020 - 5 = 1015 seconds;

[0270] Expected end time Texpected_end = Texpected + CACHE_DATA_SIZE - 1 = 1015 + 10 - 1 = 1024 seconds;

[0271] The initial time drift ΔTstart = Tstart - Texpected = 1015 - 1015 = 0 seconds;

[0272] End time drift ΔTend = Tend - Texpected_end = 1024 - 1024 = 0 seconds;

[0273] Cumulative drift D_total = 0 seconds;

[0274] Calculate health indicators:

[0275] H = 1 - (|ΔTstart| + |ΔTend|) / (2 × CACHE_DATA_SIZE) = 1 - (0 +0) / 20 = 1.0;

[0276] A health index H=1.0 indicates that the window is in very healthy condition. The window status diagnostic interface displays the current window content and the completeness of data for each second:

[0277] s(1015): 100% complete;

[0278] s(1016): 100% complete;

[0279] s(1017): 98% complete;

[0280] s(1018): 100% complete;

[0281] s(1019): 95% complete;

[0282] s(1020): 100% complete;

[0283] s(1021): 100% complete;

[0284] s(1022): 100% complete;

[0285] s(1023): 92% complete;

[0286] s(1024): 0% complete (a newly created time slot, no data has been received yet);

[0287] Recent event logs show:

[0288] [10:23:44] Normal data reception: tSOC=1022, msec=450ms;

[0289] [10:23:43] Extracted data tSOC=1015, age=5 seconds, isTimeout=true;

[0290] [10:23:42] Slight drift detected, cumulative drift amount +0.3 seconds;

[0291] [10:23:40] Window initialization complete, range [1015-1024];

[0292] Using the above methods, maintenance personnel can intuitively grasp the system's operating status and promptly identify potential problems through the window status diagnostic interface.

[0293] Example 3

[0294] Based on Embodiments 1 and 2, Embodiment 3 of this application provides a data processing system for time windows, the schematic diagram of which is shown below. Figure 10 As shown, the system is used to perform the methods shown in Embodiments 1 and 2 of this application. The system includes: a time window establishment module, a mutation monitoring module, a data processing module, a drift detection module, a data extraction module, and a status acquisition module.

[0295] The system includes the following modules: a time window establishment module, used to establish a time window containing multiple consecutive second-level time slots based on the main station system time; a mutation monitoring module, used to monitor changes in the main station system time, and initialize the time window if a time mutation is detected; a data processing module, used to receive arriving data and process the data according to the relationship between the data timescale and the time window, wherein the data processing includes one of storage, window expansion, or discarding; a drift detection module, used to accumulate the system time drift when a slow drift is detected, and perform overall translation or partial reconstruction of the time window when the system time drift reaches a preset threshold; a data extraction module, used to periodically extract the data to be processed according to the data age, remove the corresponding time slot from the time window after extraction, and slide the time window to maintain its timeliness; and a status acquisition module, used to obtain the status information of the time window and calculate the health index of the time window based on the status information.

[0296] Example 4

[0297] Having introduced the data processing system for time windows in an exemplary embodiment of this application, we will now introduce a computing device in another exemplary embodiment of this application.

[0298] Those skilled in the art will understand that various aspects of this application can be implemented as a system, method, or program product. Therefore, various aspects of this application can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software implementations, collectively referred to herein as a "circuit," "module," or "system."

[0299] In some possible implementations, the computing device according to this application may include at least one processor and at least one memory. The memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the cross-device assisted interaction method for off-site clearing according to various exemplary embodiments of this application described above.

[0300] The following reference Figure 11 To describe a computing device 130 according to this embodiment of the present application. Figure 11 The computing device 130 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this application. Figure 11As shown, the computing device 130 is presented in the form of a general-purpose smart terminal (or Bluetooth headset). The components of the computing device 130 may include, but are not limited to: at least one processor 131, at least one memory 132, and a bus 133 connecting different system components (including memory 132 and processor 131).

[0301] Bus 133 represents one or more of several bus architectures, including a memory bus or memory controller, peripheral bus, processor, or local bus using any of the various bus architectures. Memory 132 may include readable media in the form of volatile memory, such as random access memory (RAM) 1321 and / or cache memory 1322, and may further include read-only memory (ROM) 1323. Memory 132 may also include a program / utility 1325 having a set (at least one) of program modules 1324, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0302] The computing device 130 can also communicate with one or more external devices 134 (e.g., keyboard, pointing device, etc.), and / or with any device that enables the computing device 130 to communicate with one or more other smart terminals (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 135. Furthermore, the computing device 130 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 136. As shown, network adapter 136 communicates with other modules used in the computing device 130 via bus 133. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with the computing device 130, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0303] In some possible implementations, various aspects of the time window data processing method provided in this application can also be implemented in the form of a program product, which includes a computer program that, when run on a computer device, causes the computer device to perform the steps of the time window data processing method according to the various exemplary embodiments of this application described above.

[0304] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0305] The program product for data processing of time windows according to the embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include a computer program, and may run on a smart terminal. However, the program product of this application is not limited thereto. In this document, the readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0306] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a readable computer program. Such propagated data signals may take various forms, including—but not limited to—electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0307] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0308] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0309] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable access frequency prediction device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable access frequency prediction device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0310] These computer program instructions may also be stored in a computer-readable storage medium capable of directing a computer or other programmable access predictive device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0311] These computer program instructions can also be loaded onto a computer or other programmable access predictive device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0312] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.

[0313] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A data processing method for a time window, characterized in that, include: Based on the main station system time, establish a time window containing multiple consecutive second-level time slots; Monitor the time changes of the main station system. If a sudden time change is detected in the main station system, the time window is initialized. Upon receiving incoming data, the system performs data processing based on the relationship between the data's time index and the time window; wherein the data processing includes one of storage, window expansion, or discarding. When a slow drift in system time is detected, the system time drift is accumulated, and when the system time drift reaches a preset threshold, the time window is shifted as a whole or partially reconstructed. Periodically extract the data to be processed based on the data age. After extracting the data to be processed, remove the time slot of the corresponding data from the time window and slide the time window to maintain the window timeliness of the time window. Obtain the status information of the time window, and calculate the health index of the time window based on the status information.

2. The method according to claim 1, characterized in that, The establishment of a time window containing multiple consecutive second-level time slots, based on the main station system time, includes: When the system starts up or detects a serious anomaly, a time window initialization is performed. A time window is established based on the main station system time, and the start and end times of the window are represented as follows: Tstart = Tmaster - CACHE_DATA_BEFORE; Tend = Tstart + CACHE_DATA_SIZE - 1; Where Tmaster is the master station system time, Tstart is the window start time, Tend is the window end time, CACHE_DATA_BEFORE is the preset cache size, representing the length of historical data covered by the window; and CACHE_DATA_SIZE is the preset cache size, representing the total time length covered by the window. All time slots are pre-created within the time window. Each time slot contains 100 frame data slots, and each frame data slot contains a 10ms data frame. The frame index of the data frame is calculated using the following formula: frameIdx = floor(msec / 10); Where frameIdx represents the frame index formula, msec is the number of milliseconds in a frame, and floor is the floor function.

3. The method according to claim 1, characterized in that, If a sudden time change is detected in the monitoring master station system, the time window is initialized, including: Before adding data each time, obtain the current system time of the main site and calculate the difference ΔT between it and the previously recorded system time. ΔT can be expressed as: ΔT = Tcurrent - Tlast; Where Tcurrent represents the current system time of the main station, and Tlast represents the system time recorded last time; If the difference exceeds a preset mutation threshold, it is determined to be a time mutation, the current time window is cleared and reinitialized; wherein, the mutation detection function is defined as: ; Among them, MAX_TIME_JUMP_THRESHOLD represents the preset mutation threshold; Used to determine whether the difference exceeds the preset mutation threshold. When f_jump(ΔT) is 1, a window reconstruction operation is performed and an alarm log is recorded.

4. The method according to claim 1, characterized in that, The received data is processed according to the relationship between the data's time stamp and the time window, including: For the arriving data frame, let its timestamp be tSOC; The window containment function is used to determine the relationship between the time scale tSOC and the time window of the data. The window containment function is defined as follows: ; like =1, determine if the data is within the window, perform normal data storage, store it in the corresponding position according to the frame index and mark the receiving flag; If inWindow(tSOC) = 0, determine if the data exceeds the window, calculate the amount of time exceeded (ΔTfuture) and the amount of time exceeded (ΔTpast), expressed as: ΔTfuture = tSOC - Tend; ΔTpast = Tstart - tSOC; When the amount of time exceeding the end time is less than or equal to the maximum future tolerance of the preset offset and greater than 0, a window expansion operation is performed, the end time of the expanded window is updated to Tend_new = tSOC, and the oldest ΔTfuture second data in the window is deleted to keep the total window size from exceeding maxWindowSize. When the time exceeds the maximum future tolerance of the preset offset, discard the data and log a warning. If the past data is greater than 0, discard the data.

5. The method according to claim 1, characterized in that, When a slow drift in system time is detected, the system time drift is accumulated. When the system time drift reaches a preset threshold, the time window is shifted entirely or partially reconstructed, including: The cumulative system time drift is expressed as: ; Where D_total represents the system time drift, and ΔTi is the amount of time change detected each time data is added; When the absolute value of the system time drift is greater than or equal to the drift adjustment threshold, let the drift amount δ = D_total; If the absolute value of the drift is less than or equal to the preset maximum drift adjustment, the keywords of all time slots in the window are shifted as a whole, and the start and end times of the window are updated at the same time. If the absolute value of the drift is greater than the preset maximum drift adjustment, the window is rebuilt based on the current system time, retaining the data in the original window that falls within the range of the new window, and supplementing the missing time slots.

6. The method according to claim 1, characterized in that, The step of periodically extracting data to be processed based on the data age, removing the corresponding time slot from the time window after extraction, and sliding the time window to maintain its timeliness includes: The age(t) of the data to be processed is defined as: age(t) = Tcurrent - t; Where Tcurrent is the current main station system time; Find data with age(t) ≥ 1 second as the data to be processed. If no corresponding data is found, select the oldest data as the data to be processed. After finding the best candidate time tbest, extract the corresponding second data stCacheSecond, and check the timeout status of the corresponding second data. The timeout status judgment function isTimeout is defined as follows: ; After extracting the data, remove the corresponding time slot from the window corresponding to the time window, slide the time window, and establish a new window start time Tstart_new and window end time Tend_new: Tstart_new = Tstart + 1; Tend_new = Tstart_new + CACHE_DATA_SIZE - 1; New time slots are added based on the new window start time and window end time.

7. The method according to claim 1, characterized in that, Obtaining the status information of the time window and calculating the health index of the time window based on the status information includes: The status information includes at least the window start time Tstart, end time Tend, current size size, expected start time Texpected, start time drift ΔTstart, end time drift ΔTend, and cumulative drift amount D_total; The formula for calculating the health index H is as follows: ; Where H∈[0,1], the closer to 1, the healthier the window state.

8. A data processing system for time windows, characterized in that, include: The time window creation module is used to create a time window containing multiple consecutive second-level time slots based on the main station system time. The mutation monitoring module is used to monitor time changes in the main station system. If a time mutation is detected in the main station system, the time window is initialized. A data processing module is used to receive incoming data and process the data according to the relationship between the data time index and the time window; wherein, the data processing includes one of storage, window expansion or discarding; The drift detection module is used to accumulate the system time drift when a slow drift is detected in the system time, and to perform overall translation or partial reconstruction of the time window when the system time drift reaches a preset threshold. The data extraction module is used to periodically extract data to be processed based on the data age. After extracting the data to be processed, the corresponding time slot of the data is removed from the time window, and the time window is slid to maintain the window timeliness of the time window. The status acquisition module is used to obtain the status information of the time window and calculate the health index of the time window based on the status information.

9. A computing device, characterized in that, Its features include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method as described in any one of claims 1-7 according to the obtained program instructions.

10. A computer-readable storage medium, characterized in that, Includes computer-readable instructions that, when read and executed by a computer, cause the method as described in any one of claims 1-7 to be implemented.