[go: up one dir, main page]

CN119675821A - Data encoding method, system, intelligent terminal and storage medium - Google Patents

Data encoding method, system, intelligent terminal and storage medium Download PDF

Info

Publication number
CN119675821A
CN119675821A CN202411259601.4A CN202411259601A CN119675821A CN 119675821 A CN119675821 A CN 119675821A CN 202411259601 A CN202411259601 A CN 202411259601A CN 119675821 A CN119675821 A CN 119675821A
Authority
CN
China
Prior art keywords
data
length
type
encoded
estimated
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411259601.4A
Other languages
Chinese (zh)
Inventor
邹国伟
王水
梁玉生
朱少峰
沈文军
杨志强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CYG Sunri Co Ltd
Original Assignee
CYG Sunri Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CYG Sunri Co Ltd filed Critical CYG Sunri Co Ltd
Priority to CN202411259601.4A priority Critical patent/CN119675821A/en
Publication of CN119675821A publication Critical patent/CN119675821A/en
Pending legal-status Critical Current

Links

Landscapes

  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The application is applicable to the technical field of data communication and provides a data coding method, a system, an intelligent terminal and a storage medium, wherein the method comprises the steps of obtaining data to be coded and identifying the data type of the data to be coded; if the data type of the data to be coded is a complex type, the number and the data type of data items in the data to be coded are obtained, the coding estimated length of the data to be coded is determined according to the number and the data type of the data items, and data coding is carried out based on the coding estimated length of the data to be coded. The application can quickly encode the transmitted big data, and improves the encoding efficiency and the data transmission efficiency.

Description

Data encoding method, system, intelligent terminal and storage medium
Technical Field
The present application relates to the field of data communications technologies, and in particular, to a data encoding method, a system, an intelligent terminal, and a storage medium.
Background
With the continuous development of the power system, the power dispatching automation system gradually develops towards the intelligent direction, the data message interaction is carried out in the main station/station end or the client/server end structure system of the power dispatching system, and the client/server end needs to carry out network byte stream serialization and deserialization on data to be transmitted according to a certain rule, and the process is generally called as a coding and decoding process.
When the client and the server transmit data, how to rapidly encode the transmitted big data, so that the encoding efficiency and the data transmission efficiency are improved, and the problem to be considered currently is solved.
Disclosure of Invention
The embodiment of the application provides a data coding method, a system, an intelligent terminal and a storage medium, which can be used for rapidly coding transmitted big data and improving coding efficiency and data transmission efficiency.
In a first aspect, an embodiment of the present application provides a data encoding method, including:
acquiring data to be encoded, and identifying the data type of the data to be encoded;
If the data type of the data to be encoded is a basic type, determining the encoding estimation length of the data to be encoded according to a basic type estimation rule;
If the data type of the data to be coded is complex, acquiring the number and the data type of data items in the data to be coded, and determining the coding estimated length of the data to be coded according to the number and the data type of the data items;
and carrying out data coding based on the coding estimated length of the data to be coded.
In a possible implementation manner of the first aspect, the base type includes a fixed-length type and a non-fixed-length type, and if the data type of the data to be encoded is the base type, determining the estimated encoding length of the data to be encoded according to a base type estimation rule includes:
If the data type of the data to be encoded is a fixed length type, determining the encoding estimated length of the data to be encoded according to an encoding length comparison table;
If the data type of the data to be coded is a non-fixed length type, determining the coding estimated length of the data to be coded according to an estimated factor corresponding to the non-fixed length type.
In a possible implementation manner of the first aspect, the non-fixed length type includes a first non-fixed length type, the estimation factor includes a default value, and if the data type of the data to be encoded is a non-fixed length type, determining, according to the estimation factor corresponding to the non-fixed length type, an estimated encoding length of the data to be encoded includes:
When the data type of the data to be coded is a first non-fixed length type, acquiring a default value corresponding to the first non-fixed length type;
comparing the data value of the data to be encoded with the default value;
if the data value to be encoded is equal to the default value, the encoding estimated length of the data to be encoded is zero;
And if the data value of the data to be encoded is not equal to the default value, determining the encoding estimated length of the data to be encoded according to the first non-fixed length type and the default value.
In a possible implementation manner of the first aspect, the non-fixed length type includes a second non-fixed length type, the estimation factor includes a value range constraint, and if the data type of the data to be encoded is a non-fixed length type, determining, according to the estimation factor corresponding to the non-fixed length type, an estimated encoding length of the data to be encoded includes:
When the data type of the data to be encoded is a second non-fixed length type, judging whether the data to be encoded has value range constraint;
If the value range constraint exists, determining the coding estimated length of the data to be coded according to a coding length comparison table;
And if the value range constraint does not exist, determining the coding estimated length of the data to be coded according to the second non-fixed length type.
In a possible implementation manner of the first aspect, the determining, according to the number of the data items and the data type, an estimated encoding length of the data to be encoded includes:
When the data type of the data item is complex, estimating the length of the preamble redundancy amount and the occupying length of the number of the data item in the data to be encoded according to the number of the data item;
acquiring the number and the data type of the sub-item data in the data item, and determining the coding estimated length of the data item according to the number and the data type of the sub-item data;
And determining the coding estimated length of the data to be coded according to the coding estimated length of each data item in the data to be coded, the length of the lead redundancy quantity and the accumulated result of the number occupying length of the data item.
In a possible implementation manner of the first aspect, after the determining the estimated length of the encoding of the data item, the method further includes:
comparing the estimated encoding length of the data item with a preset data item length threshold;
if the estimated coding length of the data item is smaller than the preset data item length threshold, continuing to determine the estimated coding length of the next data item;
And if the estimated encoding length of the data item is greater than or equal to the preset data item length threshold, framing a previous data item of the data item before continuing to determine the estimated encoding length of the next data item, wherein the framing mark is used for identifying a framing position.
In a possible implementation manner of the first aspect, the data encoding based on the estimated encoding length of the data to be encoded includes:
if the coding estimated length of the data to be coded is larger than the preset coding length, carrying out framing treatment on the data to be coded according to the framing mark of the data item in the data to be coded to obtain framing data of the data to be coded;
And carrying out data coding based on the framing data.
In a second aspect, an embodiment of the present application provides a data encoding system, including:
The data and type acquisition unit is used for acquiring data to be encoded and identifying the data type of the data to be encoded;
the first length estimation unit is used for determining the coding estimation length of the data to be coded according to a basic type estimation rule if the data type of the data to be coded is a basic type;
the second length estimation unit is used for acquiring the number and the data type of the data items in the data to be coded if the data type of the data to be coded is a complex type, and determining the coding estimation length of the data to be coded according to the number and the data type of the data items;
and the data coding unit is used for carrying out data coding based on the coding estimated length of the data to be coded.
In a third aspect, an embodiment of the present application provides an intelligent terminal, including a memory, a processor, and a computer program stored in the memory and running on the processor, where the processor implements the data encoding method according to the first aspect when executing the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program which, when executed by a processor, implements a data encoding method as described in the first aspect above.
In a fifth aspect, embodiments of the present application provide a computer program product for causing a smart terminal to perform the data encoding method as described in the first aspect above, when the computer program product is run on the smart terminal.
In the embodiment of the application, the intelligent terminal obtains the data to be encoded, identifies the data type of the data to be encoded, determines the encoding estimation length of the data to be encoded according to the data type, determines the encoding estimation length of the data to be encoded according to the basic type estimation rule if the data type of the data to be encoded is the basic type, obtains the number and the data type of data items in the data to be encoded if the data type of the data to be encoded is the complex type, determines the encoding estimation length of the data to be encoded according to the number and the data type of the data items, and finally performs data encoding based on the encoding estimation length of the data to be encoded. The application adaptively selects a proper estimation mode according to the data type to carry out the coding length estimation, is favorable for improving the accuracy of the coding length estimation, and then carries out data coding on the data to be coded based on the coding estimation length, thereby being capable of rapidly determining whether the data to be coded needs framing processing and improving the coding efficiency and the data transmission efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an implementation of a data encoding method provided by an embodiment of the present application;
FIG. 2 is a flowchart of a specific implementation of determining an estimated coding length according to an estimation factor in a data coding method according to an embodiment of the present application;
FIG. 3 is a flowchart of another embodiment of a method for encoding data according to an embodiment of the present application, wherein the method includes determining an encoding estimated length according to an estimation factor;
FIG. 4 is a flowchart of a specific implementation of estimating a coding estimation length of data to be coded of a complex type in a data coding method according to an embodiment of the present application;
FIG. 4.1 is a schematic diagram of a data structure of a read data value service response in a data encoding method according to an embodiment of the present application;
FIG. 4.2 is a schematic diagram of data constructed in a data encoding method according to an embodiment of the present application;
FIG. 5 is a flowchart of a specific implementation of identifying framing positions in a data encoding method according to an embodiment of the present application;
FIG. 6 is a block diagram of a data encoding system according to an embodiment of the present application;
Fig. 7 is a schematic diagram of an intelligent terminal provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Furthermore, the terms "first," "second," "third," and the like in the description of the present specification and in the appended claims, are used for distinguishing between descriptions and not necessarily for indicating or implying a relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The data coding method provided by the embodiment of the application can be applied to various intelligent terminals or servers which need data coding transmission, and can specifically comprise mobile phones, tablet computers, wearable equipment, notebook computers, desktop computers and the like. The embodiment of the application does not limit the specific types of the intelligent terminal and the server.
Fig. 1 shows an implementation flow of a data encoding method provided by an embodiment of the present application, where the method flow includes steps S101 to S104. The specific implementation principle of each step is as follows:
Step S101, obtaining data to be encoded and identifying the data type of the data to be encoded.
In general, the data to be encoded is data that needs to be transmitted. The scheme of the application relies on the DL/T860 communication specification, and the data to be encoded is any data conforming to the communication specification.
In this embodiment, before transmitting data, the data to be encoded is obtained, and the data type of the data to be encoded is identified. The data types of the data to be encoded may be divided into basic types, which refer to predefined, built-in, simple data types in a programming language, which may generally be mapped directly to the underlying hardware representation (e.g., integer, floating point number, character, etc.), and which need not be explicitly defined by classes or other structures. A complex type is a data type that is constituted in a certain way by data of a base type.
In an embodiment of the present application, the complex types include ARRAY types (ARRAY) and structure types (STRUCT). An array type is understood to be a set of data of the same type, and a structure type is a new type composed of one or more types combined together. In one embodiment, the type identified by ARRAY or STRUCT is a complex type.
Step S102, if the data type of the data to be encoded is the basic type, determining the encoding estimation length of the data to be encoded according to the basic type estimation rule.
The base type estimation rule is a predefined length estimation rule for the base type data. In this embodiment, the basic types include a fixed length type and a non-fixed length type.
In this embodiment, if the data type of the data to be encoded is a fixed-length type, the estimated encoding length of the data to be encoded is determined according to an encoding length comparison table.
If the data type of the data to be encoded is a fixed length type, the length of the encoded byte is a fixed length, and the encoding estimated length of the data to be encoded can be directly determined according to the encoding length comparison table. The code length comparison table comprises a mapping relation between the data type and the code length. That is, the coding estimation length of the data to be coded of the basic type can be estimated directly by a table look-up mode.
If the data type of the data to be encoded is a non-fixed length type, the length of the encoded byte is not fixed, and the encoding estimated length of the data to be encoded is determined according to the estimation factor corresponding to the non-fixed length type. In this embodiment, the non-fixed-length type is a "special" base type. The non-fixed length type comprises a first non-fixed length type and a second non-fixed length type, and the estimation factor comprises a default value and a value range constraint.
As a possible implementation manner of the application, the non-fixed-length type comprises a first non-fixed-length type, the estimation factor comprises a default value, and the first non-fixed-length type is a basic type with the default value.
As shown in fig. 2, if the data type of the data to be encoded is a non-fixed-length type, the step of determining the estimated encoding length of the data to be encoded according to the estimation factor corresponding to the non-fixed-length type includes:
a1, when the data type of the data to be coded is a first non-fixed length type, acquiring a default value corresponding to the first non-fixed length type. The first non-fixed length type includes a BOOL type.
A2, comparing the data value of the data to be coded with the default value.
A3, if the data value to be coded is equal to the default value, the coding estimated length of the data to be coded is zero.
And a4, if the data value of the data to be coded is not equal to the default value, determining the coding estimated length of the data to be coded according to the first non-fixed length type and the default value. Specifically, the coding estimated length of the data to be coded is determined according to the byte length corresponding to the default value.
In this embodiment, some specific basic types may agree with a default value, and if the types are included in the encoded data, and the data value corresponding to the type is the agreed default value, then the default value does not participate in compiling, that is, the byte length after compiling is not increased. When the data value corresponding to the type is not the default value of the convention, the default value needs to participate in compiling, and the length of the bytes after compiling is increased. The default value is taken as an estimation factor to be taken into the estimation of the compiling length, so that the estimation accuracy can be improved.
As a possible embodiment of the present application, the non-fixed length type includes a second non-fixed length type, and the estimation factor includes a value range constraint.
As shown in fig. 3, if the data type of the data to be encoded is a non-fixed-length type, the step of determining the estimated encoding length of the data to be encoded according to the estimation factor corresponding to the non-fixed-length type includes:
and b1, judging whether the data to be encoded has value range constraint or not when the data type of the data to be encoded is a second non-fixed length type. The second non-fixed length type of data includes integer data, bit string type, and word string type. Integer data includes signed and unsigned, etc. of int8, int16, int32, int 64. The string type includes OCTSRT, VSTR, UTF STR.
And b2, if the value range constraint exists, determining the coding estimated length of the data to be coded according to a coding length comparison table.
And b3, if the value range constraint does not exist, determining the coding estimated length of the data to be coded according to the second non-fixed length type.
In this embodiment, the range of values may be constrained for integer data. In practical use, the number of bytes occupied in coding is fixed length for the number with clear upper and lower value range (maximum value and minimum value) boundary by combining bit number characteristic classification, otherwise, the length of the length bit identification data is increased for the variable length type coding. For example, INT32, which encodes a length bit of 1 byte in the PER of asn.1 plus the minimum occupied byte required to store the data value, the accuracy of the estimation can be improved by combining the consideration of the value range constraint in the encoded length estimation.
There is no value range constraint for the bit string type and the word string type. In some embodiments, if there is no value range constraint, determining an estimated encoding length of the data to be encoded according to the data length occupation and the data value occupation.
Illustratively, bit string BITSRT contains three pieces of information in total, strLen (number of bytes), bitNum (number of bits actually used), str (actual data). This type has no preamble in asn.1 coding, i.e. there is no need to add preamble redundancy control bits, where the data length range is defined as INT8, which is single byte, and the data value length is (bitNum +8)/8, then the BITSTR type code estimation length=sizeof (st_int8) + (bitNum +8)/8, where sizeof () is the size of the spatial byte used to count the type, i.e. the data length takes a bit plus the data value takes a bit. The method for estimating the encoding length of the three strings OCTSRT, VSTR, UTF STR is similar to the method for estimating the encoding length of the bit string, namely the data length occupies a bit and the data value occupies a bit.
In a possible implementation manner, in the step of determining the estimated encoding length of the data to be encoded according to the first non-fixed length type and the default value, the influence of the estimation factor value range constraint is further included, that is, the estimated encoding length of the data to be encoded is determined according to the first non-fixed length type, the default value and the value range constraint.
Step 103, if the data type of the data to be coded is complex, the number and the data type of the data items in the data to be coded are obtained, and the coding estimated length of the data to be coded is determined according to the number and the data type of the data items.
The data to be coded of the complex type comprises a plurality of data items, the data types corresponding to the data items may be different, and the coding estimated length of the data to be coded of the complex type cannot be determined directly by a table look-up mode. For example, the data to be encoded includes data item 1 and data item 2, the data item 1 being a base type, the data item 2 being a complex type of data consisting of sub-item data 2.1 and sub-item data 2.2. In this embodiment, the estimated encoding length of the data to be encoded is determined according to the number of data items in the data to be encoded and the data type of each data item.
As a possible implementation manner of the present application, fig. 4 shows a specific implementation procedure of determining the estimated coding length of the data to be coded according to the number of the data items and the data type in the data coding method provided by the embodiment of the present application, which is described in detail below:
A1, when the data type of the data item is complex, estimating the length of the leading redundancy quantity and the occupying length of the number of the data item in the data to be encoded according to the number of the data item.
The preamble redundancy amount is a bit string for identifying whether an optional data item exists in the complex type of data to be encoded. The bit length occupied by the preamble redundancy is the preamble redundancy length. The bit length occupied by the preamble redundancy amount does not exceed the number of data items. The number of data items is the number of bytes required for encoding the number of data items. The preamble redundancy is expressed in terms of bits, and how many data items require how many bits to represent. For example, 10 data items, such as 10 bits, are required to be converted into 2 bytes, and the number of the data items is only one Byte to represent the space length, and one Byte can represent the numerical range [ 0-255 ].
A2, obtaining the number and the data type of the sub-item data in the data item, and determining the coding estimated length of the data item according to the number and the data type of the sub-item data. The complex type data item comprises a plurality of sub item data, and the data item types of the sub item data can be the same or different. For sub-item data of the base type.
A3, determining the coding estimated length of the data to be coded according to the coding estimated length of each data item in the data to be coded, the length of the lead redundancy quantity and the accumulated result of the number occupying length of the data items.
When the sub item data is of a complex type, estimating the length of the sub item leading redundancy in the data item and the occupying length of the number of the sub item data according to the number of the sub item data, acquiring the number of sub item unit data in the sub item data and the data type, determining the coding estimated length of the sub item data according to the number of the sub item unit data and the data type, and determining the coding estimated length of the data item according to the accumulated result of the coding estimated length of each sub item data in the data item, the length of the sub item leading redundancy and the occupying length of the number of the sub item data. Similarly, when the sub item unit data in the sub item data is of a complex type, the encoding estimation length of the sub item data can be estimated with reference to the above steps A1 to A4.
Before the asn.1 actually encodes the complex structure, some necessary information of the complex structure is encoded, including information of whether the data item options exist, the number of data items, etc., which makes the number of encoded bytes slightly larger. In this embodiment, when estimating the estimated length of the data to be encoded, the length of the preamble redundancy and the occupied length of the number of data items are included into the estimation factors, so that the length of some necessary information codes of the asn.1 coding complex structure can be ensured to be covered, the whole estimated length is ensured not to be smaller than the actual coding length, and the accuracy and the effectiveness of the estimation can be improved.
As a possible embodiment of the present application, when a data item in data to be encoded of a complex type is a base type, the encoding estimation length of the data item is determined according to a base type estimation rule.
In this embodiment, when the data type of the data item is a fixed-length type in the basic type, the encoding estimated length of the data item is determined according to the encoding length comparison table, when the data type of the data item is a non-fixed-length type in the basic type, the encoding estimated length of the data item is determined according to the data type of the data item and the estimation factor corresponding to the data type, and then the encoding estimated length of the data item to be encoded is determined according to the accumulation result of the encoding estimated lengths of the data items in the data to be encoded. The specific process of determining the estimated encoding length of the data item according to the data type of the data item and the estimation factor corresponding to the data type refers to the specific step of determining the estimated encoding length of the data to be encoded according to the estimation factor corresponding to the non-fixed length type, which is not described herein.
In this embodiment, for the encoding length estimation of the non-fixed-length type data item in the data to be encoded, the estimation factors such as the default value, the value range constraint and the like are taken into consideration, so that the estimation accuracy can be further improved. In the practical application process, the configuration mode can be combined with the practical requirement to select the included estimation factors, so that smaller granularity control is realized.
Illustratively, the data structure of the read data value service response is shown in fig. 4.1, the moreFollows variable is of the boolean type, the default value is TRUE, the data constructed for it is shown in fig. 4.2, there are two data to be encoded in the read data value service response data, moreFollows is indicated as whether there are subsequent frames of the boolean type, dataValue is of the ARRAY type, dataValue has one sub item data stucture, stucture is of the STRUCT type, and stucture has sub item unit data containing 2 basic types, respectively boolean type and INT32 integer. The service response data of the read data value is of a STRUCT type, the length of the leading redundancy is estimated to be 1Byte, the number of data to be coded is estimated to be 1Byte, the non-ARRAY type subitem moreFollows is required to be estimated preferentially when the length of the data to be coded is estimated, the Boolean type is estimated to be 1Byte, the ARRAY ARRAY type leading redundancy is estimated to be 1Byte, the number of data to be coded of the ARRAY is estimated to be 1Byte, the number of subitem data of the STRUCT is estimated to be 1Byte, the Boolean type is estimated to be 1Byte, and the INT32 type is estimated to be 4Byte. The read data value service responds to the coding of the data with an initial estimate of 1+1+1+1+1+1+1+4=12 Bytes, a total code length of 8Bytes, a morefollows value of TRUE, no participation in the coding at this point moreFollows, a code of "00011002 1CC00103", a code length error of 4 Bytes from the initial estimate, and a code of "80011002 1CC00103 00" for 9Bytes if the moreFollows value is set to FALSE with the remainder unchanged, and an error of 3 Bytes from the initial estimate of 12 Bytes without consideration of the default value. Further, if the constraint range is further included, the estimated length of the original 4Byte of the INT32 type is corrected to be 2Byte, then the overall estimated value is changed from 12Byte to 10Byte, and at this time, the error is reduced to 1Byte compared with the encoding result with moreFollows value set as FALSE.
In the embodiment of the application, the encoding length of the data to be encoded is estimated, so that a rapid and effective framing strategy can be provided when the transmission data volume is large.
And step S104, data encoding is carried out based on the encoding estimated length of the data to be encoded.
The substation secondary system communication message specification is taken as an important part in the power automation communication network and system, and defines a communication service mechanism, a data frame format and a communication process. After the client and the server establish the TCP connection, an association negotiation service is initiated first, where the service agrees with other service parameters such as an Application Protocol Data Unit (APDU) and an Application Service Data Unit (ASDU) maximum length, where the APDU and ASDU values define the maximum length of the application data complete frame. If a large data is needed to be transmitted between the client and the server and the byte number of the data after ASN.1 coding exceeds the maximum value of ASDU agreed by the association negotiation service, the data needs to be effectively framed at the application layer, and the integrity of the data cannot be destroyed.
As a possible implementation manner of the present application, fig. 5 shows a specific implementation flow of identifying a framing position in the data encoding method provided by the embodiment of the present application, which is described in detail below:
B1, after the coding estimated length of the data item is determined, comparing the coding estimated length of the data item with a preset data item length threshold. The preset data item length threshold is agreed ASDUSize.
B2, if the estimated encoding length of the data item is smaller than the preset data item length threshold, continuing to determine the estimated encoding length of the next data item;
And B3, if the estimated encoding length of the data item is greater than or equal to the preset data item length threshold, framing the previous data item of the data item before continuing to determine the estimated encoding length of the next data item, wherein the framing mark is used for identifying the framing position.
In this embodiment, the estimated length of the code of the data item is determined every time, the estimated length of the code is required to be accumulated, the index value of the data item identification is added by 1, the accumulated value of the estimated length of the code is compared with the agreed ASDUSize size, if the accumulated value is smaller than ASDUSize, the estimated length of the code of the next data item is determined, if the accumulated value is larger than ASDUSize, the length of the data item after the code is considered to be longer than ASDUSize, the data to be encoded needs to be framed, after framing the previous data item of the data item is marked, the index value of the data item identification needs to be subtracted by one, because the length of the last index position data after the code is closest to ASDUSize, and the framing position of the data can be determined according to the framing mark.
In the embodiment of the application, if the coding estimated length of the data to be coded is greater than the preset coding length, the data to be coded can be subjected to framing processing directly according to the framing mark of the data item in the data to be coded, so that the framing data of the data to be coded is obtained, the rapid framing processing is realized, and then the data coding is performed based on the framing data, so that the coding efficiency and the data transmission efficiency can be improved.
In this embodiment, the real-time encoding length can be estimated simultaneously when the data structure of the data to be encoded is traversed once, and meanwhile, the framing position can be determined, so that framing processing can be rapidly realized when the data volume is too large, which is beneficial to reducing the framing times and improving the encoding efficiency and the data transmission efficiency.
In some embodiments, the real-time estimated value and the framing mark in the temporary storage estimation process are used, and released after the encoding estimated length estimation is completed, so that the storage space is not needed to be occupied, and the storage space occupancy rate is low.
In one possible implementation manner, if the estimated length of the data to be encoded is greater than the preset encoding length and the data to be encoded cannot be subjected to framing processing, discarding the data to be encoded, and sending a discarding notification to a sender of the data to be encoded to inform the sender that the data to be encoded cannot be encoded and sent.
From the above, in the embodiment of the present application, the coding length estimation is performed by adaptively selecting a suitable estimation mode according to the data type, which is favorable for improving the accuracy of coding length estimation, and then the data to be coded is coded based on the coding estimation length, so that it can be quickly determined whether the data to be coded needs framing processing, and the coding efficiency and the data transmission efficiency are improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Corresponding to the data encoding method described in the above embodiments, fig. 6 shows a block diagram of a data encoding system provided in an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown.
Referring to fig. 6, the data encoding system includes a data and type acquisition unit 61, a first length estimation unit 62, a second length estimation unit 63, a data encoding unit 64, wherein:
A data and type obtaining unit 61, configured to obtain data to be encoded, and identify a data type of the data to be encoded;
A first length estimation unit 62, configured to determine, if the data type of the data to be encoded is a base type, an estimated encoding length of the data to be encoded according to a base type estimation rule;
A second length estimation unit 63, configured to obtain the number and the data type of the data items in the data to be encoded if the data type of the data to be encoded is a complex type, and determine an estimated encoding length of the data to be encoded according to the number and the data type of the data items;
and a data encoding unit 64 for performing data encoding based on the encoding estimated length of the data to be encoded.
As a possible embodiment of the present application, the basic types include a fixed length type and a non-fixed length type, and the first length estimation unit 62 includes:
The first length estimation module is used for determining the coding estimated length of the data to be coded according to a coding length comparison table if the data type of the data to be coded is a fixed length type;
And the second length estimation module is used for determining the coding estimated length of the data to be coded according to the estimation factor corresponding to the non-fixed length type if the data type of the data to be coded is the non-fixed length type.
As a possible implementation manner of the present application, the non-fixed length type includes a first non-fixed length type, the estimation factor includes a default value, and the second length estimation module is specifically configured to:
When the data type of the data to be coded is a first non-fixed length type, acquiring a default value corresponding to the first non-fixed length type;
comparing the data value of the data to be encoded with the default value;
if the data value to be encoded is equal to the default value, the encoding estimated length of the data to be encoded is zero;
And if the data value of the data to be encoded is not equal to the default value, determining the encoding estimated length of the data to be encoded according to the first non-fixed length type and the default value.
As a possible implementation manner of the present application, the non-fixed length type includes a second non-fixed length type, and the estimation factor includes a value range constraint, where the second length estimation module is specifically configured to:
When the data type of the data to be encoded is a second non-fixed length type, judging whether the data to be encoded has value range constraint;
If the value range constraint exists, determining the coding estimated length of the data to be coded according to a coding length comparison table;
And if the value range constraint does not exist, determining the coding estimated length of the data to be coded according to the second non-fixed length type.
As a possible embodiment of the present application, the second length estimation unit 63 includes:
the first estimation module is used for estimating the length of the preamble redundancy amount and the occupying length of the number of the data items in the data to be encoded according to the number of the data items when the data type of the data items is complex;
The second estimation module is used for acquiring the number and the data type of the sub-item data in the data item and determining the coding estimation length of the data item according to the number and the data type of the sub-item data;
and the third length estimation module is used for determining the coding estimated length of the data to be coded according to the coding estimated length of each data item in the data to be coded, the length of the lead redundancy quantity and the accumulated result of the number occupying length of the data item.
As a possible embodiment of the present application, the data encoding system further includes:
The data item encoding method comprises the steps of comparing the encoding estimated length of a data item with a preset data item length threshold, continuously determining the encoding estimated length of the next data item if the encoding estimated length of the data item is smaller than the preset data item length threshold, and carrying out framing marking on the previous data item of the data item before continuously determining the encoding estimated length of the next data item if the encoding estimated length of the data item is larger than or equal to the preset data item length threshold, wherein the framing marking is used for marking the framing position.
As a possible embodiment of the present application, the data encoding unit 64 includes:
The framing processing module is used for framing the data to be encoded according to the framing mark of the data item in the data to be encoded if the encoding estimated length of the data to be encoded is greater than the preset encoding length, so as to obtain framing data of the data to be encoded;
And the encoding module is used for carrying out data encoding based on the framing data.
From the above, in the embodiment of the present application, the coding length estimation is performed by adaptively selecting a suitable estimation mode according to the data type, which is favorable for improving the accuracy of coding length estimation, and then the data to be coded is coded based on the coding estimation length, so that it can be quickly determined whether the data to be coded needs framing processing, and the coding efficiency and the data transmission efficiency are improved.
It should be noted that, because the content of information interaction and execution process between the above systems/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of any one of the data encoding methods as represented in fig. 1 to 5.
The embodiment of the application also provides an intelligent terminal, which comprises a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor realizes the steps of any one of the data coding methods shown in fig. 1 to 5 when executing the computer program.
Embodiments of the present application also provide a computer program product which, when run on an intelligent terminal, causes the intelligent terminal to perform the steps of implementing any one of the data encoding methods as represented in fig. 1 to 5.
Fig. 7 is a schematic diagram of an intelligent terminal according to an embodiment of the present application. As shown in fig. 7, the intelligent terminal 7 of this embodiment comprises a processor 70, a memory 71 and a computer program 72 stored in said memory 71 and executable on said processor 70. The steps of the respective data encoding method embodiments described above, such as steps S101 to S104 shown in fig. 1, are implemented when the processor 70 executes the computer program 72. Or the processor 70, when executing the computer program 72, performs the functions of the modules/units of the system embodiments described above, e.g., the functions of the units 61-64 of fig. 6.
By way of example, the computer program 72 may be partitioned into one or more modules/units that are stored in the memory 71 and executed by the processor 70 to complete the present application. The one or more modules/units may be a series of computer readable instruction segments capable of performing specific functions describing the execution of the computer program 72 in the intelligent terminal 7.
The intelligent terminal 7 may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of the intelligent terminal 7 and is not limiting of the intelligent terminal 7, and may include more or less components than illustrated, or may combine some components, or different components, e.g., the intelligent terminal 7 may further include input and output devices, network access devices, buses, etc.
The Processor 70 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the smart terminal 7, such as a hard disk or a memory of the smart terminal 7. The memory 71 may also be an external storage device of the smart terminal 7, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the smart terminal 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the smart terminal 7. The memory 71 is used for storing the computer program and other programs and data required by the intelligent terminal. The memory 71 may also be used for temporarily storing data that has been output or is to be output.
It should be noted that, because the content of information interaction and execution process between the above systems/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the system is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium can include at least any entity or system capable of carrying computer program code to a system/terminal device, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
The foregoing embodiments are merely illustrative of the technical solutions of the present application, and not restrictive, and although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that modifications may still be made to the technical solutions described in the foregoing embodiments or equivalent substitutions of some technical features thereof, and that such modifications or substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method of encoding data, comprising:
acquiring data to be encoded, and identifying the data type of the data to be encoded;
If the data type of the data to be encoded is a basic type, determining the encoding estimation length of the data to be encoded according to a basic type estimation rule;
If the data type of the data to be coded is complex, acquiring the number and the data type of data items in the data to be coded, and determining the coding estimated length of the data to be coded according to the number and the data type of the data items;
and carrying out data coding based on the coding estimated length of the data to be coded.
2. The method according to claim 1, wherein the base type includes a fixed-length type and a non-fixed-length type, and wherein if the data type of the data to be encoded is the base type, determining the estimated encoding length of the data to be encoded according to a base type estimation rule includes:
If the data type of the data to be encoded is a fixed length type, determining the encoding estimated length of the data to be encoded according to an encoding length comparison table;
If the data type of the data to be coded is a non-fixed length type, determining the coding estimated length of the data to be coded according to an estimated factor corresponding to the non-fixed length type.
3. The method of claim 2, wherein the non-fixed length type comprises a first non-fixed length type, the estimation factor comprises a default value, and wherein if the data type of the data to be encoded is a non-fixed length type, determining the estimated encoding length of the data to be encoded according to the estimation factor corresponding to the non-fixed length type comprises:
When the data type of the data to be coded is a first non-fixed length type, acquiring a default value corresponding to the first non-fixed length type;
comparing the data value of the data to be encoded with the default value;
if the data value to be encoded is equal to the default value, the encoding estimated length of the data to be encoded is zero;
And if the data value of the data to be encoded is not equal to the default value, determining the encoding estimated length of the data to be encoded according to the first non-fixed length type and the default value.
4. The method of claim 2, wherein the non-fixed length type comprises a second non-fixed length type, wherein the estimation factor comprises a value range constraint, wherein if the data type of the data to be encoded is a non-fixed length type, determining the estimated encoding length of the data to be encoded according to the estimation factor corresponding to the non-fixed length type comprises:
When the data type of the data to be encoded is a second non-fixed length type, judging whether the data to be encoded has value range constraint;
If the value range constraint exists, determining the coding estimated length of the data to be coded according to a coding length comparison table;
And if the value range constraint does not exist, determining the coding estimated length of the data to be coded according to the second non-fixed length type.
5. The method of claim 1, wherein determining the estimated length of the code of the data to be coded based on the number of data items and the data type comprises:
When the data type of the data item is complex, estimating the length of the preamble redundancy amount and the occupying length of the number of the data item in the data to be encoded according to the number of the data item;
acquiring the number and the data type of the sub-item data in the data item, and determining the coding estimated length of the data item according to the number and the data type of the sub-item data;
And determining the coding estimated length of the data to be coded according to the coding estimated length of each data item in the data to be coded, the length of the lead redundancy quantity and the accumulated result of the number occupying length of the data item.
6. The method of claim 5, further comprising, after said determining the estimated length of the encoding of the data item:
comparing the estimated encoding length of the data item with a preset data item length threshold;
if the estimated coding length of the data item is smaller than the preset data item length threshold, continuing to determine the estimated coding length of the next data item;
And if the estimated encoding length of the data item is greater than or equal to the preset data item length threshold, framing a previous data item of the data item before continuing to determine the estimated encoding length of the next data item, wherein the framing mark is used for identifying a framing position.
7. The method of claim 6, wherein the data encoding based on the estimated encoding length of the data to be encoded comprises:
if the coding estimated length of the data to be coded is larger than the preset coding length, carrying out framing treatment on the data to be coded according to the framing mark of the data item in the data to be coded to obtain framing data of the data to be coded;
And carrying out data coding based on the framing data.
8. A data encoding system, comprising:
The data and type acquisition unit is used for acquiring data to be encoded and identifying the data type of the data to be encoded;
the first length estimation unit is used for determining the coding estimation length of the data to be coded according to a basic type estimation rule if the data type of the data to be coded is a basic type;
the second length estimation unit is used for acquiring the number and the data type of the data items in the data to be coded if the data type of the data to be coded is a complex type, and determining the coding estimation length of the data to be coded according to the number and the data type of the data items;
and the data coding unit is used for carrying out data coding based on the coding estimated length of the data to be coded.
9. A smart terminal comprising a memory, a processor and a computer program stored in the memory and running on the processor, characterized in that the processor implements the data encoding method according to any of claims 1 to 7 when executing the computer program.
10. A computer readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the data encoding method according to any one of claims 1 to 7.
CN202411259601.4A 2024-09-09 2024-09-09 Data encoding method, system, intelligent terminal and storage medium Pending CN119675821A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411259601.4A CN119675821A (en) 2024-09-09 2024-09-09 Data encoding method, system, intelligent terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411259601.4A CN119675821A (en) 2024-09-09 2024-09-09 Data encoding method, system, intelligent terminal and storage medium

Publications (1)

Publication Number Publication Date
CN119675821A true CN119675821A (en) 2025-03-21

Family

ID=94995131

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411259601.4A Pending CN119675821A (en) 2024-09-09 2024-09-09 Data encoding method, system, intelligent terminal and storage medium

Country Status (1)

Country Link
CN (1) CN119675821A (en)

Similar Documents

Publication Publication Date Title
US8265407B2 (en) Method for coding and decoding 3D data implemented as a mesh model
US20230281385A1 (en) Fpga-based fast protocol decoding method, apparatus, and device
US11023412B2 (en) RDMA data sending and receiving methods, electronic device, and readable storage medium
CN118200141B (en) Semantic communication resource optimization method, device, equipment and storage medium
CN112202623A (en) Data processing method and device
CN112003814B (en) Market data processing method and device, terminal equipment and storage medium
CN115037700A (en) Complex network data packet transmission method, system, terminal and storage medium
CN108573069B (en) Twins method for accelerating matching of regular expressions of compressed flow
CN113613289B (en) Bluetooth data transmission method, system and communication equipment
CN119675821A (en) Data encoding method, system, intelligent terminal and storage medium
CN114615074B (en) Network message decoding method, network attack detection method, device and storage medium
CN110401458B (en) Data check coding method and system
CN116996490A (en) Image data transmission method, device, equipment and medium
CN115499393A (en) TCP connection message processing method based on network interface chip
US20150078674A1 (en) Component sorting based encoding for 3d mesh compression
CN116668691A (en) A picture compression transmission method, device and terminal equipment
CN115811516A (en) Method, device, equipment and medium for concurrently reporting multi-frame files
CN114726480A (en) Data encoding method and related device, electronic equipment and storage medium
CN109033189B (en) Compression method and device of link structure log, server and readable storage medium
CN113242473A (en) Data processing method and system, data acquisition equipment and readable storage medium
US10742783B2 (en) Data transmitting apparatus, data receiving apparatus and method thereof having encoding or decoding functionalities
CN113141409A (en) Data transmission method and device, terminal equipment and readable storage medium
CN111813718A (en) Log output method, device and equipment and readable storage medium
CN116847303B (en) 5G technology-based power data transmission and processing method and system
CN114697657B (en) A data processing method, device, equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination