XML-based visual configuration multi-protocol processing method and simulator system
Through the visual configuration of multi-protocol processing method based on XML, multiple communication protocols are supported, which solves the problem that the existing device simulator system does not support UDP and serial port protocols, improves the system's configurability and compatibility, and realizes online simulation of multi-device.
Patent Information
- Application Number
- CN202411608385.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-21
AI Technical Summary
The existing device emulator system only supports application layer protocols such as HTTP and SNMP, and does not support byte stream protocols such as UDP and serial port. It has low configurability, complex use, and poor system compatibility and portability.
The multi-protocol processing method based on XML is adopted, and multiple communication protocols such as HTTP, SNMP, UDP and serial port are supported. Parameter conversion and encapsulation are performed through XML configuration files and sent to designated devices to realize online simulation of multiple devices.
It realizes support for multiple communication protocols, improves the system's configurability and simplicity of use, improves system compatibility and portability, and supports multiple devices to be online at the same time.
Smart Images

Figure CN119670696A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of computer technology, and in particular relates to a visualized configuration multi-protocol processing method based on XML and a simulator system. Background Art
[0002] Device simulators play an important role in software development. They have the following functions:
[0003] (1) Application development and testing: Device simulators allow developers to develop and test applications without a real device. Developers can run their applications on simulators to debug and verify their functionality without an actual physical device.
[0004] (2) Performance testing and optimization: Device simulators usually provide performance analysis tools that developers can use to evaluate the performance of their applications and optimize them. These tools can help identify bottlenecks and resource consumption in applications.
[0005] (3) System Demonstration and Exercise: For product demonstration or system exercise, device simulators can be used to simulate real scenarios and demonstrate product functions and operating procedures without the need for real equipment support on site.
[0006] (4) Cross-platform development support: Device simulators can simulate different operating systems and hardware environments, allowing developers to test the performance of their applications on multiple platforms on the same device simulator. For example, device simulators can be used for development and testing on both iOS and Android.
[0007] The current mainstream device simulator systems on the market have the following main problems:
[0008] (1) Only supports application layer protocols such as HTTP and SNMP, but does not support byte stream protocols such as UDP and serial port;
[0009] (2) Low configurability, complex use, and poor usability;
[0010] (3) The system has low compatibility and poor portability. Summary of the invention
[0011] Purpose of the invention: In order to solve the problems existing in the existing device simulators, the present invention proposes a visual configuration multi-protocol processing method and simulator system based on XML, which can simulate multiple devices online at the same time and support multiple communication protocols such as HTTP, SNMP, UDP, serial port, etc. The device simulator system proposed by the present invention itself runs on the JVM virtual machine and has good system compatibility and portability.
[0012] Technical solution: A multi-protocol processing method for visual configuration based on XML, comprising the following steps:
[0013] According to the request to be responded to, according to the communication protocol type in the XML configuration file, parameter conversion is performed, the conversion result is encapsulated into a response communication message, and sent to the specified device;
[0014] The communication protocol type includes any one of UDP protocol, HTTP protocol, SNMP protocol and serial port protocol;
[0015] For the UDP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the specified device, specifically including:
[0016] Get device field attributes and corresponding attribute values from the XML configuration file;
[0017] According to the predefined conversion function, the device field attributes and the corresponding attribute values are converted into bytes;
[0018] Assemble into a response communication message according to the protocol format;
[0019] Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device;
[0020] For the HTTP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the designated device, specifically including:
[0021] Get device field attributes and corresponding attribute values from the XML configuration file;
[0022] Combine device field attributes and corresponding attribute values into a JSON object;
[0023] Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the JSON object to the specified device;
[0024] For the SNMP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the specified device, specifically including:
[0025] Get device field attributes and corresponding attribute values from the XML configuration file;
[0026] According to the key-value pair method, the device field attributes and corresponding attribute values are reassembled into a response communication message in the SNMP protocol format;
[0027] Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device;
[0028] For the serial port protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the specified device, specifically including:
[0029] Get device field attributes and corresponding attribute values from the XML configuration file;
[0030] According to the predefined conversion function, the device field attributes and the corresponding attribute values are converted into bytes;
[0031] Assemble into a response communication message according to the protocol format;
[0032] Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device.
[0033] Further, the predefined conversion functions include: a numerical byte conversion function, a date text byte conversion function and a BCD text byte conversion function;
[0034] In the numerical value-to-byte conversion function, numerical values are divided into signed numbers and unsigned numbers, integer numbers and floating-point numbers; the converted byte numbers include: one byte, two bytes, four bytes and eight bytes;
[0035] The date text to byte function is used to process the conversion of date to byte and time to byte;
[0036] The BCD text to byte function is used to process the conversion of BCD codes.
[0037] Furthermore, for the UDP protocol and the serial port protocol, the device field attributes and the corresponding attribute values are converted into bytes according to the predefined conversion function, and the specific operations include:
[0038] Configure the endType meta node in the XML configuration file and use the endType meta node to control the end sequence.
[0039] Convert device field attributes and corresponding attribute values to bytes according to predefined conversion functions.
[0040] The present invention discloses an XML-based visual configuration multi-protocol device simulator system, comprising:
[0041] XML file storage module, used to store XML configuration files in a fixed format;
[0042] The multi-protocol processing module is used to perform parameter conversion according to the request to be responded to and the communication protocol type in the XML configuration file, encapsulate the conversion result into a response communication message, and send it to the designated device;
[0043] The XML-based visual configuration multi-protocol processing method described in any one of claims 1 to 3 is run in the multi-protocol processing module.
[0044] Further, the XML configuration file includes device connection configuration information and device attribute field configuration information;
[0045] The device connection configuration information includes:
[0046] The protocol type meta-node is used to define the communication protocol type for interacting with the device simulator, and supports UDP protocol, HTTP protocol, SNMP protocol and serial port protocol;
[0047] The device listening port meta-node is used to define the listening port of the device simulator under the UDP protocol communication. The user can monitor the device simulator only by sending query and setting request messages to the listening port;
[0048] The device sending port meta-node is used to define the sending destination port of the device simulator under UDP protocol communication;
[0049] UDP protocol type identification meta-node, used to identify the specific type of UDP protocol communication;
[0050] The serial port type identification meta-node is used to identify the specific protocol type of the serial port communication;
[0051] The device attribute field configuration information is divided into:
[0052] Simple field attributes are used to mark single field types and define and set device attribute values according to specific fields;
[0053] Composite field attributes are used to mark composite parameters and are suitable for defining field groups with dependencies.
[0054] The device attribute field configuration information also includes the following information tags:
[0055] Field serial number, used to globally uniquely identify the field;
[0056] Field display name, used to display the name on the interface;
[0057] Field attribute name, used to identify the field attribute name;
[0058] The oid keyword is used for SNMP protocol devices to define the oid of the field through this attribute;
[0059] The oidType value type is used to identify the protocol type of the SNMP protocol device field;
[0060] transFunc predefined text conversion byte function, for UDP and serial port protocols, a predefined function used to convert text values into bytes;
[0061] reverseFunc predefined byte conversion text function, for UDP and serial port protocols, a predefined function used to convert bytes into text values;
[0062] keyword byte field keyword, for UDP and serial port protocols, it is used to configure the protocol keyword of the field;
[0063] endType is the keyword of the endian control field. For UDP and serial port protocols, this attribute is used to identify the big and small endian sequences that should be used when converting character bytes.
[0064] Furthermore, it also includes:
[0065] The device parameter modification page module is used to provide a visual page for users to operate the page to change the parameter values of the XML configuration file;
[0066] The service request receiving module is used to process the parameter request sent by the device parameter modification page module and transfer it to the multi-protocol processing module for processing.
[0067] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0068] (1) The device simulator system proposed in the present invention can generate corresponding simulated devices by only configuring the standard device XML, which has the advantages of simple user operation and high degree of configurability;
[0069] (2) The device simulator system proposed in the present invention supports device simulation of four protocols: HTTP, UDP, SNMP, and serial port;
[0070] (3) The device simulator system proposed by the present invention supports multiple devices to be online at the same time;
[0071] (4) The device simulator system proposed in the present invention has a visual operation interface, which is convenient for users to modify device parameters and has the advantage of good usability;
[0072] (5) The device simulator system proposed in the present invention is lightweight, has no database dependency, only requires a JDK environment, and has good system compatibility and portability. BRIEF DESCRIPTION OF THE DRAWINGS
[0073] Figure 1A schematic diagram of the functional architecture of a multi-protocol device simulator system with XML-based visual configuration proposed by the present invention;
[0074] Figure 2 It is a schematic diagram of combining and configuring data units;
[0075] Figure 3 It is a schematic diagram of byte data structure;
[0076] Figure 4 This is a schematic diagram for single simulator deployment;
[0077] Figure 5 Schematic diagram for multi-simulator deployment. DETAILED DESCRIPTION
[0078] To make the purpose, technical solutions and advantages of the present invention more clear, the XML-based visual configuration multi-protocol device simulator system proposed by the present invention will be further described below in conjunction with the accompanying drawings in the present invention.
[0079] Embodiment 1:
[0080] This embodiment proposes an XML-based visual configuration multi-protocol device simulator system, which mainly implements the following functions:
[0081] Function 1: Receive query parameter requests from the device, convert and reorganize data according to the communication protocol format requirements, and respond to the corresponding message;
[0082] Function 2: Receive parameter setting requests from the device, change device attribute values, and respond to device setting results according to the communication protocol format.
[0083] like Figure 1 As shown, the device simulator system can query multiple simulated device parameters for monitoring at the same time, and users can modify device parameter values through a visual interface.
[0084] like Figure 2 As shown, the device simulator system proposed in this embodiment is mainly divided into: an XML file storage module, a service request receiving module, a multi-protocol processing module and a device parameter modification page module.
[0085] Among them, the XML file storage module is mainly responsible for the reading and writing operations of the XML configuration file. In this embodiment, XML is used as the source data carrier, which has the advantages of being lightweight, clearly structured, and flexible. The XML element node information of this embodiment is mainly divided into a device connection configuration information node part and a device attribute field node part.
[0086] Specifically, the device connection configuration information node part mainly includes:
[0087] protocal protocol type meta node, mainly used to define the communication protocol for interacting with the simulated device, supporting HTTP, UDP, SNMP and serial port protocols;
[0088] The netPort device listening port meta-node is used to define the listening port of the device when the device uses the UDP protocol for communication. The client system needs to send query and setting request messages to the listening port to monitor the device;
[0089] rmtPort device sending port meta-node, used to define the device's sending destination port when the device uses UDP protocol communication;
[0090] udpType UDP protocol type identification meta-node, used to identify the specific type of UDP protocol communication, mainly divided into point-to-point communication, multicast communication and broadcast communication;
[0091] serialType serial port type identification meta node is used to identify the specific protocol type of serial port communication, which is mainly divided into RSS232, RSS485 and RSS422 communication;
[0092] Specifically, the device attribute field node part mainly includes two types of element nodes:
[0093] Type 1: Simple field attribute, marking a single field type, defining and setting device attribute values according to specific fields;
[0094] Type 2: Combined field attributes, marking composite parameters, suitable for defining field groups with dependencies;
[0095] In addition, the device attribute field node defines the following information tags:
[0096] no field number, which uniquely identifies the field globally;
[0097] The name field displays the name, which is used to display the name on the interface;
[0098] enname field attribute name, used to identify the field attribute name;
[0099] OID keyword. For SNMP protocol devices, this attribute defines the OID of the field.
[0100] oidType value type, identifies the protocol type of the SNMP protocol device field;
[0101] transFunc predefined text conversion byte function, for UDP and serial port protocols, this field identifies the predefined function that can convert the text value into bytes;
[0102] reverseFunc predefined byte conversion text function, for UDP and serial port protocols, this field identifies the predefined function that can convert bytes into text;
[0103] keyword byte field keyword. For UDP and serial port protocols, this attribute is used to configure the protocol keyword of the field, and the protocol keyword is used to mark the business field keyword name;
[0104] endType is the keyword of the endian control field. For UDP and serial port protocols, this attribute is used to identify the big and small endian sequences that should be used when converting character bytes.
[0105] For UDP and serial port byte protocols, this embodiment supports typical communication protocols starting with 7E and ending with 7E. The protocol format is as follows: Figure 3 As shown. Since XML stores text data, for byte-type protocols, the system needs to convert the parameters from text to bytes. The first thing to solve in the conversion is the endianness issue. This system supports configurable endianness, which can be achieved by configuring the endType meta-node in XML; the second is the definition and design of conversion functions and inverse conversion functions. According to the commonly used field attribute values of analog devices, the system predefines the following types of commonly used conversion functions:
[0106] Numerical conversion to byte functions, which are the most important type of conversion. Numerical values can be divided into signed and unsigned numbers, integers and floating-point numbers. The bytes to be converted are mainly one byte, two bytes, four bytes and eight bytes, so the preset functions are mainly combinations of the above situations;
[0107] Date text to byte function, mainly handles some date to byte and time to byte conversion;
[0108] BCD text to byte function, handles the conversion of some BCD codes.
[0109] Among them, the service request receiving module mainly processes parameter requests sent by the third-party system and the device parameter modification page module, and transfers them to the multi-protocol processing module for processing;
[0110] Among them, the multi-protocol processing module mainly receives the request forwarded by the service request receiving module, and performs parameter conversion according to the response protocol type configured by the requesting device, and encapsulates the communication message. For different communication protocol types, this module needs to process different conversion logics and tasks, which can be processed as UDP protocol response, HTTP protocol response, SNMP protocol response and serial port protocol response respectively;
[0111] Specifically, for the HTTP protocol, the main communication message body format for interacting with the device is JSON. For read requests, the multi-protocol processing module mainly combines the device field attributes and corresponding attribute values parsed by the XML file storage module into a JSON object and returns it to the device. It only needs to perform text structure conversion without processing data type conversion. Simple parameters can be converted directly, and for compound parameters, the compound parameter items need to be combined into a JSON object as a whole; for setting requests, users modify device parameters through the visual page, and the XML file storage module processes and modifies the XML device data.
[0112] Specifically, the main feature of the UDP protocol is that it uses bytes as units. After the system is started, it will listen to the specified port request according to the parameter configuration in XML. For read requests, the XML file storage module reads the original device attribute data from XML, and the multi-protocol processing module converts the field into bytes according to the configured predefined conversion function, and finally converts the data into bytes according to the predefined conversion function. Figure 3 The protocol format is assembled into the final response message, the device address is parsed from the request message, and the message is sent out in combination with the device listening address in the XML.
[0113] Specifically, for the SNMP protocol, device attributes are defined as a series of mapping relationships from oid to field values. The multi-protocol processing module reads the text values read by the XML file storage module, reorganizes them into the SNMP protocol format according to the mapping relationship from oid to field values, and sends a response to the device.
[0114] Specifically, the processing method of the serial port protocol is similar to that of the UDP protocol, with bytes as the processing data unit. The protocol processing module converts the field into bytes according to the configured predefined conversion function, and then assembles it into the final response message according to the protocol format, and sends it to the device according to the serial port message format.
[0115] Among them, the device parameter modification page module provides a visual page for users to operate the page to change the parameter values of the simulated device.
[0116] The specific operations include: the user must first configure the device standard XML in a fixed format and place it in the system-specified directory. After the system is started, each simulated device will be automatically created based on the device configuration XML.
[0117] like Figure 4 As shown, in a certain in-station monitoring function test scenario, the device simulator system deployed according to this embodiment simulates and generates one HTTP protocol device, one SNMP protocol device, one UDP protocol device and one serial port device. Each simulated device receives its own protocol message request sent by the in-station monitoring system and returns a device response as required. The simulator and the in-station monitoring system are deployed on different machines to avoid port conflicts.
[0118] like Figure 5 As shown, in a certain in-station monitoring performance test scenario, the device simulator system described in this embodiment is deployed in each of the four machines. Machine two simulates and generates 100 HTTP protocol devices, machine three simulates and generates 100 SNMP protocol devices, machine four simulates and generates 100 UDP protocol devices, and machine five simulates and generates 100 serial port protocol devices. The separate machine deployment ensures the response speed of the simulated devices. The number of simulated devices can be increased or decreased according to actual test requirements, which can conveniently meet various requirements of the in-station monitoring system performance test scenarios.
Claims
1. A method for visually configuring multi-protocol processing based on XML, characterized in that: The following steps are involved: According to the request to be responded to, according to the communication protocol type in the XML configuration file, parameter conversion is performed, the conversion result is encapsulated into a response communication message, and sent to the specified device; The communication protocol type includes any one of UDP protocol, HTTP protocol, SNMP protocol and serial port protocol; For the UDP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, encapsulate the conversion result into a response communication message, and send it to the specified device, specifically including: Get device field attributes and corresponding attribute values from the XML configuration file; According to the predefined conversion function, the device field attributes and the corresponding attribute values are converted into bytes; Assemble into a response communication message according to the protocol format; Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device; For the HTTP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the designated device, specifically including: Get device field attributes and corresponding attribute values from the XML configuration file; Combine device field attributes and corresponding attribute values into a JSON object; Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the JSON object to the specified device; For the SNMP protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the specified device, specifically including: Get device field attributes and corresponding attribute values from the XML configuration file; According to the key-value pair method, the device field attributes and corresponding attribute values are reassembled into a response communication message in the SNMP protocol format; Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device; For the serial port protocol, the communication protocol type in the XML configuration file is used to perform parameter conversion, and the conversion result is encapsulated into a response communication message and sent to the specified device, specifically including: Get device field attributes and corresponding attribute values from the XML configuration file; According to the predefined conversion function, the device field attributes and the corresponding attribute values are converted into bytes; Assemble into a response communication message according to the protocol format; Parse the device address from the request message, combine it with the device listening address in the XML configuration file, and send the response communication message to the specified device.
2. The XML-based visual configuration multi-protocol processing method according to claim 1, characterized in that: The predefined conversion functions include: a numerical byte conversion function, a date text byte conversion function and a BCD text byte conversion function; In the numerical value-to-byte conversion function, numerical values are divided into signed numbers and unsigned numbers, integer numbers and floating-point numbers; the converted byte numbers include: one byte, two bytes, four bytes and eight bytes; The date text to byte function is used to process the conversion of date to byte and time to byte; The BCD text to byte function is used to process the conversion of BCD codes.
3. The XML-based visual configuration multi-protocol processing method according to claim 1, characterized in that: For the UDP protocol and the serial port protocol, the device field attributes and the corresponding attribute values are converted into bytes according to the predefined conversion function. The specific operations include: Configure the endType meta node in the XML configuration file and use the endType meta node to control the end sequence. Convert device field attributes and corresponding attribute values to bytes according to predefined conversion functions.
4. A multi-protocol device simulator system with visual configuration based on XML, characterized in that: include: XML file storage module, used to store XML configuration files in a fixed format; The multi-protocol processing module is used to perform parameter conversion according to the request to be responded to and the communication protocol type in the XML configuration file, encapsulate the conversion result into a response communication message, and send it to the designated device; The XML-based visual configuration multi-protocol processing method described in any one of claims 1 to 3 is run in the multi-protocol processing module.
5. The XML-based visual configuration multi-protocol device simulator system according to claim 4, characterized in that: The XML configuration file includes device connection configuration information and device attribute field configuration information; The device connection configuration information includes: The protocol type meta-node is used to define the communication protocol type for interacting with the device simulator, and supports UDP protocol, HTTP protocol, SNMP protocol and serial port protocol; The device listening port meta-node is used to define the listening port of the device simulator under the UDP protocol communication. The user can monitor the device simulator only by sending query and setting request messages to the listening port; The device sending port meta-node is used to define the sending destination port of the device simulator under UDP protocol communication; UDP protocol type identification meta-node, used to identify the specific type of UDP protocol communication; The serial port type identification meta-node is used to identify the specific protocol type of the serial port communication; The device attribute field configuration information is divided into: Simple field attributes are used to mark single field types and define and set device attribute values according to specific fields; Composite field attributes are used to mark composite parameters and are suitable for defining field groups with dependencies. The device attribute field configuration information also includes the following information tags: Field serial number, used to globally uniquely identify the field; Field display name, used to display the name on the interface; Field attribute name, used to identify the field attribute name; The oid keyword is used for SNMP protocol devices to define the oid of the field through this attribute; The oidType value type is used to identify the protocol type of the SNMP protocol device field; transFunc predefined text conversion byte function, for UDP and serial port protocols, a predefined function used to convert text values into bytes; reverseFunc predefined byte conversion text function, for UDP and serial port protocols, a predefined function used to convert bytes into text values; keyword byte field keyword, for UDP and serial port protocols, it is used to configure the protocol keyword of the field; endType is the keyword of the endian control field. For UDP and serial port protocols, this attribute is used to identify the big and small endian sequences that should be used when converting character bytes.
6. The XML-based visual configuration multi-protocol device simulator system according to claim 4, characterized in that: Also includes: The device parameter modification page module is used to provide a visual page for users to operate the page to change the parameter values of the XML configuration file; The service request receiving module is used to process the parameter request sent by the device parameter modification page module and transfer it to the multi-protocol processing module for processing.