Method and apparatus for caching industrial real-time data

By dividing the measurement points into dedicated cache areas, the complete data is cached initially, and only the data change values ​​are cached subsequently. The large memory consumption problem when caching real-time industrial data is solved by using a compressed writing method, thus improving caching efficiency and performance.

CN116049231BActive Publication Date: 2026-04-21ZHEJIANG DATANG WUSHASHAN POWER GENERATION CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DATANG WUSHASHAN POWER GENERATION CO LTD
Filing Date
2022-12-05
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies, caching real-time industrial data requires repeated memory allocation and release, resulting in high memory consumption and performance degradation.

Method used

By allocating dedicated cache areas for measurement points, the complete tag number data is cached initially, and only the data change values ​​are cached subsequently. Furthermore, memory usage is reduced through compressed writing, avoiding repeated memory allocation and release.

Benefits of technology

It effectively reduces memory usage, improves caching efficiency, and avoids wasting CPU resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049231B_ABST
    Figure CN116049231B_ABST
Patent Text Reader

Abstract

This application discloses a method and apparatus for caching industrial real-time data. The method includes: acquiring the first bit data of a target measurement point acquired at a first acquisition time, the first bit data including a first time tag, a first quality code, and a first data value; if the first acquisition time is the initial acquisition time, directly writing the first bit data into a dedicated target cache area for the target measurement point, and updating data variables based on the first bit data, the data variables including a previous value variable, a time difference variable, and a cache pointer; if the first acquisition time is not the initial acquisition time, acquiring the data variables, determining the second bit data to be cached based on the data variables and the first bit data, compressing the second bit data and writing it into the target cache area, and updating the data variables based on the first bit data and the data variables. This application solves the technical problem in related technologies where caching industrial real-time data requires repeated memory allocation and release, resulting in significant memory consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and more specifically, to a method and apparatus for caching industrial real-time data. Background Technology

[0002] In process industries, historical data such as process data and operating status of various production units within an enterprise are used to create trend charts, various statistical reports, and for various online process analyses. As production continues, historical data is continuously generated. Due to the large number of reference points and high frequency of data changes in industrial real-time data, real-time databases or time-series databases are typically used in the industrial field to store historical reference point data. In the storage design of real-time databases, to reduce disk I / O, data is usually written to an internal storage buffer before being written to the archive file. Since the archive file is stored in blocks by reference point, the storage buffer is also allocated according to reference point, and data is written to the buffer corresponding to the reference point.

[0003] If each piece of data stored in the cache has a complete timestamp, quality code, and data, the space occupied will be enormous. The previous implementation method was to store it in a skip list or hash table. This method requires memory allocation every time data is added, and allocating and releasing memory from the system is very performance-intensive. In addition, since complete data is stored, a lot of memory will be used.

[0004] There is currently no effective solution to the above problems. Summary of the Invention

[0005] This application provides a method and apparatus for caching industrial real-time data, which at least solves the technical problem in the related art that when caching industrial real-time data, it is necessary to repeatedly apply for and release memory, and the memory consumption is large.

[0006] According to one aspect of the embodiments of this application, a method for caching industrial real-time data is provided, comprising: acquiring the first bit number data of a target measurement point acquired at a first acquisition time, wherein the first bit number data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value; when the first acquisition time is the initial acquisition time, directly writing the first bit number data into a target cache area, and updating data variables based on the first bit number data, wherein the target cache area is a dedicated cache area for the target measurement point, and the data variables include: a previous value variable, a time difference variable, and a cache pointer, wherein the previous value variable is used to reflect the bit number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times; when the first acquisition time is not the initial acquisition time, acquiring data variables, determining second bit number data to be cached based on the data variables and the first bit number data, compressing and writing the second bit number data into the target cache area, and updating data variables based on the first bit number data and the data variables.

[0007] Optionally, before writing the first number data into the target cache area, the target cache area is partitioned from memory as a dedicated cache area for the target measurement point.

[0008] Optionally, updating the data variable based on the first digit includes: writing the first digit to the previous value variable; setting the time difference variable to 0; and using the cache address of the first digit in the target cache area as a cache pointer.

[0009] Optionally, the process of acquiring data variables and determining the second position data to be cached based on the data variables and the first position data includes: acquiring the previous value variable and the time difference variable from the data variables, wherein the previous value variable includes: the second position data of the target measurement point acquired at the second acquisition time, the second acquisition time being the previous adjacent acquisition time of the first acquisition time; the second position data includes at least: the second time tag, the second quality code, and the second data value corresponding to the second acquisition time; the time difference variable is 0 or the first difference between the second acquisition time and the third acquisition time, the third acquisition time being the previous adjacent acquisition time of the second acquisition time; calculating the second difference between the first time tag and the second time tag, and calculating the third difference between the second difference and the time difference variable; calculating the fourth difference between the first quality code and the second quality code; determining the target data value to be cached based on the type of the first data value; generating a marker variable based on the third difference, the fourth difference, and the first data value; writing the marker variable into the target cache area; and determining the second position data based on the marker variable, wherein the second position data includes at least one of the following: the third difference, the fourth difference, and the target data value.

[0010] Optionally, determining the target data value to be cached based on the type of the first data value includes: when the first data value is Boolean data, there is no target data value; when the first data value is integer data, calculate the fifth difference between the first data value and the second data value, and use the fifth difference as the target data value; when the first data value is other types of data besides Boolean and integer, use the first data value as the target data value.

[0011] Optionally, generating a marker variable based on the third difference, the fourth difference, and the first data value includes: determining the time unit of the third difference and determining a first flag bit in the marker variable based on the time unit, wherein the first flag bit includes at least a microsecond flag bit and a millisecond flag bit; when the third difference is 0, the microsecond flag bit is 0 and the millisecond flag bit is 0; when the time unit of the third difference is microseconds, the microsecond flag bit is 1 and the millisecond flag bit is 0; when the time unit of the third difference is milliseconds, the microsecond flag bit is 1 and the millisecond flag bit is 1; when the time unit of the third difference is seconds, the microsecond flag bit is 1 and the millisecond flag bit is 1; using the fourth difference as a second flag bit in the marker variable; determining a third flag bit in the marker variable based on the type of the first data value, wherein the third flag bit includes at least a Boolean flag bit and a non-Boolean flag bit; when the first data value is Boolean data, the non-Boolean flag bit is a first preset value and the Boolean flag bit is the first data value; when the first data value is not Boolean data, the non-Boolean flag bit is a second preset value and the Boolean flag bit is 0.

[0012] Optionally, determining the second bit number data based on the marker variable includes: when both the microsecond flag and the millisecond flag are 0, determining that the second bit number data does not include the third difference; otherwise, determining that the second bit number data includes the third difference; when the second flag is 0, determining that the second bit number data does not include the fourth difference; otherwise, determining that the second bit number data includes the fourth difference; when the non-Boolean flag is 1, determining that the second bit number data includes the target data value; otherwise, determining that the second bit number data does not include the target data value.

[0013] Optionally, updating the data variable based on the first data number and the data variable includes: updating the previous value variable based on the first data number; updating the time difference variable based on the second difference; and updating the cache pointer based on the cache address of the first data number in the target cache area.

[0014] According to another aspect of the embodiments of this application, an industrial real-time data caching device is also provided, comprising: an acquisition module, configured to acquire the first bit number data of a target measurement point acquired at a first acquisition time, wherein the first bit number data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value; a first writing module, configured to directly write the first bit number data into a target cache area when the first acquisition time is the initial acquisition time, and update data variables based on the first bit number data, wherein the target cache area is a dedicated cache area for the target measurement point, and the data variables include: a previous value variable, a time difference variable, and a cache pointer, wherein the previous value variable is used to reflect the bit number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times; and a second writing module, configured to acquire data variables when the first acquisition time is not the initial acquisition time, determine second bit number data to be cached based on the data variables and the first bit number data, compress and write the second bit number data into the target cache area, and update data variables based on the first bit number data and the data variables.

[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, the electronic device including: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described industrial real-time data caching method through the computer program.

[0016] In this embodiment, the first bit number data of the target measurement point collected at the first acquisition time is first obtained. The first bit number data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value. When the first acquisition time is the initial acquisition time, the first bit number data is directly written into the target cache area, and the data variables are updated according to the first bit number data. The target cache area is a dedicated cache area for the target measurement point. The data variables include: a previous value variable, a time difference variable, and a cache pointer. The previous value variable is used to reflect the bit number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times. When the first acquisition time is not the initial acquisition time, the data variables are obtained, and the second bit number data to be cached is determined according to the data variables and the first bit number data. The second bit number data is compressed and written into the target cache area, and the data variables are updated according to the first bit number data and the data variables. By allocating dedicated cache areas for measurement points, repeated memory allocation and release are avoided. Furthermore, only complete tag data is cached initially, and subsequent data changes are cached only. Compressed writing effectively reduces memory usage, thus solving the technical problem of repeated memory allocation and release and large memory consumption when caching real-time industrial data in related technologies. Attached Figure Description

[0017] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0018] Figure 1 This is a flowchart illustrating an optional method for caching industrial real-time data according to an embodiment of this application.

[0019] Figure 2 This is a schematic diagram of an optional time flag determination process according to an embodiment of this application;

[0020] Figure 3 This is a schematic diagram of an optional bit data caching process according to an embodiment of this application;

[0021] Figure 4 This is a schematic diagram of an optional industrial real-time data caching device according to an embodiment of this application. Detailed Implementation

[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application.

[0023] It should be noted that the terms "first," "second," etc., used in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0024] To better understand the embodiments of this application, the following is a translation and explanation of some nouns or terms that appear in the description of the embodiments of this application:

[0025] Measurement point: A measurement point used to monitor field devices, which is equivalent to a tag number in the system.

[0026] Tag number: Defines the I / O point in the industrial control field.

[0027] Tag data: Tag data at a specific moment, generally including a timestamp, value, and quality code. The timestamp indicates when the data was generated; the quality code indicates the data status and whether the data is reliable; the value indicates the instrument reading.

[0028] Cache area: A block of memory used to temporarily store data.

[0029] Archive files: Files with a fixed format designed for easy retrieval and used to store tag data; they can be understood as database files.

[0030] Example 1

[0031] According to an embodiment of this application, a method for caching industrial real-time data is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0032] Figure 1 This is a flowchart illustrating an optional industrial real-time data caching method according to an embodiment of this application, as shown below. Figure 1 As shown, the method includes at least steps S102-S106, wherein:

[0033] Step S102: Obtain the first bit data of the target measurement point collected at the first acquisition time. The first bit data includes at least: the first time tag corresponding to the first acquisition time, the first quality code and the first data value.

[0034] Step S104: If the first acquisition time is the initial acquisition time, the first number data is directly written into the target buffer area, and the data variables are updated according to the first number data. The target buffer area is a dedicated buffer area for the target measurement point. The data variables include: the previous value variable, the time difference variable, and the buffer pointer. The previous value variable is used to reflect the position number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times.

[0035] To avoid wasting CPU resources due to repeated memory allocation and deallocation during data caching, as an optional implementation method, before writing the first bit data into the target cache area, a target cache area can be allocated from memory as a dedicated cache area for the target measurement point. The size of this target cache area can be adjusted automatically according to the importance of the target measurement point.

[0036] Understandably, no matter how the tag data is simplified, a complete set of tag data is always needed as a reference. Therefore, the first tag data collected at the initial acquisition time can be directly written into the target buffer area. At the same time, data variables of the target data structure can be generated based on the first tag data, mainly including the pre-value variable (prev_value), the time difference variable (delta_ts), and the buffer pointer, which are used as a reference for subsequent tag data processing.

[0037] As an optional implementation, when generating data variables based on the first digit, the first digit can be directly written into the previous value variable, the time difference variable can be set to 0, and the cache address of the first digit in the target cache area can be used as a cache pointer.

[0038] Step S106: If the first acquisition time is not the initial acquisition time, acquire the data variable, determine the second digit data to be cached based on the data variable and the first digit data, compress the second digit data and write it into the target cache area, and update the data variable based on the first digit data and the data variable.

[0039] Typically, the data in the buffer is continuous in time, indicating that the timestamp of the data acquisition time is generally increasing, while the quality code of the data is likely to be the same, that is, the data changes slowly. Considering these characteristics of the data in the buffer, this application proposes to simplify the acquired bit data in the following way to reduce its memory usage.

[0040] Specifically, the preceding value variable and the time difference variable in the data variables can be obtained first. The preceding value variable includes the second position data of the target measurement point collected at the second acquisition time. The second acquisition time is the previous adjacent acquisition time of the first acquisition time. The second position data includes at least the second time tag, the second quality code and the second data value corresponding to the second acquisition time. If the second acquisition time is the next adjacent acquisition time of the initial acquisition time, the obtained time difference variable is 0. If the second acquisition time is another acquisition time after that, the obtained time difference variable is the first difference between the second acquisition time and the third acquisition time. The third acquisition time is the previous adjacent acquisition time of the second acquisition time.

[0041] Then, the second difference between the first time tag and the second time tag can be calculated, and the third difference (delta_delta) between the second difference and the time difference variable can be calculated. The first time tag can be reflected by the third difference. The fourth difference (delta_Q) between the first quality code and the second quality code can also be calculated. The first quality code can be reflected by the fourth difference.

[0042] When simplifying data values, the target data value to be cached can be determined based on the type of the first data value. As an optional implementation, if the first data value is a Boolean type, it can be determined that no target data value exists, and the first data value can be reflected subsequently by a marker variable. If the first data value is an integer type, the fifth difference (delta_V) between the first and second data values ​​can be calculated, and this fifth difference can be used as the target data value. If the first data value is of a type other than Boolean or integer, the first data value can be directly used as the target data value.

[0043] Then, a marker variable can be generated based on the third difference, the fourth difference, and the first data value. The marker variable is written into the target cache area, and the second bit data is determined based on the marker variable. The second bit data includes at least one of the following: the third difference, the fourth difference, and the target data value.

[0044] The flag variable is a one-byte variable, allocated bit by bit. When generating the flag variable, the time unit of the third difference can be determined first, and the first flag bit in the flag variable can be determined based on the time unit. The first flag bit includes at least a microsecond flag bit and a millisecond flag bit. When the third difference is 0, the microsecond flag bit is 0 and the millisecond flag bit is 0; when the time unit of the third difference is microsecond, the microsecond flag bit is 1 and the millisecond flag bit is 0; when the time unit of the third difference is millisecond, the microsecond flag bit is 1 and the millisecond flag bit is 1; when the time unit of the third difference is second, the microsecond flag bit is 1 and the millisecond flag bit is 1.

[0045] Figure 2 A flowchart illustrating an optional time unit for determining the third difference is shown, such as... Figure 2 As shown, first calculate the third difference delta_delta and determine if delta_delta is equal to 0; if delta_delta is equal to 0, directly set the first flag to indicate that delta_delta = 0; if delta_delta is not equal to 0, first determine if the number of microseconds in delta_delta is 0; if it is 0, set the first flag to indicate that the time unit is microseconds; if it is not 0, convert delta_delta to milliseconds and determine if the number of milliseconds in delta_delta is 0; if it is 0, set the first flag to indicate that the time unit is milliseconds; if it is not 0, convert delta_delta to seconds and set the first flag to indicate that the time unit is seconds.

[0046] Then, the fourth difference can be used as the second flag bit in the marker variable; the third flag bit in the marker variable can also be determined according to the type of the first data value, wherein the third flag bit includes at least: a Boolean flag bit and a non-Boolean flag bit. When the first data value is Boolean data, the non-Boolean flag bit is the first preset value and the Boolean flag bit is the first data value; when the first data value is not Boolean data, the non-Boolean flag bit is the second preset value and the Boolean flag bit is 0.

[0047] An optional flag variable has the following structure: |Q|S|us|ms|v|0|1|1|, where Q is the second flag bit, S is the flag bit used to reflect the data status, us is the microsecond flag bit, ms is the millisecond flag bit, v is the Boolean flag bit, and 0 / 1 / 1 are non-Boolean flag bits.

[0048] Once the marker variables are determined, the second bit number data can be determined based on the marker variables. Specifically: when both the microsecond and millisecond flags are 0, the second bit number data does not include the third difference; otherwise, the second bit number data includes the third difference. When the second flag is 0, the second bit number data does not include the fourth difference; otherwise, the second bit number data includes the fourth difference. When the non-Boolean flag is 1, the second bit number data includes the target data value; otherwise, the second bit number data does not include the target data value.

[0049] Then, the determined second bit number data can be compressed and written to the target buffer area. For the third difference delta_delta, the fourth difference delta_Q, and the integer target data value, ZIG-ZAG encoding can be used before writing to reduce the number of bit numbers written when writing complex numbers. At the same time, varint encoding can be used when writing. For floating-point target data values, they can be written directly. For string or binary target data values, they can be compressed first and then written.

[0050] After writing the second bit data into the target cache area, it is also necessary to update the data variables based on the first bit data and the current data variable. Specifically, the previous value variable can be updated based on the first bit data; the time difference variable can be updated based on the second difference; and the cache pointer can be updated based on the cache address of the first bit data in the target cache area.

[0051] Figure 3 A complete flowchart of an optional bit number data caching process is shown, which includes the following steps:

[0052] S1, retrieve the first digit data;

[0053] S2, determine whether the first data number is the first group of cached data. If yes, proceed to step S3; otherwise, proceed to step S6.

[0054] S3, write the 64-bit first time tag;

[0055] S4, write the first quality code in 32 bits;

[0056] S5, update the data variable using the first digit, and the process ends;

[0057] S6, calculate delta_delta;

[0058] S7, determine the time unit of delta_delta;

[0059] S8 sets the first flag in the flag;

[0060] S9, calculate delta_Q;

[0061] S10, set the second flag in the flag;

[0062] S11, calculate delta_V;

[0063] S12, set the third flag in the flag;

[0064] S13, write the flag;

[0065] S14, write delta_delta;

[0066] S15, write delta_Q;

[0067] S16, write delta_V, process ends.

[0068] In this embodiment, the first bit number data of the target measurement point collected at the first acquisition time is first obtained. The first bit number data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value. When the first acquisition time is the initial acquisition time, the first bit number data is directly written into the target cache area, and the data variables are updated according to the first bit number data. The target cache area is a dedicated cache area for the target measurement point. The data variables include: a previous value variable, a time difference variable, and a cache pointer. The previous value variable is used to reflect the bit number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times. When the first acquisition time is not the initial acquisition time, the data variables are obtained, and the second bit number data to be cached is determined according to the data variables and the first bit number data. The second bit number data is compressed and written into the target cache area, and the data variables are updated according to the first bit number data and the data variables. By allocating dedicated cache areas for measurement points, repeated memory allocation and release are avoided. Furthermore, only complete tag data is cached initially, and subsequent data changes are cached only. Compressed writing effectively reduces memory usage, thus solving the technical problem of repeated memory allocation and release and large memory consumption when caching real-time industrial data in related technologies.

[0069] Example 2

[0070] According to an embodiment of this application, an industrial real-time data caching device is also provided for implementing the industrial real-time data caching method in Embodiment 1, such as... Figure 4 As shown, the industrial real-time data caching device includes at least an acquisition module 41, a first writing module 42, and a second writing module 43, wherein:

[0071] The acquisition module 41 is used to acquire the first number data of the target measurement point acquired at the first acquisition time. The first number data includes at least: the first time tag corresponding to the first acquisition time, the first quality code and the first data value.

[0072] The first writing module 42 is used to directly write the first bit number data into the target buffer area when the first acquisition time is the initial acquisition time, and update the data variables according to the first bit number data. The target buffer area is a dedicated buffer area for the target measurement point. The data variables include: the previous value variable, the time difference variable, and the buffer pointer. The previous value variable is used to reflect the bit number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times.

[0073] To avoid wasting CPU resources due to repeated memory allocation and deallocation during data caching, as an optional implementation method, before writing the first bit data into the target cache area, a target cache area can be allocated from memory as a dedicated cache area for the target measurement point. The size of this target cache area can be adjusted automatically according to the importance of the target measurement point.

[0074] Understandably, no matter how the tag number data is simplified, a complete set of tag number data is always needed as a reference. Therefore, the first tag number data collected at the initial acquisition time can be directly written into the target cache area. At the same time, data variables of the target data structure can be generated based on the first tag number data, mainly including the previous value variable, the time difference variable, and the cache pointer, which can be used as a reference for subsequent tag number data processing.

[0075] As an optional implementation, when generating data variables based on the first digit, the first digit can be directly written into the previous value variable, the time difference variable can be set to 0, and the cache address of the first digit in the target cache area can be used as a cache pointer.

[0076] The second writing module 43 is used to acquire data variables when the first acquisition time is not the initial acquisition time, determine the second bit number data to be cached based on the data variables and the first bit number data, compress the second bit number data and write it into the target cache area, and update the data variables based on the first bit number data and the data variables.

[0077] Typically, the data in the buffer is continuous in time, indicating that the timestamp of the data acquisition time is generally increasing, while the quality code of the data is likely to be the same, that is, the data changes slowly. Considering these characteristics of the data in the buffer, this application proposes to simplify the acquired bit data in the following way to reduce its memory usage.

[0078] Specifically, the preceding value variable and the time difference variable in the data variables can be obtained first. The preceding value variable includes the second position data of the target measurement point collected at the second acquisition time. The second acquisition time is the previous adjacent acquisition time of the first acquisition time. The second position data includes at least the second time tag, the second quality code and the second data value corresponding to the second acquisition time. If the second acquisition time is the next adjacent acquisition time of the initial acquisition time, the obtained time difference variable is 0. If the second acquisition time is another acquisition time after that, the obtained time difference variable is the first difference between the second acquisition time and the third acquisition time. The third acquisition time is the previous adjacent acquisition time of the second acquisition time.

[0079] Then, a second difference between the first time tag and the second time tag can be calculated, and a third difference between the second difference and the time difference variable can be calculated. The first time tag can be reflected by the third difference. A fourth difference between the first quality code and the second quality code can also be calculated. The first quality code can be reflected by the fourth difference.

[0080] When simplifying data values, the target data value to be cached can be determined based on the type of the first data value. As an optional implementation, if the first data value is a Boolean type, it can be determined that no target data value exists, and the first data value can be reflected subsequently by a marker variable; if the first data value is an integer type, the fifth difference between the first data value and the second data value can be calculated, and this fifth difference can be used as the target data value; if the first data value is of a type other than Boolean or integer, the first data value can be directly used as the target data value.

[0081] Then, a marker variable can be generated based on the third difference, the fourth difference, and the first data value. The marker variable is written into the target cache area, and the second bit data is determined based on the marker variable. The second bit data includes at least one of the following: the third difference, the fourth difference, and the target data value.

[0082] The flag variable is a one-byte variable, allocated bit by bit. When generating the flag variable, the time unit of the third difference can be determined first, and the first flag bit in the flag variable can be determined based on the time unit. The first flag bit includes at least a microsecond flag bit and a millisecond flag bit. When the third difference is 0, the microsecond flag bit is 0 and the millisecond flag bit is 0; when the time unit of the third difference is microsecond, the microsecond flag bit is 1 and the millisecond flag bit is 0; when the time unit of the third difference is millisecond, the microsecond flag bit is 1 and the millisecond flag bit is 1; when the time unit of the third difference is second, the microsecond flag bit is 1 and the millisecond flag bit is 1.

[0083] Then, the fourth difference can be used as the second flag bit in the marker variable; the third flag bit in the marker variable can also be determined according to the type of the first data value, wherein the third flag bit includes at least: a Boolean flag bit and a non-Boolean flag bit. When the first data value is Boolean data, the non-Boolean flag bit is the first preset value and the Boolean flag bit is the first data value; when the first data value is not Boolean data, the non-Boolean flag bit is the second preset value and the Boolean flag bit is 0.

[0084] Once the marker variables are determined, the second bit number data can be determined based on the marker variables. Specifically: when both the microsecond and millisecond flags are 0, the second bit number data does not include the third difference; otherwise, the second bit number data includes the third difference. When the second flag is 0, the second bit number data does not include the fourth difference; otherwise, the second bit number data includes the fourth difference. When the non-Boolean flag is 1, the second bit number data includes the target data value; otherwise, the second bit number data does not include the target data value.

[0085] Then, the determined second bit number data can be compressed and written to the target buffer area. For the third difference delta_delta, the fourth difference delta_Q, and the integer target data value, ZIG-ZAG encoding can be used before writing to reduce the number of bit numbers written when writing complex numbers. At the same time, varint encoding can be used when writing. For floating-point target data values, they can be written directly. For string or binary target data values, they can be compressed first and then written.

[0086] After writing the second bit data into the target cache area, it is also necessary to update the data variables based on the first bit data and the current data variable. Specifically, the previous value variable can be updated based on the first bit data; the time difference variable can be updated based on the second difference; and the cache pointer can be updated based on the cache address of the first bit data in the target cache area.

[0087] It should be noted that each module in the industrial real-time data caching device in this application embodiment corresponds one-to-one with each implementation step of the industrial real-time data caching method in embodiment 1. Since embodiment 1 has been described in detail, some details not shown in this embodiment can be referred to embodiment 1, and will not be elaborated further here.

[0088] Example 3

[0089] According to an embodiment of this application, a non-volatile storage medium is also provided, which includes a stored program, wherein the device where the non-volatile storage medium is located executes the industrial real-time data caching method in Embodiment 1 by running the program.

[0090] Specifically, the device containing the non-volatile storage medium executes the following steps by running the program: acquiring the first bit data of the target measurement point acquired at the first acquisition time, the first bit data including at least: the first time tag corresponding to the first acquisition time, the first quality code, and the first data value; if the first acquisition time is the initial acquisition time, directly writing the first bit data into the target cache area, and updating the data variables according to the first bit data, wherein the target cache area is a dedicated cache area for the target measurement point, and the data variables include: the previous value variable, the time difference variable, and the cache pointer, the previous value variable is used to reflect the bit data, and the time difference variable is used to reflect the time difference between adjacent acquisition times; if the first acquisition time is not the initial acquisition time, acquiring the data variables, determining the second bit data to be cached according to the data variables and the first bit data, compressing the second bit data and writing it into the target cache area, and updating the data variables according to the first bit data and the data variables.

[0091] According to an embodiment of this application, a processor is also provided for running a program, wherein the program executes the industrial real-time data caching method in Embodiment 1 during runtime.

[0092] Specifically, the program executes the following steps during runtime: First, it acquires the first bit data of the target measurement point acquired at the first acquisition time. The first bit data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value. If the first acquisition time is the initial acquisition time, it directly writes the first bit data into the target cache area and updates the data variables based on the first bit data. The target cache area is a dedicated cache area for the target measurement point. The data variables include: a previous value variable, a time difference variable, and a cache pointer. The previous value variable reflects the bit data, and the time difference variable reflects the time difference between adjacent acquisition times. If the first acquisition time is not the initial acquisition time, it acquires the data variables, determines the second bit data to be cached based on the data variables and the first bit data, compresses the second bit data and writes it into the target cache area, and updates the data variables based on the first bit data and the data variables.

[0093] According to an embodiment of this application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the industrial real-time data caching method of Embodiment 1 through the computer program.

[0094] Specifically, the processor is configured to execute the following steps via a computer program: acquire the first bit data of the target measurement point acquired at the first acquisition time, wherein the first bit data includes at least: a first time tag corresponding to the first acquisition time, a first quality code, and a first data value; if the first acquisition time is the initial acquisition time, directly write the first bit data into the target cache area and update the data variables based on the first bit data, wherein the target cache area is a dedicated cache area for the target measurement point, and the data variables include: a previous value variable, a time difference variable, and a cache pointer, wherein the previous value variable is used to reflect the bit data, and the time difference variable is used to reflect the time difference between adjacent acquisition times; if the first acquisition time is not the initial acquisition time, acquire the data variables, determine the second bit data to be cached based on the data variables and the first bit data, compress the second bit data and write it into the target cache area, and update the data variables based on the first bit data and the data variables.

[0095] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0096] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0097] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.

[0098] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0099] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0100] If the integrated unit is implemented as a software functional unit 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 application, 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 a computer 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 application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0101] The above are merely preferred embodiments of this application. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for caching real-time industrial data, characterized in that, include: Obtain the first bit number data of the target measurement point collected at the first acquisition time. The first bit number data includes at least: the first time tag corresponding to the first acquisition time, the first quality code and the first data value. When the first acquisition time is the initial acquisition time, the first position number data is directly written into the target buffer area, and the data variables are updated according to the first position number data. The target buffer area is a buffer area dedicated to the target measurement point. The data variables include: previous value variable, time difference variable and buffer pointer. The previous value variable is used to reflect the position number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times. When the first acquisition time is not the initial acquisition time, the data variable is acquired, the second bit data to be cached is determined based on the data variable and the first bit data, the second bit data is compressed and written into the target cache area, and the data variable is updated based on the first bit data and the data variable. The process of acquiring the data variables and determining the second position data to be cached based on the data variables and the first position data includes: acquiring the previous value variable and the time difference variable from the data variables, wherein the previous value variable includes: the second position data of the target measurement point acquired at the second acquisition time, the second acquisition time being the previous adjacent acquisition time of the first acquisition time, the second position data including at least: the second time tag, the second quality code, and the second data value corresponding to the second acquisition time, the time difference variable being 0 or the first difference between the second acquisition time and the third acquisition time, the third acquisition time being the... The preceding adjacent acquisition time of the second acquisition time; calculate the second difference between the first time tag and the second time tag, and calculate the third difference between the second difference and the time difference variable; calculate the fourth difference between the first quality code and the second quality code; determine the target data value to be cached based on the type of the first data value; generate a marker variable based on the third difference, the fourth difference and the first data value, write the marker variable into the target cache area, and determine the second bit number data based on the marker variable, wherein the second bit number data includes at least one of the following: the third difference, the fourth difference, and the target data value.

2. The method according to claim 1, characterized in that, Before writing the first bit data to the target cache area, the method further includes: The target cache region is allocated from memory as a dedicated cache region for the target measurement points.

3. The method according to claim 1, characterized in that, Update data variables based on the first bit number data, including: Write the first bit data into the previous value variable; Set the time difference variable to 0; The cache address of the first bit data in the target cache region is used as the cache pointer.

4. The method according to claim 1, characterized in that, Determining the target data value to be cached based on the type of the first data value includes: When the first data value is a Boolean value, the target data value does not exist; When the first data value is an integer, calculate the fifth difference between the first data value and the second data value, and use the fifth difference as the target data value; When the first data value is of a data type other than Boolean or integer, the first data value is used as the target data value.

5. The method according to claim 4, characterized in that, Generate a marker variable based on the third difference, the fourth difference, and the first data value, including: The time unit of the third difference is determined, and a first flag bit in the marker variable is determined based on the time unit. The first flag bit includes at least a microsecond flag bit and a millisecond flag bit. When the third difference is 0, the microsecond flag bit is 0 and the millisecond flag bit is 0; when the time unit of the third difference is microseconds, the microsecond flag bit is 1 and the millisecond flag bit is 0; when the time unit of the third difference is milliseconds, the microsecond flag bit is 1 and the millisecond flag bit is 1; when the time unit of the third difference is seconds, the microsecond flag bit is 1 and the millisecond flag bit is 1. The fourth difference is used as the second flag bit in the marker variable; The third flag bit in the marker variable is determined based on the type of the first data value. The third flag bit includes at least a Boolean flag bit and a non-Boolean flag bit. When the first data value is Boolean data, the non-Boolean flag bit is a first preset value and the Boolean flag bit is the first data value. When the first data value is not Boolean data, the non-Boolean flag bit is a second preset value and the Boolean flag bit is 0.

6. The method according to claim 5, characterized in that, Determining the second bit data based on the marker variable includes: When both the microsecond flag and the millisecond flag are 0, it is determined that the second bit data does not include the third difference; otherwise, it is determined that the second bit data includes the third difference. When the second flag bit is 0, it is determined that the second bit number data does not include the fourth difference value; otherwise, it is determined that the second bit number data includes the fourth difference value. When the non-Boolean flag is 1, it is determined that the second bit number data includes the target data value; otherwise, it is determined that the second bit number data does not include the target data value.

7. The method according to claim 1, characterized in that, Updating the data variable based on the first bit data and the data variable includes: Update the previous value variable based on the first bit data; Update the time difference variable based on the second difference; Update the cache pointer based on the cache address of the first bit data in the target cache region.

8. A buffer device for industrial real-time data, characterized in that, include: The acquisition module is used to acquire the first bit number data of the target measurement point collected at the first acquisition time. The first bit number data includes at least: the first time tag corresponding to the first acquisition time, the first quality code and the first data value. The first writing module is used to directly write the first tag number data into the target cache area when the first acquisition time is the initial acquisition time, and update the data variables according to the first tag number data. The target cache area is a dedicated cache area for the target measurement point. The data variables include: a previous value variable, a time difference variable, and a cache pointer. The previous value variable is used to reflect the tag number data, and the time difference variable is used to reflect the time difference between adjacent acquisition times. The second writing module is used to acquire the data variable when the first acquisition time is not the initial acquisition time, and to determine the second position data to be cached based on the data variable and the first position data. This includes: acquiring the previous value variable and the time difference variable from the data variable, wherein the previous value variable includes: the second position data of the target measurement point acquired at the second acquisition time, the second acquisition time being the previous adjacent acquisition time of the first acquisition time; the second position data includes at least: a second time tag, a second quality code, and a second data value corresponding to the second acquisition time; the time difference variable is 0 or a first difference between the second acquisition time and the third acquisition time, the third acquisition time being the previous adjacent acquisition time of the second acquisition time. The process involves: calculating a second difference between the first time tag and the second time tag, and calculating a third difference between the second difference and the time difference variable; calculating a fourth difference between the first quality code and the second quality code; determining a target data value to be cached based on the type of the first data value; generating a marker variable based on the third difference, the fourth difference, and the first data value; writing the marker variable into the target cache area; and determining the second bit number data based on the marker variable, wherein the second bit number data includes at least one of the following: the third difference, the fourth difference, and the target data value; further comprising compressing the second bit number data and writing it into the target cache area, and updating the data variable based on the first bit number data and the data variable.

9. An electronic device, characterized in that, include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute, via the computer program, the industrial real-time data caching method of any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data updating method and device for storage area and computer readable storage medium

    CN113849134A

  • Satellite auxiliary data generation method and system based on high-precision high-frequency attitude data

    CN115276761A