A data description-based dial data format universal conversion method
Patent Information
- Application Number
- CN202311047197.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-18
- Publication Date
- 2026-08-21
- Estimated Expiration
- 2043-08-18
AI Technical Summary
由于厂家众多,实时设备更新换代,系统记录文件格式以及数据帧格式发生变化,如数据协议变化、数据种类增减、数据信息结构调整等,给通用数据处理带来很大困难
[0019]1、本发明为用户提供了识别数据帧结构体的冗余方法。数据帧结构体通常由“数据帧标志”唯一确定,用户在《记盘文件描述表》中配置“数据帧标志计算方法”后,可从数据帧头中识别出数据帧结构体;少数“数据帧标志”对应了多个结构体,此时可通过配置《数据帧描述表》中的“数据帧标志1计算方法”以及“数据帧标志1值”、“数据帧标志2计算方法”以及“数据帧标志2值”进一步识别,为用户提供了多次选择的机会。
Smart Images

Figure CN117194539B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of aerospace telemetry and control data processing, and relates to a data format conversion method used in real-time data recording systems. It is used to extract, process, and display various binary disk recording data. Users can configure database tables and configuration files to describe the disk recording file format, so as to achieve universal processing of multi-source disk recording files. Background Technology
[0002] In real-time systems, manufacturers record the raw data acquired by their systems according to a custom format. After the task is completed, users need to analyze and process the recorded data. Due to the large number of manufacturers and the upgrading of real-time equipment, the system's record file format and data frame format have changed, such as changes in data protocols, additions or subtractions of data types, and adjustments to data information structure, which brings great difficulties to general data processing.
[0003] Traditional data analysis or processing software analyzes and processes data information by using fixed data structures. When the data structure changes, the software needs to be modified to adapt, resulting in poor scalability and adaptability, increased workload, and difficulty in maintaining the software code.
[0004] Real-time system data files typically consist of a file header, a file body, and a file footer:
[0005] (1) The file header or file footer usually contains only one type of structured data frame with a fixed length, and there may be no file header or file footer.
[0006] (2) The file body consists of various types of structured data frames. When designing the disk format, it is necessary to ensure that different types of data frames can be distinguished by one or more “data frame flags” located in fixed positions.
[0007] (3) A data frame can be divided into a “data frame header” and a “data frame body”. The fixed-length part containing the “data frame flag” is called the “data frame header”, and the remaining part is called the “data frame body”. Different types of data frames all contain a “data frame header” with the same structure.
[0008] (4) The “data frame length” is usually located in the “data frame header”. For some special disk data, the data frame length is located in the “data frame body”.
[0009] The disk file format consisting of n data frames is illustrated below, where the values of "Data Frame Flag 1" to "Data Frame Flag n" are all different:
[0010] File header (fixed length, length can be 0)
[0011] Data frame header (fixed length, including "Data Frame Flag 1"), data frame body 1
[0012] …………………………………
[0013] Data frame header (fixed length, including "data frame flag n"), data frame body n
[0014] File footer (fixed length, length can be 0)
[0015] By providing a general description of the disk recording format, a universal data format conversion method can be designed to enable standardized processing and display of different disk recording formats. Summary of the Invention
[0016] The technical problem to be solved by this invention is to provide a generalized conversion method for disk recording data format based on data description. This method describes the disk recording file format and the structured data therein through database tables and configuration files, realizes the separation of data parsing function and data description function, adapts to changes in disk recording file format and data structure adjustment, so as to achieve generalized parsing of various types of real-time disk recording data.
[0017] The technical solution adopted by the present invention to solve the above problems is as follows:
[0018] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0019] 1. This invention provides users with a redundant method for identifying data frame structures. A data frame structure is typically uniquely identified by a "data frame flag." After configuring the "data frame flag calculation method" in the "Disk File Description Table," the user can identify the data frame structure from the data frame header. In cases where a few "data frame flags" correspond to multiple structures, further identification can be achieved by configuring the "data frame flag 1 calculation method" and "data frame flag 1 value," and the "data frame flag 2 calculation method" and "data frame flag 2 value" in the "Data Frame Description Table," providing users with multiple selection opportunities.
[0020] 2. This invention provides users with three methods for calculating the length of the data frame body. When the data frame body length is in the data frame header, the user configures the "data frame length calculation method flag" in the "Disk File Description Table"; when the data frame body length is in the data frame body, the user configures the "data frame length calculation method flag" in the "Data Frame Description Table"; when the data frame body length is in the data and not transmitted, this method automatically calculates the number of formatted bytes in the data frame body and converts it into the data frame body length.
[0021] 3. This invention provides two methods for users to iterate through fields in a structure: "fixed repetition count" and "dynamic repetition count". The "fixed repetition count" is the number of times the user predefines the field in the structure, used for continuous repetition of a single field; the "dynamic repetition count" is the number of times the user calculates from the original data, and its value is not fixed, which can be used to iterate through multiple consecutive fields. Attached Figure Description
[0022] Figure 1 This is a flowchart of the structure definition file reading process designed in this invention. The file is read line by line, automatically skipping comment lines and blank lines, identifying the structure and its field information, and determining whether the field information, the structure definition, and the structure file are valid.
[0023] Figure 2 This is a flowchart of the disk file reading process designed in this invention. The disk file is opened in a memory-mapped manner. Based on the disk file format and data frame structure information described by the user, the file header and file footer information are first displayed. Then, starting from the footer of the file header data frame, the data frame header and data frame body are identified frame by frame and displayed in a formatted manner. Detailed Implementation
[0024] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0025] This application provides a generalized conversion method for disk recording data format based on data description. The method consists of three steps: disk recording file format description and structure description, configuration information initialization and legality check, and disk recording file processing and display.
[0026] Step A: Record the disk file format description and structure description.
[0027] This invention uses a combination of database tables and configuration files to describe the disk record file and data frame structure, specifically including: a disk record file description table, a data frame header structure description table, a data frame description table, a data frame length calculation method description table, a data frame flag calculation method description table, a structure definition file, a basic data type description table, and a processing function description table. The byte positions in the tables start from 1.
[0028] Step A.1: Design of the "Disk File Description Table".
[0029] This table stores overall information about the disk record files. The field definitions are shown in Table 1. This description table typically contains only one row. When multiple rows are configured, extra rows are automatically ignored.
[0030] Table 1. Description of Disk Record Files
[0031]
[0032] (1) The "File Path" and "Structure Definition File Path" fields are divided into absolute paths and relative paths. The starting path of the relative path is the directory where the executable file is located. The "File Path" field is used to store the path where the disk file is located, and the "Structure Definition File Path" field is used to store the structure information corresponding to the disk file.
[0033] (2) The “File Header Data Frame Flag” field and the “File Tail Data Frame Flag” field are used to configure the file header and file tail format. When the disk file does not contain this information, its value is filled with 0; when it is not 0, it points to the “Data Frame Flag” field in the “Data Frame Header Structure Description Table”.
[0034] (3) The “Data Frame Header Structure Data Frame Flag” field is used to configure the structure information of the data frame header in the configuration body. This value is a foreign key that points to the “Data Frame Flag” field in the “Data Frame Header Structure Description Table”.
[0035] (4) The "Data Frame Flag Calculation Method" field is used to configure the data frame identification method. The file body is usually composed of various types of structured data frames. Different types of data frames are distinguished by a primary key located in a fixed position in the structure. This value is a foreign key that points to the "Data Frame Flag Calculation Method" field in the "Data Frame Flag Calculation Method Description Table".
[0036] (5) The “Data Frame Length Calculation Method Flag” field is used to obtain the length of the data frame. 0 indicates that there is no data frame length in the data frame header, and other values point to the “Data Frame Length Calculation Method Flag” field in the “Data Frame Length Calculation Method Description Table”. When this value is 0, the length calculation method needs to be described in the structure of the data frame.
[0037] Step A.2, Design of the "Data Frame Header Structure Description Table".
[0038] This table stores the structure information of the file header, file footer, and data frame header. The definitions of each field are shown in Table 2. All structures in this table have a fixed length.
[0039] Table 2. Description of Data Frame Header Structure
[0040] Serial Number Fields type Range of values illustrate 1 Data frame flags Integer ≥1 Primary key 2 Structure name String non-empty The name of this structure; this structure exists in the "Structure Definition File". 3 Structure Description String Can be empty Detailed description of this structure
[0041] Step A.3, Design of the Data Frame Description Table.
[0042] This table stores all the structure description information of the data frame body. The field definitions are shown in Table 3. This table usually contains multiple records.
[0043] Table 3. Data Frame Description Table
[0044]
[0045] (1) The value of the “Data Frame Flag” field is derived from the data frame flag of the data frame body in the disk file; the structure corresponding to the “Structure Name” is described in detail in the “Structure Definition File”; when the “Data Frame Length Calculation Method Flag” is not 0, the calculation method of its data length is defined by the “Data Frame Length Calculation Method Flag”.
[0046] (2) A small number of “data frame flags” correspond to multiple structures. In this case, they can be identified by the “data frame flag 1 calculation method” and the “data frame flag 1 value”, as well as the “data frame flag 2 calculation method” and the “data frame flag 2 value”.
[0047] Step A.4, Design of the "Description Table of Data Frame Length Calculation Method".
[0048] This table stores descriptive information about the methods for calculating data frame length, with each field defined as shown in Table 4. A single disk record file may contain multiple methods for calculating data frame length, which are typically related to the data type. Common length calculation methods include single-byte integer, two-byte integer, multi-byte integer, and length calculations related to the target quantity.
[0049] Table 4. Description of Data Frame Length Calculation Method
[0050]
[0051]
[0052] Assuming the initial value of the data frame length calculated from the original value is nFrameL, the final data frame length is obtained by subtracting the "data frame length correction value" from this value.
[0053] Step A.5, Design of the "Description Table of Data Frame Flag Calculation Method".
[0054] This table stores descriptive information about the data frame flag calculation method, and the definitions of each field are shown in Table 5. The data frame flag typically occupies multiple bytes and is used to distinguish different data frames.
[0055] Table 5. Description of Data Frame Flag Calculation Method
[0056]
[0057] When the value of "data frame flag interval byte" is 0, it means that the original code value of "data frame flag occupied bytes" will be continuously obtained starting from "data frame flag start position".
[0058] Step A.6, "Structure Definition File".
[0059] (1) A disk record file uses only one structure file, which consists of many structures. The structure names are not allowed to be repeated. The structure file has the following form:
[0060] / / Basic structure. The structure name 1 is used for...
[0061] struct structure name 1
[0062] {
[0063] Field type 1, field name 1, processing function 1, processing parameters 1, field description 1;
[0064] Field type 2; Field name 2; Processing function 2; Processing parameters 2; Field description 2;
[0065] ... ... ... ... ...;
[0066] Field type m, field name m, processing function m, processing parameters m, field description m;
[0067] };
[0068] / / Loop structure. This structure name 2 is used for...
[0069] struct structure name 2
[0070] {
[0071] Field type 1, field name 1, processing function 1, processing parameters 1, field description 1;
[0072] ... ... ... ... ...;
[0073] Field type k: Number of loops in FieldLoop i,j; Field description k;
[0074] ... ... ... ... ...;
[0075] Field type k+i, field name k+i, processing function k+i, processing parameters k+i, field description k+i
[0076] ... ... ... ... ...;
[0077] Field type k+j, field name k+j, processing function k+j, processing parameters k+j, field description k+j
[0078] ... ... ... ... ...;
[0079] Field type m; Field name m; Processing function m; Processing parameters m; Field description m;
[0080] };
[0081] / / Diagram of a composite structure. The structure name 2 is used for…
[0082] struct structure name 3
[0083] {
[0084] Field type 1, field name 1, processing function 1, processing parameters 1, field description 1;
[0085] Structure name 1 Field name 2 NULL 0 Field description 2;
[0086] ... ... ... ... ...;
[0087] Field type p; Field name p; Processing function p; Processing parameters p; Field description p;
[0088] };
[0089] The example above illustrates a structure file with three structures.
[0090] The first structure is a basic structure with m variables, all of which are composed of basic data types. The second structure is a loop structure with n variables, where the k-th field is the loop count. The function is FieldLoop, with parameters "i,j", indicating that the loop from field k+i to field k+j needs to be repeated a certain number of times. i is called the "loop field offset start" and j is called the "loop field offset end". The number of loops is determined by the result value of field k. The third structure is a composite structure with p variables, and the second field is of the same type as the first structure.
[0091] Each struct field consists of 5 elements, separated by spaces. Struct fields are separated by semicolons (;). A struct begins with the keyword "struct", and the characters between this keyword and curly braces "{" form the struct name. A struct ends with "};", where "{" is on the next line after the "struct" keyword, and "};" occupies a separate line. Lines beginning with " / / " are comments. A struct can have multiple sub-structs, and structs can be nested.
[0092] (2) The structure field definitions are shown in Table 6. There are two types of "Field Type": one is a basic data type, whose value is selected from the "Data Type" in the "Basic Data Type Description Table"; the second is a structure type, whose value is another structure in the structure file, and this structure must be defined before this structure definition. The "Field Name" may contain "[n]" (n is an integer greater than 0), indicating that the field needs to be repeated n times.
[0093] Table 6 Definitions of Structure Fields
[0094]
[0095] Step A.7, Design of the Basic Data Type Description Table.
[0096] Basic data types refer to indivisible data types, such as byte, short, int, int64, float, and double. Spaces are not allowed between basic data types. The meanings of each field are shown in Table 7, where formatting parameters are the default formatting parameters conforming to the C language printf function standard for that data type.
[0097] Table 7. Description of Basic Data Types
[0098]
[0099] Step A.8, Design of the "Processing Function Description Table".
[0100] This table stores various functions used to process and display the fields in the structure. The field definitions are shown in Table 7. Records with a "Function Identifier" of 0 store records with a "Function Name" of "NULL", indicating that this field is not processed for display. Records with a "Function Identifier" of 1 store records with a "Function Name" of "FieldLoop", indicating that this field is used to dynamically obtain the loop count. "Function Parameters" provides examples of parameters used; the actual parameters are specified in the structure, and multiple parameters are separated by commas.
[0101] Table 8. Description of Processing Functions
[0102] Serial Number Fields type Range of values illustrate 1 Function identifier Integer ≥0 Keywords, arranged in order 2 function name text non-empty The name of the processing function 3 function parameters text non-empty Function parameters associated with the processing function 4 Function description text non-empty Detailed description of the function's functionality.
[0103] Step B: Initialize configuration information and check its validity.
[0104] Of the eight database tables or configuration files designed in this invention, only the "Basic Data Type Description Table" and the "Processing Function Description Table" are maintained by the programmer. The other six are maintained by the user. Users can customize the following six database tables or configuration files according to their own data analysis needs, including the "Disk File Description Table", "Data Frame Header Structure Description Table", "Data Frame Description Table", "Data Frame Length Calculation Method Description Table", "Data Frame Flag Calculation Method Description Table", and "Structure Definition File".
[0105] The main task of configuration information initialization and validity checking is to read various database tables or configuration files, perform validity checks on the configuration information, and execute the following steps in sequence:
[0106] Step B.1: Read the "Processing Function Description Table". For each record in the table, perform the following validity checks: For records with "Function Identifier" of 0, check if the "Function Name" is "NULL"; for records with "Function Identifier" of 1, check if the "Function Name" is "FieldLoop"; check if the remaining "Function Names" are functions already implemented by the programmer. If all the above checks are passed, the data is valid.
[0107] After the processing function description table is read, a data pair with the following form will be formed: {nFunSer, strFun, strParam} nFun ,in"{} nFun " indicates that there are a total of nFun functions, nFunSer is the function index number, with a value range of (1 to nFun), which represents the function identifier, strFun is the function name, and strParam is the function parameter.
[0108] Step B.2: Read the "Basic Data Type Description Table". For each record in the table, perform the following validity check: check whether the "Data Type", "Data Occupancy in Bytes", and "Formatting Parameters" conform to the formatting parameter standards of the C language printf function. If they do not conform, the validity check fails; otherwise, the data is valid.
[0109] After the basic data type description table is read, data pairs with the following format will be formed: {nTypeSer, strType, nBytes, strFormat} nType ,in"{} nType " indicates that there are a total of nType basic data types, nTypeSer is the data type index number, with a value range of (1 to nType), strType is the data type, nBytes is the number of bytes occupied by the data, and strFormat is the formatting parameter.
[0110] Step B.3: Read the "Structure Definition File".
[0111] According to the "Structure Definition File Path" configured in the "Disk File Description Table", the system reads the structure file and performs a validity check on each structure in the file. If file reading fails, the user is prompted that the file does not exist and the validity check failed. Otherwise, the file is read. During the reading process, data lines starting with "\\" and blank lines are automatically skipped, which will not be elaborated further. The system sets the structure number nStruct, with an initial value of 0, representing the structure data currently acquired and also serving as a marker for identifying the structure; it sets the structure field number nField, with an initial value of 0, representing the number of fields identified in the current structure. When a new structure is found, it is re-initialized to 0. The flowchart is as follows. Figure 1 As shown.
[0112] (1) Obtain the structure name. Read the file line by line, searching for lines that begin with the string "struct". If not found, a syntax error occurs, and the system exits; otherwise, obtain the string after "struct" and use it as the name of the structure. If the name is empty, a syntax error occurs, and the system exits; otherwise, search for the name among the known structure names. If it exists, prompt the user that the structure definition is duplicated, and the system exits; otherwise, analyze whether the structure name contains "[n]" (n is a number). If it does, set the value of the field "nRepeat" to n; otherwise, set the value to 1.
[0113] (2) Move the file pointer down one line and check if it is "{". If not, the validity check fails and the user is prompted that there is a syntax error in the data line. The system exits. If it is, the number of fields in the current structure nField is set to 0 and the next step is executed.
[0114] (3) Move the file pointer down one line and check if the line ends with a semicolon (;). If not, prompt the user that the line contains a syntax error and exit the system. If yes, proceed to the next step.
[0115] (4) If the data in the row is “};”, then the structure has been read and step (5) is executed; if the data in the row is not “};”, then the definition information of the structure field is obtained from the data in the row and the validity of the data in the row is checked.
[0116] ① Analyze whether the number of spaces separating the strings in the data row is 5. If not, prompt the user that there is a syntax error in the data row and exit the system. Then, sequentially retrieve the "Field Type", "Field Name", "Processing Function", "Processing Parameter", and "Field Description" from the data row, and perform validity checks on the "Field Type", "Processing Function", and "Processing Parameter".
[0117] ② Perform a validity check on the "processing function". If the "processing function" is "NULL", or if a corresponding "processing function" exists in the "Processing Function Description Table", then the "processing function" is valid. Record its function index number nFunSer and processing parameter strParam, and proceed to the next step; otherwise, prompt the user that the "processing function" is incorrect, and the system exits.
[0118] ③ Perform a validity check on the "Field Type". If the "Field Type" exists in the "Basic Data Type Description Table", then record its data type index number nTypeSer, and the data is valid. Form a "Field Information Data Pair" with the following form: [nFieldSer, nTypeSer, nRepeat, nFunSer, strParam], where nFieldSer is the structure field sequence number, nTypeSer is the data type index number, nRepeat is the fixed number of repetitions for the field, nFunSer is the function index number, and strParam is the processing parameter. Proceed to the next step.
[0119] Otherwise, search for the existence of the "field type" in the discovered structure names. If found, then the "field type" is a substructure. Insert all nF "field information data pairs" of the substructure into the "field information data pairs" of this structure, increment the nField value by nF, and proceed to the next step; otherwise, prompt an error and the system exits.
[0120] ④ If the “processing function” is “FieldLoop”, it means that the structure is a loop structure. Get the corresponding parameters i and j, the total number of substructure fields from i to j, assuming its value is nF (which may be 0), then the parameter j is modified to “j+nF-1”.
[0121] ⑤ Once this field has been identified, increment the value of nField by 1 and proceed to step (3) to continue execution.
[0122] (5) After the structure is read, it will form a data pair with the following form: {nStructSer, strStruct, nField, {nFieldSer, nTypeSer, nRepeat, nFunSer, strParam} nField}, where nStructSer is the index number of the current structure, strStruct is the name of the current structure, nField is the number of fields in the current structure, and {nFieldSer, nTypeSer, nRepeat, nFunSer, strParam}. nField There are nField "field information data pairs".
[0123] (6) Move the file pointer down one line and repeat steps (1) to (4) until the file reading is finished. After the structure file is read, all composite structures have been converted into basic structures.
[0124] Finally, a data pair of the form {nStructSer, strStruct, nField, {nFieldSer, nTypeSer, nRepeat, nFunSer, strParam} will be formed. nField} nStruct ,in"{} nStruct " indicates that there are a total of nStruct structures, where nStructSer is the index number. The above data pair is called the "structure definition table".
[0125] Step B.4: Read the "Data Frame Flag Calculation Method Description Table".
[0126] After the "Data Frame Flag Calculation Method Description Table" is read, a data pair with the following form will be formed: {nSignMethodSer, nFrameLayout, nFrameBytes, nFrameStart, nFrameHigh} nSignMethod ,in"{} nSignMethod " indicates that there are a total of nSignMethod methods, nSignMethodSer is the index number of the data frame flag calculation method, and its value range is (1 to nSignMethod), nFrameLayout is the data frame flag interval bytes, nFrameBytes is the data frame flag occupied bytes, nFrameStart is the data frame flag start position, and nFrameHigh is the data frame flag high byte transmitted first.
[0127] Step B.5: Read the "Description Table of Data Frame Length Calculation Method".
[0128] After the "Data Frame Length Calculation Method Description Table" is read, a data pair with the following format will be formed: {nLenMethodSer, nOffsetBytes, nLenBytes, nLenStart, nLenHigh} nLenMethod ,in"{} nLenMethod" indicates that there are a total of nLenMethod methods, where nLenMethodSer is the index number of the data frame length calculation method flag, with a value range of (1 to nLenMethod), nOffsetBytes is the data frame length correction value, nLenBytes is the number of bytes occupied by the data frame length value, nLenStart is the position where the data frame length value is obtained, and nLenHigh is the flag that the high byte of the data frame length is transmitted first.
[0129] Step B.6, read the Data Frame Description Table. For each record in the table, perform the following validity check:
[0130] (1) Check if the structure configured in “Structure Name” exists in the “Structure Definition Description Table” in step B.3. If it exists, record its structure number nStructSer. Otherwise, prompt the user that the structure does not exist and the validity check fails.
[0131] (2) Check if the “data frame length calculation method flag” exists in the “data frame length calculation method description table”. If it exists, record its data frame length calculation method flag nLenSign. Otherwise, prompt the user that the data frame length calculation method flag does not exist and the validity check fails.
[0132] (3) Check if the “Data Frame Flag 1 Calculation Method” is valid. If the data is 0, it means that the data type has no auxiliary flag, and the data is valid; otherwise, check if it exists in the “Data Frame Flag Calculation Method Description Table”. If it exists, record its data frame length calculation method flag nLenSign1; otherwise, prompt the user that the auxiliary flag calculation method for the data type does not exist and the validity check fails.
[0133] (4) Check whether the “data frame flag 2 calculation method” is valid. The checking method is the same as step (3). Record its data frame length calculation method flag nLenSign2.
[0134] After the Data Frame Description Table is read, a data pair with the following form will be formed, called the Data Frame Description Table: {nFrameSignSer, nFrameSign, nStructSer, nLenSign, nSignMethodSer1, nFrameSign1, nSignMethodSer2, nFrameSign2, nOffest} nFrameWhere “{}nFrame” indicates that there are a total of nFrame data frames, nFrameSignSer is the data frame flag index number, with a value range of (1 to nFrame), nFrameSign is the data frame flag, nStructSer is the structure sequence number, nLenSign is the data frame length calculation method flag, nSignMethodSer1 is the calculation method for data frame flag 1, nFrameSign1 is the value of data frame flag 1, nSignMethodSer2 is the calculation method for data frame flag 2, nFrameSign2 is the value of data frame flag 2, and nOffest is the structure start offset byte.
[0135] Step B.7: Read the "Data Frame Header Structure Description Table". For each record in the table, perform the following validity check: Check if the structure configured in "Structure Name" exists in the "Structure Definition Description Table" in step B.3. If it exists, record its structure number nFrameHeadStructSer; otherwise, prompt the user that the structure does not exist and the validity check fails.
[0136] After the Data Frame Header Structure Description Table is read, a data pair with the following form will be formed: {nFrameHeadSer, nFrameHeadStructSer} nFrameHead , where "{} nFrameHead " indicates that there are a total of nFrameHead data frame header structures, nFrameHeadSer is its index number, the value range is (1 to nFrameHead), represents the data frame flag, and nFrameHeadStructSer is the structure sequence number.
[0137] Step B.8: Read the "Disk File Description Table". Read the record with the smallest "File Number" value in the table and perform a validity check on that record.
[0138] (1) Check if the file configured in the "file path" actually exists. If it does, proceed to the next step. Otherwise, prompt the user that the file does not exist and the validity check fails.
[0139] (2) Check if the "File Header Data Frame Flag" is valid. If the data is 0, then set the file header structure number nHeadStructSer to 0 and proceed to the next step; otherwise, check if the corresponding "Data Frame Flag" exists in the "Data Frame Header Structure Description Table"; if it exists, obtain the corresponding structure number, save it as nHeadStructSer, and proceed to the next step; otherwise, prompt the user that the data frame flag does not exist and the validity check fails.
[0140] (3) Check whether the “File Tail Data Frame Flag” and “Data Frame Header Structure Data Frame Flag” are valid in sequence. The checking method is the same as step (2). Obtain the structure number nTailStructSer of the file tail and the structure number nFrameHeadStructSer of the data frame header.
[0141] (4) Check whether the “data frame flag calculation method” and the “data frame length calculation method flag” exist in the “data frame flag calculation method description table”. If they exist, the data is valid; otherwise, prompt the user that the corresponding information does not exist and the validity check fails.
[0142] After the disk record file description table is read, a data pair with the following format will be formed, called the "disk record file description table": {sFileDir, sStructDir, nHeadStructSer, nTailStructSer, nFrameHeadStructSer, nSignMethodSer, nLenMethodSer}, where sFileDir and sStructDir are the disk record file path and the structure file path, respectively; nHeadStructSer, nTailStructSer, and nFrameHeadStructSer are the file header structure number, file tail structure number, and frame header structure number, respectively; nSignMethodSer is the data frame flag calculation method; and nLenMethodSer is the data frame length calculation method.
[0143] Step C: Processing and displaying disk files.
[0144] Open the disk record file corresponding to the "file path" using memory mapping, obtain the "disk record file pointer", which points to the beginning of the file. The main flowchart is as follows. Figure 2 As shown.
[0145] Step C.1: Process the file header and file footer.
[0146] (1) When the file header structure number value is greater than 0, “format display” (step C.3) the file header information; if the “format display” operation fails, then prompt that the file format is incorrect and the system processing ends, otherwise proceed to the next step.
[0147] (2) When the file tail structure index value is greater than 0, the "disk pointer" points to the beginning of the file tail structure and the file tail information is "formatted and displayed". If the "formatted and displayed" operation fails, a message indicating that the file format is incorrect is displayed and the system processing ends. Otherwise, the "disk pointer" points to the beginning of the file and the length of the file head structure is moved forward.
[0148] Step C.2, process the data frame.
[0149] A data frame consists of a data frame header and a data frame body. The "data frame header length" is a fixed length, which is completely determined by the data frame header structure. The "data frame body length" is calculated by the data frame length calculation method and in combination with the original data in the data frame.
[0150] (1) Obtain the “data frame header length” and “format display” data frame header information according to the data frame header structure number; if the “format display” operation fails, then prompt that the file format is incorrect and the system processing ends, otherwise proceed to the next step.
[0151] (2) Obtain the data frame flag. The data frame flag calculation method is to obtain the data frame flag from the data frame header according to the "Data Frame Flag Calculation Algorithm" (step C.4).
[0152] (3) Obtain the structure corresponding to the data frame. Check if the corresponding "data frame flag" exists in the "data frame description table". If it exists, record its "data frame index number" and "structure sequence number"; otherwise, prompt the user that there is an unknown data frame type.
[0153] (4) Calculate the data frame body length. If the data frame length calculation method in the "Disk Record File Description Table" is greater than 0, then calculate the "data frame body length" from the data frame header according to the "data frame length calculation algorithm" (step C.5). The "Disk Record File Pointer" moves forward by the "data frame header length".
[0154] (5) Calculate auxiliary flags. Obtain the "Data Frame Flag 1 Calculation Method" and "Data Frame Flag 2 Calculation Method" corresponding to the "Data Frame Flag". If the value of "Data Frame Flag 1 Calculation Method" is equal to 0, then the data frame type has been identified and step (8) is executed; otherwise, calculate its "Data Frame Flag 1"; if the value of "Data Frame Flag 2 Calculation Method" is equal to 0, then the data frame type has been identified and step (6) is executed; otherwise, calculate "Data Frame Flag 2" according to "Data Frame Flag 2 Calculation Method" and execute step (7).
[0155] (6) Determine the structure by using the "data frame flag" and "data frame flag 1". Check if the corresponding "data frame flag" and "data frame flag 1" exist in the "data frame description table". If they exist, record the "data frame index number" and "structure sequence number" and proceed to step (8); otherwise, prompt the user that there is an unknown data frame type.
[0156] (7) Determine the structure by using the data frame flag and "Data Frame Flag 1" and "Data Frame Flag 2". Check if the corresponding "Data Frame Flag", "Data Frame Flag 1", and "Data Frame Flag 2" exist in the "Data Frame Description Table". If they exist, record their "Data Frame Index Number" and "Structure Sequence Number" and proceed to step (8); otherwise, indicate that there is an unknown data frame type.
[0157] (8) Recalculate the data frame body length. If the data frame length calculation method flag corresponding to the "data frame index number" is greater than 0, then calculate the "data frame body length" from the data frame body.
[0158] (9) Format the data frame body. Using "disk file pointer" and "structure sequence number" as input parameters, format the original code of the data frame body (this operation will return "the length of the formatted structure"). If the operation fails, an error message will be displayed indicating an incorrect file format.
[0159] (10) If the “data frame body length” value is 0, it indicates that the user has not set the data frame length calculation method for the structure in the database. Obtain the “structure start offset byte” of the structure. The “data frame body length” is set to the sum of the “formatted structure data length” and the “structure start offset byte” returned in step (9).
[0160] (11) Loop processing. The "disk file pointer" moves forward by the "data frame body length". If the "disk file pointer" has exceeded the beginning of the file end structure, then the data frame processing ends and the system processing ends; otherwise, step (1) is executed.
[0161] Step C.3: Format the structure display.
[0162] After obtaining the raw data of the structure, the fields are formatted and output according to the structure definition. The function expression described in C language is:
[0163] int FormatStruct(unsigned char*pFileCur,int nStructSer)
[0164] The parameter pFileCur points to the beginning of the structure, nStructSer is the structure index number, and the return value is the length of the formatted structure data.
[0165] Set the variable "number of formatted bytes" and initialize it to 0; set the variable "structure pointer" and initialize it to pFileCur; set the variables "dynamic loop processing start field" nFstart and "dynamic loop processing end field" nFend and initialize them to -1; set "dynamic loop execution count" nFcontnue and initialize it to 0; set the variable "structure field serial number" nFieldSer and initialize it to 0. Loop and execute the following steps until the value of nFieldSer is greater than or equal to the current "number of structure fields" nField, and the function returns the "number of formatted bytes":
[0166] (1) According to the "data type index number" of the nFieldSer field, obtain the "data occupied bytes", "formatting parameters", and "fixed repetition count" of this field, and obtain the original value from the "structure pointer"; if the "function index number" is greater than 0, then according to the "function index number" and "processing parameters" of this field, convert the original value into a result value, and format and output the result value according to the "formatting parameters" of this field. Move the "structure pointer" backward by the "data occupied bytes", and increase the "number of formatted bytes" by the "data occupied bytes".
[0167] (2) If the "fixed repetition count" (value is n) is greater than 1, then loop and execute step (1) until step (1) has been executed n times in total.
[0168] (3) If the "function index number" of this field is 1, then obtain the processing result of this field, that is, the "dynamic loop count" (nLoop), and record the serial number value (nFieldLoop) of this field; extract the "loop field offset start" value (i) and "loop field offset end" value (j) from its "processing parameters", then set nFstart to (nFieldLoop + i), set the value of nFend to (nFieldLoop + j), and set nFcontnue to 1.
[0169] (4) Increase nFieldSer by 1. If the value of nLoop is greater than 0, nFieldSer > nFend, and nFcontnue < nLoop, then reset the value of nFieldSer to nFstart and increase nFcontnue by 1. Jump to step (1).
[0170] Step C.4, data frame flag calculation algorithm.[[ID=—]] [[ID=—]]
[0171] Starting from the "data frame flag start position", at an interval of the "data frame flag interval bytes", obtain the original code of the "data frame flag occupied bytes", and assemble it into an integer value according to the "data frame flag high byte first transmission", which is the final data frame flag.
[0172] Step C.5, Data frame length calculation algorithm.
[0173] Starting from the "data frame length value acquisition position", continuously acquire the source code of "data frame length value occupied bytes", assemble it into an integer value according to the "data frame length high byte first transmission flag", and the calculation result is the initial value of the data frame length. Assuming that the value is nFrameL, subtract the "data frame length correction value" from this value to get the final data frame length.
[0174] 1. Implement the "Basic Data Type Description Table". Programmers can add other basic data types as needed, as shown below:
[0175] Table 9, "Description of Basic Data Types," contains the following content.
[0176]
[0177]
[0178] 2. Implement the "Processing Function Description Table". When certain fields cannot be displayed using basic data types, programmers can add corresponding functions to this table, such as:
[0179] Table 10, "Description of Processing Functions", contains the following content.
[0180]
[0181] 3. Implement the "Structure Definition File". The user defines three structures: file header, data frame header, and temperature parameter. The temperature parameter is a loop structure, and the number of loop iterations for the Temperature field is determined by the TempN field.
[0182]
[0183]
[0184] 4. Implement the "Description Table of Data Frame Flag Calculation Method":
[0185] Table 11, "Description of Data Frame Flag Calculation Method," contains the following content:
[0186]
[0187] 5. Implement the "Data Frame Length Calculation Method Description Table". In the table, the "Data Frame Length Correction Value" is 0, indicating that the length is calculated from one byte after "FrameLen".
[0188] Table 12, "Description of Data Frame Length Calculation Method," contains the following content:
[0189]
[0190] 6. Implement the "Data Frame Description Table". Assume the data frame flag for the temperature parameter is 5678, and set all other fields in the table to 0.
[0191] Table 13, "Data Frame Description Table," contains the following contents.
[0192] Data frame flags Structure name Structure Description 5678 sFrameBody Temperature parameters
[0193] 7. Implement the "Data Frame Header Structure Description Table".
[0194] Table 13, "Data Frame Description Table," contains the following contents.
[0195] Data frame flags Structure name Structure Description 1 sFileHead File header structure 2 sFrameHead Data frame header structure
[0196] 8. Implement the "Disk File Description Table", where "File End Data Frame Flag" is 0, indicating that there is no file end.
[0197] Table 13, "Data Frame Description Table," contains the following contents.
[0198]
[0199] In addition to the above embodiments, the present invention also includes other embodiments. All technical solutions formed by equivalent transformation or equivalent substitution should fall within the protection scope of the claims of the present invention.
Claims
1. A generalized conversion method for disk data formats based on data description, characterized in that... The method includes the following three steps: Step A: Description of disk file format and structure A total of seven database tables and one text file were designed: “Disk File Description Table”, “Data Frame Header Structure Description Table”, “Data Frame Description Table”, “Data Frame Length Calculation Method Description Table”, “Data Frame Flag Calculation Method Description Table”, “Structure Definition File”, “Basic Data Type Description Table”, and “Processing Function Description Table”. The “Basic Data Type Description Table” and “Processing Function Description Table” are maintained by the programmer, while the other database tables and files are maintained by the user. Step B: Configuration information initialization and validity check The system sequentially reads the following tables: Processing Function Description Table, Basic Data Type Description Table, Structure Definition File, Data Frame Flag Calculation Method Description Table, Data Frame Length Calculation Method Description Table, Data Frame Description Table, Data Frame Header Structure Description Table, and Disk File Description Table, and performs a validity check on each table. If the validity check fails, the system displays an error message to the user and exits. Once the legality check is successful, proceed to step C; Step C: Processing and displaying disk-based files Open the disk file in memory-mapped mode. Based on the processing result of step B, first read and display the information of the file header and file tail. Then, starting from the tail of the file header, identify the data frame header and data frame body frame by frame and format and display the data frame header and data frame body until the file pointer reaches the beginning of the file header structure. The database tables designed in step A have the following characteristics: (1) In step A.1, design the "Disk File Description Table". When the value of the "File Header Data Frame Flag", "File Tail Data Frame Flag", or "Data Frame Header Structure Data Frame Flag" field in the table is not 0, it all points to the "Data Frame Flag" in the "Data Frame Header Structure Description Table". The "Data Frame Flag Calculation Method" field points to the "Data Frame Flag Calculation Method Description Table". When the value of the "Data Frame Length Calculation Method Flag" field is not 0, it points to the "Data Frame Length Calculation Method Description Table". (2) In step A.2, design the “Data Frame Header Structure Description Table”, which only stores the structure description information of the file header, file footer and data frame header. The structure corresponding to the “Structure Name” is described in detail in the “Structure Definition File”. (3) In step A.3, design the “Data Frame Description Table” to store the structure description information of all data frame bodies. The structure corresponding to the “Structure Name” is described in the “Structure Definition File”. When the value of “Data Frame Length Calculation Method Flag” is not 0, the calculation method of data length is defined by the “Data Frame Length Calculation Method Flag”. A small number of “Data Frame Flags” correspond to multiple structures. In this case, the “Data Frame Flag 1 Calculation Method” and “Data Frame Flag 1 Value”, “Data Frame Flag 2 Calculation Method” and “Data Frame Flag 2 Value” are used for auxiliary identification. The “Structure Start Offset Byte” field defines the offset of the structure start byte relative to the start byte of the “Data Frame Body”. 0 indicates no offset. The database tables designed in step A have the following characteristics: (1) In step A.4, design the “Description Table of Data Frame Length Calculation Method” to store the description information of the data frame length calculation method. The “Bytes occupied by data frame length value” field is defined as the number of bytes occupied by the “data frame length” value in the “data frame body”. The “Data frame length value acquisition position” field is defined as the starting position of the “data frame length” value in the “data frame body”. The meaning of the “Data frame length correction value” field is as follows: Assuming that the original value of the data frame length is calculated from the original data, the original value minus the “data frame length correction value” is the final data frame length. (2) In step A.5, design the “Description Table of Data Frame Flag Calculation Method” to store the description information of the data frame flag calculation method; the definition of the “Data Frame Flag Interval Byte” field is as follows: when the value is n, starting from the “Data Frame Flag Start Position”, after an interval of (n-1) bytes, obtain the original code value of the “Data Frame Flag Occupied Bytes”, and assemble it into an integer according to the order of “Data Frame Flag High Byte First”. The value of the integer is the data frame flag. The "Structure Definition File" designed in step A.6 has the following characteristics: (1) "Structure Definition File", which defines all the structures used in the disk file. It includes three types: basic structure, loop structure and composite structure. (2) Each structure field contains five data elements, namely "field type", "field name", "processing function", "processing parameter" and "field description", with the elements separated by spaces; (3) When the "field type" is a basic data type, it points to the "data type" in the "basic data type description table". If the "processing function" value is "NULL", the field will be displayed according to the default display method; otherwise, it will be displayed according to the display method corresponding to the "processing function". When the "field type" is a structure type, its value is the name of other structures. Its "processing function" value is "NULL", and its display method will be determined by the structure. (4) The "processing function" of the "loop count" field is the keyword "FieldLoop". The "FieldLoop" function cannot be used for fields other than "loop count". Its "field type" is the integer type among the basic data types. The "processing parameter" of the "loop count" field is in the form of "i,j", which means that the loop field is offset from i fields to j fields after the "loop count" field. The number of loops is determined by the value of the "loop count" field. Step B, the configuration information initialization and validity check process, has the following characteristics: (1) In step B.1 of the process of reading the “Processing Function Description Table”, the record with “Function Identifier” of 0 will be checked to see if its “Function Name” is “NULL”; the record with “Function Identifier” of 1 will be checked to see if its “Function Name” is “FieldLoop”. (2) In step B.3 of the process of reading the "Structure Definition File", when the "Field Type" is found to be another structure, all field information of the structure is inserted into the field information of this structure; when the loop structure contains substructures, if these substructures are located in the loop field, the "Loop Field Offset End" will be automatically updated; after the "Structure Definition File" is read, the "Structure Definition Table" will be generated. Step C, the disk file processing and display process, has the following characteristics: (1) In the data frame processing flow in step C.2, the data frame structure is usually uniquely determined by the "data frame flag". First, the data frame structure is identified from the data frame header. If the "data frame flag" corresponds to multiple structures, then the "data frame flag 1" and "data frame flag 2" will continue to be calculated from the data frame body. (2) In the data frame processing flow in step C.2, there are three ways to calculate the length of the data frame body. If the data frame length calculation method in the "disk file description table" is greater than 0, then the "data frame body length" is first calculated from the data frame header. If the data frame length calculation method flag corresponding to the "data frame index number" is greater than 0, then the "data frame body length" is recalculated. If the first two methods fail, then the "data frame body length" is set to the sum of the "data length of the formatted structure" and the "structure start offset bytes". (3) In the structure formatting display process in step C.3, "fixed repetition count" is the number of times the user predefines the field loop in the structure, which is used to perform continuous repetition processing on a field; "dynamic loop count" is the number of loops calculated from the original data, and its value is not fixed, which can be used to perform repetition processing on multiple consecutive fields.
Citation Information
Patent Citations
Satellite navigation message parameter resolving method based on database description
CN109212556A
Self-resolving based correctness verification system for navigation message data of shipborne satellite navigation equipment
CN110471090A