A recording wave file analysis method and system
Patent Information
- Application Number
- CN202311661001.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-05
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-12-05
AI Technical Summary
[0005]本申请提供一种录波文件解析方法及系统,其所要解决的一个技术问题是:Comtrade二进制文件状态量的编译码规则较为复杂,导致解析过程耗时较长的问题
[0061]通过上述技术方案,本申请提供的录波文件解析方法及系统,包括:确定录波文件的时间变量矩阵;确定录波文件的模拟变量矩阵;确定录波文件的数字变量矩阵;将时间变量矩阵、模拟变量矩阵及数字变量矩阵自左向右依次进行拼接,以得到解析后的录波文件解析矩阵。其通过分别对录波文件的时间变量、模拟变量及数字变量进行提取,以分别确定出对应的时间变量矩阵、模拟变量矩阵及数字变量矩阵,最后将时间变量矩阵、模拟变量矩阵及数字变量矩阵自左向右依次进行拼接即能够完成对二进制录波数据的解析,且该过程中分别提取时间变量、模拟变量及数字变量这三种单一变量,使得提取速度快,从而能够缩短解析时间。另外,通过矩阵计算及处理可以快速准确的对二进制录波文件的数据进行解析,不涉及复杂的通道数据判断及数据分离过程,易于通过计算软件实现,且所解析的结果通过矩阵方式进行呈现,矩阵中的每一行表示一个数据采样记录,以便于对解析后的内容的读取。
Smart Images

Figure CN117609164B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method and system for parsing waveform recording files. Background Technology
[0002] Waveform recordings, or Comtrade format, are a standard universal format for exchanging transient data in power systems. This format defines a standard for recording transient waveforms and fault data acquired from power systems or power system models. It provides an easily interpretable format for exchanging data, rather than a standard for exchanging data files over communication networks.
[0003] Each Comtrade file record has a set of up to four associated files, each with a different information level. The four files are: header file (.hdr), configuration file (.cfg), data file (.dat), and information file (.inf).
[0004] Compared to text files, Comtrade binary data files have advantages such as smaller storage space requirements and no conversion time (reading and writing do not require encoding or decoding, but directly write values), which helps to mitigate the adverse effects of massive data files, and therefore are currently widely used. However, the encoding and decoding rules for Comtrade binary file state variables are relatively complex, resulting in a longer parsing process. Summary of the Invention
[0005] This application provides a method and system for parsing waveform recording files. One of the technical problems it aims to solve is that the encoding and decoding rules of Comtrade binary file state variables are relatively complex, resulting in a long parsing time.
[0006] In a first aspect, embodiments of this application provide a method for parsing waveform recording files, the method comprising:
[0007] Determine the time variable matrix of the waveform file;
[0008] Determine the analog variable matrix of the waveform recording file;
[0009] Determine the digital variable matrix of the waveform file;
[0010] The time variable matrix, the analog variable matrix, and the digital variable matrix are concatenated from left to right to obtain the parsed waveform file parsing matrix.
[0011] In some embodiments, before determining the time variable matrix of the waveform file, the method further includes:
[0012] Obtain the binary data of the waveform recording file;
[0013] Convert the binary data to hexadecimal;
[0014] The data after hexadecimal conversion is processed according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data;
[0015] The time variable matrix, the analog variable matrix, and the digital variable matrix are determined based on the intermediate processing data.
[0016] In some embodiments, determining the time variable matrix based on the intermediate processing data includes:
[0017] The intermediate processing data is written into the first matrix as an unsigned 16-bit integer data type;
[0018] The first matrix is extracted according to formula (1) to obtain the second matrix;
[0019] data2=data1(3,:)+data1(4,:)*65536 (1)
[0020] The second matrix is transposed to obtain the time variable matrix;
[0021] Where data1 is the first matrix, data1(3,:) is the third row of the first matrix, data1(4,:) is the fourth row of the first matrix, and data2 is the second matrix.
[0022] In some embodiments, determining the analog variable matrix of the waveform file based on the intermediate processing data includes:
[0023] The intermediate processing data is written into the third matrix as a signed 16-bit integer data type;
[0024] The third matrix is extracted according to formula (2) to obtain the fourth matrix;
[0025] data4=data3(5:4+Ana_Ch,:) (2)
[0026] The fourth matrix is transposed to obtain the simulation variable matrix;
[0027] In this matrix, data3 is the third matrix, Ana_Ch is the total number of analog variable channels in the waveform recording file, and data4 is the fourth matrix.
[0028] In some embodiments, determining the digital variable matrix of the waveform file based on the intermediate processing data includes:
[0029] The intermediate processing data is written into the fifth matrix as an unsigned 16-bit integer.
[0030] The fifth matrix is extracted according to formula (3) to obtain the sixth matrix;
[0031] data6=data5(5+Ana_Ch:4+dNum+Ana_Ch,:) (3)
[0032] The data in the sixth matrix is processed into 16-bit binary and stored in the seventh matrix according to the rule of low-order bits on the right and high-order bits on the left.
[0033] The seventh matrix is transposed to obtain the eighth matrix;
[0034] The eighth matrix is reorganized to obtain the ninth matrix;
[0035] Transpose the ninth matrix to obtain the tenth matrix;
[0036] The tenth matrix is extracted according to formula (4) to obtain the numerical variable matrix;
[0037] data11=data10(:,1:Dig_Ch) (4)
[0038] In this matrix, data5 is the fifth matrix, Ana_Ch is the total number of analog variable channels in the waveform recording file, dNum = (Dig_Ch + 7) / 16, Dig_Ch is the total number of digital channels in the waveform recording file, data6 is the sixth matrix, data10 is the tenth matrix, and data11 is the eleventh matrix.
[0039] In some embodiments, determining the digital variable matrix of the waveform file based on the intermediate processing data includes:
[0040] The intermediate processing data is written into the fifth matrix as an unsigned 16-bit integer.
[0041] The fifth matrix is extracted according to formula (3) to obtain the sixth matrix;
[0042] data6=data5(5+Ana_Ch:4+dNum+Ana_Ch,:) (3)
[0043] The data in the sixth matrix is processed into 16-bit binary and stored in the seventh matrix according to the rule of low-order bits on the right and high-order bits on the left.
[0044] The seventh matrix is transposed to obtain the eighth matrix;
[0045] The eighth matrix is reorganized to obtain the ninth matrix;
[0046] Transpose the ninth matrix to obtain the tenth matrix;
[0047] The tenth matrix is extracted according to formula (4) to obtain the numerical variable matrix;
[0048] data11=data10(:,1:Dig_Ch) (4)
[0049] In this matrix, data5 is the fifth matrix, Ana_Ch is the total number of analog variable channels in the waveform file, dNum = ceil(Dig_Ch / 16) = 1, ceil is the round-up function, Dig_Ch is the total number of digital channels in the waveform file, data6 is the sixth matrix, data10 is the tenth matrix, and data11 is the eleventh matrix.
[0050] Secondly, embodiments of this application provide a waveform recording file parsing system, the waveform recording file parsing system comprising:
[0051] The first determining module is used to determine the time variable matrix of the waveform recording file;
[0052] The second determining module is used to determine the analog variable matrix of the waveform recording file;
[0053] The third determining module is used to determine the digital variable matrix of the waveform recording file;
[0054] The splicing module is used to splice the time variable matrix, the analog variable matrix, and the digital variable matrix from left to right to obtain the parsed waveform file parsing matrix.
[0055] In some embodiments, the waveform file parsing system may further include:
[0056] The acquisition module is used to acquire the binary data of the waveform recording file;
[0057] The conversion module is used to convert the binary data into hexadecimal;
[0058] The processing module is used to process the binary data according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data.
[0059] Thirdly, embodiments of this application provide an electronic device, the electronic device comprising: a processor, a memory, and a bus; wherein the processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the method described in any one of the above.
[0060] Fourthly, embodiments of this application provide a computer-readable storage medium, the computer-readable storage medium comprising: a stored program; wherein, when the program is executed, it controls the device where the storage medium is located to perform the method described in any one of the above.
[0061] The waveform recording file parsing method and system provided in this application, through the above technical solution, includes: determining the time variable matrix of the waveform recording file; determining the analog variable matrix of the waveform recording file; determining the digital variable matrix of the waveform recording file; and concatenating the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the parsed waveform recording file parsing matrix. By extracting the time variables, analog variables, and digital variables of the waveform recording file separately to determine the corresponding time variable matrix, analog variable matrix, and digital variable matrix, and finally concatenating them from left to right, the parsing of binary waveform recording data can be completed. Furthermore, the separate extraction of these three single variables (time variables, analog variables, and digital variables) in this process results in fast extraction speed, thereby shortening the parsing time. In addition, matrix calculation and processing can quickly and accurately parse the data in binary waveform recording files without involving complex channel data judgment and data separation processes. It is easily implemented using calculation software, and the parsed results are presented in a matrix format, with each row representing a data sampling record, facilitating the reading of the parsed content.
[0062] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, the preferred embodiments of this application are described in detail below with reference to the accompanying drawings. Attached Figure Description
[0063] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0064] Figure 1 The flowchart of the waveform file parsing method provided in the embodiments of this application Figure 1 ;
[0065] Figure 2 The flowchart of the waveform file parsing method provided in the embodiments of this application Figure 2 ;
[0066] Figure 3 The flowchart of the waveform file parsing method provided in the embodiments of this application Figure 3 ;
[0067] Figure 4 Module connections for the waveform file parsing system provided in the embodiments of this application Figure 1 ;
[0068] Figure 5 Module connections for the waveform file parsing system provided in the embodiments of this application Figure 2 . Detailed Implementation
[0069] The embodiments of this application will be further described in detail below with reference to the accompanying drawings and examples. The detailed description of the following embodiments and the accompanying drawings are used to illustrate the principles of this application by way of example, but should not be used to limit the scope of this application. This application can be implemented in many different forms and is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.
[0070] These embodiments are provided to make the application thorough and complete, and to fully express the scope of the application to those skilled in the art. It should be noted that, unless otherwise specifically stated, the relative arrangement of components and steps, material composition, numerical expressions, and values illustrated in these embodiments should be interpreted as merely exemplary and not as limiting.
[0071] It should be noted that, in the description of this application, unless otherwise stated, "a plurality of" means two or more; the terms "upper," "lower," "left," "right," "inner," and "outer," etc., indicating orientation or positional relationship, are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0072] Furthermore, the terms "first," "second," and similar terms used in this application do not indicate any order, quantity, or importance, but are merely used to distinguish different parts. "Vertical" is not strictly vertical, but within the permissible margin of error. "Parallel" is not strictly parallel, but within the permissible margin of error. Terms such as "including" or "contains" mean that the element preceding the word encompasses the element listed after it, and do not exclude the possibility of encompassing other elements as well.
[0073] It should also be noted that, in the description of this application, unless otherwise expressly specified and limited, the terms "installation," "connection," and "joining" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a direct connection or an indirect connection through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms in this application depending on the specific circumstances. When a specific device is described as being located between a first device and a second device, an intermediary device may or may not be present between the specific device and the first or second device.
[0074] All terms used in this application have the same meaning as understood by one of ordinary skill in the art to which this application pertains, unless otherwise specifically defined. It should also be understood that terms defined in general dictionaries should be interpreted as having meanings consistent with their meanings in the context of the relevant art, and not as idealized or highly formalized, unless expressly defined herein.
[0075] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0076] First, let's explain the data file (Comtrade file).
[0077] The data file is the main file of the waveform recording, containing the values of all input channels for each sample recorded. The data file also contains a sequence number and a time stamp for each sample. The data file can be recorded in ASCII or binary data format. For binary data files, a data stream format is used, with the word format defined as LSB first, MSB last. The basic structure of the cell group is similar to the ASCII format, but the numeric variables are formatted and delimited.
[0078] Each data sample record should contain data arranged as follows:
[0079] n, timestamp, A1, A2,...Ak, D1, D2,...Dm
[0080] Where: n is the number of samples, which is an integer and stored as four bytes of unsigned binary data; timestamp is the time stamp number, with the basic unit being us, and stored as four bytes of unsigned binary data; A1, A2, ... Ak are the waveform recording analog variable channel information, stored as two bytes of unsigned binary data; D1, D2, ... Dm are the waveform recording digital variable channel information, stored in grouped bytes, with each two bytes used for each of the 16 status channels.
[0081] First aspect
[0082] This application provides a method for parsing waveform recording files. See also... Figure 1 and Figure 2 As shown, the methods for parsing waveform recordings include:
[0083] S101: Determine the time variable matrix of the waveform recording file;
[0084] S102: Determine the analog variable matrix of the waveform recording file;
[0085] S103: Determine the digital variable matrix for the waveform recording file;
[0086] S104: Concatenate the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the analytical matrix of the analyzed waveform file.
[0087] Here, the waveform recording file is in binary data, meaning the binary data is either zero or 1, making it difficult to read. Therefore, it needs to be parsed to obtain a more easily readable decimal representation. The acquisition of the time variable matrix, analog variable matrix, and digital variable matrix from the waveform recording file can be done manually or through a computing device; no specific limitation is made here.
[0088] In one specific embodiment, the waveform file parsing method includes:
[0089] First, the binary data in the waveform recording file is converted to hexadecimal. The processed data is: 01 00 00 0000 00 00 00 1E FC B5 04 64 00 1D 00 79 FF 3B FF 00 00 02 00 00 00 A7 00 00 0051 FC CF 04 5E 00 25 00 77 FF ED FE 00 00; where 01 00 00 00 is the first sample number, 0000 00 00 is the first timestamp, 1E FC B5 04 64 00 1D 00 79 FF 3B FF represents 6 analog variable data, and 00 00 represents 6 digital variable data; 02 00 00 00 is the second sample number, A7 00 00 00 is the second timestamp, 51FC CF 04 5E 00 25 00 77 FF ED FE are the data for 6 analog variables, and 00 00 are the data for 6 digital variables.
[0090] Then, the hexadecimal data is parsed to determine the time variable matrix of the recorded waveform file as follows:
[0091]
[0092] Next, the hexadecimal data is parsed to determine the analog variable matrix of the recorded waveform file:
[0093]
[0094] Next, the hexadecimal data is parsed to determine the numerical variable matrix of the recorded waveform file:
[0095]
[0096] Finally, the time variable matrix t1, the analog variable matrix t2, and the digital variable matrix t3 are concatenated from left to right to obtain the analytical matrix of the analyzed waveform file:
[0097]
[0098] According to the analytical matrix t4 of the waveform recording file, we can intuitively read that: at time 0, the analog variables are -994, 1205, 100, 29, 135, 197, and the digital variables are 0, 0, 0, 0, 0, 0; at time 167, the digital variables are -943, 1231, 94, 37, -137, -275, and the digital variables are 0, 0, 0, 0, 0, 0.
[0099] In this embodiment, the waveform recording file parsing method includes: S101: determining the time variable matrix of the waveform recording file; S102: determining the analog variable matrix of the waveform recording file; S103: determining the digital variable matrix of the waveform recording file; S104: concatenating the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the parsed waveform recording file parsing matrix. This method extracts the time variables, analog variables, and digital variables of the waveform recording file separately to determine the corresponding time variable matrix, analog variable matrix, and digital variable matrix. Finally, concatenating these matrices from left to right completes the parsing of the binary waveform recording data. Furthermore, the separate extraction of these three individual variables (time variables, analog variables, and digital variables) during this process results in fast extraction speed, thereby shortening the parsing time. In addition, matrix calculation and processing can quickly and accurately parse the data in binary waveform files without involving complex channel data judgment and data separation processes. It is easy to implement through calculation software, and the parsed results are presented in a matrix manner, with each row in the matrix representing a data sampling record, so as to facilitate the reading of the parsed content.
[0100] In some embodiments, see Figure 3 As shown, before S101 determines the time variable matrix of the waveform file, it also includes:
[0101] S201: Obtain the binary data of the waveform recording file;
[0102] S202: Convert binary data to hexadecimal;
[0103] S203: The hexadecimal converted data is processed according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data;
[0104] The time variable matrix, analog variable matrix, and digital variable matrix are determined based on the intermediate processing data.
[0105] Here, the binary data of the waveform recording file is the original data in the waveform recording file, which can be read directly.
[0106] In one specific embodiment, the waveform file parsing method includes:
[0107] S301: Obtain the binary data of the waveform recording file;
[0108] S302: Convert binary data to hexadecimal;
[0109] S303: The hexadecimal converted data is processed according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data;
[0110] S304: Determine the time variable matrix, analog variable matrix, and digital variable matrix respectively based on the intermediate processing data.
[0111] S305: Concatenate the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the analytical matrix of the analyzed waveform file.
[0112] In this embodiment, the binary data of the acquired waveform file is first converted to hexadecimal. Then, the hexadecimal data is processed according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processing data. Next, the time variable matrix, analog variable matrix, and digital variable matrix are quickly extracted from the intermediate processing data. Finally, the time variable matrix, analog variable matrix, and digital variable matrix are concatenated from left to right to obtain the waveform file parsing matrix. This process, by preprocessing the binary data, simplifies the data processing when determining the time variable matrix, analog variable matrix, and digital variable matrix, thereby further shortening the parsing time.
[0113] In some embodiments, determining the time variable matrix based on intermediate processing data in S204 includes:
[0114] S401: Write the intermediate processing data into the first matrix as an unsigned 16-bit integer data type;
[0115] S402: Extract the first matrix according to formula (1) to obtain the second matrix;
[0116] data2=data1(3,:)+data1(4,:)*65536 (1)
[0117] S403: Transpose the second matrix to obtain the time variable matrix;
[0118] Where data1 is the first matrix, data1(3,:) is the third row of the first matrix, data1(4,:) is the fourth row of the first matrix, and data2 is the second matrix.
[0119] Here, since the purpose of this embodiment is to determine the time variable matrix, and time has no negative values, the intermediate processing data is written into the first matrix as an unsigned 16-bit integer (i.e., uint16) to simplify the calculation process and further shorten the parsing time. The number of rows in the first matrix is the total number of binary continuous data streams in the waveform file (.dat), and the number of columns is the total number of sampling points in a single channel, which can be obtained by parsing the configuration file (.cfg). The third and fourth rows in the first matrix correspond to the time variables, and the fourth row is the high-order value. Therefore, the time variable matrix can be obtained by extracting the first matrix using formula (1) and then transposing it.
[0120] In some embodiments, determining the analog variable matrix of the waveform file based on intermediate processing data in S204 includes:
[0121] S501: Write the intermediate processing data into the third matrix as a signed 16-bit integer data type;
[0122] S502: Extract the third matrix according to formula (2) to obtain the fourth matrix;
[0123] data4=data3(5:4+Ana_Ch,:) (2)
[0124] S503: Transpose the fourth matrix to obtain the simulation variable matrix;
[0125] In this matrix, data3 is the third matrix, Ana_Ch is the total number of analog variable channels in the waveform recording file, and data4 is the fourth matrix.
[0126] Here, unlike time variables, analog variables have positive and negative values. Therefore, intermediate processing data is written into the third matrix as a signed 16-bit integer data type (i.e., int16). Ana_Ch is the total number of analog variable channels in the waveform file, which can be obtained by parsing the configuration file (.cfg). data3(5:4+Ana_Ch,:) indicates that data is extracted from the 5th row of the third matrix to the 4th row of the total number of analog variable channels in the waveform file to obtain the fourth matrix. The number of rows in the third matrix is the total number of binary continuous data streams in the waveform file (.dat), and the number of columns is the total number of sampling points for a single channel, which can be obtained by parsing the configuration file (.cfg). Since the data from the 5th row to the 4+Ana_Ch row in the third matrix corresponds to the analog variable data, the fourth matrix is obtained by extracting data from the third matrix using formula (2). Finally, the fourth matrix is transposed to obtain the analog variable matrix.
[0127] In some embodiments, determining the digital variable matrix of the waveform file based on intermediate processing data in S204 includes:
[0128] S601: Write the intermediate processing data into the fifth matrix as an unsigned 16-bit integer data type;
[0129] S602: Extract the fifth matrix according to formula (3) to obtain the sixth matrix;
[0130] data6=data5(5+Ana_Ch:4+dNum+Ana_Ch,:) (3)
[0131] S603: Process the data of the sixth matrix into 16-bit binary and store it in the seventh matrix according to the rule of low-order bits on the right and high-order bits on the left;
[0132] S604: Transpose the seventh matrix to obtain the eighth matrix;
[0133] S605: Reorganize the eighth matrix to obtain the ninth matrix;
[0134] S606: Transpose the ninth matrix to obtain the tenth matrix;
[0135] S607: Extract the tenth matrix according to formula (4) to obtain the numerical variable matrix;
[0136] data11=data10(:,1:Dig_Ch) (4)
[0137] In this matrix, data5 is the fifth matrix, Ana_Ch is the total number of analog variable channels in the waveform recording file, dNum = (Dig_Ch + 7) / 16, Dig_Ch is the total number of digital channels in the waveform recording file, data6 is the sixth matrix, data10 is the tenth matrix, and data11 is the eleventh matrix.
[0138] Here, the numerical variables are either very large or very small, either very high or very low, making their representation either A or B, and they have no negative sign. Therefore, the intermediate processing data is written into the fifth matrix as an unsigned 16-bit integer data type (i.e., unit16) to simplify the calculation process and further shorten the parsing time. The number of rows in the fifth matrix represents the total number of binary continuous data streams in the waveform file (.dat), and the number of columns represents the total number of sampling points per channel, which can be obtained by parsing the configuration file (.cfg). Ana_Ch represents the total number of analog variable channels in the waveform file, which can also be obtained by parsing the configuration file (.cfg). 5+Ana_Ch represents the row number of the first row of the digital quantity, and 4+dNum+Ana_Ch represents the row number of the last row of the digital quantity. dNum represents the number of binary data streams occupied by the digital quantity, which is also the number of rows in the sixth matrix. The seventh matrix has dNum*datalength rows and 16 columns. The ninth matrix has 16*dNum rows and the number of columns represents the total number of sampling points per channel. Dig_Ch represents the total number of digital channels in the waveform file, which can be obtained by parsing the configuration file (.cfg). The tenth matrix contains null values; data10(:,1:Dig_Ch) represents the column number from the first to the last column of the digital data to remove these null values.
[0139] In some embodiments, determining the digital variable matrix of the waveform file based on intermediate processing data in S204 includes:
[0140] S601: Write the intermediate processing data into the fifth matrix as an unsigned 16-bit integer data type;
[0141] S602: Extract the fifth matrix according to formula (3) to obtain the sixth matrix;
[0142] data6=data5(5+Ana_Ch:4+dNum+Ana_Ch,:) (3)
[0143] S603: Process the data of the sixth matrix into 16-bit binary and store it in the seventh matrix according to the rule of low-order bits on the left and high-order bits on the right;
[0144] S604: Transpose the seventh matrix to obtain the eighth matrix;
[0145] S605: Reorganize the eighth matrix to obtain the ninth matrix;
[0146] S606: Transpose the ninth matrix to obtain the tenth matrix;
[0147] S607: Extract the tenth matrix according to formula (4) to obtain the numerical variable matrix;
[0148] data11=data10(:,1:Dig_Ch) (4)
[0149] In this matrix, data5 is the fifth matrix, Ana_Ch is the total number of analog variable channels in the waveform file, dNum = ceil(Dig_Ch / 16) = 1, ceil is the round-up function, Dig_Ch is the total number of digital channels in the waveform file, data6 is the sixth matrix, data10 is the tenth matrix, and data11 is the eleventh matrix.
[0150] Here, the numerical variables are either very large or very small, either very high or very low, making their representation either A or B, and they have no negative sign. Therefore, the intermediate processing data is written into the fifth matrix as an unsigned 16-bit integer data type (i.e., unit16) to simplify the calculation process and further shorten the parsing time. The number of rows in the fifth matrix represents the total number of binary continuous data streams in the waveform file (.dat), and the number of columns represents the total number of sampling points per channel, which can be obtained by parsing the configuration file (.cfg). Ana_Ch represents the total number of analog variable channels in the waveform file, which can also be obtained by parsing the configuration file (.cfg). 5+Ana_Ch represents the row number of the first row of the digital quantity, and 4+dNum+Ana_Ch represents the row number of the last row of the digital quantity. dNum represents the number of binary data streams occupied by the digital quantity, which is also the number of rows in the sixth matrix. The seventh matrix has dNum*datalength rows and 16 columns. The ninth matrix has 16*dNum rows and the number of columns represents the total number of sampling points per channel. Dig_Ch represents the total number of digital channels in the waveform file, which can be obtained by parsing the configuration file (.cfg). The tenth matrix contains null values; data10(:,1:Dig_Ch) represents the column number from the first to the last column of the digital data to remove these null values.
[0151] Next, the waveform data analysis method will be described in detail with two examples.
[0152] Example 1:
[0153] S701: Obtain binary data from the waveform recording file;
[0154] S702: Converts binary data to hexadecimal;
[0155] The converted data is: 01 00 00 00 00 00 00 00 1E FC B5 04 64 00 1D 00 79 FF3B FF 00 00 02 00 00 00 A7 00 00 00 51 FC CF 04 5E 00 25 00 77 FF ED FE 0000; where 01 00 00 00 is the first sample number, 00 00 00 00 is the first timestamp, 1E FC B5 04 6400 1D 00 79 FF 3B FF represents 6 analog variable data, and 00 00 represents 6 digital variable data; 02 00 00 00 is the second sample number, A7 00 00 00 is the second timestamp, and 51 FC CF 04 5E 00 25 00 77 FF ED FE represents 6 analog variable data, and 00 00 represents 6 digital variable data.
[0156] S703: The hexadecimal converted data is processed according to the rule of two bytes per unit, with the least significant byte on the left and the most significant byte on the right, to obtain intermediate processed data;
[0157] Intermediate processing data is as follows: 0x0001 0x0000 0x0000 0x0000 0xFC1E 0x04B5 0x0064 0x001D 0xFF79 0xFF3B 0x0000 0x0002 0x0000 0x00A7 0x0000 0xFC51 0x04CF 0x005E 0x0025 0xFF77 0xFEED 0x0000
[0158] S704: Determine the time variable matrix based on S401 to S402;
[0159] S401 writes the intermediate processing data into the first matrix as an unsigned 16-bit integer data type;
[0160] The intermediate data is processed into unsigned 16-bit integers as follows:
[0161] 0x0001=1, 0x0000=0, 0x0000=0, 0x0000=0, 0xFC1E=64542, 0x04B5=1205, 0x0064=100, 0x001D=29, 0xFF79=65401, 0xFF3B=65339, 0x0000=0;
[0162] 0x0002=2, 0x0000=0, 0x00A7=167, 0x0000=0, 0xFC51=64593, 0x04CF=1231, 0x005E=94, 0x0025=37, 0xFF77=65399, 0xFEED=65261, 0x0000=0
[0163] Write the first matrix data1 as an unsigned 16-bit integer:
[0164]
[0165] S402: Extract the first matrix according to formula (1) to obtain the second matrix data2;
[0166] data2=data1(3,;)+data1(4,;)*65536=[0 167]
[0167] S403: Transpose the second matrix to obtain the time variable matrix T;
[0168]
[0169] S705: Determine the simulation variable matrix based on S501 to S503;
[0170] S501: Write the intermediate processing data into the third matrix data3 as a signed 16-bit integer data type;
[0171] The intermediate data is processed into signed 16-bit integers as follows:
[0172] 0x0001=1, 0x0000=0, 0x0000=0, 0x0000=0, 0xFC1E=-994, 0x04B5=1205, 0x0064=100, 0x001D=29, 0xFF79=-135, 0xFF3B=-197, 0x0000=0;
[0173] 0x0002=2, 0x0000=0, 0x00A7=167, 0x0000=0, 0xFC51=-943, 0x04CF=1231, 0x005E=94, 0x0025=37, 0xFF77=-137, 0xFEED=0275, 0x0000=0
[0174] Write the data to the third matrix data3 as a signed 16-bit integer:
[0175]
[0176] S502: Extract the third matrix according to formula (2) to obtain the fourth matrix data4;
[0177]
[0178] S503: Transpose the fourth matrix to obtain the simulation variable matrix A;
[0179]
[0180] S706: Determine the numerical variable matrix based on S601 to S607;
[0181] S601: Write the intermediate processing data into the fifth matrix data5 as an unsigned 16-bit integer;
[0182] The intermediate data is processed into unsigned 16-bit integers as follows:
[0183] 0x0001=1, 0x0000=0, 0x0000=0, 0x0000=0, 0xFC1E=64542, 0x04B5=1205, 0x0064=100, 0x001D=29, 0xFF79=65401, 0xFF3B=65339, 0x0000=0;
[0184] 0x0002=2, 0x0000=0, 0x00A7=167, 0x0000=0, 0xFC51=64593, 0x04CF=1231, 0x005E=94, 0x0025=37, 0xFF77=65399, 0xFEED=65261, 0x0000=0
[0185] Write the data into the fifth matrix, data5, using an unsigned 16-bit integer data type:
[0186]
[0187] S602: Extract the fifth matrix according to formula (3) to obtain the sixth matrix data6;
[0188] data6=data3(5+Anz_Ch:4+dNum+Ana_Ch,:)=[0 0]
[0189] S603: Process the data of the sixth matrix into 16-bit binary and store it in the seventh matrix data7 according to the rule of low-order bits on the left and high-order bits on the right;
[0190]
[0191] S604: Transpose the seventh matrix to obtain the eighth matrix, data8;
[0192]
[0193] S605: Reorganize the eighth matrix to obtain the ninth matrix dat9;
[0194]
[0195] S606: Transpose the ninth matrix to obtain the tenth matrix, data10;
[0196]
[0197] S607: Extract the tenth matrix according to formula (4) to obtain the numerical variable matrix D;
[0198]
[0199] S707: Concatenate the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the analytical matrix of the analyzed waveform file.
[0200]
[0201] Compared to parsing loop statements, parsing the entire matrix is more efficient.
[0202] Example 2:
[0203] S801: Obtain the binary data of the waveform recording file;
[0204] S802: Converts binary data to hexadecimal;
[0205] The converted data is: 04 00 00 00 F5 01 00 00 C6 FC F1 04 50 00 34 00 74 FF56 FE 10 00 05 00 00 00 9C 02 00 00 08FD FA 04 48 00 3D 00 74 FF 0A FE 30 00; where 04 00 00 00 is the first sample number, F5 01 00 00 is the first timestamp, C6 FC F1 04 50 0034 00 74 FF 56FE represents 6 analog variable data, and 10 00 represents 6 digital variable data; 05 00 00 00 is the second sample number, 9C 02 00 00 is the second timestamp, and 08FD... FA 04 48 00 3D 00 74 FF 0A FE represents 6 analog variable data, and 30 00 represents 6 digital variable data.
[0206] S803: The hexadecimal converted data is processed according to the rule of two bytes per unit, with the least significant byte on the left and the most significant byte on the right, to obtain intermediate processed data;
[0207] Intermediate processing data is as follows: 0x0004 0x0000 0x01F5 0x0000 0xFCC6 0x04F1 0x0050 0x0034 0xFF74 0xFE56 0x0010 0x0005 0x0000 0x029C 0x0000 0xFD08 0x04FA 0x0048 0x003D 0xFF74 0xFE0A 0x0030
[0208] S804: Determine the time variable matrix based on S401 to S402;
[0209] S401 writes the intermediate processing data into the first matrix as an unsigned 16-bit integer data type;
[0210] The intermediate data is processed into unsigned 16-bit integers as follows:
[0211] 0x0004=4, 0x0000=0, 0x01F5=501, 0x0000=0, 0xFCC6=64710, 0x04F1=1265, 0x0050=80, 0x0034=52, 0xFF74=65396, 0xFE56=65110, 0x0010=16;
[0212] 0x0005=5, 0x0000=0, 0x029C=668, 0x0000=0, 0xFD08=64776, 0x04FA=1274, 0x0048=72, 0x003D=61, 0xFF74=65396, 0xFE0A=65034, 0x0030=48
[0213] Write the first matrix data1 as an unsigned 16-bit integer:
[0214]
[0215] S402: Extract the first matrix according to formula (1) to obtain the second matrix data2;
[0216] data2=data1(3,:)+data1(4,:)*65536=[501 668]
[0217] S403: Transpose the second matrix to obtain the time variable matrix T;
[0218]
[0219] S805: Determine the simulation variable matrix based on S501 to S503;
[0220] S501: Write the intermediate processing data into the third matrix data3 as a signed 16-bit integer data type;
[0221] The intermediate data is processed into signed 16-bit integers as follows:
[0222] 0x0004=4, 0x0000=0, 0x01F5=501, 0x0000=0, 0xFCC6=-826, 0x04F1=1265, 0x0050=80, 0x0034=52, 0xFF74=-140, 0xFE56=-426, 0x0010=16;
[0223] 0x0005=5, 0x0000=0, 0x029C=668, 0x0000=0, 0xFD08=-760, 0x04FA=1274, 0x0048=72, 0x003D=61, 0xFF74=-140, 0xFE0A=-502, 0x0030=48
[0224]
[0225] S502: Extract the third matrix according to formula (2) to obtain the fourth matrix data4;
[0226]
[0227] S503: Transpose the fourth matrix to obtain the simulation variable matrix A;
[0228]
[0229] S806: Determine the numerical variable matrix based on S601 to S607;
[0230] S601: Write the intermediate processing data into the fifth matrix data5 as an unsigned 16-bit integer;
[0231] The intermediate data is processed into unsigned 16-bit integers as follows:
[0232] 0x0004=4, 0x0000=0, 0x01F5=501, 0x0000=0, 0xFCC6=64710, 0x04F1=1265, 0x0050=80, 0x0034=52, 0xFF74=65396, 0xFE56=65110, 0x0010=16;
[0233] 0x0005=5, 0x0000=0, 0x029C=668, 0x0000=0, 0xFD08=64776, 0x04FA=1274, 0x0048=72, 0x003D=61, 0xFF74=65396, 0xFE0A=65034, 0x0030=48
[0234] Write the data into the fifth matrix, data5, using an unsigned 16-bit integer data type:
[0235]
[0236] S602: Extract the fifth matrix according to formula (3) to obtain the sixth matrix data6;
[0237] data6=data3(5+Ana_Ch:4+dNum+Ana_Ch,:)=[16 48]
[0238] S603: Process the data of the sixth matrix into 16-bit binary and store it in the seventh matrix data7 according to the rule of low-order bits on the left and high-order bits on the right;
[0239]
[0240] S604: Transpose the seventh matrix to obtain the eighth matrix, data8;
[0241]
[0242] S605: Reorganize the eighth matrix to obtain the ninth matrix dat9;
[0243]
[0244] S606: Transpose the ninth matrix to obtain the tenth matrix, data10;
[0245]
[0246] S607: Extract the tenth matrix according to formula (4) to obtain the numerical variable matrix D;
[0247]
[0248] S807: Concatenate the time variable matrix T, the analog variable matrix A, and the digital variable matrix D from left to right to obtain the analytical matrix of the analyzed waveform file.
[0249]
[0250] Compared to parsing loop statements, parsing the entire matrix is more efficient.
[0251] Based on Embodiments 1 and 2 above, the waveform data parsing method of this application parses COMTRADE binary waveform files. Through matrix calculation and processing, the time variable matrix T, analog variable matrix A, and digital variable matrix D of the waveform file are obtained respectively. Finally, the time variable matrix T, analog variable matrix A, and digital variable matrix D are concatenated from left to right to obtain the parsed waveform file parsing matrix. This process extracts the three single variables—time, analog, and digital—separately, resulting in fast extraction speed and shortening the parsing time. Furthermore, matrix calculation and processing can quickly and accurately parse the data in binary waveform files without involving complex channel data judgment and data separation processes. It is easily implemented using calculation software, and the parsed results are presented in a matrix format, with each row representing a data sampling record, facilitating the reading of the parsed content.
[0252] Second aspect
[0253] This application provides a waveform recording file parsing system, see [link to documentation]. Figure 4 As shown, the waveform recording file parsing system includes:
[0254] The first determining module is used to determine the time variable matrix of the waveform recording file;
[0255] The second determining module is used to determine the analog variable matrix of the waveform recording file;
[0256] The third determining module is used to determine the digital variable matrix of the waveform recording file;
[0257] The splicing module is used to splice the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the analytical matrix of the analyzed waveform file.
[0258] Here, the waveform recording file is in binary data, meaning the binary data is either zero or 1, making it difficult to read. Therefore, it needs to be parsed to obtain a more easily readable decimal representation. The acquisition of the time variable matrix, analog variable matrix, and digital variable matrix from the waveform recording file can be done manually or through a computing device; no specific limitation is made here.
[0259] In one specific embodiment, the waveform recording file parsing system includes:
[0260] The first determining module is used to determine the time variable matrix of the waveform recording file;
[0261] The second determining module is used to determine the analog variable matrix of the waveform recording file;
[0262] The third determining module is used to determine the digital variable matrix of the waveform recording file;
[0263] The splicing module is used to splice the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the analytical matrix of the analyzed waveform file. The analysis process is as follows:
[0264] First, the binary data in the waveform recording file is converted to hexadecimal. The processed data is: 01 00 00 0000 00 00 00 1E FC B5 04 64 00 1D 00 79 FF 3B FF 00 00 02 00 00 00 A7 00 00 0051 FC CF 04 5E 00 25 00 77 FF ED FE 00 00; where 01 00 00 00 is the first sample number, 0000 00 00 is the first timestamp, 1E FC B5 04 64 00 1D 00 79 FF 3B FF represents 6 analog variable data, and 00 00 represents 6 digital variable data; 02 00 00 00 is the second sample number, A7 00 00 00 represents the second timestamp, 51 FC CF 04 5E 00 25 00 77 FF ED FE represents the data for 6 analog variables, and 00 00 represents the data for 6 digital variables.
[0265] Then, the hexadecimal data is parsed to determine the time variable matrix of the recorded waveform file as follows:
[0266]
[0267] Next, the hexadecimal data is parsed to determine the analog variable matrix of the recorded waveform file:
[0268]
[0269] Next, the hexadecimal data is parsed to determine the numerical variable matrix of the recorded waveform file:
[0270]
[0271] Finally, the time variable matrix t1, the analog variable matrix t2, and the digital variable matrix t3 are concatenated from left to right to obtain the analytical matrix of the analyzed waveform file:
[0272]
[0273] According to the analytical matrix t4 of the waveform recording file, we can intuitively read that: at time 0, the analog variables are -994, 1205, 100, 29, 135, 197, and the digital variables are 0, 0, 0, 0, 0, 0; at time 167, the digital variables are -943, 1231, 94, 37, -137, -275, and the digital variables are 0, 0, 0, 0, 0, 0.
[0274] In this embodiment, the waveform recording file parsing system includes: a first determining module for determining the time variable matrix of the waveform recording file; a second determining module for determining the analog variable matrix of the waveform recording file; a third determining module for determining the digital variable matrix of the waveform recording file; and a splicing module for sequentially splicing the time variable matrix, analog variable matrix, and digital variable matrix from left to right to obtain the parsed waveform recording file parsing matrix. By extracting the time variables, analog variables, and digital variables of the waveform recording file separately to determine the corresponding time variable matrix, analog variable matrix, and digital variable matrix, and finally splicing them sequentially from left to right, the system can complete the parsing of binary waveform recording data. Furthermore, the separate extraction of these three single variables (time variables, analog variables, and digital variables) during this process results in fast extraction speed, thereby shortening the parsing time. In addition, matrix calculation and processing can quickly and accurately parse the data in binary waveform files without involving complex channel data judgment and data separation processes. It is easy to implement through calculation software, and the parsed results are presented in a matrix manner, with each row in the matrix representing a data sampling record, so as to facilitate the reading of the parsed content.
[0275] In some embodiments, see Figure 5 As shown, the waveform recording file parsing system may also include:
[0276] The acquisition module is used to acquire the binary data of the waveform recording file;
[0277] The conversion module is used to convert binary data to hexadecimal.
[0278] The processing module processes binary data according to the rule of two bytes per unit, with the least significant byte on the left and the most significant byte on the right, to obtain intermediate processed data.
[0279] The time variable matrix, analog variable matrix, and digital variable matrix are determined based on the intermediate processing data.
[0280] Here, the binary data of the waveform recording file is the original data in the waveform recording file, which can be read directly.
[0281] In this embodiment, the acquisition module obtains the binary data of the waveform recording file. Then, the conversion module first converts the acquired binary data of the waveform recording file into hexadecimal. Next, the processing module processes the hexadecimal converted data according to the rule of two bytes per unit, with the least significant byte on the left and the most significant byte on the right, to obtain intermediate processing data. Finally, the time variable matrix, analog variable matrix, and digital variable matrix are quickly extracted from the intermediate processing data. This process, by preprocessing the binary data, simplifies the data processing when determining the time variable matrix, analog variable matrix, and digital variable matrix, thereby further shortening the parsing time.
[0282] It should be noted that the embodiments of the waveform data analysis system and the methods described above are similar, and have similar technical content and beneficial effects. For technical content not disclosed in the embodiments of the waveform data analysis system of this application, please refer to the description of the method embodiments in this application for understanding, and will not be repeated here.
[0283] Third aspect
[0284] This application provides an electronic device, which includes a processor, a memory, and a bus; wherein the processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute any of the methods described above.
[0285] It should be noted that the methods in the electronic devices provided in this application are similar to those described in the above-described method embodiments, and have similar beneficial effects. For technical details not disclosed in the electronic device embodiments of this application, please refer to the description of the method embodiments in this application for understanding; they will not be repeated here.
[0286] Fourth aspect
[0287] This application provides a computer-readable storage medium, which includes a stored program; wherein, when the program is running, it controls the device where the storage medium is located to execute any of the methods described above.
[0288] It should be noted that the methods in the computer-readable storage medium provided in this application are similar to those described in the above-described method embodiments, and have similar beneficial effects. For technical details not disclosed in the computer-readable storage medium embodiments of this application, please refer to the description of the method embodiments in this application for understanding; they will not be repeated here.
[0289] The embodiments of this application have now been described in detail. To avoid obscuring the concept of this application, some details known in the art have not been described. Those skilled in the art can fully understand how to implement the technical solutions disclosed herein based on the above description.
[0290] While specific embodiments of this application have been described in detail by way of examples, those skilled in the art should understand that the above examples are for illustrative purposes only and are not intended to limit the scope of this application. Those skilled in the art should understand that modifications can be made to the above embodiments or equivalent substitutions can be made to some technical features without departing from the scope and spirit of this application. In particular, as long as there is no structural conflict, the various technical features mentioned in the embodiments can be combined in any manner.
Claims
1. A method for parsing waveform recording files, characterized in that, include: Determine the time variable matrix of the waveform file; Determine the analog variable matrix of the waveform recording file; Determine the digital variable matrix of the waveform file; The time variable matrix, the analog variable matrix, and the digital variable matrix are concatenated from left to right to obtain the parsed waveform file parsing matrix. Before determining the time variable matrix of the waveform recording file, the method further includes: Obtain the binary data of the waveform recording file; Convert the binary data to hexadecimal; The data after hexadecimal conversion is processed according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data; The time variable matrix, the analog variable matrix, and the digital variable matrix are determined based on the intermediate processing data. Determining the time variable matrix based on the intermediate processing data includes: The intermediate processing data is written into the first matrix as an unsigned 16-bit integer data type; The first matrix is extracted according to formula (1) to obtain the second matrix; data2=data1(3,:)+data1(4,:)*65536 (1) The second matrix is transposed to obtain the time variable matrix; Where data1 is the first matrix, data1(3,:) is the third row of the first matrix, data1(4,:) is the fourth row of the first matrix, and data2 is the second matrix; The analog variable matrix of the waveform file is determined based on the intermediate processing data, including: The intermediate processing data is written into the third matrix as a signed 16-bit integer data type; The third matrix is extracted according to formula (2) to obtain the fourth matrix; data4=data3(5:4+Ana_Ch,:) (2) The fourth matrix is transposed to obtain the simulation variable matrix; Among them, data3 is the third matrix, Ana_Ch is the total number of analog variable channels in the waveform recording file, and data4 is the fourth matrix; The digital variable matrix of the waveform file is determined based on the intermediate processing data, including: The intermediate processing data is written into the fifth matrix as an unsigned 16-bit integer. The fifth matrix is extracted according to formula (3) to obtain the sixth matrix; data6=data5(5+Ana_Ch:4+dNum+Ana_Ch,:) (3) The data in the sixth matrix is processed into 16-bit binary and stored in the seventh matrix according to the rule of low-order bits on the right and high-order bits on the left. The seventh matrix is transposed to obtain the eighth matrix; The eighth matrix is reorganized to obtain the ninth matrix; Transpose the ninth matrix to obtain the tenth matrix; The tenth matrix is extracted according to formula (4) to obtain the numerical variable matrix; data11=data10(:,1:Dig_Ch) (4) In this matrix, data5 is the fifth matrix, Ana_Ch is the total number of analog variable channels in the waveform file, dNum = (Dig_Ch+7) / 16 or dNum = ceil(Dig_Ch / 16)=1, ceil is the round-up function, Dig_Ch is the total number of digital channels in the waveform file, data6 is the sixth matrix, data10 is the tenth matrix, and data11 is the eleventh matrix.
2. A waveform recording file parsing system, used to perform the method as described in claim 1, characterized in that, include: The first determining module is used to determine the time variable matrix of the waveform recording file; The second determining module is used to determine the analog variable matrix of the waveform recording file; The third determining module is used to determine the digital variable matrix of the waveform recording file; The splicing module is used to splice the time variable matrix, the analog variable matrix, and the digital variable matrix from left to right to obtain the parsed waveform file parsing matrix. The acquisition module is used to acquire the binary data of the waveform recording file; The conversion module is used to convert the binary data into hexadecimal; The processing module is used to process the binary data according to the rule of two bytes per unit, with the least significant byte on the right and the most significant byte on the left, to obtain intermediate processed data.
3. An electronic device, characterized in that, include: Processor, memory, bus; The processor and the memory communicate with each other via the bus. The processor is used to invoke program instructions in the memory to execute the method as described in claim 1.
4. A computer-readable storage medium, characterized in that, include: Stored programs; During the execution of the program, the device containing the storage medium is controlled to perform the method as described in claim 1.
Citation Information
Patent Citations
Binary file analysis method, apparatus and device, and storage medium
CN107704567A
Arbitrary digital optical matrix calculation method and system, terminal and medium
CN115409167A