General control method and device for Modbus RTU equipment, equipment and medium
By selecting the device type and selecting the corresponding device template, generating read and write interfaces and Modbus RTU request messages, the problem of customized development of Modbus RTU device control software in the prior art is solved, and high-quality and reliable general control effects are achieved.
Patent Information
- Application Number
- CN202510522292.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-24
- Publication Date
- 2025-06-03
AI Technical Summary
The existing Modbus RTU device control software requires the development of customized control software separately based on the data point form of each device, resulting in large development and maintenance workload, poor user experience, low software quality and reliability.
It provides a general control method for Modbus RTU devices, selecting the corresponding device template by selecting the device type, generating a read and write interface and Modbus RTU request message, and establishing a connection with the device through communication parameters to realize universal control of the device.
There is no need to customize the development of Modbus RTU equipment control software, which significantly reduces the threshold for software development and use, improves the quality and reliability of the control software, and enhances the user experience.
Smart Images

Figure CN120090937A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of industrial automation control, and particularly relates to a general control method, device, equipment and medium for Modbus RTU devices. Background Art
[0002] As a widely used industrial communication protocol, the Modbus RTU protocol plays an important role in the field of industrial automation, especially in data transmission between devices with high efficiency and reliability. However, since the Modbus RTU protocol only clearly stipulates the data link layer, and the specific implementation of the application layer is user-defined, this flexibility leads to significant differences in the data point tables between different devices. Therefore, when controlling different Modbus RTU devices, it is usually necessary to develop customized control software separately according to the data point table of each device. This method not only brings a huge amount of development and maintenance work, wastes a large amount of human and material resources, but also due to the different design styles of different software, the user experience is poor when switching, affecting the operation efficiency. In addition, during each development process, it is necessary to implement functions one by one according to the point table, which is prone to missing software functions due to human oversight, further reducing the quality and reliability of the software. Summary of the Invention
[0003] The purpose of the present invention is to overcome the defects existing in the prior art, and provide a general control method, device, equipment and medium for Modbus RTU devices that do not require customized development of Modbus RTU device control software, improve the quality and reliability of the control software and the user experience.
[0004] To achieve the above object, the first aspect of the present invention provides a general control method for Modbus RTU devices, including: Selecting a corresponding device template according to the device type of the Modbus RTU device, where the device template includes the data point table, communication parameters and interface configuration of the Modbus RTU device; Generating a corresponding read / write interface according to the interface configuration; Generating a Modbus RTU request message according to the data point table; Establishing a communication connection with the Modbus RTU device based on the communication parameters, and sending the Modbus RTU request message to the Modbus RTU device; Receiving and parsing the Modbus RTU response message returned by the Modbus RTU device, and displaying the data point data in the Modbus RTU response message in the read / write interface.
[0005] Further, before selecting the corresponding device template according to the device type of the Modbus RTU device, it further includes: Pre-storing device templates of multiple types of Modbus RTU devices in the template library; The selecting the corresponding device template according to the device type of the Modbus RTU device includes: Querying the device template corresponding to the device type of the Modbus RTU device in the template library; If there is no corresponding device template, sending a template making reminder for the Modbus RTU device so that the user can edit and make the device template of the Modbus RTU device; Binding the device template made by the user to the device type of the Modbus RTU device and storing it in the template library; If there is a corresponding device template, selecting the corresponding device template.
[0006] Further, the data point table includes the register address, data type, parsing rule and read / write permission of the data point, and the interface configuration includes the control corresponding to the data point; The generating the read / write interface corresponding to the interface configuration includes: Generating a read / write interface including the control corresponding to each data point; Among them, the control corresponding to the data point of the read-only type register includes a display control for displaying the data point data; the control corresponding to the data point of the read / write type register includes the display control, an input box for the user to modify the register value and a first button control.
[0007] Further, the generating the Modbus RTU request message according to the data point table includes: Generating a Modbus RTU request message for the read / write instruction for the corresponding register in the Modbus RTU device according to the register address, data type, parsing rule and read / write permission of the data point in the data point table.
[0008] Further, the parsing the Modbus RTU response message returned by the Modbus RTU device and displaying the data point data in the Modbus RTU response message in the read / write interface includes: Parsing the data point data in the Modbus RTU response message according to the parsing rule; Displaying the corresponding data point data in the display control corresponding to the data point in the display form of the corresponding data type.
[0009] Further, the method further includes: In response to a special command editing operation of the user, a corresponding second button control is generated in the read-write interface, and the special command is bound to the second button control; When the user clicks the second button control, a special command message instructing the Modbus RTU device to execute the special command is generated by combining the special command and the data point table, and the special command message is sent to the Modbus RTU device so that the Modbus RTU device executes the special command.
[0010] Further, the communication parameters include RS485 communication parameters and / or Ethernet communication parameters. The RS485 communication parameters include baud rate, data bits, stop bits, and parity mode; the Ethernet communication parameters include IP address, port number, and timeout.
[0011] A second aspect of the present invention provides a general control device for a Modbus RTU device, including: A device template module for selecting a corresponding device template according to the device type of the Modbus RTU device. The device template includes the data point table, communication parameters, and interface configuration of the Modbus RTU device; An interactive interface module for generating a corresponding read-write interface according to the interface configuration; A Modbus packet assembly module for generating a Modbus RTU request message according to the data point table; A communication module for establishing a communication connection with the Modbus RTU device based on the communication parameters and sending the Modbus RTU request message to the Modbus RTU device; The communication module is further configured to receive a Modbus RTU response message returned by the Modbus RTU device; The Modbus packet assembly module is further configured to parse the Modbus RTU response message returned by the Modbus RTU device; The interactive interface module is further configured to display the data point data in the Modbus RTU response message in the read-write interface.
[0012] Further, before selecting a corresponding device template according to the device type of the Modbus RTU device, the device template module is further configured to pre-store device templates of multiple types of Modbus RTU devices in a template library; When selecting a corresponding device template according to the device type of the Modbus RTU device, the device template module is specifically configured to query the device template corresponding to the device type of the Modbus RTU device in the template library; if there is no corresponding device template, a template production reminder is sent for the Modbus RTU device to enable the user to edit and produce the device template of the Modbus RTU device; bind the device template made by the user to the device type of the Modbus RTU device and store it in the template library; if there is a corresponding device template, select the corresponding device template.
[0013] Further, the data point table includes the register address, data type, parsing rule, and read / write permission of the data point, and the interface configuration includes the control corresponding to the data point; When generating a read / write interface corresponding to the interface configuration, the interactive interface module is specifically configured to generate a read / write interface including the control corresponding to each data point; among them, the control corresponding to the data point of the read-only type register includes a display control for displaying the data point data; the control corresponding to the data point of the read / write type register includes the display control, an input box for the user to modify the register value, and a first button control.
[0014] Further, when generating a Modbus RTU request message according to the data point table, the Modbus packet assembly module is specifically configured to generate a Modbus RTU request message for the read / write instruction of the corresponding register in the Modbus RTU device according to the register address, data type, parsing rule, and read / write permission of the data point in the data point table.
[0015] Further, when parsing the Modbus RTU response message returned by the Modbus RTU device, the Modbus packet assembly module is specifically configured to parse the data point data in the Modbus RTU response message according to the parsing rule; When displaying the data point data in the Modbus RTU response message in the read / write interface, the interactive interface module is specifically configured to display the corresponding data point data in the display control corresponding to the data point in the display form corresponding to the data type.
[0016] Further, the device further includes a special command module, which is used to generate a corresponding second button control in the read / write interface in response to the user's special command editing operation, and bind the special command to the second button control; The Modbus packet assembly module is further configured to, when the user clicks the second button control, generate a special command message for instructing the Modbus RTU device to execute the special command by combining the special command and the data point table; The communication module is further configured to send the special command message to the Modbus RTU device, so that the Modbus RTU device executes the special command.
[0017] Furthermore, the communication parameters include RS485 communication parameters and / or Ethernet communication parameters. The RS485 communication parameters include baud rate, data bits, stop bits, and parity mode; the Ethernet communication parameters include IP address, port number, and timeout.
[0018] A third aspect of the present invention provides an electronic device, including a memory and a processor. Among them, a computer program is stored in the memory. When the computer program is executed by the processor, the method described in any item of the first aspect is implemented.
[0019] A fourth aspect of the present invention provides a computer-readable storage medium, on which program instructions are stored. When the program instructions are executed, the method described in any item of the first aspect is implemented.
[0020] The advantages and beneficial effects of the present invention are as follows: The control software introduces a device template that matches the device type, and can automatically generate a read / write interface for controlling the Modbus RTU device and a Modbus RTU request message according to the device template. Thus, the data point data returned by the Modbus RTU device in response to the Modbus RTU request message can be displayed on the read / write interface for the user to view, realizing a closed-loop process for controlling the Modbus RTU device. The matching of the device template and the device type enables the control software to generate the same interactive interface for the user to operate when loading the device template for the same type of Modbus RTU device. The user can adapt different devices of the same type through a unified interface operation, significantly reducing the development and use threshold of the software, eliminating the need for customized development of the Modbus RTU device control software, avoiding the work of repeatedly developing software, saving human resources, and reducing the possibility of human errors in customized software, enhancing the reliability of the software. Description of the Drawings
[0021] Figure 1 is the general control method flowchart of the Modbus RTU device of the present invention; Figure 2 is the structural schematic diagram of the general control device of the Modbus RTU device of the present invention; Figure 3 is the structural schematic diagram of the electronic device of the present invention.
[0022] In the figure: 200 is the general control device of the Modbus RTU device; 201 is the device template module; 202 is the interaction interface module; 203 is the Modbus packet assembly module; 204 is the communication module; 205 is the special command module; 300 is the electronic device; 301 is the memory; 302 is the processor; 303 is the communication interface. Specific embodiments
[0023] The following combines the accompanying drawings and embodiments to further describe the specific embodiments of the present invention. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and cannot be used to limit the protection scope of the present invention.
[0024] According to Figure 1 As shown, the general control method of the Modbus RTU device of the present invention includes the following steps: S101. Select the corresponding device template according to the device type of the Modbus RTU device. The device template includes the data point table, communication parameters, and interface configuration of the Modbus RTU device.
[0025] S102. Generate the corresponding read / write interface according to the interface configuration.
[0026] S103. Generate a Modbus RTU request message according to the data point table.
[0027] S104. Establish a communication connection with the Modbus RTU device based on the communication parameters and send the Modbus RTU request message to the Modbus RTU device.
[0028] S105. Receive and parse the Modbus RTU response message returned by the Modbus RTU device, and display the data point data in the Modbus RTU response message in the read / write interface.
[0029] The data point table of the Modbus RTU device is a configuration file that describes the data points in the Modbus RTU device, and defines key information such as the data address, data type, read / write permission, and data parsing rule required for device communication. For example, the data address includes the coil address (0x0001), input register address (0x3001), etc. The data type includes binary (coil, discrete input) or numerical (input register, holding register). Read / write permission: Some addresses only support reading (such as input registers) or support reading and writing (such as holding registers). Data parsing rule: The value of a certain register address may represent temperature (divide by 10) or status code (display directly).
[0030] Since the Modbus RTU protocol only standardizes the data link layer and the application layer is customized by device manufacturers, the point tables of different types of devices vary greatly. For example, a temperature sensor may store the temperature value in a register with address 0x3001, while an electricity meter device may use a register with address 0x3100, resulting in the need to develop control software separately for different devices.
[0031] The present invention abstracts the point table information through device templates to achieve one-time development and general adaptation. The control software is deployed on the control-end device (such as a computer, industrial touch screen, embedded host, etc.). Among them, the device template module supports users to edit, import / export templates. The device template contains the data point table information (address, type, parsing rule) of the device, interface configuration (such as control type, layout), and communication parameters (such as RS485 communication parameters, Ethernet communication parameters). The device template module will select the corresponding device template according to the device type of the Modbus RTU device. For example, the device template module will select and load the same device template for devices of the temperature sensor type, because the information in the data point tables of devices of the same type is usually the same, and even if there are differences, the differences are very small. When there are minor differences, users only need to edit the difference information in the device template through the device template module. The device templates of different types of devices vary greatly, and developers need to develop device templates for different types of devices, as shown in the following table: Attribute Temperature Sensor Template Electric Meter Template Communication Parameter RS485, Serial Port Parameters Need to be Configured Ethernet, IP and Port Need to be Configured Data Point Type Single Temperature Value (Float32) Multiple Parameters (Voltage, Current, Power) Parsing Rule Scaling Factor 0.1 Independent Scaling of Different Parameters (0.1, 0.01) Interface Control Configuration Simple Numerical Display Numerical Display + Dynamic Chart The interaction interface module can dynamically generate a visual read / write interface according to the template. For example, if the device template defines address 0x3001 as the temperature value, the interface will automatically generate a numerical display box and associate it with the read function, thus unifying the operation interface and improving the user experience.
[0032] The Modbus packet assembly module can automatically generate a request message that conforms to the Modbus RTU protocol according to the template. For example, if the device template defines address 0x3001 as the temperature value (holding register), the Modbus packet assembly module will automatically generate a request message of "read holding register 0x3001".
[0033] The communication module supports connecting and communicating with Modbus RTU devices in two ways: RS485 and Ethernet, and automatically adapts the communication connection method of the Modbus RTU device according to the communication parameters of the Modbus RTU device in the device template, so as to send the Modbus RTU request message to the Modbus RTU device.
[0034] The communication module receives the response message returned by the Modbus RTU device. After the Modbus packet assembly module parses the data point data in the response message, the interactive interface module updates and displays it in the read / write interface (for example, displays the latest temperature value). If the communication fails, an error is prompted.
[0035] By introducing a device template that matches the device type, the present invention automatically generates a read / write interface for controlling the Modbus RTU device and a Modbus RTU request message according to the device template. Thus, the data point data returned by the Modbus RTU device in response to the Modbus RTU request message can be displayed in the read / write interface for the user to view, realizing a closed-loop process for controlling the Modbus RTU device. The matching of the device template with the device type enables the control software to generate the same interactive interface for the user to operate when loading the device template for the same type of Modbus RTU device. The user can adapt different devices of the same type through the unified interface operation, significantly reducing the development and use threshold of the software. There is no need to customize the development of the Modbus RTU device control software, avoiding the work of repeatedly developing software, saving human resources, and reducing the possibility of human omissions in the customized software, enhancing the reliability of the software.
[0036] To enhance the flexibility and expandability of the control software, a preferred implementation of the present invention is that before selecting the corresponding device template according to the device type of the Modbus RTU device, it further includes: pre-storing device templates of multiple types of Modbus RTU devices in the template library.
[0037] Selecting the corresponding device template according to the device type of the Modbus RTU device includes: querying the device template corresponding to the device type of the Modbus RTU device in the template library; if there is no corresponding device template, sending a template making reminder for the Modbus RTU device to enable the user to edit and make the device template of the Modbus RTU device; binding the device template made by the user to the device type of the Modbus RTU device and storing it in the template library; if there is a corresponding device template, selecting the corresponding device template.
[0038] Developers can pre-store templates of devices from different manufacturers and different models in the template library of the control software, enabling the control software to seamlessly adapt to diverse Modbus RTU devices.
[0039] After the control software starts, the device template module first executes the template library query process to confirm whether the device template file corresponding to the current Modbus RTU device exists. If the template for the corresponding device does not exist in the template library, the control software prompts that the template is missing. The user can import the device template through the device template module or create and save a new device template file through the template editing function of the device template module. If the template for the corresponding device already exists in the template library, the template file is directly loaded and the visualization interface loading process is entered.
[0040] In order to make the design of the device template take into account both flexibility and standardization and generate a visual read / write interface that is convenient for users to operate intuitively, the preferred implementation of the present invention is that the data point table includes the register address, data type, parsing rule, and read / write permission of the data point, and the interface configuration includes the controls corresponding to the data points.
[0041] Generate a read / write interface corresponding to the interface configuration, including: generating a read / write interface containing the controls corresponding to each data point; among them, the controls corresponding to the data points of the read-only type registers include display controls for displaying the data of the data points; the controls corresponding to the data points of the read / write type registers include display controls, input boxes for the user to modify the register value, and the first button control.
[0042] Each data point in the data point table mainly includes the following information: register address, such as the address of a single register or coil (such as 0x3001). Data type, such as Uint16, Float32, for parsing the raw data in the register. Read / write permission, such as read-only (read) or writable (write). Data parsing rule, such as scale factor (the actual temperature is obtained by multiplying the raw value by 0.1), unit, data format, etc.
[0043] Each control in the generated read / write interface corresponds to an entry in the data point table defined in the device template. For the data points of the read-only type registers, the interaction interface module generates display controls to present the data returned by the Modbus RTU device. For the data points of the read / write type registers, in addition to the display controls, the interaction interface module also generates input boxes and corresponding button controls for the user to modify the register value. For example, in the device template file, the temperature sensor address 40010 is defined as a read-only holding register (Float32 type), and the interaction interface module generates a numeric box in the read / write interface to display the current temperature; the address 40011 is defined as a writable holding register, and the read / write interface generates a text box allowing the user to input a threshold value and a modify / submit button; the address 40012 is defined as a writable coil (to control the relay switch), and the read / write interface generates an "on / off" button; the addresses 40013 - 40019 are defined as a register group for continuous read / write of power values (Float32 type), and the read / write interface generates a line chart that updates in real time.
[0044] To achieve automated message generation and reduce the possibility of human oversight, a preferred embodiment of the present invention is to generate a Modbus RTU request message based on a data point table, including: generating a read / write instruction for the corresponding register in the Modbus RTU device according to the register address, data type, parsing rule, and read / write permission of the data points in the data point table.
[0045] A Modbus RTU message is a binary instruction generated by software according to a device template for communicating with a Modbus RTU device. The format and content of the message are dynamically determined by the point table information (such as register address, data type, read / write permission) in the template. For example, if the device template defines address 0x3001 as "temperature reading" (holding register, read-only), the software will automatically generate a request message for "reading holding register 0x3001" without the developer having to manually write the function code and address parsing logic.
[0046] A Modbus RTU message usually contains fields such as register address, function code, and data field. The function code is used to define the operation type (such as read, write). Depending on the function code, the data field may contain the register address, number of registers, data value, etc. When generating a Modbus RTU message, the Modbus packet assembly module first extracts information such as register address, function code, data type, and scaling rule from the device template file, and then fills in the standard fields according to the data frame format of the Modbus RTU protocol, including device address, function code, register address, number of registers, etc. Then, the data value is processed, including converting the user input value (such as 25.5 °C) to the original byte (such as 0x41 CC 00 00 corresponding to 25.5 in Float32) according to the data type, and filling in the data length according to the function code requirement (such as the number of bytes when writing multiple registers). Finally, the CRC checksum is calculated by performing a CRC-16 calculation on all bytes from the device address to the data field and appending it to the end of the message.
[0047] To improve data readability and user experience, a preferred embodiment of the present invention is to parse the Modbus RTU response message returned by the Modbus RTU device and display the data points in the Modbus RTU response message on the read / write interface, including: parsing the data points in the Modbus RTU response message according to the parsing rule; displaying the corresponding data points in the display control corresponding to the data points in the display form corresponding to the data type.
[0048] Parse the response message returned by the Modbus RTU device through predefined parsing rules (such as scaling factor, offset, data type conversion) to ensure the accuracy of data point data parsing. For example, the register value 250 is displayed as 25.0℃ according to the scaling factor 0.1 defined in the device template, and the 6-bit integer 0x00FF is parsed as the Boolean value True (corresponding to the device switch status).
[0049] In the display control corresponding to the data point, the corresponding data point data is displayed in the display form of the corresponding data type. Through the diversification of controls (such as value boxes, progress bars, and charts), the display requirements of different scenarios are met. For example, the device status is marked with color, green indicates normal, and red indicates fault; the voltage data dynamically reflects the voltage fluctuation trend in a real-time line chart. The display control presents different colors when the temperature data is in different numerical segments. When the temperature value box shows 2.0℃, the control background is blue. When the temperature value exceeds the threshold of 30.0℃, the control background of the temperature value box turns red.
[0050] In order to further enhance the flexibility and functionality of the control software, a further preferred implementation of the present invention further includes: in response to a user's special command editing operation, generating a corresponding second button control in the read-write interface, and binding the special command to the second button control; when the user clicks the second button control, a special command message instructing the Modbus RTU device to execute the special command is generated in combination with the special command and the data point table, and the special command message is sent to the Modbus RTU device to enable the Modbus RTU device to execute the special command.
[0051] Special command modules allow users to define complex operation logic and bind these commands to button controls on the read / write interface. Special commands are complex instructions that go beyond regular data read / write operations, such as device control: resetting the device, starting calibration, clearing alarm status. Batch operations: writing to multiple registers at the same time, executing a preset sequence of instructions. Custom functions: triggering special modes of the device (such as debug mode, firmware upgrade). These commands usually require combining multiple Modbus function codes or sending specific messages, which cannot be directly implemented through a simple read / write interface.
[0052] Taking the special command for the "zeroing electricity quantity" operation of the smart meter as an example, the user edits the special command for "zeroing electricity quantity" through the special command module to write the values of 10 registers at register addresses 40001 - 40010 as 0 (function code 0x10). The read - write interface generates a "zeroing electricity quantity" button. When the user clicks the "zeroing electricity quantity" button, a confirmation dialog box pops up. After the user clicks to confirm, the Modbus packet assembly module converts the instruction with the values of 0 written to register addresses 40001 - 40010 into a special command message and sends it to the smart meter through the communication module. After receiving the message, the smart meter executes the zeroing electricity quantity instruction, clears the electricity quantity register, and returns a successful response message.
[0053] To improve the compatibility of the software with Modbus RTU devices in communication, a preferred implementation of the present invention is that the communication parameters include RS485 communication parameters and / or Ethernet communication parameters. The RS485 communication parameters include baud rate, data bits, stop bits, and parity mode; the Ethernet communication parameters include IP address, port number, and timeout.
[0054] The control software supports establishing a communication link with Modbus RTU devices through RS485 serial communication or Ethernet communication. In the RS485 mode, the communication module configures the baud rate, data bits, stop bits, and parity mode of the Modbus RTU device to communicate with the Modbus RTU device; in the Ethernet mode, the communication module configures the IP address, port number, and timeout of the Modbus RTU device to communicate with the Modbus RTU device.
[0055] According to Figure 2 as shown, the general control device 200 of the Modbus RTU device of the present invention includes: The device template module 201 is used to select the corresponding device template according to the device type of the Modbus RTU device. The device template includes the data point table, communication parameters, and interface configuration of the Modbus RTU device; The interaction interface module 202 is used to generate the corresponding read - write interface according to the interface configuration; The Modbus packet assembly module 203 is used to generate Modbus RTU request messages according to the data point table; The communication module 204 is used to establish a communication connection with the Modbus RTU device based on the communication parameters and send Modbus RTU request messages to the Modbus RTU device; The communication module 204 is also used to receive Modbus RTU response messages returned by the Modbus RTU device; The Modbus packet assembly module 203 is also used to parse the Modbus RTU response message returned by the Modbus RTU device; The interaction interface module 202 is also used to display the data point data in the Modbus RTU response message in the read / write interface.
[0056] Furthermore, before selecting the corresponding device template according to the device type of the Modbus RTU device, the device template module 201 is also used to pre-store the device templates of multiple types of Modbus RTU devices in the template library; When the device template module 201 selects the corresponding device template according to the device type of the Modbus RTU device, it is specifically used to query the device template corresponding to the device type of the Modbus RTU device in the template library; if there is no corresponding device template, a template production reminder is sent for the Modbus RTU device so that the user can edit and produce the device template of the Modbus RTU device; the device template made by the user is bound to the device type of the Modbus RTU device and stored in the template library; if there is a corresponding device template, the corresponding device template is selected.
[0057] Furthermore, the data point table includes the register address, data type, parsing rule and read / write permission of the data point, and the interface configuration includes the controls corresponding to the data points; When the interaction interface module 202 generates the read / write interface corresponding to the interface configuration, it is specifically used to generate a read / write interface including the controls corresponding to each data point; among them, the controls corresponding to the data points of the read-only type registers include display controls for displaying the data point data; the controls corresponding to the data points of the read / write type registers include display controls, input boxes for the user to modify the register value and the first button controls.
[0058] Furthermore, when the Modbus packet assembly module 203 generates the Modbus RTU request message according to the data point table, it is specifically used to generate a Modbus RTU request message for the read / write instruction of the corresponding register in the Modbus RTU device according to the register address, data type, parsing rule and read / write permission of the data points in the data point table.
[0059] Furthermore, when the Modbus packet assembly module 203 parses the Modbus RTU response message returned by the Modbus RTU device, it is specifically used to parse the data point data in the Modbus RTU response message according to the parsing rule; When the interaction interface module 202 displays the data point data in the Modbus RTU response message in the read / write interface, it is specifically used to display the corresponding data point data in the display control corresponding to the data point in the display form of the corresponding data type.
[0060] Further, the general control device 200 of the Modbus RTU device further includes a special command module 205, which is used to generate a corresponding second button control in the read-write interface in response to the user's special command editing operation, and bind the special command to the second button control; The Modbus packet assembly module 203 is further used to generate a special command message indicating that the Modbus RTU device executes a special command by combining the special command and the data point table when the user clicks the second button control; The communication module 204 is further used to send the special command message to the Modbus RTU device so that the Modbus RTU device executes the special command.
[0061] Further, the communication parameters include RS485 communication parameters and / or Ethernet communication parameters. The RS485 communication parameters include baud rate, data bits, stop bits, and parity mode; the Ethernet communication parameters include IP address, port number, and timeout.
[0062] Figure 2 The general control device of the Modbus RTU device shown can be used to execute the technical solutions of the above method embodiments, and its implementation principles and technical effects are similar, which will not be elaborated here.
[0063] Figure 3 The electronic device shown can execute the processing flow provided by the embodiment of the general control method of the Modbus RTU device. The electronic device 300 includes: a memory 301, a processor 302, a computer program, and a communication interface 303; wherein, the computer program is stored in the memory 301 and is configured to be executed by the processor 302 to perform the general control method of the Modbus RTU device as above. In a specific embodiment, the memory 301 can be a non-volatile solid-state memory. In a specific embodiment, the memory 301 includes a read-only memory ROM (Read-Only Memory).
[0064] The present invention also provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the general control method of the Modbus RTU device described in the above embodiments. Among them, the storage medium can be a non-volatile / non-temporary computer-readable storage medium.
[0065] For, a preferred embodiment of the present invention is, For, a further preferred embodiment of the present invention is also that there is an elliptical through hole 4, and the major axis of the ellipse is parallel to the axis of the tube body 3.
[0066] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the technical principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A general control method for Modbus RTU equipment, characterized in that, include: Select a corresponding device template according to the device type of the Modbus RTU device, wherein the device template includes a data point table, communication parameters and interface configuration of the Modbus RTU device; Generate a corresponding read-write interface according to the interface configuration; Generate a Modbus RTU request message according to the data point table; Establishing a communication connection with the Modbus RTU device based on the communication parameters, and sending the Modbus RTU request message to the Modbus RTU device; Receive and parse the Modbus RTU response message returned by the Modbus RTU device, and display the data point data in the Modbus RTU response message in the read-write interface.
2. The universal control method of Modbus RTU equipment according to claim 1, characterized in that, Before selecting the corresponding device template according to the device type of the Modbus RTU device, the method further includes: Pre-store device templates for various types of Modbus RTU devices in the template library; The selecting a corresponding device template according to the device type of the Modbus RTU device includes: Querying the template library for a device template corresponding to the device type of the Modbus RTU device; If there is no corresponding device template, a template creation reminder is issued for the Modbus RTU device, so that the user can edit and create the device template of the Modbus RTU device; Binding the device template made by the user to the device type of the Modbus RTU device and storing them in the template library; If a corresponding device template exists, select the corresponding device template.
3. The universal control method of Modbus RTU equipment according to claim 1, characterized in that, The data point table includes the register address, data type, parsing rules and read / write permissions of the data point, and the interface configuration includes the controls corresponding to the data point; The generating of a read-write interface corresponding to the interface configuration includes: Generate a read-write interface containing controls corresponding to each data point; Among them, the controls corresponding to the data points of the read-only type register include a display control for displaying the data point data; the controls corresponding to the data points of the read-write type register include the display control and an input box and a first button control for the user to modify the register value.
4. The universal control method of Modbus RTU equipment according to claim 3, characterized in that, Generating a Modbus RTU request message according to the data point table includes: A Modbus RTU request message for read and write instructions for a corresponding register in the Modbus RTU device is generated according to the register address, data type, parsing rule and read and write permission of the data point in the data point table.
5. The universal control method of Modbus RTU equipment according to claim 3, characterized in that, The parsing of the Modbus RTU response message returned by the Modbus RTU device, and displaying the data point data in the Modbus RTU response message in the read-write interface, includes: Parsing the data point data in the Modbus RTU response message according to the parsing rule; The corresponding data point data is displayed in the display control corresponding to the data point according to the display form of the corresponding data type.
6. The universal control method of Modbus RTU equipment according to claim 3, characterized in that, The method further comprises: In response to a user's special command editing operation, generating a corresponding second button control in the read-write interface, and binding the special command to the second button control; When the user clicks the second button control, a special command message instructing the Modbus RTU device to execute the special command is generated in combination with the special command and the data point table, and the special command message is sent to the Modbus RTU device so that the Modbus RTU device executes the special command.
7. The universal control method of Modbus RTU equipment according to claim 1, characterized in that, The communication parameters include RS485 communication parameters and / or Ethernet communication parameters. The RS485 communication parameters include baud rate, data bit, stop bit and check mode; the Ethernet communication parameters include IP address, port number and timeout period.
8. A universal control device for Modbus RTU equipment, characterized in that: include: A device template module, used to select a corresponding device template according to the device type of the Modbus RTU device, wherein the device template includes a data point table, communication parameters and interface configuration of the Modbus RTU device; An interactive interface module, used to generate a corresponding read-write interface according to the interface configuration; A Modbus packet assembly module, used for generating a Modbus RTU request message according to the data point table; A communication module, used to establish a communication connection with the Modbus RTU device based on the communication parameters, and send the Modbus RTU request message to the Modbus RTU device; The communication module is also used to receive the Modbus RTU response message returned by the Modbus RTU device; The Modbus packet assembly module is also used to parse the Modbus RTU response message returned by the Modbus RTU device; The interactive interface module is also used to display the data point data in the Modbus RTU response message in the read-write interface.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: Program instructions are stored thereon, and when the program instructions are executed, the method according to any one of claims 1 to 7 is implemented.