On-board diagnostic file storage method, device, electronic device and storage medium
By chunking and similarity calculations of vehicle diagnostic files, unified character replacement or frequency replacement, the problem of on-board diagnostic files occupying a large amount of storage space is solved, and storage space is optimized.
Patent Information
- Application Number
- CN202410152602.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-03
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-02-03
AI Technical Summary
Due to the limited storage capacity of existing vehicle diagnostic instruments, the vehicle diagnostic files occupy a large storage space, and there is a problem of insufficient storage space.
By chunking the on-board diagnostic files, the similarity of each block file is calculated, and a unified character replacement or frequency replacement is performed according to the similarity, an update block file is generated and the on-board diagnostic storage file is finally obtained.
It reduces the storage size of on-board diagnostic files, reduces the storage space occupied, and improves storage efficiency.
Smart Images

Figure HDA0004696238340000011 
Figure HDA0004696238340000021 
Figure HDA0004696238340000022
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of on-board diagnostic instruments, and in particular to an on-board diagnostic file storage method, device, electronic device and storage medium. Background Art
[0002] On-Board Diagnostics (OBD) can monitor the working conditions of the engine electronic control system and other functional modules of the vehicle in real time during the operation of the vehicle. When an abnormal condition is detected, the specific fault is determined based on a specific algorithm and stored in the system's memory in the form of a diagnostic fault code. The fault can be quickly located based on the diagnostic fault code, providing assistance for vehicle repair and maintenance.
[0003] At present, due to the cost issue of embedded handheld products, the solution of combining the main control MCU chip with an external FLASH memory is adopted. This solution has the technical problems of limited storage capacity and the on-board diagnostic files occupying a large storage space. Summary of the invention
[0004] In view of this, the present application provides an on-board diagnostic file storage method, device, electronic device and storage medium, which can reduce the storage size of the on-board diagnostic file to reduce the occupied storage space.
[0005] A first aspect of the present application provides a method for storing an on-board diagnostic file, the method comprising:
[0006] Divide the on-board diagnostic file into blocks to obtain multiple block files;
[0007] According to multiple diagnosis records in each block file, the similarity of the corresponding block files is calculated;
[0008] Compare the similarity of each block file with a preset similarity threshold;
[0009] When the similarity is greater than or equal to the preset similarity threshold, uniformly replacing characters in each diagnostic record in the corresponding block file to obtain an updated block file;
[0010] When the similarity is less than the preset similarity threshold, obtaining the frequency of each diagnosis record in the corresponding block file, and performing character replacement on the corresponding block file according to the frequency of each diagnosis record to obtain an updated block file;
[0011] An on-board diagnostic storage file is obtained according to the plurality of update block files.
[0012] In an optional implementation, dividing the on-board diagnostic file into blocks to obtain a plurality of block files includes:
[0013] Obtaining the number of rows of multiple diagnostic records in the on-board diagnostic file;
[0014] Creating a first sliding window with one column and multiple rows according to the number of rows;
[0015] Using the first sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the on-board diagnostic file;
[0016] During each sliding operation, determining whether the plurality of characters corresponding to the first sliding window are completely identical;
[0017] When the multiple characters corresponding to the current first sliding window are not completely the same, the position of the last character of the previous first sliding window is used as a block dividing line to divide the on-board diagnostic file into blocks to obtain a block file and a remaining on-board diagnostic file;
[0018] Reducing the length of the first sliding window to obtain a second sliding window;
[0019] Using the second sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the remaining on-board diagnostic file;
[0020] During each sliding operation, determining whether the plurality of characters corresponding to the second sliding window are completely identical;
[0021] When the multiple characters corresponding to the current second sliding window are not completely the same, the position of the last character of the previous second sliding window is used as the block dividing line to divide the remaining on-board diagnostic file into blocks to obtain a block file.
[0022] In an optional implementation, performing a unified character replacement on each diagnostic record in the corresponding block file to obtain an updated block file includes:
[0023] Calculating a hash value of the block file;
[0024] Determine the position of the block file in the on-board diagnostic file, and perform position encoding on the position;
[0025] Generate a Unicode according to the hash value and the position code;
[0026] The unified character encoding is used to replace the unified characters of each line of diagnostic records in the block file to obtain an updated block file.
[0027] In an optional implementation, the step of performing character replacement on the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file includes:
[0028] According to the frequency, calculating the proportion of the corresponding diagnosis record in the multiple diagnosis records;
[0029] updating the first record file according to the ratio to obtain a second record file;
[0030] generating a character code for each diagnostic record in the second record file;
[0031] Characters of the block files corresponding to the similarity are replaced according to the character encoding to obtain updated block files.
[0032] In an optional implementation, calculating the proportion of the corresponding diagnosis record in the plurality of diagnosis records according to the frequency includes:
[0033] Obtaining a frequency sum according to the frequencies of the plurality of diagnosis records;
[0034] According to the ratio of the frequency to the total frequency, the proportion of the diagnosis record corresponding to the frequency in the multiple diagnosis records is obtained.
[0035] In an optional implementation, updating the first record file according to the ratio to obtain the second record file includes:
[0036] Calculate a mean value of the proportion according to the proportion of each of the diagnosis records in the multiple diagnosis records;
[0037] comparing each of said proportions to said proportion mean;
[0038] The diagnostic records corresponding to the ratios smaller than the mean ratio are deleted from the first record file to obtain a second record file.
[0039] In an optional implementation, generating a character code for each diagnostic record in the second record file includes:
[0040] Obtain the number of diagnostic records in the second record file;
[0041] Determining a coding rule based on the quantity;
[0042] According to the encoding rule, a character code is generated for each diagnostic record in the second record file according to the position sequence of each diagnostic record in the second record file.
[0043] A second aspect of the present application provides an on-board diagnostic file storage device, the device comprising:
[0044] A block module, used for dividing the on-board diagnostic file into blocks to obtain multiple block files;
[0045] A calculation module, used for calculating the similarity of corresponding block files according to multiple diagnosis records in each block file;
[0046] A comparison module, used for comparing the similarity of each block file with a preset similarity threshold;
[0047] A replacement module, configured to replace each diagnostic record in the corresponding block file with a uniform character when the similarity is greater than or equal to the preset similarity threshold, to obtain an updated block file;
[0048] The replacement module is further configured to obtain the frequency of each diagnostic record in the corresponding block file when the similarity is less than the preset similarity threshold, and replace characters in the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file;
[0049] A storage module is used to obtain an on-board diagnostic storage file according to the multiple update block files.
[0050] A third aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the on-board diagnostic file storage method when executing the computer program.
[0051] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program, when executed, implements the steps of the on-board diagnostic file storage method.
[0052] The present application obtains multiple block files by dividing the on-board diagnostic file into blocks; according to multiple diagnostic records in each block file, the similarity of the corresponding block file is calculated; the similarity of each block file is compared with a preset similarity threshold; when the similarity is greater than or equal to the preset similarity threshold, each diagnostic record in the corresponding block file is uniformly replaced with characters to obtain an updated block file; when the similarity is less than the preset similarity threshold, the frequency of each diagnostic record in the corresponding block file is obtained, and the corresponding block file is replaced with characters according to the frequency of each diagnostic record to obtain an updated block file; and the on-board diagnostic storage file is obtained according to multiple updated block files. The present application can reduce the storage size of the on-board diagnostic file to reduce the size of the storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a flow chart of a method for storing on-board diagnostic files provided by an embodiment of the present application;
[0054] Figure 2 It is a schematic diagram of replacing a block file with an updated block file provided by an embodiment of the present application;
[0055] Figure 3 It is a schematic diagram of replacing another block file with an updated block file provided in an embodiment of the present application;
[0056] Figure 4 It is a functional module diagram of an on-board diagnostic file storage device provided by an embodiment of the present application;
[0057] Figure 5 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0058] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to any or all possible combinations comprising one or more of the listed items.
[0059] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0060] Figure 1 It is a flow chart of a method for storing an on-board diagnostic file provided in an embodiment of the present application. The method for storing an on-board diagnostic file is executed by an electronic device and specifically includes the following steps.
[0061] S11, dividing the on-board diagnostic file into blocks to obtain a plurality of block files.
[0062] On-board diagnostic files, also known as fault code files, are files stored in a fixed storage format in the vehicle's electronic control unit or related equipment. They contain information about historical faults, vehicle performance, sensor data, system status, etc., and are used to diagnose vehicle problems, monitor performance, and perform maintenance. File chunking refers to the process of dividing a large file into smaller chunks or parts according to specific rules. Chunk files refer to the files corresponding to each area after the on-board diagnostic file is chunked.
[0063] According to a specific division rule, the on-board diagnostic file is divided into a plurality of block areas, and each divided area is a block file.
[0064] In an optional implementation, dividing the on-board diagnostic file into blocks to obtain a plurality of block files includes:
[0065] Obtaining the number of rows of multiple diagnostic records in the on-board diagnostic file;
[0066] Creating a first sliding window with one column and multiple rows according to the number of rows;
[0067] Using the first sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the on-board diagnostic file;
[0068] During each sliding operation, determining whether the plurality of characters corresponding to the first sliding window are completely identical;
[0069] When the multiple characters corresponding to the current first sliding window are not completely the same, the position of the last character of the previous first sliding window is used as a block dividing line to divide the on-board diagnostic file into blocks to obtain a block file and a remaining on-board diagnostic file;
[0070] Reducing the length of the first sliding window to obtain a second sliding window;
[0071] Using the second sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the remaining on-board diagnostic file;
[0072] During each sliding operation, determining whether the plurality of characters corresponding to the second sliding window are completely identical;
[0073] When the multiple characters corresponding to the current second sliding window are not completely the same, the position of the last character of the previous second sliding window is used as the block dividing line to divide the remaining on-board diagnostic file into blocks to obtain a block file.
[0074] The on-board diagnostic file consists of multiple lines of data, each line of data has the same storage format, and each line of data is a diagnostic record. The sliding window is an algorithm technology used to process sub-arrays or sub-sequences in an array or list. During the traversal of the array, the window moves according to its width and height, and performs operations such as calculation and comparison on the characters in the window. The first sliding window refers to a window with an initial width and height set according to the data size of the on-board diagnostic file. The second sliding window refers to a sliding window that is continuously adjusted during the sliding process when multiple non-identical characters are detected in the window.
[0075] Set the statistical flag of the on-board diagnostic file, use the file processing function to traverse and read each line of diagnostic records in the on-board diagnostic file, and increase the statistical flag by 1 every time a line of diagnostic records in the on-board diagnostic file is read. After traversing all diagnostic records, the number of lines of diagnostic records in the on-board diagnostic file is obtained.
[0076] The number of rows of the diagnostic record in the on-board diagnostic file is determined as the number of rows of the first sliding window, and according to the data size of the diagnostic record in the on-board diagnostic file, an appropriate character width is determined as the width of the first sliding window, and a first sliding window of a one-column multi-row format is obtained according to the number of rows and the width of the first sliding window. The character width refers to a column in the one-column multi-row format, that is, the number of characters contained in the width of a column in the first sliding window.
[0077] Taking the position of the first character in the on-board diagnostic file as the initial position, determine the initial file data of the on-board diagnostic file in the first sliding window, and use the first sliding window to slide without overlap. The non-overlapping sliding means that each time the first sliding window is used to slide, the data selected by the first sliding window each time does not overlap or have a gap with the data selected during the previous sliding. Get the column position of the first character of the previous sliding window, calculate the sum of the column position of the first character and the character width of the first sliding window, and obtain the column position of the first character corresponding to the first sliding window during the next sliding.
[0078] Each time sliding, it is determined whether multiple characters in the same column position of the first sliding window are exactly the same. When the multiple characters in the same column position in the current first sliding window are not exactly the same, the on-board diagnostic file is segmented according to the column position of the last character of the previous first sliding window, and all characters before the column position of the last character are determined as block files, and all characters after the column position of the last character are determined as remaining on-board diagnostic files.
[0079] The length of the first sliding window is appropriately reduced to obtain a second sliding window, and the second sliding window is used to slide non-overlappingly from the first character position in the remaining on-board diagnostic file. During the next sliding, the sum of the column position of the first character and the character width of the second sliding window is calculated to obtain the column position of the first character corresponding to the second sliding window during the next sliding.
[0080] Each time sliding, determine whether multiple characters in the same column position of the second sliding window are exactly the same. When multiple characters in the same column position of the current second sliding window are not exactly the same, use the position of the last character of the previous second sliding window as the block dividing line to divide the remaining on-board diagnostic file into blocks to obtain a block file.
[0081] See also Figure 2 As shown, the on-board diagnostic file is divided into blocks, assuming that the column width of the first sliding window and the second sliding window is always 2, then the block files obtained after the on-board diagnostic file is divided into blocks correspond to the areas of block 1, block 2, block 3, block 4, and block 5 in the figure. It should be noted that the letters in the figure can represent one or more characters.
[0082] In the above optional implementation, a first sliding window is created according to the number of lines of the on-board diagnostic file and the on-board diagnostic file is slid without overlap, which can ensure that each diagnostic record is processed only once, avoid redundant calculations, and improve processing efficiency; at each sliding, it is determined whether the multiple characters corresponding to the first sliding window are completely identical. When the multiple characters corresponding to the current first sliding window are not completely identical, the position of the last character of the previous first sliding window is used as the block segmentation line, and the block file and the remaining on-board diagnostic file are obtained by block segmentation. The position of the multiple characters that are not completely identical is used as the judgment of block segmentation, and the segmentation position can be accurately obtained to improve the accuracy of block segmentation; the length of the first sliding window is reduced to obtain a second sliding window, and the second sliding window is used to start non-overlapping sliding from the first character of the multiple lines of diagnostic records in the remaining on-board diagnostic file, and the sliding window can be flexibly adjusted according to the actual situation during the sliding process, and the sliding window is reduced in the area with large character differences, so as to improve the efficiency of block segmentation; and the position of the multiple characters that are not completely identical in the second sliding window is used as the judgment of block segmentation, and the remaining on-board diagnostic file is divided into blocks to obtain block files.
[0083] S12, calculating the similarity of the corresponding block files according to the multiple diagnosis records in each block file.
[0084] Similarity refers to the measure of the difference between characters in a block file. The smaller the difference between characters stored in a block file, the higher the similarity. The greater the difference between characters stored in a block file, the lower the similarity.
[0085] The similarity of multiple diagnosis records in each block file is calculated using a text similarity algorithm, wherein the text similarity algorithm includes but is not limited to a cosine similarity algorithm, a Jaccard similarity algorithm, an edit distance, and the like.
[0086] Each diagnostic record in the block file is segmented to obtain the segmentation word list corresponding to each diagnostic record. The segmentation word list is merged and deduplicated to obtain all the segmentations corresponding to the block file. The word frequency of the segmentation is selected as the feature vector, each diagnostic record is vectorized, and the cosine similarity between each diagnostic record and other diagnostic records is calculated. Then, the average similarity of multiple diagnostic records is calculated to obtain the similarity of the block file.
[0087] See also Figure 2 As shown, Figure 1The similarity of block 2 in is calculated, then the word segmentation vocabulary corresponding to block 2 is (BC DE). In block 2, the vector corresponding to the first row of diagnosis records is expressed as (1, 1, 0, 0), the vector corresponding to the second row of diagnosis records is expressed as (1, 0, 0, 1), the vector corresponding to the third row of diagnosis records is expressed as (1, 0, 1, 0), and the vector corresponding to the fourth row of diagnosis records is expressed as (1, 1, 0, 0). The cosine similarities between the first row of diagnosis records and the second, third, and fourth rows of diagnosis records are 0.5, 0.5, and 1 respectively. The cosine similarities between the second row of diagnosis records and the third and fourth rows of diagnosis records are 0.5 and 0.5 respectively. The cosine similarity between the third row of diagnosis records and the fourth row of diagnosis records is 0.5. The average value of all similarities is 0.583, that is, the similarity of block 2 is 0.583. Figure 2 The similarity calculation method of other blocks in is the same as described above and will not be repeated here.
[0088] S13, comparing the similarity of each block file with a preset similarity threshold.
[0089] The preset similarity threshold refers to a standard value for comparing the similarity of block files.
[0090] The similarity of each block file is compared with the preset similarity threshold, and different storage strategies are adopted for the block files according to the comparison results.
[0091] S14, when the similarity is greater than or equal to the preset similarity threshold, uniformly replace characters in each diagnosis record in the corresponding block file to obtain an updated block file.
[0092] The update block file refers to the block file obtained after performing uniform character replacement on the diagnostic record. Uniform character replacement is a method for processing text data, the purpose of which is to replace specific characters or character strings in the text with a uniform standard form.
[0093] When the similarity of the block files is greater than or equal to the preset similarity threshold, it indicates that the similarity of the characters in the block files is extremely high, and the diagnosis records in the corresponding block files are replaced with unified characters.
[0094] In an optional implementation, performing a unified character replacement on each diagnostic record in the corresponding block file to obtain an updated block file includes:
[0095] Calculating a hash value of the block file;
[0096] Determine the position of the block file in the on-board diagnostic file, and perform position encoding on the position;
[0097] Generate a Unicode according to the hash value and the position code;
[0098] The unified character encoding is used to replace the unified characters of each line of diagnostic records in the block file to obtain an updated block file.
[0099] The unified character encoding refers to the unified character encoding generated according to certain encoding rules for the hash value of the block file and the position encoding corresponding to all the diagnostic records with the same hash value in the block file.
[0100] A hash function is used to calculate the hash value of each diagnostic record in the block file to obtain a hash value corresponding to each diagnostic record. When the hash values corresponding to the diagnostic records are the same, it indicates that the characters of the diagnostic records are exactly the same. The hash function includes but is not limited to the MD5 hash function, the SHA-1 hash function, and the SHA-256 hash function.
[0101] According to the file structure of the block file, the block file is traversed in a loop to determine the position of the first character of each diagnostic record in the block file in the on-board diagnostic file, and the position of the first character is encoded to obtain a position code. The position code can be in the form of a number, a string, or other data types, and is used to uniquely identify the position of the diagnostic record in the block file in the on-board diagnostic file.
[0102] Obtain the position codes of the diagnostic records with exactly the same characters, that is, obtain the position codes of the diagnostic records with the same hash values, and generate a unified character code by combining the position codes and hash values corresponding to the diagnostic records with the same hash values according to certain encoding rules. The encoding rule may be to connect the hash value and the position code with a connector, or to encode and calculate the hash value and the position code using an encoding function.
[0103] Loop through each line of diagnostic records in the block file, cluster the diagnostic records with the same hash value in the block file, use the character replacement function to replace one line of diagnostic records with the same hash value with a unified character code, and replace the diagnostic records in other lines with empty content to obtain an updated block file. The unified character code is generated by the hash value and all the position codes with the same hash value.
[0104] See also Figure 2 As shown in FIG. 1 , a block file is replaced with an updated block file when the similarity of the block file is greater than or equal to a preset similarity threshold. Figure 2 In the figure, block 2 is replaced with block 2. Assuming that the position code of the first line of diagnostic records in block 2 is 21, the position code of the second line of diagnostic records is 22, the position code of the third line of diagnostic records is 23, and the position code of the fourth line of diagnostic records is 24, the updated block file corresponding to block 2 is shown in the updated block file 2 in the figure. Since the hash values of the first line of diagnostic records and the fourth line of diagnostic records in block 2 are the same, only one unified character code is retained for storage, which reduces the storage space of the block file.
[0105] In the above optional implementation, the hash value of the block file is calculated, the position of the block file in the on-board diagnostic file is determined, and the position is encoded, a unified character code is generated according to the hash value and the position code, and each line of diagnostic records in the block file is replaced with a unified character using the unified character code to obtain an updated block file. The unified character code is generated using the hash value and all position codes with the same hash value, and one line of diagnostic records with the same hash value is replaced with the unified character code, which can reduce duplicate data and reduce storage space usage.
[0106] S15, when the similarity is less than the preset similarity threshold, obtaining the frequency of each diagnosis record in the corresponding block file, and performing character replacement on the corresponding block file according to the frequency of each diagnosis record to obtain an updated block file.
[0107] When the similarity is less than the preset similarity threshold, it indicates that the similarity between the diagnostic records in the block file is low, and there are large differences in the characters between the diagnostic records. Traverse each diagnostic record in the corresponding block file to determine whether the diagnostic record appears for the first time. If the diagnostic record appears for the first time, add the diagnostic record to the statistical list and increase the frequency of the diagnostic record by 1. If the diagnostic record does not appear for the first time, increase the frequency of the diagnostic record by 1. In this way, traverse all diagnostic records to obtain each diagnostic record and the frequency corresponding to the diagnostic record.
[0108] According to the frequency and replacement rule of each diagnostic record, characters of the corresponding block file are replaced to obtain an updated block file.
[0109] In an optional implementation, the step of performing character replacement on the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file includes:
[0110] According to the frequency, calculating the proportion of the corresponding diagnosis record in the multiple diagnosis records;
[0111] updating the first record file according to the ratio to obtain a second record file;
[0112] generating a character code for each diagnostic record in the second record file;
[0113] Characters of the block files corresponding to the similarity are replaced according to the character encoding to obtain updated block files.
[0114] According to the frequency of diagnosis records, the proportion of diagnosis records in all diagnosis records is calculated.
[0115] In an optional implementation, calculating the proportion of the corresponding diagnosis record in the plurality of diagnosis records according to the frequency includes:
[0116] Obtaining a frequency sum according to the frequencies of the plurality of diagnosis records;
[0117] According to the ratio of the frequency to the total frequency, the proportion of the diagnosis record corresponding to the frequency in the multiple diagnosis records is obtained.
[0118] The frequency sum refers to the sum of the frequencies of all diagnosis records. The ratio refers to the ratio of the diagnosis record to all diagnosis records.
[0119] The sum of the frequencies of multiple diagnostic records is calculated to obtain the total frequency of the block file. The ratio of the frequency of the diagnostic record to the total frequency is calculated to obtain the proportion of the diagnostic record in all diagnostic records.
[0120] The first record file is updated according to the ratio of the diagnosis record to obtain a second record file.
[0121] In an optional implementation, updating the first record file according to the ratio to obtain the second record file includes:
[0122] Calculate a mean value of the proportion according to the proportion of each of the diagnosis records in the multiple diagnosis records;
[0123] comparing each of said proportions to said proportion mean;
[0124] The diagnostic records corresponding to the ratios smaller than the mean ratio are deleted from the first record file to obtain a second record file.
[0125] The first record file stores the diagnostic records in the current block file and the frequencies corresponding to the diagnostic records. The second record file refers to the diagnostic records obtained by screening the first record file, and is used to store the diagnostic records that appear frequently in the block file.
[0126] Calculate the mean of the proportion of each diagnostic record in multiple diagnostic records to obtain the proportion mean. Determine the size of the proportion of each diagnostic record and the proportion mean. When the proportion of each diagnostic record is less than the proportion mean, it indicates that the frequency of occurrence of the diagnostic record is low, and the diagnostic record is deleted from the first record file. When the proportion of each diagnostic record is greater than or equal to the proportion mean, it indicates that the frequency of occurrence of the diagnostic record is high, and the diagnostic record is retained to obtain a second record file.
[0127] See also Figure 3As shown, according to the diagnostic records in the block file and the corresponding frequencies of the diagnostic records, a first record file is obtained. In the first record file, the proportion of diagnostic records ABC is 0.5, the proportion of diagnostic records ABE is 0.25, the proportion of diagnostic records BCE is 0.125, the proportion of diagnostic records CDE is 0.125, the mean proportion is 0.25, the proportion of diagnostic records BCE and diagnostic records CDE is less than the mean proportion, the diagnostic records BCE and diagnostic records CDE are deleted from the first record file to obtain the second record file.
[0128] In the above optional implementation, the mean proportion is calculated based on the proportion of each diagnostic record in multiple diagnostic records, each proportion is compared with the mean proportion, and the diagnostic records corresponding to the proportions smaller than the mean proportion are deleted from the first record file to obtain a second record file, so that the diagnostic records that appear frequently can be retained in the second record file.
[0129] Generate a corresponding character code for each diagnostic record in the second record file.
[0130] In an optional implementation, generating a character code for each diagnostic record in the second record file includes:
[0131] Obtain the number of diagnostic records in the second record file;
[0132] Determining a coding rule based on the quantity;
[0133] According to the encoding rule, a character code is generated for each diagnostic record in the second record file according to the position sequence of each diagnostic record in the second record file.
[0134] The number of diagnostic records is obtained through the length acquisition function. For example, the number of all diagnostic records in the second record file can be obtained through the length function.
[0135] The encoding rules are determined according to the quantity. The encoding rules refer to mapping each diagnostic record to a unique character code according to a certain algorithm or rule. The specific encoding rules can be determined according to the needs. Including but not limited to the following encoding rules: sequential encoding, hash encoding, custom rule encoding, fixed length encoding. Among them, the sequential encoding assigns increasing integers or letter codes according to the order of the diagnostic records in the block file. Hash encoding converts each diagnostic record into a fixed-length code through a hash function to ensure uniqueness. Custom rule encoding refers to custom design rules, which are encoded according to the specific structural characteristics of the diagnostic record to meet specific business needs. Fixed-length encoding can ensure that the encoding of each diagnostic record has the same length to maintain consistency in processing and storage.
[0136] Determine the rules for encoding the diagnostic records based on the number of all diagnostic records in the second record file, detect the number of digits of all diagnostic records in the second record file, and determine the corresponding code based on the number of digits. Exemplarily, assuming that the number of diagnostic records in the second record file is 9, the encoding method uses a single digit, encoded from 1 to 9; assuming that the number of diagnostic records in the second record file is 99, the encoding method uses a two-digit number, encoded from 01 to 99; assuming that the number of diagnostic records in the second record file is 156, the encoding method uses a three-digit number, encoded from 001 to 156. The numbering of the diagnostic records can be flexibly adjusted according to the number of diagnostic records to ensure the consistency of the numbering.
[0137] According to the above encoding rules, character encoding is incrementally generated for each diagnostic record in the second record file according to the position sequence of each diagnostic record in the second record file, thereby ensuring the uniqueness of the encoding and corresponding to the sequence of the diagnostic records in the file.
[0138] In the above optional implementation, the number of diagnostic records in the second record file is obtained, the encoding rules are flexibly adjusted according to the number, and a character code is generated for each diagnostic record in the second record file according to the encoding rules. The encoding rules can be adjusted according to the actual number, so that the generation of the code is more efficient, unnecessary calculation and storage overhead are reduced, and the overall performance is improved.
[0139] According to each diagnostic record and the corresponding code in the second record file, the diagnostic record in the corresponding block file is replaced with the character code to obtain a new block file corresponding to the current block file.
[0140] See also Figure 3 As shown, it is a schematic diagram of replacing a block file with an updated block file when the similarity of the block file is less than a preset similarity threshold. In the second record file, the character code corresponding to the diagnostic record ABC is 1, and the character code corresponding to the diagnostic record ABE is 2. According to the diagnostic record and the corresponding character code, the diagnostic record in the corresponding block file is replaced with the character code to obtain an updated block file.
[0141] In the above optional implementation, by calculating the sum of the frequencies of multiple diagnostic records to obtain the total frequency, and then calculating the proportion of the diagnostic records corresponding to the frequency in the multiple diagnostic records, the weight of the diagnostic record in all diagnostic records can be reflected. The proportion of each diagnostic record is compared with the mean proportion, and the diagnostic records corresponding to the proportion less than the mean proportion are deleted from the first record file, and the diagnostic records that appear frequently are retained in the second record file. The encoding rules are flexibly adjusted according to the number of diagnostic records in the second record file, and the diagnostic records that appear frequently in the block file are replaced according to the character encoding to obtain an updated block file, which can replace the diagnostic records that appear frequently with the character encoding to reduce storage space.
[0142] S16, obtaining an on-board diagnostic storage file according to the plurality of update block files.
[0143] The multiple update block files are spliced according to the corresponding positions of the update block files in the on-board diagnostic file to obtain the on-board diagnostic storage file.
[0144] The present application divides the on-board diagnostic file into blocks to obtain multiple block files, and can divide the blocks with the same character features in the on-board diagnostic storage file; calculate the similarity of the corresponding block files according to the multiple diagnostic records in each block file; compare the similarity of each block file with the preset similarity threshold, and adopt different replacement strategies for the block file according to the comparison result; when the similarity is greater than or equal to the preset similarity threshold, uniformly replace the characters of each diagnostic record in the corresponding block file to obtain an updated block file, which can uniformly store repeated diagnostic records and reduce the storage space of the block file; when the similarity is less than the preset similarity threshold, obtain the frequency of each diagnostic record in the corresponding block file, replace the characters of the corresponding block file according to the frequency of each diagnostic record, and obtain an updated block file, which can replace the high-frequency diagnostic records in the block file with lower similarity with character codes, reduce the storage space of the block file, and keep the low-frequency diagnostic records unchanged, which can improve the efficiency of character replacement; obtain the on-board diagnostic storage file according to the multiple updated block files. The present application can reduce the storage size of the on-board diagnostic file to reduce the size of the storage space.
[0145] Figure 4 It is a functional module diagram of an on-board diagnostic file storage device provided in an embodiment of the present application.
[0146] In some embodiments, the on-board diagnostic file storage device 40 may include a plurality of functional modules composed of computer program segments. The computer programs of the various program segments in the on-board diagnostic file storage device 40 may be stored in a memory of the on-board diagnostic file storage device and executed by at least one processor to perform (see Figure 1Description) Functionality of the on-board diagnostic file storage method.
[0147] In this embodiment, the on-board diagnostic file storage device 40 can be divided into multiple functional modules according to the functions it performs. The functional modules can include: a block module 401 , a calculation module 402 , a comparison module 403 , a replacement module 404 and a storage module 405 .
[0148] The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and is stored in a memory.
[0149] The block division module 401 is used to divide the on-board diagnostic file into blocks to obtain multiple block files.
[0150] The calculation module 402 is used to calculate the similarity of the corresponding block files according to the multiple diagnosis records in each block file.
[0151] The comparison module 403 is used to compare the similarity of each block file with a preset similarity threshold.
[0152] The replacement module 404 is used to replace each diagnosis record in the corresponding block file with a unified character to obtain an updated block file when the similarity is greater than or equal to the preset similarity threshold.
[0153] The replacement module 404 is further configured to obtain the frequency of each diagnostic record in the corresponding block file when the similarity is less than the preset similarity threshold, and replace characters in the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file.
[0154] The storage module 405 is used to obtain an on-board diagnostic storage file according to the multiple update block files.
[0155] It should be understood that the various variations and specific embodiments of the on-board diagnostic file storage method provided in the above embodiments are also applicable to the on-board diagnostic file storage device in this embodiment. Through the above detailed description of the on-board diagnostic file storage method, those skilled in the art can clearly understand the implementation process of the on-board diagnostic file storage device in this embodiment. For the sake of brevity of the specification, it will not be described in detail here.
[0156] An embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements all or part of the steps of the on-board diagnostic file storage method when executing the computer program.
[0157] See also Figure 5FIG. 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. In a preferred embodiment of the present application, the electronic device 5 includes a memory 51 , at least one processor 52 , and at least one communication bus 53 .
[0158] Those skilled in the art should understand that Figure 5 The structure of the electronic device shown does not constitute a limitation of the embodiments of the present application, and may be either a bus structure or a star structure. The electronic device 5 may also include more or less other hardware or different component arrangements than shown in the figure.
[0159] In some embodiments, the electronic device 5 is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits, programmable gate arrays, digital processors, and embedded devices. The electronic device 5 may also include client devices, which include but are not limited to any electronic product that can interact with a client through a keyboard, mouse, remote control, touchpad, or voice-controlled device, such as a personal computer, tablet computer, smart phone, digital camera, etc.
[0160] In some embodiments, the memory 51 stores a computer program, and when the computer program is executed by the at least one processor 52, all or part of the steps in the on-board diagnostic file storage method are implemented. The memory 51 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data. Further, the computer-readable storage medium mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc.
[0161] In some embodiments, the at least one processor 52 is the control core (ControlUnit) of the electronic device 5, and uses various interfaces and lines to connect various components of the entire electronic device 5, and executes various functions and processes data of the electronic device 5 by running or executing programs or modules stored in the memory 51, and calling data stored in the memory 51. For example, when the at least one processor 52 executes the computer program stored in the memory, it implements all or part of the steps of the on-board diagnostic file storage method described in the embodiment of the present application; or implements all or part of the functions of the on-board diagnostic file storage method. The at least one processor 52 can be composed of an integrated circuit, for example, it can be composed of a single packaged integrated circuit, or it can be composed of multiple integrated circuits with the same function or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.
[0162] In some embodiments, the at least one communication bus 53 is configured to realize the connection and communication between the memory 51 and the at least one processor 52. Although not shown, the electronic device 5 may also include a power supply (such as a battery) for powering each component. Preferably, the power supply may be logically connected to the at least one processor 52 through a power management device, so that the power management device can realize the functions of managing charging, discharging, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 5 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0163] The above integrated unit implemented in the form of software function modules can be stored in a computer-readable storage medium. The above software function modules are stored in a storage medium and include several instructions for enabling a processor to execute parts of the methods described in various embodiments of the present application.
[0164] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0165] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, and may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0166] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.
Claims
1. A method for storing vehicle diagnostic files, characterized in that: The method comprises: Divide the on-board diagnostic file into blocks to obtain multiple block files; Calculate the similarity of the corresponding block files according to the multiple diagnosis records in each block file, wherein the similarity refers to the measure of the difference between the characters in the block files; Compare the similarity of each block file with a preset similarity threshold; When the similarity is greater than or equal to the preset similarity threshold, uniformly replacing characters in each diagnostic record in the corresponding block file to obtain an updated block file; When the similarity is less than the preset similarity threshold, obtaining the frequency of each diagnosis record in the corresponding block file, and performing character replacement on the corresponding block file according to the frequency of each diagnosis record to obtain an updated block file; Obtaining an on-board diagnostic storage file according to the plurality of update block files; The step of replacing each diagnostic record in the corresponding block file with a unified character to obtain an updated block file includes: Calculating a hash value of the block file; Determine the position of the block file in the on-board diagnostic file, and perform position encoding on the position; Generate a Unicode according to the hash value and the position code; The unified character encoding is used to replace the unified characters of each line of diagnostic records in the block file to obtain an updated block file.
2. The on-board diagnostic file storage method according to claim 1, characterized in that: The on-board diagnostic file is divided into blocks to obtain multiple block files including: Obtaining the number of rows of multiple diagnostic records in the on-board diagnostic file; Creating a first sliding window with one column and multiple rows according to the number of rows; Using the first sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the on-board diagnostic file; During each sliding operation, determining whether the plurality of characters corresponding to the first sliding window are completely identical; When the multiple characters corresponding to the current first sliding window are not completely the same, the position of the last character of the previous first sliding window is used as a block dividing line to divide the on-board diagnostic file into blocks to obtain a block file and a remaining on-board diagnostic file; and the length of the first sliding window is reduced to obtain a second sliding window; Using the second sliding window to slide without overlap starting from the first character of the multiple lines of diagnostic records in the remaining on-board diagnostic file; During each sliding operation, determining whether the plurality of characters corresponding to the second sliding window are completely identical; When the multiple characters corresponding to the current second sliding window are not completely the same, the position of the last character of the previous second sliding window is used as a block dividing line to divide the remaining on-board diagnostic file into blocks to obtain a block file.
3. The on-board diagnostic file storage method according to claim 1, characterized in that: The step of replacing characters in the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file includes: According to the frequency, calculating the proportion of the corresponding diagnosis record in the multiple diagnosis records; updating the first record file according to the ratio to obtain a second record file; generating a character code for each diagnostic record in the second record file; Characters of the block files corresponding to the similarity are replaced according to the character encoding to obtain updated block files.
4. The on-board diagnostic file storage method according to claim 3, characterized in that: Calculating the proportion of the corresponding diagnosis record in the plurality of diagnosis records according to the frequency includes: Obtaining a frequency sum according to the frequencies of the plurality of diagnosis records; According to the ratio of the frequency to the total frequency, the proportion of the diagnosis record corresponding to the frequency in the multiple diagnosis records is obtained.
5. The on-board diagnostic file storage method according to claim 4, characterized in that: The updating of the first record file according to the ratio to obtain the second record file comprises: Calculate a mean value of the proportion according to the proportion of each of the diagnosis records in the multiple diagnosis records; comparing each of said proportions to said proportion mean; The diagnostic records corresponding to the ratios smaller than the mean ratio are deleted from the first record file to obtain a second record file.
6. The on-board diagnostic file storage method according to claim 5, characterized in that: Generating a character code for each diagnostic record in the second record file comprises: Obtain the number of diagnostic records in the second record file; Determining a coding rule based on the quantity; According to the encoding rule, a character code is generated for each diagnostic record in the second record file according to the position sequence of each diagnostic record in the second record file.
7. An on-board diagnostic file storage device, characterized in that: The device comprises: A block module, used for dividing the on-board diagnostic file into blocks to obtain multiple block files; A calculation module, used for calculating the similarity of the corresponding block files according to the multiple diagnosis records in each block file, wherein the similarity refers to the measure of the difference between the characters in the block files; A comparison module, used for comparing the similarity of each block file with a preset similarity threshold; A replacement module, configured to replace each diagnostic record in the corresponding block file with a uniform character when the similarity is greater than or equal to the preset similarity threshold, to obtain an updated block file; The replacement module is further configured to obtain the frequency of each diagnostic record in the corresponding block file when the similarity is less than the preset similarity threshold, and replace characters in the corresponding block file according to the frequency of each diagnostic record to obtain an updated block file; A storage module, used for obtaining an on-board diagnostic storage file according to the plurality of update block files; The replacement module is specifically used for: Calculating a hash value of the block file; Determine the position of the block file in the on-board diagnostic file, and perform position encoding on the position; Generate a Unicode according to the hash value and the position code; The unified character encoding is used to replace the unified characters of each line of diagnostic records in the block file to obtain an updated block file.
8. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the on-board diagnostic file storage method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the on-board diagnostic file storage method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Document classification method based on similarity
CN103049263A
File processing method, device and system
CN109324998A