A DLT698 protocol analysis method, system, device and medium
Through the DLT698 protocol analysis method, the power data APDU is parsed and the attribute ID is obtained, which solves the problem of insufficient flexibility in handling complex power data in traditional protocols, and realizes efficient processing and transmission of different types of power data to meet the complexity of power data. need.
Patent Information
- Application Number
- CN202411436338.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2044-10-15
AI Technical Summary
Traditional power network communication protocols lack flexibility and adaptability when facing complex power data, making it difficult to effectively process and transmit different types of power data, and cannot meet the complexity and diversification needs of power data.
By adopting the DLT698 protocol analysis method, by sending request frames to the target receiving device, receiving and parsing the response frames, obtaining user data APDU, and obtaining attribute IDs based on the object attribute descriptor for data analysis, improving the flexibility and adaptability of data processing and transmission .
It improves the processing and transmission capabilities of complex power data, meets the complexity and diversification needs of power data, and enhances the flexibility and adaptability of the system.
Smart Images

Figure CN118945245B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data analysis, and in particular to a DLT698 protocol analysis method, system, device and medium. Background Art
[0002] The DLT698 protocol is part of the Chinese power industry standard and is mainly used for data communication between devices in the power system. It is widely used in smart meters and distribution automation. The protocol has efficient data transmission, security, compatibility and real-time performance, and can quickly and reliably transmit large amounts of data to meet the power system's needs for real-time monitoring and control.
[0003] In traditional power network communication protocols, the data structure is relatively simple, and usually only fixed-format or fixed-size data can be transmitted. At the same time, power data is usually more complex, involving basic information such as real-time monitoring of current, voltage, and power, as well as multi-dimensional data such as equipment status, fault diagnosis, load forecasting, and energy management. However, the fixed format of traditional protocols limits their flexibility and adaptability when facing complex power data, which makes it difficult to effectively process and transmit different types of power data, and cannot meet the complex and diversified needs of power data. Summary of the invention
[0004] In order to improve the flexibility of data analysis, the present application provides a DLT698 protocol analysis method, system, device and medium.
[0005] In the first aspect, the present application provides a DLT698 protocol parsing method, which adopts the following technical solution:
[0006] A DLT698 protocol parsing method, comprising:
[0007] Sending a request frame to a target receiving device based on the DLT698 protocol, wherein the target receiving device sends a response frame in response to the request frame;
[0008] The response frame is received based on the DLT698 protocol, and the response frame is parsed to obtain the corresponding user data APDU;
[0009] Acquire a corresponding object attribute descriptor OAD according to the user data APDU, and acquire at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD;
[0010] The user data APDU is parsed according to the at least one attribute ID to obtain corresponding parsed data.
[0011] By adopting the above technical solution, a request frame is sent to the target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame, and then the response frame is received based on the DLT698 protocol, and the response frame is parsed to obtain the corresponding user data APDU, and then the corresponding object attribute descriptor OAD is obtained according to the user data APDU, and at least one attribute ID in the object attribute descriptor OAD is obtained according to the object attribute descriptor OAD. Finally, the user data APDU is parsed according to at least one attribute ID to obtain the corresponding parsed data. Compared with the data parsing method based on the traditional protocol, the flexibility and adaptability of processing and parsing complex power data are improved, which is conducive to the processing and transmission of different types of power data, and can better meet the current complex and diversified needs of power data.
[0012] Optionally, the step of parsing the user data APDU according to the at least one attribute ID to obtain corresponding parsed data includes:
[0013] Storing the at least one attribute ID into a predefined array to obtain a target array;
[0014] For the attribute ID in the target array, determine the entity class corresponding to the attribute ID according to the attribute ID, and determine the data type corresponding to the data in the user data APDU according to the attribute ID;
[0015] Determine the corresponding data length according to the data type and the predefined enumeration class;
[0016] Determine whether an error occurs in the user data APDU according to the attribute ID and the data length, and if not, read corresponding data from the user data APDU according to the attribute ID and the data length to obtain a corresponding data reading result;
[0017] The entity class corresponding to the attribute ID is initialized according to the attribute ID and the data reading result to obtain the corresponding parsed data.
[0018] By adopting the above technical solution, in order to obtain the corresponding parsed data, at least one attribute ID is first stored in a predefined array to obtain a target array, and then for the attribute ID in the target array, the entity class corresponding to the attribute ID is determined according to the attribute ID, and the data type corresponding to the data in the user data APDU is determined according to the attribute ID, and then the corresponding data length is determined according to the data type and the predefined enumeration class, and then it is determined whether an error occurs in the user data APDU according to the attribute ID and the data length. If no error occurs in the user data APDU, the corresponding data is read from the user data APDU according to the attribute ID and the data length to obtain the corresponding data reading result, and finally the entity class corresponding to the attribute ID is initialized according to the attribute ID and the data reading result to obtain the corresponding parsed data.
[0019] Optionally, the step of reading data from the user data APDU according to the attribute ID and the data length to obtain a corresponding data reading result includes:
[0020] Determine the starting position for data reading according to the attribute ID;
[0021] Corresponding data is read from the user data APDU according to the starting position and the data length to obtain a data reading result corresponding to the attribute ID.
[0022] By adopting the above technical solution, in order to obtain the corresponding data reading result, the starting position for data reading is first determined according to the attribute ID, and then the corresponding data is read from the user data APDU according to the starting position and data length to obtain the data reading result corresponding to the attribute ID.
[0023] Optionally, the step of sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sending a response frame in response to the request frame, includes:
[0024] The target requesting device acquires a communication mode with the target receiving device, and establishes a connection with the target receiving device according to the communication mode;
[0025] The target requesting device obtains the requested attribute description information and the device address of the target receiving device, and constructs a request frame according to the device address, the attribute description information and a predefined request frame format;
[0026] Sending the request frame to the target receiving device;
[0027] The target receiving device receives the request frame, and parses the request frame to obtain corresponding request content;
[0028] The target receiving device obtains a request result according to the request content, and constructs a response frame according to the request result and a predefined response frame format;
[0029] The target receiving device sends the response frame to the target requesting device.
[0030] By adopting the above technical solution, the target requesting device obtains the communication method between the target receiving device and the target receiving device, and establishes a connection with the target receiving device according to the communication method, then the target requesting device obtains the attribute description information of the request and the device address of the target receiving device, and constructs a request frame according to the device address, the attribute description information and the predefined request frame format, and then sends the request frame to the target receiving device, then the target receiving device receives the request frame, and parses the request frame to obtain the corresponding request content, then the target receiving device obtains the request result according to the request content, and constructs a response frame according to the request result and the predefined response frame format, and finally the target receiving device sends the response frame to the target requesting device.
[0031] Optionally, the step of the target requesting device acquiring a communication mode with the target receiving device and establishing a connection with the target receiving device according to the communication mode includes:
[0032] The target requesting device obtains the identity information of the target receiving device, and sends a communication mode query request to the target receiving device according to the identity information;
[0033] The target receiving device receives the communication mode query request, and determines whether there are multiple communication modes according to the communication mode query request, and if so, obtains communication parameters of the communication mode for each of the communication modes, the communication parameters including signal strength, transmission speed and communication delay, and normalizes the communication parameters to obtain corresponding normalized data;
[0034] Inputting the normalized data into a pre-generated fuzzy control model to obtain a corresponding fuzzy score;
[0035] Determining an optimal communication method according to the fuzzy score;
[0036] A connection is established between the target requesting device and the target receiving device according to the optimal communication mode.
[0037] By adopting the above technical solution, the target requesting device obtains the identity information of the target receiving device, and sends a communication mode query request to the target receiving device according to the identity information, and then the target receiving device receives the communication mode query request, and determines whether there are multiple communication modes according to the communication mode query request. If there are multiple communication modes, for each communication mode, the communication parameters of the communication mode are obtained, and the communication parameters include signal strength, transmission speed and communication delay, and the communication parameters are normalized to obtain corresponding normalized data, and then the normalized data is input into the pre-generated fuzzy control model to obtain the corresponding fuzzy score, and then the optimal communication mode is determined according to the fuzzy score, and finally the connection between the target requesting device and the target receiving device is established according to the optimal communication mode.
[0038] Optionally, the step of receiving the response frame based on the DLT698 protocol and parsing the response frame to obtain the corresponding user data APDU includes:
[0039] Receiving the response frame based on the DLT698 protocol, and extracting a check code from the response frame according to a predefined frame format;
[0040] Determine whether the user data APDU is complete according to the check code, if so, extract the user data APDU from the response frame, if not, generate error information.
[0041] By adopting the above technical solution, a response frame is first received based on the DLT698 protocol, and a check code is extracted from the response frame according to a predefined frame format. Then, whether the user data APDU is complete is determined based on the check code. If the user data APDU is complete, the user data APDU is extracted from the response frame. If the user data APDU is incomplete, an error message is generated.
[0042] Optionally, before the step of sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sending a response frame in response to the request frame, the step further includes:
[0043] Obtain a predefined interface class, and implement the predefined interface class to obtain a first entity class corresponding to the predefined interface class; the first entity class includes an electric energy class, a maximum demand class, a variable class, a time class, a parameter class, a collection and monitoring class, and a control class;
[0044] Acquire extended data types in the first entity class and the interface class, the extended data types including Array class, DateTime class, DateTimeS class and TSA class, and define a second entity class corresponding to the extended data type according to the extended data type;
[0045] A data type is obtained, wherein the data type includes an extended data type and a basic data type, and a corresponding enumeration class is defined according to the data type; the enumeration class includes a data type tag and a data length corresponding to the data type.
[0046] By adopting the above technical solution, a predefined interface class is first obtained, and the predefined interface class is implemented to obtain a first entity class corresponding to the predefined interface class, the first entity class includes an electric energy class, a maximum demand class, a variable class, a time class, a parameter class, a collection monitoring class, and a control class, and then the extended data types in the first entity class and the interface class are obtained, the extended data types include an Array class, a DateTime class, a DateTimeS class, and a TSA class, and a second entity class corresponding to the extended data type is defined according to the extended data type, and then the data type is obtained, the data type includes an extended data type and a basic data type, and the corresponding enumeration class is defined according to the data type. The enumeration class includes a data type tag and a data length corresponding to the data type.
[0047] In the second aspect, the present application also provides a DLT698 protocol parsing system, which adopts the following technical solution:
[0048] A DLT698 protocol analysis system, comprising:
[0049] A request frame sending module, used for sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame;
[0050] A user data APDU generation module is used to receive the response frame based on the DLT698 protocol, and parse the response frame according to a predefined frame format to obtain a corresponding user data APDU;
[0051] An attribute ID generating module, used for acquiring a corresponding object attribute descriptor OAD according to the user data APDU, and acquiring at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD;
[0052] The data parsing module is used to parse the user data APDU according to the at least one attribute ID to obtain corresponding parsed data.
[0053] In a third aspect, the present application also provides a computer device, which adopts the following technical solution:
[0054] A computer device comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the method described in the first aspect when executing the computer program.
[0055] In a fourth aspect, the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0056] A computer-readable storage medium stores a computer program that can be loaded by a processor and execute the method described in the first aspect.
[0057] In summary, the present application includes at least the following beneficial technical effects: sending a request frame to the target receiving device based on the DLT698 protocol, the target receiving device sending a response frame in response to the request frame, then receiving the response frame based on the DLT698 protocol, parsing the response frame to obtain the corresponding user data APDU, then obtaining the corresponding object attribute descriptor OAD according to the user data APDU, and obtaining at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD, and finally parsing the user data APDU according to at least one attribute ID to obtain the corresponding parsed data. Compared with the data parsing method based on the traditional protocol, the flexibility and adaptability of processing and parsing complex power data are improved, which is conducive to processing and transmitting different types of power data, and can better meet the current complex and diversified needs of power data. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 It is a schematic diagram of the overall process of an embodiment of the present application.
[0059] Figure 2 It is a schematic diagram of the structure of the response frame of the present application.
[0060] Figure 3 It is a schematic diagram of the structure of the system of this application.
[0061] Figure 4 It is a structural block diagram of the computer device of the present application. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of this application more clear, the following Figure 1-4 It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0063] The embodiment of the present application discloses a DLT698 protocol parsing method.
[0064] Reference Figure 1 , a DLT698 protocol parsing method, comprising:
[0065] Step S11, sending a request frame to the target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame.
[0066] Step S12, receiving a response frame based on the DLT698 protocol, and parsing the response frame to obtain a corresponding user data APDU.
[0067] It should be noted that in this application, reference Figure 2 , the response frame includes a frame header, APDU or APDU framing fragment and a frame tail. The frame header consists of a start character (68H), a length field L, a control field C, an address field A and a frame header check HCS. Specifically, the start character 68H indicates the beginning of the frame and is usually used to identify the starting position of the data packet; the length field L is used to indicate the length of the subsequent data to ensure that the receiver can correctly parse the data; the control field C contains control information to indicate the type or processing method of the data; the address field A is used to specify the target address of the data to ensure that the data can be sent to the correct receiver; the frame header check HCS is used to verify the integrity of the frame header to ensure that the data has not been tampered with during transmission. APDU or APDU framing fragment represents link user data, which is the actual data content transmitted and may contain user requests or other information. User data APDU is data extracted from APDU or APDU framing fragment; in the DLT698 protocol, user data APDU contains actual application layer data, which is the main carrier of messages transmitted from devices (such as smart meters) to clients (such as management systems). Usually, APDU consists of header information and payload (data part), which is used to specify the requested command, the data to be transmitted, and the status of the response. User data APDU is the encapsulation of commands for specific operations (such as reading and writing data), and carries the actual data in the communication. The frame tail consists of the frame check FCS and the end character (16H). The frame check FCS is used to verify the integrity of the entire frame to ensure that no errors occur during data transmission; the end character 16H is used to indicate the end of the frame and identify the end position of the data packet.
[0068] Step S13: acquiring a corresponding object attribute descriptor OAD according to the user data APDU, and acquiring at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD.
[0069] It should be noted that the object attribute descriptor OAD is the data extracted from the user data APDU. The object attribute descriptor OAD is a structure used to describe data objects and their attributes, and contains metadata such as the object's identifier, version, and type. In the DLT698 protocol, the object attribute descriptor OAD can help devices or systems identify and understand the specific characteristics of data objects, such as the definition of the object, the type of the attribute, etc. The object attribute descriptor OAD provides a standardized way to describe objects and ensure interoperability between different devices.
[0070] It should be further explained that the attribute ID is an identifier used in the object attribute descriptor OAD to uniquely identify an attribute of a specific object; in the DLT698 protocol, when requesting certain information about a specific object, the attribute ID helps the system quickly locate and access the specific attributes of the object. The attribute ID is usually a numeric type that can clearly identify the different attributes of the object.
[0071] Step S14, parsing the user data APDU according to at least one attribute ID to obtain corresponding parsed data.
[0072] In the above implementation, a request frame is sent to the target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame, and then the response frame is received based on the DLT698 protocol, and the response frame is parsed to obtain the corresponding user data APDU, and then the corresponding object attribute descriptor OAD is obtained according to the user data APDU, and at least one attribute ID in the object attribute descriptor OAD is obtained according to the object attribute descriptor OAD. Finally, the user data APDU is parsed according to at least one attribute ID to obtain the corresponding parsed data. Compared with the data parsing method based on the traditional protocol, the flexibility and adaptability of processing and parsing complex power data are improved, which is conducive to processing and transmitting different types of power data, and can better meet the current complex and diversified needs of power data.
[0073] As a further implementation of the parsing method, the step of parsing the user data APDU according to at least one attribute ID to obtain corresponding parsed data includes:
[0074] Step S21, storing at least one attribute ID into a predefined array to obtain a target array.
[0075] Step S22: for the attribute ID in the target array, determine the entity class corresponding to the attribute ID according to the attribute ID, and determine the data type corresponding to the data in the user data APDU according to the attribute ID.
[0076] Step S23, determining the corresponding data length according to the data type and the predefined enumeration class.
[0077] It should be noted that in the present application, the enumeration class predefined in step S23 includes a data type tag and a data length corresponding to the data type. In the predefined enumeration class, positive integers and negative integers are used to represent conventional data types (i.e., basic data types) and special data types (i.e., extended data types), respectively. For different data types, the corresponding data length and data parsing method are also different. If the data length is a positive integer, the data length is the length of the corresponding data content; when the data length is -1, it means that the actual length of the data is uncertain, and the byte obtained immediately after the data type is converted into decimal, which is the length of the data; when the data length is -2, it means that the actual length of the data is uncertain, and what is obtained immediately after the data type is not the length, but the number of elements, and then the length of each element is read one by one; when the data length is -3, it means that the data type is a combined data type, and the number of elements cannot be read from the subsequent bytes at this time, but the data type corresponding to the data length itself has the number of elements, such as SID (number of elements = 2), SID_MAC (3). Examples of data type tags and data lengths corresponding to data types are as follows:
[0078]
[0079] Among them, reserved types are reserved according to different types.
[0080] Step S24, judging whether the user data APDU has an error according to the attribute ID and the data length, if not, reading the corresponding data from the user data APDU according to the attribute ID and the data length to obtain the corresponding data reading result.
[0081] Specifically, determine whether there is an error in the user data APDU based on the attribute ID and the data length. If there is no error, read the corresponding data from the user data APDU based on the attribute ID and the data length to obtain the corresponding data reading result. If there is an error, generate a prompt message.
[0082] It should be noted that in this application, when the data length is 0, it means that an error occurs in the user data APDU, and an error message will be returned; when the data length is a positive integer, -1, -2 or -3, the data is read normally. In addition, when the data length is a negative number, it is necessary to call the format method in the entity class for data conversion.
[0083] Step S25, initializing the entity class corresponding to the attribute ID according to the attribute ID and the data reading result, and obtaining the corresponding parsed data.
[0084] It should be noted that each entity class defines a type of Map<String,Map> The local variable oadMap is used to store all objects under this class; wherein the key is the object identifier id, and the content includes the class identifier (classid), the parsed name (objName), the unit, and the number of decimal places (-1 means one decimal place, -2 means two decimal places, etc.); the entity class is used to parse the corresponding data. In step S25, the class identifier (class id), the parsed name (objName), the unit, and the number of decimal places corresponding to the attribute ID can be obtained from the local variable in the entity class according to the attribute ID;
[0085] It can be understood that if the message (i.e., the response frame) is: 68 92 00 C3 05 28 59 66 04 37 00 10EA 0E 90 00 79 85 03 00 50 04 02 00 04 00 20 21 02 00 00 00 10 02 00 00 00 2002 00 00 00 30 02 00 01 01 1C 07 E6 07 0E 00 00 00 01 05 06 00 02 64 25 06 0000 05 48 06 00 00 EC 48 06 00 01 5D C0 06 00 00 14 D4 01 05 06 00 00 00 00 0600 00 00 00 06 00 00 00 00 06 00 00 00 00 06 00 00 00 00 01 05 05 00 02 60 CD05 00 00 07 EB 05 00 00 DD 37 05 00 01 5F 17 05 00 00 1C 93 00 00 01 00 04 53F4 47 70 1A 8F 16. Among them, this message segment is in hexadecimal, 68 indicates the starting character; 92 00 indicates the message length, which is 146 in decimal; c3 indicates the control field; 05 indicates the address type and length (server address); 28 59 66 04 37 00 (negated 03704665928) indicates the specific address information; EA 0E indicates the frame header check, and 79 indicates the APDU length;
[0086] In the above message, the APDU is 85 03 00 50 04 02 00 04 00 20 21 02 00 00 0010 02 00 00 00 20 02 00 00 00 30 02 00 01 01 1C 07 E6 07 0E 00 00 00 01 05 0600 02 64 25 06 00 00 05 48 06 00 00 EC 48 06 00 01 5D C0 06 00 00 14 D4 01 0506 00 00 00 00 06 00 00 00 00 06 00 00 00 00 06 00 00 00 00 06 00 00 00 00 0105 05 00 02 60 CD 05 00 00 07 EB 05 00 00 DD 37 05 00 01 5F 17 05 00 00 1C 9300 00. 85 represents request response (GET-Response), O3 represents record-type object attribute (Get Response Record), in 85 03 00, 00 represents the service priority is general, if 00 is 01, it means the service priority is high; 50 04 0200 represents record-type object description OAD, 5004 is the attribute ID, 02 is the attribute, 00 is the index; 04 represents the number of associated object attributes; 00 20 21 02 00, 00 00 10 02 00, 00 00 20 02 00, and 00 00 30 02 00 are all associated objects, and 20 21, 00 10, 00 20, and 00 30 all represent attribute IDs of different data.During the parsing process, 50 04 is parsed first. 50 04 is a frozen class that only records the type and quantity. Then 20 21 is parsed. 20 21 indicates the data freezing time. The first digit is 2, which means that the corresponding entity class is a variable class. In 01 01 1C, the first 01 indicates that the result type is an array, the second 01 indicates the quantity 1, 1C indicates the data type 28-date_time_s, and the length is 7. 07 E6 07 0E00 00 00 indicates that the corresponding time is 2022-07-14 00 00 00; then 00 10 is parsed. 00 10 indicates positive active energy. 01 05 indicates the data type (01 indicates array, 05 indicates the quantity), and 06 indicates the data type (double-long-unsigned). The corresponding length is 4 digits and the decimal is 2 digits. The data 00 02 64 25 Convert to decimal: 156709*0.01= 1567.09, and then parse the subsequent messages according to the above parsing method.
[0087] In the above implementation, in order to obtain the corresponding parsed data, at least one attribute ID is first stored in a predefined array to obtain a target array, and then for the attribute ID in the target array, the entity class corresponding to the attribute ID is determined according to the attribute ID, and the data type corresponding to the data in the user data APDU is determined according to the attribute ID, and then the corresponding data length is determined according to the data type and the predefined enumeration class, and then it is determined whether an error occurs in the user data APDU according to the attribute ID and the data length. If no error occurs in the user data APDU, the corresponding data is read from the user data APDU according to the attribute ID and the data length to obtain the data reading result, and finally the entity class corresponding to the attribute ID is initialized according to the attribute ID and the data reading result to obtain the corresponding parsed data.
[0088] As a further implementation of the parsing method, the step of reading corresponding data from the user data APDU according to the attribute ID and the data length to obtain the corresponding data reading result includes:
[0089] Step S31, determining the starting position for data reading according to the attribute ID.
[0090] It can be understood that all object attribute descriptors (OADs) can be obtained from the APDU, and then the attribute IDs are stored in order as an array, and the pointer of the APDU data is moved to the end of the OAD.
[0091] Step S32, reading corresponding data from the user data APDU according to the starting position and the data length, and obtaining a data reading result corresponding to the attribute ID.
[0092] In the above implementation, in order to obtain the corresponding data reading result, the starting position for data reading is first determined according to the attribute ID, and then the corresponding data is read from the user data APDU according to the starting position and data length to obtain the data reading result corresponding to the attribute ID.
[0093] As a further implementation of the parsing method, the step of sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sending a response frame in response to the request frame, includes:
[0094] Step S41, the target requesting device obtains the communication mode between itself and the target receiving device, and establishes a connection with the target receiving device according to the communication mode.
[0095] Step S42: The target requesting device obtains the requested attribute description information and the device address of the target receiving device, and constructs a request frame according to the device address, the attribute description information and a predefined request frame format.
[0096] Step S43: Send the request frame to the target receiving device.
[0097] Step S44: the target receiving device receives the request frame and parses the request frame to obtain corresponding request content.
[0098] Step S45: The target receiving device obtains the request result according to the request content, and constructs a response frame according to the request result and a predefined response frame format.
[0099] Step S46: The target receiving device sends a response frame to the target requesting device.
[0100] In the above-mentioned embodiment, the target requesting device obtains the communication method between itself and the target receiving device, and establishes a connection with the target receiving device according to the communication method. Then, the target requesting device obtains the attribute description information of the request and the device address of the target receiving device, and constructs a request frame according to the device address, the attribute description information and the predefined request frame format, and then sends the request frame to the target receiving device. Then, the target receiving device receives the request frame and parses the request frame to obtain the corresponding request content. Then, the target receiving device obtains the request result according to the request content, and constructs a response frame according to the request result and the predefined response frame format. Finally, the target receiving device sends the response frame to the target requesting device.
[0101] As a further implementation of the parsing method, the step of the target requesting device acquiring the communication mode between the target receiving device and the target receiving device, and establishing a connection with the target receiving device according to the communication mode, includes:
[0102] Step S51, the target requesting device obtains the identity information of the target receiving device, and sends a communication mode query request to the target receiving device according to the identity information.
[0103] Step S52, the target receiving device receives a communication mode query request, and determines whether there are multiple communication modes based on the communication mode query request. If so, for each communication mode, the communication parameters of the communication mode are obtained, and the communication parameters include signal strength, transmission speed and communication delay, and the communication parameters are normalized to obtain corresponding normalized data.
[0104] It should be noted that if there is only one communication mode, the connection between the target requesting device and the target receiving device is established according to the communication mode; the communication mode includes a wired communication mode and a wireless communication mode.
[0105] Step S53, inputting the normalized data into the pre-generated fuzzy control model to obtain the corresponding fuzzy score;
[0106] Step S54, determining the optimal communication method according to the fuzzy score.
[0107] It should be further explained that the generation method or method of the pre-generated fuzzy control model is: obtaining model training data, the model training data includes historical communication parameters and historical communication rates, and establishing fuzzy control rules based on the model training data; then constructing a fuzzy control model based on the fuzzy control rules; then optimizing the fuzzy control model to obtain the pre-generated fuzzy control model.
[0108] Specifically, historical transmission data between a target requesting device and a target receiving device is obtained, and corresponding historical data characteristic values are determined based on the historical transmission data. The historical data characteristic values include the total transmission volume, average transmission volume, peak transmission volume, and valley transmission volume corresponding to the historical transmission data, and a corresponding transmission volume score is determined based on the historical data characteristic values; a comprehensive score is calculated based on the transmission volume score and the fuzzy score, and the optimal communication method is determined based on the comprehensive score.
[0109] It should be noted that in this embodiment, for different communication modes, the weights corresponding to their parameters are the same, that is, the weights set for the total transmission volume, average transmission volume, peak transmission volume and valley transmission volume are the same. According to the total transmission volume, average transmission volume, peak transmission volume and valley transmission volume and their corresponding weights, a transmission volume score can be obtained; the transmission volume score and the fuzzy score are set with corresponding calculation factors, but for different communication modes, the corresponding calculation factors are usually different. The calculation factor can be a number between 0 and 1, or a value greater than 1. The comprehensive score is obtained by the transmission volume score, the fuzzy score and their corresponding calculation factors.
[0110] Step S55: establishing a connection between the target requesting device and the target receiving device according to the optimal communication method.
[0111] In the above-mentioned embodiment, the target requesting device obtains the identity information of the target receiving device, and sends a communication mode query request to the target receiving device according to the identity information, and then the target receiving device receives the communication mode query request, and determines whether there are multiple communication modes according to the communication mode query request. If there are multiple communication modes, then for each communication mode, the communication parameters of the communication mode are obtained, and the communication parameters include signal strength, transmission speed and communication delay, and the communication parameters are normalized to obtain corresponding normalized data, and then the normalized data is input into the pre-generated fuzzy control model to obtain the corresponding fuzzy score, and then the optimal communication mode is determined according to the fuzzy score, and finally the connection between the target requesting device and the target receiving device is established according to the optimal communication mode.
[0112] As a further implementation of the parsing method, the step of receiving a response frame based on the DLT698 protocol and parsing the response frame to obtain the corresponding user data APDU includes:
[0113] Step S61, receiving a response frame based on the DLT698 protocol, and extracting a check code from the response frame according to a predefined frame format.
[0114] Step S62, determining whether the user data APDU is complete according to the check code, if so, extracting the user data APDU from the response frame, if not, generating an error message.
[0115] In the above implementation, a response frame is first received based on the DLT698 protocol, and a check code is extracted from the response frame according to a predefined frame format. Then, whether the user data APDU is complete is determined based on the check code. If the user data APDU is complete, the user data APDU is extracted from the response frame. If the user data APDU is incomplete, an error message is generated.
[0116] As a further implementation of the parsing method, before the step of sending a request frame to the target receiving device based on the DLT698 protocol and the target receiving device sending a response frame in response to the request frame, it also includes:
[0117] Step S71, obtain a predefined interface class, and implement the predefined interface class to obtain a first entity class corresponding to the predefined interface class. The first entity class includes electric energy class, maximum demand class, variable class, time class, parameter class, acquisition monitoring class and control class.
[0118] It can be understood that implementing a predefined interface class means implementing specific steps (or contents) in the predefined interface class.
[0119] Step S72, obtaining the extended data types in the first entity class and the interface class, and defining the second entity class corresponding to the extended data type according to the extended data type.
[0120] Among them, the extended data types include Array class, DateTime class, DateTimeS class and TSA class.
[0121] Step S73, obtaining data types, which include extended data types and basic data types, and defining corresponding enumeration classes according to the data types. The enumeration classes include data type tags and data lengths corresponding to the data types.
[0122] It is understandable that the basic data types are conventional data types, such as bool, long, etc.
[0123] In the above implementation, a predefined interface class is first obtained, and the predefined interface class is implemented to obtain a first entity class corresponding to the predefined interface class, the first entity class includes an electric energy class, a maximum demand class, a variable class, a time class, a parameter class, a collection monitoring class, and a control class, and then the extended data types in the first entity class and the interface class are obtained, the extended data types include an Array class, a DateTime class, a DateTimeS class, and a TSA class, and a second entity class corresponding to the extended data type is defined according to the extended data type, and then the data type is obtained, the data type includes an extended data type and a basic data type, and the corresponding enumeration class is defined according to the data type. The enumeration class includes a data type tag and a data length corresponding to the data type.
[0124] The embodiment of the present application also discloses a DLT698 protocol parsing system.
[0125] refer to Figure 3 , a DLT698 protocol analysis system, comprising:
[0126] A request frame sending module, used for sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame;
[0127] A user data APDU generation module is used to receive a response frame based on the DLT698 protocol, and parse the response frame according to a predefined frame format to obtain a corresponding user data APDU;
[0128] An attribute ID generating module, used for obtaining a corresponding object attribute descriptor OAD according to the user data APDU, and obtaining at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD;
[0129] The data parsing module is used to parse the user data APDU according to at least one attribute ID to obtain corresponding parsed data.
[0130] A DLT698 protocol parsing system of the present invention can implement any one of the DLT698 protocol parsing methods, and the specific working process of a DLT698 protocol parsing system of the present invention can refer to the corresponding process in the above-mentioned DLT698 protocol parsing method.
[0131] The embodiment of the present application also discloses a computer device.
[0132] refer to Figure 4 A computer device includes a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, any one of the above-mentioned DLT698 protocol parsing methods is implemented.
[0133] The embodiment of the present application also discloses a computer-readable storage medium.
[0134] A computer-readable storage medium stores a computer program that can be loaded by a processor and execute any one of the above-mentioned DLT698 protocol parsing methods.
[0135] Among them, computer-readable storage media can be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus or device; the program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0136] In some embodiments, the computer readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or various devices including one or any combination of the above memories. The computer may be various computing devices including intelligent terminals and servers.
[0137] In the above embodiments of the present disclosure, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0138] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0140] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable non-volatile storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a non-volatile storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the various embodiments of the present disclosure. The aforementioned non-volatile storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0142] The above are only preferred embodiments of the present disclosure. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present disclosure. These improvements and modifications should also be regarded as the protection scope of the present disclosure.
Claims
1. A DLT698 protocol analysis method, characterized in that: include: Sending a request frame to a target receiving device based on the DLT698 protocol, wherein the target receiving device sends a response frame in response to the request frame; Receive the response frame based on the DLT698 protocol, and parse the response frame to obtain the corresponding user data APDU; Acquire a corresponding object attribute descriptor OAD according to the user data APDU, and acquire at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD; Parsing the user data APDU according to the at least one attribute ID to obtain corresponding parsed data; The step of parsing the user data APDU according to the at least one attribute ID to obtain corresponding parsed data includes: Storing the at least one attribute ID into a predefined array to obtain a target array; For the attribute ID in the target array, determine the entity class corresponding to the attribute ID according to the attribute ID, and determine the data type corresponding to the data in the user data APDU according to the attribute ID; Determine the corresponding data length according to the data type and the predefined enumeration class; Determine whether an error occurs in the user data APDU according to the attribute ID and the data length, and if not, read corresponding data from the user data APDU according to the attribute ID and the data length to obtain a corresponding data reading result; The entity class corresponding to the attribute ID is initialized according to the attribute ID and the data reading result to obtain the corresponding parsed data.
2. A DLT698 protocol analysis method according to claim 1, characterized in that: The step of reading corresponding data from the user data APDU according to the attribute ID and the data length to obtain a corresponding data reading result comprises: Determine the starting position for data reading according to the attribute ID; Corresponding data is read from the user data APDU according to the starting position and the data length to obtain a data reading result corresponding to the attribute ID.
3. A DLT698 protocol analysis method according to claim 1, characterized in that: The step of sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sending a response frame in response to the request frame, comprises: The target requesting device acquires a communication mode with the target receiving device, and establishes a connection with the target receiving device according to the communication mode; The target requesting device obtains the requested attribute description information and the device address of the target receiving device, and constructs a request frame according to the device address, the attribute description information and a predefined request frame format; Sending the request frame to the target receiving device; The target receiving device receives the request frame, and parses the request frame to obtain corresponding request content; The target receiving device obtains a request result according to the request content, and constructs a response frame according to the request result and a predefined response frame format; The target receiving device sends the response frame to the target requesting device.
4. A DLT698 protocol analysis method according to claim 3, characterized in that: The step of the target requesting device acquiring a communication mode with the target receiving device and establishing a connection with the target receiving device according to the communication mode includes: The target requesting device obtains the identity information of the target receiving device, and sends a communication mode query request to the target receiving device according to the identity information; The target receiving device receives the communication mode query request, and determines whether there are multiple communication modes according to the communication mode query request, and if so, obtains communication parameters of the communication mode for each of the communication modes, the communication parameters including signal strength, transmission speed and communication delay, and normalizes the communication parameters to obtain corresponding normalized data; Inputting the normalized data into a pre-generated fuzzy control model to obtain a corresponding fuzzy score; Determining an optimal communication method according to the fuzzy score; A connection is established between the target requesting device and the target receiving device according to the optimal communication mode.
5. A DLT698 protocol analysis method according to claim 1, characterized in that: The step of receiving the response frame based on the DLT698 protocol and parsing the response frame to obtain the corresponding user data APDU includes: Receiving the response frame based on the DLT698 protocol, and extracting a check code from the response frame according to a predefined frame format; Determine whether the user data APDU is complete according to the check code, if so, extract the user data APDU from the response frame, if not, generate error information.
6. A DLT698 protocol analysis method according to claim 1, characterized in that: Before the step of sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sending a response frame in response to the request frame, the step further includes: Obtain a predefined interface class, and implement the predefined interface class to obtain a first entity class corresponding to the predefined interface class; the first entity class includes an electric energy class, a maximum demand class, a variable class, a time class, a parameter class, a collection and monitoring class, and a control class; Acquire extended data types in the first entity class and the interface class, the extended data types including Array class, DateTime class, DateTimeS class and TSA class, and define a second entity class corresponding to the extended data type according to the extended data type; A data type is obtained, wherein the data type includes an extended data type and a basic data type, and a corresponding enumeration class is defined according to the data type; the enumeration class includes a data type tag and a data length corresponding to the data type.
7. A DLT698 protocol analysis system, characterized in that: include: A request frame sending module, used for sending a request frame to a target receiving device based on the DLT698 protocol, and the target receiving device sends a response frame in response to the request frame; A user data APDU generation module is used to receive the response frame based on the DLT698 protocol, and parse the response frame according to a predefined frame format to obtain a corresponding user data APDU; An attribute ID generating module, used for acquiring a corresponding object attribute descriptor OAD according to the user data APDU, and acquiring at least one attribute ID in the object attribute descriptor OAD according to the object attribute descriptor OAD; A data parsing module, used for parsing the user data APDU according to the at least one attribute ID to obtain corresponding parsed data; The step of parsing the user data APDU according to the at least one attribute ID to obtain corresponding parsed data includes: Storing the at least one attribute ID into a predefined array to obtain a target array; For the attribute ID in the target array, determine the entity class corresponding to the attribute ID according to the attribute ID, and determine the data type corresponding to the data in the user data APDU according to the attribute ID; Determine the corresponding data length according to the data type and the predefined enumeration class; Determine whether an error occurs in the user data APDU according to the attribute ID and the data length, and if not, read corresponding data from the user data APDU according to the attribute ID and the data length to obtain a corresponding data reading result; The entity class corresponding to the attribute ID is initialized according to the attribute ID and the data reading result to obtain the corresponding parsed data.
8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 6.
