Fault data query method, system and equipment and storage medium
By receiving and processing fault data query requests in the database, determining the fault type identification and data quantity, the problem of low efficiency in fault data query in traditional storage solutions is solved, and fast and efficient fault data query is achieved.
Patent Information
- Application Number
- CN202411443401.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-21
AI Technical Summary
传统的历史故障数据存储方案难以高效查询故障数据,尤其是按故障类型进行分类查询时,需要逐条读取和遍历所有故障数据,导致查询效率低下。
By building a database, receiving historical fault data query requests, determining the fault type identification and data quantity based on the preset fault type information, matching the target number of historical fault data for each fault type and returning it.
It realizes rapid query of relevant fault data. Even if the user does not specify the specific fault type, he can obtain fault type and fault data according to the target number, which improves query efficiency and user experience.
Smart Images

Figure CN119493797A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a fault data query method, system, device and storage medium. Background Art
[0002] In embedded device control systems, in order to perform after-sales maintenance and troubleshooting of the system, it is necessary to record relevant data when the system fails. Since failures may be sporadic or periodic, it is necessary to continuously store failure data that occurs over a relatively long period of time.
[0003] Traditional historical fault data storage solutions store fault data in chronological order. Therefore, they usually only support querying the most recent N fault data in chronological order. If you need to query by fault type, you need to read and traverse all fault data one by one, which reduces query efficiency and affects user experience. Summary of the invention
[0004] The main purpose of the present invention is to provide a fault data query method, system, device and storage medium. By calling the constructed database, the user can quickly query the relevant fault data. Even if the user does not specify a specific fault type, the fault type and fault data can be provided according to the target quantity.
[0005] In order to achieve the above objectives, the present application provides the following technical solutions:
[0006] According to a first aspect of an embodiment of the present application, a fault data query method is provided, the method comprising:
[0007] receiving a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried;
[0008] According to the historical fault data query request not carrying the target fault type, determining a number of fault type identifiers and the amount of data corresponding to each fault type identifier according to preset fault type information;
[0009] For each fault type identifier, according to the data quantity corresponding to the fault type identifier, historical fault data that meets the quantity condition is matched according to the target quantity and returned.
[0010] Optionally, the determining of a plurality of fault type identifiers and the amount of data corresponding to each fault type identifier according to preset fault type information includes:
[0011] Acquire the target number of fault type identifiers from the fault type identifier sequence in the database; the fault type identifier represents a unique identifier for each fault type;
[0012] Counting a number of fault type identifiers and the number of occurrences of each fault type identifier according to the target number of fault type identifiers;
[0013] The corresponding data quantity is determined according to the number of occurrences of the fault type identifier.
[0014] Optionally, the matching of historical fault data that meets a quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes:
[0015] Determine, according to the fault type identifier and the corresponding data quantity, a historical index number corresponding to the data quantity;
[0016] According to the fault type identifier of the fault type and the corresponding historical index number, the corresponding fault data is matched in the fault type list of the database.
[0017] Optionally, the matching of historical fault data that meets a quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes:
[0018] Determine the historical index numbers corresponding to the target number of fault type identifiers of the target fault type;
[0019] According to the fault type identifier of the target fault type and the corresponding historical index number, the corresponding fault data is matched in the fault type list of the database.
[0020] Optionally, before receiving the historical fault data query request, the method further includes:
[0021] In response to a fault occurrence instruction, acquiring fault data and fault occurrence time;
[0022] Identify the fault type corresponding to the fault data, and obtain a fault type identifier corresponding to the fault type;
[0023] The fault data, the fault type identifier and the corresponding historical index number are stored in the fault type list; the historical index number is a natural number sorted according to the time when the fault occurred;
[0024] The fault type identifier is stored in a fault type identifier sequence according to the fault occurrence time.
[0025] Optionally, the fault type list includes a list of several fault type identifiers;
[0026] The storing the fault data, the fault type identifier and the corresponding historical index number in the fault type list includes:
[0027] Query whether the fault type identifier exists in the fault type list;
[0028] According to the fact that the fault type identifier does not exist in the fault type list, a new list of the fault type identifier is created, a historical index number is generated, and the fault data and the corresponding historical index number are stored in the list of the fault type identifier;
[0029] According to the fact that the fault type identifier already exists in the fault type list, the fault data is stored in the corresponding list of the fault type identifiers, and all historical index numbers in the list of the fault type identifiers are updated according to the fault occurrence time.
[0030] Optionally, updating all historical index numbers in the list of fault type identifiers according to the fault occurrence time includes:
[0031] Determine the historical index number corresponding to the fault data as 0;
[0032] The previously existing historical index numbers in the list of fault type identifiers are increased by one respectively.
[0033] According to a second aspect of an embodiment of the present application, a fault data query system is provided, the system comprising:
[0034] A message receiving module, used for receiving a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried;
[0035] An unclassified module, used for determining a number of fault type identifiers and the amount of data corresponding to each fault type identifier according to the preset fault type information, according to the historical fault data query request not carrying the target fault type;
[0036] The query module is used to match and return historical fault data that meets the quantity condition according to the target quantity for each fault type identifier and the data quantity corresponding to the fault type identifier.
[0037] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect above.
[0038] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the method described in the first aspect above.
[0039] In summary, the embodiments of the present application provide a fault data query method, system, device and storage medium, by receiving a historical fault data query request, the historical fault data query request carries the target number of fault data to be queried; according to the fact that the historical fault data query request does not carry the target fault type, several fault type identifiers and the number of data corresponding to each fault type identifier are determined according to the preset fault type information; for each fault type identifier, according to the number of data corresponding to the fault type identifier, the historical fault data that meets the quantity condition is matched according to the target number and returned. By calling the constructed database, the user can quickly query the relevant fault data, and even if the user does not specify a specific fault type, the fault type and fault data can be provided according to the target number. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0041] The structures, proportions, sizes, etc. illustrated in this specification are only used to match the contents disclosed in the specification so as to facilitate understanding and reading by persons familiar with the technology. They are not used to limit the conditions under which the present invention can be implemented, and therefore have no substantial technical significance. Any structural modification, change in proportion or adjustment of size shall still fall within the scope of the technical contents disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.
[0042] Figure 1 A schematic diagram of a fault data query method flow provided in an embodiment of the present application;
[0043] Figure 2 A schematic diagram of a fault data storage structure provided in an embodiment of the present application;
[0044] Figure 3 A block diagram of a fault data query system provided in an embodiment of the present application;
[0045] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present application is shown;
[0046] Figure 5 A diagram showing a computer-readable storage medium provided by an embodiment of the present application.
[0047] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] It should be noted that all directional indications in the embodiments of the present invention (such as up, down, left, right, front, back, etc.) are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0050] In addition, in the present invention, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0051] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0052] In addition, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0053] Figure 1 The fault data query method provided in the embodiment of the present application is shown, which specifically includes the following steps:
[0054] S101: receiving a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried;
[0055] S102: According to the historical fault data query request not carrying the target fault type, a number of fault type identifiers and the amount of data corresponding to each fault type identifier are determined according to preset fault type information;
[0056] S103: For each fault type identifier, according to the data quantity corresponding to the fault type identifier, historical fault data that meets the quantity condition is matched according to the target quantity and returned.
[0057] In a possible implementation, in S101, the amount of fault data that the user needs to query is obtained. A request may be received through a user interface or an API interface, which includes the target amount of fault data specified by the user.
[0058] The system maintains a fault type database or mapping table, which contains fault type identifiers and the number of data corresponding to each type. If no fault type is provided, the system will use this mapping table to determine the type of query.
[0059] In a possible implementation manner, in S102, determining a plurality of fault type identifiers and the amount of data corresponding to each fault type identifier according to preset fault type information includes:
[0060] The target number of fault type identifiers is obtained from the fault type identifier sequence of the database; the fault type identifier represents a unique identifier for each fault type; according to the target number of fault type identifiers, several types of fault type identifiers and the number of occurrences of each fault type identifier are counted; and the corresponding data quantity is determined according to the number of occurrences of the fault type identifier.
[0061] In a possible implementation manner, matching historical fault data that meets the quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes:
[0062] According to the fault type identifier and the corresponding data quantity, determine the historical index number corresponding to the data quantity; according to the fault type identifier and the corresponding historical index number of the fault type, match the corresponding fault data in the fault type list of the database.
[0063] Extract the corresponding number of fault type identifiers from the fault type identifier sequence in the database according to the target number specified by the user. Each identifier is a unique identifier for the corresponding fault type. Count the extracted fault type identifiers and record the frequency of occurrence of each identifier. Calculate the number of data that should be matched for each fault type based on the number of occurrences of the fault type identifier. Determine the required historical data index number based on the fault type identifier and the corresponding data quantity. Use the fault type identifier and the corresponding historical index number to retrieve and match the corresponding fault data in the fault type list of the database.
[0064] The system maintains a fault type database or mapping table, which contains fault type identifiers and corresponding data quantities. When the user does not specify the fault type, the system uses this mapping table to determine the type of query. Through the pre-maintained mapping table and statistical methods, the system can quickly respond to user query requests and improve query efficiency.
[0065] In a possible implementation manner, matching historical fault data that meets the quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes:
[0066] Determine the historical index numbers corresponding to the target number of fault type identifiers of the target fault type; and match the corresponding fault data in the fault type list of the database according to the fault type identifier of the target fault type and the corresponding historical index number.
[0067] In a possible implementation manner, before receiving the historical fault data query request, the method further includes:
[0068] In response to a fault occurrence instruction, fault data and fault occurrence time are obtained; the fault type corresponding to the fault data is identified, and a fault type identifier corresponding to the fault type is obtained; the fault data, the fault type identifier and the corresponding historical index number are stored in the fault type list; the historical index number is a natural number sorted according to the fault occurrence time; the fault type identifier is stored in a fault type identifier sequence according to the fault occurrence time.
[0069] In a possible implementation, the fault type list includes a list of several fault type identifiers; storing the fault data, the fault type identifier and the corresponding historical index number in the fault type list includes: querying whether the fault type identifier exists in the fault type list; based on the fact that the fault type identifier does not exist in the fault type list, creating a new list of fault type identifiers, generating a historical index number, and storing the fault data and the corresponding historical index number in the list of fault type identifiers; based on the fact that the fault type identifier already exists in the fault type list, storing the fault data in the corresponding list of fault type identifiers, and updating all historical index numbers in the list of fault type identifiers according to the time when the fault occurred.
[0070] In a possible implementation manner, updating all historical index numbers in the list of fault type identifiers according to the fault occurrence time includes:
[0071] The historical index number corresponding to the fault data is determined to be 0; and the historical index numbers previously existing in the list of fault type identifiers are increased by one respectively.
[0072] When a fault is identified, the system automatically obtains the fault data and the time when the fault occurred. Identify the fault type corresponding to the acquired fault data, and obtain the fault type identifier corresponding to the type. Store the fault data, fault type identifier, and the corresponding historical index number in the fault type list. The historical index numbers are sorted according to the time when the fault occurred to form a natural number sequence. Specifically, the system queries whether the fault type identifier already exists in the fault type list. If the fault type identifier does not exist, the system will create a new list for the identifier, generate a historical index number, and store the fault data and index number. If the fault type identifier already exists, the system will store the fault data in the corresponding list and update all historical index numbers according to the time when the fault occurred. Set the historical index number corresponding to the newly recorded fault data to 0. For the historical index numbers already in the fault type identifier list, perform an increment operation to maintain the continuity and sequentiality of the index.
[0073] The fault type identification sequence is also stored in the fault type identification sequence according to the time of fault occurrence, ensuring the accuracy of the time sequence. The system can respond to fault occurrence instructions immediately, obtain and record fault data, and ensure real-time data updates. As the number of fault types and data increases, the system can be easily expanded to include more fault type identifications and data. The system dynamically manages the fault type list, and can efficiently handle new fault types or updates to existing types. By updating the mechanism of historical index numbers, data retrieval efficiency is optimized, making it easy to quickly locate and analyze fault data.
[0074] Combine the following Figure 2 A schematic diagram of partition storage provided in an embodiment of the present application is shown and explained in detail.
[0075] The method provided in the embodiment of the present application stores information and data in a dispersed manner to maximize the service life of the storage device. The system supports the storage of historical fault data of variable length, and through compact data layout, it can maximize the use of storage space to store more data. The system also provides two efficient query methods: one is to query in chronological order, and the other is to query by classification according to the fault type. No matter which query method is used, it can be completed quickly and efficiently, ensuring that users can quickly obtain the required information, thereby improving the efficiency of fault analysis and processing.
[0076] The system provided by the embodiments of this application adopts a flash memory chip partitioning strategy, aiming to maximize the service life and reliability of the device. The size of each partition is directly related to its number of erasable times, that is, the larger the partition, the higher its durability. The overall storage solution is based on a key-value storage management system (NVS), which is designed specifically to optimize the service life of flash memory chips. The NVS system adopts an efficient decentralized storage strategy to achieve balanced management of the erasure and writing of flash memory chips. This strategy ensures that when the storage space reaches the capacity limit, the system will automatically trigger a recycling mechanism for the oldest historical data. In this way, it can be ensured that all storage blocks in the flash memory partition can obtain uniform erasure and writing times, thus avoiding the risk of damage caused by individual storage blocks reaching the erasure times limit prematurely.
[0077] Each storage unit requires two pieces of information to be uniquely determined <key, historical index>, similar to how a cell in a table requires <row number, column number> to be uniquely located. Storing the same key multiple times does not overwrite the previous value, but instead allocates new space and adds a new value (the old value is retained). In this way, as values are stored, a list of values is stored for each key.
[0078] When storing, it is accompanied by a fault type identifier, and the data format is also consistent. Classification query requirement: It refers to the most recent N records in chronological order for a specified fault classification type (for a specific fault type). Non-classification query requirement: It refers to the most recent M records in chronological order (for all M fault types). The dashed line in the figure indicates the specific data pointed to by the index.
[0079] In the stored structural layout, <fault type identifier, historical index number> = fault data; specifically including fault type 0, fault type 1... fault type m; historical index 0, historical index 1... historical index n. [Historical index number] is the position corresponding to this fault data in the storage list of this fault type identifier. As new data is continuously written, the system will automatically assign an index value to each data item in chronological order, which is the "historical index number". The historical index is in reverse order, that is, the latest storage operation corresponds to the smallest index value. Each time a new value is added for a specific fault type identifier, the index of this value is 0, and the indexes of the old values increase sequentially. This means that the latest written data will obtain index 0, the data immediately following it will obtain index 1, and the data from the previous write will obtain index 2, and so on. This reverse index strategy optimizes the access speed to the latest data and also makes the retrieval of historical data intuitive and orderly.
[0080] At the same time, the latest fault type identifier is stored as an index in the value of a specific Key, and the fault type identifiers of the most recent n times are stored. Whenever the system records a new unclassified fault, the value of this specific Key is updated, and the fault type identifier of the new fault is added to the list. The stored structural layout also includes a fault type identifier sequence composed of fault type identifiers (fault type numbers) in the order of storage. The use of specific keys ensures that even when storage space is limited, the system can maintain the chronological order of unclassified faults, allowing users to query the most recent fault data. By using specific keys, the system can optimize the use of storage space without sacrificing data access efficiency, because specific keys only store indexes instead of actual data.
[0081] Ensure that management information and data use the same decentralized storage strategy to maximize the life of storage devices. Support variable-length historical fault data and compactly use storage space to maximize the amount of stored data. Ensure that both query methods (time sequence query and fault type classification query) can be completed quickly and efficiently.
[0082] The fault data storage process specifically includes the following steps:
[0083] Step 1: The application layer detects the failure, triggers the storage motivation, and records the specific time when the failure occurs.
[0084] Encapsulates the system operation status information at the time of the fault, including the time of the fault, the sensor collection value at the time of the fault, the control status at the time of the fault, and other information.
[0085] Step 2: Identify the fault type based on the fault characteristics.
[0086] The type and range of the key value are limited by the implementation of the underlying NVS storage system. Because the key value itself also needs to occupy flash storage space, and the storage space is limited after all. Therefore, 16-bit unsigned numbers are a more suitable choice in this application scenario after balancing the storage cost and the number of different key values that can be represented. According to the fault type, a unique 16-bit digital identifier is assigned as the key, ranging from 0 to 65534. Use 16-bit unsigned integers from 0 to 65534 as keys to represent 65535 different fault type identifiers. Reserve 65535 as a special key for storing the unclassified index of the most recent N fault data. Each fault type is identified by a unique 16-bit unsigned integer. This design allows up to 65536 different fault types to be defined, covering a numerical range from 0 to 65535.
[0087] Step 3: Use the NVS system to associate the packaged fault data with the Key and store it in the flash chip. The NVS system allocates new storage space for the Key and writes the fault data into it.
[0088] For each Key, call the set(key, value) function to store the value. Each time the set function is called, the existing value will not be overwritten, but new storage space will be allocated to add a new value for the Key. The NVS system retains historical data to form a linked list structure, and new data is inserted into the head of the linked list. When new data for each Key is written, the index value is automatically updated to build a chronological index. Each Key has an internal index, which is the index of the fault data list associated with each Key. Each time a fault occurs and data is stored, the system creates a new data item for this Key internally and assigns an index. These indexes are usually arranged in reverse chronological order, with the latest data item having the smallest index and the oldest data item having the largest index. The index for each fault type Key is used to access the time series of all historical fault data under that type. The specific steps include:
[0089] Step 301: The system searches the flash memory storage area to check whether a corresponding storage entry already exists for the specified Key.
[0090] Step 302: If the Key appears for the first time, the system will allocate a new storage space for it, store the Key value and the corresponding data value in the newly allocated space, and update the address lookup cache so that the new data entry can be quickly retrieved in the future.
[0091] Step 303: If the key already exists, the system will also allocate a new storage space and store the current key value and data value. Unlike creating a new entry, the system also needs to update the link information to ensure that the newly stored data can be connected to the old storage entry through the index linked list, and update the address lookup cache to reflect this change.
[0092] Storage example: Use the set function to store different Value values three times in sequence:
[0093] Call set(1,1): The first Value is stored and assigned the latest historical index 0, so the storage result is <1,0>=a.
[0094] Call set(1,2) again: the second Value is stored in the system. Since the historical index is in reverse order, this value is assigned index 1, and the storage result is <1,1>=b.
[0095] The third call to set(1,3): The third Value is stored, it gets index 2, and the stored result is <1,2>=c.
[0096] 0, 1, 2 are historical index values, and the historical index is in reverse order.
[0097] Each time the set function is called, the new value is always stored at the smallest available index. The index of the old value is moved up accordingly, ensuring that each value has a unique index. The index is in reverse order, with the newest value having the smallest index value and the oldest value having the largest index value. This storage mechanism ensures that the latest fault data can be accessed quickly, while also retaining historical data for easy fault analysis and historical queries.
[0098] When there is insufficient storage space, the system will select the oldest node in the linked list for deletion to reclaim storage space and ensure that the system can continue to receive and store new data entries.
[0099] Step 4: Store the latest fault type identifier as an index in the value of the index Key of Key=65535 to maintain the unclassified index of the most recent N fault data.
[0100] The special key 65535 maintains an index list of unclassified fault data. Whenever new fault data is stored, the value of this special key is updated and the index of the new fault is added to the front of the list. The index of the special key (65535) is a separate index. This index is not used to index data items of a specific key, but is used to quickly access the most recent fault events, regardless of the type of fault they belong to. This index is also arranged in reverse chronological order, and the latest fault event has the smallest index. The reason for storing this fault type identifier again is to maintain the chronological order of the occurrence of unclassified faults in order to meet the requirements of unclassified data queries.
[0101] In summary, the system adopts an efficient and intelligent method to manage and store fault data. First, the system determines the type of fault through an accurate identification mechanism and generates corresponding fault data accordingly. In order to ensure the traceability and uniqueness of the data, the system assigns a unique 16-bit digital identifier to each piece of fault data. This identifier is between 0 and 65534, providing a clear identifier for each fault type. Subsequently, the system uses this fault type identifier as the storage key to store the fault data in the non-volatile storage system (NVS). The NVS system allocates new storage space for this key and writes the data efficiently. At the same time, the NVS system has the function of automatically retaining historical records and providing persistent storage for fault data with the same key.
[0102] To optimize data access and index management, the system uses a special key 65535 to maintain an index list that stores the latest N fault type identifiers in the order in which the faults occurred. When the index list is full, the system automatically removes the oldest identifier to ensure that the latest fault data records are always retained in the list.
[0103] Users can directly access the latest data of a specific fault type through the Key, or efficiently access the historical data of a specific fault type through the index Key65535 and the corresponding index value.
[0104] The specific fault data query process includes the following steps:
[0105] Step 1: In response to a user's query request, obtain the number of fault data targets to be queried by the user, and determine whether the query request carries classified fault information.
[0106] Step 2: For queries that carry classified fault information, use the fault type identifier and the expected historical index number to directly query.
[0107] The fault type identifier specified by the user and the historical index number expected by the user are obtained, and the fault type identifier and the historical index number are further used to directly query the corresponding fault data.
[0108] Step 3: If the query does not carry classified fault information, it includes:
[0109] Step 3-1: Use the special key value 65535 as the index key and query the fault type index information of the most recent N times through the index key.
[0110] Step 3-2: Analyze the index information of the most recent N fault types obtained by query, identify different fault types, and count each fault type to determine the number of times each fault type appears in the most recent N faults.
[0111] Step 3-3: Based on the analysis results, restore the information required to access specific historical fault data: For each fault type, use its fault type identifier. Based on the count of the fault type, determine the range of the historical index number.
[0112] Step 3-4: Use the restored (<fault type identifier>, <historical index number>) information to obtain specific historical fault data for each item.
[0113] Step 3-5: Display the queried target quantity of unclassified historical fault data to the user for viewing and analysis.
[0114] When it is necessary to query the unclassified fault data for the most recent N times, first obtain the list of fault type identifiers for the most recent N faults through a special key (65535). Then, by counting the number of occurrences of each fault identifier, the historical index corresponding to each fault identifier can be restored. That is, use the special key (65535) to query the fault type index for the most recent N times, count the queried fault types, and restore the (<fault type identifier>, <historical index number>) information required to access specific historical fault data. According to the restored information, obtain the most recent N unclassified historical fault data. The above query process ensures that users can efficiently query and analyze historical fault data in a classified or unclassified manner according to different needs.
[0115] An example is given to illustrate the query of unclassified fault data: Taking the fault identifier sequence 1, 2, 3, 4, 5 and the fault occurrence order 5, 5, 3, 2, 4, 4, 1, 1, 4, 5 as an example, if you want to access the most recent 10 unclassified fault data, the following index list can be constructed:
[0116] Stored order list: <5>, <4>, <1>, <1>, <4>, <4>, <2>, <3>, <5>, <5>;
[0117] Restored index list: <5,0>, <4,0>, <1,0>, <1,1>, <4,1>, <4,2>, <2,0>, <3,0>, <5,1>, <5,2>.
[0118] If you want to access the most recent 10 unclassified fault data in chronological order from the most recent to the oldest, the following <key, historical index> list is required: <5,0>; <4,0>; <1,0>; <1,1>; <4,1>; <4,2>; <2,0>; <3,0>; <5,1>; <5,2>; For the same fault identifier (left value), its corresponding historical index (right value) is arranged in the order of 0 1 2 3... Therefore, only the fault identifiers need to be stored in order, and their corresponding historical indexes can be restored by counting.
[0119] Stored: <5><4><1><1><4><4><2><3><5><5>;
[0120] Restored: The 0th 5 of <5> = <5,0>; The 0th 4 of <4> = <4,0>; The 0th 1 of <1> = <1,0>; The 1st 1 of <1> = <1,1>; The 1st 4 of <4> = <4,1>; The 2nd 4 of <4> = <4,2>; The 0th 2 of <2> = <2,0>; The 0th 3 of <3> = <3,0>; The 1st 5 of <5> = <5,1>; The 2nd 5 of <5> = <5,2>.
[0121] In summary, the embodiment of the present application provides a fault data query method, by receiving a historical fault data query request, the historical fault data query request carries the target number of fault data to be queried; according to the historical fault data query request not carrying the target fault type, several fault type identifiers and the number of data corresponding to each fault type identifier are determined according to the preset fault type information; for each fault type identifier, according to the number of data corresponding to the fault type identifier, historical fault data that meets the quantity condition is matched according to the target number and returned. By calling the constructed database, the user can quickly query the relevant fault data, and even if the user does not specify a specific fault type, the fault type and fault data can be provided according to the target number.
[0122] Based on the same technical concept, the embodiment of the present application also provides a fault data query system, such as Figure 3 As shown, the system comprises:
[0123] A message receiving module 301 is used to receive a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried;
[0124] An unclassified module 302 is used to determine a number of fault type identifiers and the amount of data corresponding to each fault type identifier according to the preset fault type information, based on the fact that the historical fault data query request does not carry a target fault type;
[0125] The query module 303 is used to match the historical fault data that meets the quantity condition according to the target quantity for each fault type identifier and return the matched historical fault data according to the data quantity corresponding to the fault type identifier.
[0126] The present application also provides an electronic device corresponding to the method provided in the above embodiment. Figure 4 , which shows an electronic device diagram provided by some embodiments of the present application. The electronic device 20 may include: a processor 200, a memory 201, a bus 202 and a communication interface 203, wherein the processor 200, the communication interface 203 and the memory 201 are connected via the bus 202; the memory 201 stores a computer program that can be run on the processor 200, and the processor 200 executes the method provided by any of the aforementioned embodiments of the present application when running the computer program.
[0127] The memory 201 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one physical port (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0128] The bus 202 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs, and the processor 200 executes the programs after receiving execution instructions. The method disclosed in any implementation of the aforementioned embodiment of the present application may be applied to the processor 200, or implemented by the processor 200.
[0129] The processor 200 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 200. The above processor 200 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a readily available programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 201, and the processor 200 reads the information in the memory 201 and completes the steps of the above method in combination with its hardware.
[0130] The electronic device provided in the embodiment of the present application and the method provided in the embodiment of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, operated or implemented by them.
[0131] The present application also provides a computer-readable storage medium corresponding to the method provided in the above embodiment. Figure 5The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is run by a processor, the method provided in any of the aforementioned embodiments is executed.
[0132] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0133] The computer-readable storage medium provided in the above-mentioned embodiments of the present application and the method provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the method adopted, run or implemented by the application program stored therein.
[0134] It should be noted that the above embodiments illustrate the present application rather than limit the present application, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be constructed as a limitation to the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present application may be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names.
[0135] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
[0136] The above description is only a preferred embodiment of the present invention, and does not limit the patent scope of the present invention. All equivalent structural changes made by using the contents of the present invention specification and drawings under the concept of the present invention, or directly / indirectly applied in other related technical fields are included in the patent protection scope of the present invention.
Claims
1. A fault data query method, characterized in that: The method comprises: receiving a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried; According to the historical fault data query request not carrying the target fault type, determining a number of fault type identifiers and the amount of data corresponding to each fault type identifier according to preset fault type information; For each fault type identifier, according to the data quantity corresponding to the fault type identifier, historical fault data that meets the quantity condition is matched according to the target quantity and returned.
2. The method according to claim 1, characterized in that The determining of a plurality of fault type identifiers and the amount of data corresponding to each fault type identifier according to the preset fault type information includes: Acquire the target number of fault type identifiers from the fault type identifier sequence in the database; the fault type identifier represents a unique identifier for each fault type; Counting a number of fault type identifiers and the number of occurrences of each fault type identifier according to the target number of fault type identifiers; The corresponding data quantity is determined according to the number of occurrences of the fault type identifier.
3. The method according to claim 2, characterized in that The matching of historical fault data meeting the quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes: Determine, according to the fault type identifier and the corresponding data quantity, a historical index number corresponding to the data quantity; According to the fault type identifier of the fault type and the corresponding historical index number, the corresponding fault data is matched in the fault type list of the database.
4. The method according to claim 1, characterized in that The matching of historical fault data meeting the quantity condition according to the target quantity according to the quantity of data corresponding to the fault type identifier includes: Determine the historical index numbers corresponding to the target number of fault type identifiers of the target fault type; According to the fault type identifier of the target fault type and the corresponding historical index number, the corresponding fault data is matched in the fault type list of the database.
5. The method according to any one of claims 2 to 4, characterized in that: Before receiving the historical fault data query request, the method further includes: In response to a fault occurrence instruction, acquiring fault data and fault occurrence time; Identify the fault type corresponding to the fault data, and obtain a fault type identifier corresponding to the fault type; The fault data, the fault type identifier and the corresponding historical index number are stored in the fault type list; the historical index number is a natural number sorted according to the time when the fault occurred; The fault type identifier is stored in a fault type identifier sequence according to the fault occurrence time.
6. The method according to claim 5, characterized in that The fault type list includes a list of several fault type identifiers; The storing the fault data, the fault type identifier and the corresponding historical index number in the fault type list includes: Query whether the fault type identifier exists in the fault type list; According to the fact that the fault type identifier does not exist in the fault type list, a new list of the fault type identifier is created, a historical index number is generated, and the fault data and the corresponding historical index number are stored in the list of the fault type identifier; According to the fact that the fault type identifier already exists in the fault type list, the fault data is stored in the corresponding list of the fault type identifiers, and all historical index numbers in the list of the fault type identifiers are updated according to the fault occurrence time.
7. The method according to claim 6, characterized in that The updating of all historical index numbers in the list of fault type identifiers according to the fault occurrence time includes: Determine the historical index number corresponding to the fault data as 0; The previously existing historical index numbers in the list of fault type identifiers are increased by one respectively.
8. A fault data query system, characterized in that: The system comprises: A message receiving module, used for receiving a historical fault data query request, wherein the historical fault data query request carries a target number of fault data to be queried; An unclassified module, used for determining a number of fault type identifiers and the amount of data corresponding to each fault type identifier according to the preset fault type information, according to the historical fault data query request not carrying the target fault type; The query module is used to match and return historical fault data that meets the quantity condition according to the target quantity for each fault type identifier and the data quantity corresponding to the fault type identifier.
9. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1-7.