A gateway device Modbus uplink configuration and data processing method and system

By configuring and processing the Modbus uplink protocol in the gateway device, the problem of low configuration and processing efficiency of Modbus uplink protocol in the substation site is solved, and the general configuration and uplink message processing of the Modbus uplink protocol are realized, ensuring the consistency and efficiency of sensor data processing.

CN119766912APending Publication Date: 2025-04-04NANJING ZHENGTU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411986980.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In substations and distribution stations, it is difficult for the existing technology to realize the general configuration of the Modbus uplink protocol and the uplink message processing, resulting in low sensor data processing efficiency and inconsistent protocol processing.

Method used

By presetting the uplink protocol type and data analysis method in the database dictionary table of the gateway machine, model and model information points are configured for each sensor, and uplink protocol model information points are created based on the model information points to generate an uplink protocol sensor data point table. Load data analysis and encapsulate dynamic libraries, encapsulate and store data, and realize Modbus data processing.

Benefits of technology

It realizes the general configuration of the Modbus uplink protocol and uplink message processing, ensuring the consistency of the corresponding Modbus protocol processing of the same sensor, improving data processing efficiency and protocol processing flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119766912A_ABST
    Figure CN119766912A_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of smart substations, and in particular to a gateway device Modbus uplink configuration and data processing method and system. The gateway device Modbus uplink configuration and data processing are performed according to the sensor type, and the sensor data is stored hierarchically (three-level map table) according to the Modbus communication address, read-write function code and register address. When the data changes, the register value is refreshed in time, and when the master station inquires, the frame is quickly assembled for response.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of smart substations, and in particular relates to a gateway device Modbus uplink configuration and data processing method and system. Background Art

[0002] Modbus is a serial communication protocol that is widely used in the field of industrial automation. It is mainly used to realize data transmission between devices and to monitor and control industrial processes. In substations, the use of Modbus protocol is also common. Modbus protocol includes three protocols: Modbus ASCII, Modbus RTU, and Modbus TCP. When using serial port transmission, you can use Modbus ASCII or Modbus RTU protocol. These two protocols specify messages, data structures, commands and response methods, and require data verification; when using Modbus TCP protocol, data verification is not required, but a 2-byte transaction identifier, a 2-byte protocol type, and a 2-byte data length are added.

[0003] In the substation, the intelligent auxiliary system gateway device is used to collect sensor data in the substation, process the data and upload it to the platform of other devices. The intelligent auxiliary system gateway device has multiple interfaces such as serial port, network port, input and output interface, wireless interface, etc., which supports the collection of various types of sensor data and also supports the upload of various types of protocol data.

[0004] For the gateway devices in the station house, it is also a common scenario to use the serial port or network port to upload the Modbus data protocol. In this mode, the host device or the upstream platform acts as the Modbus master station and sends query messages to the gateway device at regular intervals. The gateway device organizes the message to be sent according to the Modbus communication address and register address range defined in the query message. For the control message sent by the host device or the upstream platform, the gateway device obtains the Modbus communication address, register address and control value defined in the message, and translates the control command and writes it into the controlled sensor device. Summary of the invention

[0005] The object of the present invention is to provide a gateway device Modbus uplink configuration and data processing method and system, which is a universal configuration method of the Modbus uplink protocol and an uplink message processing method.

[0006] In order to achieve the above-mentioned objectives, the first aspect of the present invention is to provide a Modbus uplink configuration method for a gateway device, wherein the uplink protocol type and data parsing method are preset in the database dictionary table of the gateway; a model and a model information point are configured for each sensor in the gateway; sensor information is configured in the gateway, including a sensor table and a sensor data point table; according to the model information point, an uplink protocol model information point corresponding to the model information point is created; according to the sensor table and the sensor data point table of the gateway, the uplink protocol model information point corresponding to the model information point corresponding to the sensor data point is found, and an uplink protocol sensor data point table is generated.

[0007] In a preferred implementation scheme, the address url of the uplink protocol sensor data point inherits the address url information of the corresponding uplink protocol model information point, and a Modbus communication address is assigned to each sensor in the address url of the uplink protocol sensor data point according to the sensor serial number (equivalent to the sensor order, starting from 1 and increasing).

[0008] Furthermore, the address url information of the uplink protocol model information point includes the Modbus register address, data length, multiplication rate, read / write function code, and data encapsulation method.

[0009] The second aspect of the present invention discloses a gateway device Modbus data processing method, comprising the following steps:

[0010] Load the data parsing and encapsulation dynamic library, load the parsing functions and encapsulation functions in the data parsing and encapsulation dynamic library;

[0011] Load the aforementioned configured sensor table, sensor data point table and uplink protocol sensor data point table;

[0012] A three-level Map table is preset for the uplink protocol sensor data point data to store the corresponding sensor data. The keyword of the first-level Map table is the Modbus communication address, the keyword of the second-level Map table is the Modbus register type, and the keyword of the third-level Map table is the Modbus register address, and the value is the register value;

[0013] When the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point, processes the sensor data according to the magnification, and then calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data, and stores the encapsulated data in the corresponding position of the three-level map table. The corresponding position refers to the corresponding Modbus register address;

[0014] When the master station sends a Modbus query command, the gateway obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs a frame response according to the Modbus message format;

[0015] When the master station sends a Modbus control command, the gateway obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

[0016] In a preferred implementation scheme, when loading the sensor table, sensor data point table and uplink protocol sensor data point table, the Modbus communication address, Modbus register address, data type, data length, multiplier, data encapsulation method, and read and write function code information of the uplink protocol sensor data point are parsed according to the address url configured for the uplink protocol sensor data point.

[0017] A third aspect of the present invention is to provide a gateway device Modbus uplink configuration system, comprising:

[0018] A gateway machine database dictionary table configuration module, which presets the uplink protocol type and data parsing method in the gateway machine's database dictionary table;

[0019] Model and model information point configuration module, which configures the model and model information point for each sensor in the gateway machine;

[0020] A sensor information configuration module configures sensor information in the gateway machine, including a sensor table and a sensor data point table;

[0021] An uplink protocol model information point configuration module creates an uplink protocol model information point corresponding to the model information point according to the model information point;

[0022] The uplink protocol sensor data point configuration module searches for the uplink protocol model information point corresponding to the model information point corresponding to the sensor data point according to the sensor table and sensor data point table of the gateway machine, and generates the uplink protocol sensor data point table.

[0023] A fourth aspect of the present invention discloses a gateway device Modbus data processing system, comprising:

[0024] Data parsing and encapsulation dynamic library loading module, loading data parsing and encapsulation dynamic library, loading parsing functions and encapsulation functions in data parsing and encapsulation dynamic library;

[0025] The Modbus uplink configuration loading module of the gateway device loads the sensor table, sensor data point table and uplink protocol sensor data point table configured by the gateway device;

[0026] The data storage map table module presets a three-level map table for the sensor data of the uplink protocol sensor data point to store the corresponding data. The keyword of the first-level map table is the Modbus communication address, the keyword of the second-level map table is the Modbus register type, and the keyword of the third-level map table is the Modbus register address, and the value is the register value;

[0027] Data encapsulation module: after the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point and calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data;

[0028] The query response module, when the master station sends a Modbus query command, obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs frame response according to the Modbus message format;

[0029] The control module, when the master station sends a Modbus control instruction, obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

[0030] The control instructions are generally the control of the sensor switch quantity, on or off, etc., which are expressed as 1 or 0 in the control value; there are also parameter settings for the sensor, such as adjustment of the air conditioning mode, temperature control, etc.

[0031] When the upstream Modbus master controls and queries sensor data, the read and write function codes are used to distinguish register types.

[0032] When the uplink Modbus master controls the sensor data, finding the corresponding uplink protocol sensor data point means: the gateway finds the uplink protocol sensor data point whose Modbus communication address is consistent with the Modbus communication address in the control message, whose write function code is consistent with the write function code in the control message, and whose register address is the same as the register address in the control message, and then finds the corresponding sensor data point according to the sensor data point id.

[0033] When the upstream Modbus master station queries the sensor data, the value of the corresponding register address is obtained from the three-level Map table: the gateway machine searches the three-level Map table for the Modbus communication address that is consistent with the Modbus communication address in the control message, the read function code that is consistent with the read function code in the control message, and the register address that is within the register address range in the control message. Setting up the three-level Map table makes it easier for the upstream Modbus master station to search for sensor data; through the communication address, read and write function code and register address, it is easier for the Modbus master station to control the sensor data.

[0034] A fifth aspect of the present invention is to provide a processor, which is used to run a computer program. When the computer program is running, it executes the Modbus uplink configuration method of the gateway device as described above, and the Modbus data processing method of the gateway device as described above.

[0035] The sixth aspect of the present invention is to disclose a gateway machine, including the aforementioned gateway machine device Modbus uplink configuration system and the aforementioned gateway machine device Modbus data processing system.

[0036] The seventh aspect of the present invention is to provide a computer-readable medium having a computer program stored thereon, wherein the computer program is executed by a processor as described above in the gateway device Modbus uplink configuration method and the gateway device Modbus data processing method.

[0037] The invention is beneficial in that: by configuring the uplink Modbus protocol model information point according to the model information point, the invention can achieve consistency in Modbus protocol processing corresponding to the same sensor. Multiple sensor devices of the same type only have different Modbus communication addresses, and the register addresses and packaging methods and other parameters of the same data point of the same sensor device are consistent, which facilitates the uplink Modbus master station to process the data points of the same type of sensor. In addition, the sensor data is hierarchically stored (three-level Map table) according to the read-write function code, and the register value is timely refreshed according to the parameter (multiplier) and packaging method when the data changes. When the master station inquires, the frame is quickly assembled for response.

[0038] The present invention supports flexible switching of uplink protocols (ModbusRTU, ModbusTCP), establishes communication channels and processes response message framing according to the configured uplink protocols, supports Modbus configuration export, uses data encapsulation dynamic library methods for data processing, and supports encapsulation method expansion. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is the correspondence between the model information point and the uplink protocol model information point;

[0040] Figure 2 It is the correspondence between sensor data points and uplink protocol sensor data points;

[0041] Figure 3 It is a schematic diagram of the storage and packaging of sensor numerical point values;

[0042] Figure 4 This is a schematic diagram of the gateway machine data processing when the master station sends a Modbus query command. DETAILED DESCRIPTION

[0043] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.

[0044] A Modbus uplink configuration method for a gateway device includes presetting an uplink protocol type and a data parsing method in a database dictionary table of the gateway; configuring a model and a model information point for each sensor in the gateway; configuring sensor information in the gateway, including a sensor table and a sensor data point table; creating an uplink protocol model information point corresponding to the model information point according to the model information point; searching for an uplink protocol model information point corresponding to the model information point corresponding to the sensor data point according to the sensor table and the sensor data point table of the gateway, and generating an uplink protocol sensor data point table.

[0045] The address url of the upstream protocol sensor data point inherits the address url information of the corresponding upstream protocol model information point, and allocates a Modbus communication address in the address url of the upstream protocol sensor data point to each sensor according to the sensor sequence number.

[0046] The address url information of the uplink protocol model information point includes the Modbus register address, data length, multiplication rate, read and write function code, and data encapsulation method.

[0047] A gateway device Modbus data processing method comprises the following steps:

[0048] Load data parsing and encapsulation dynamic libraries, load parsing functions and encapsulation functions in dynamic libraries;

[0049] Load the aforementioned configured sensor table, sensor data point table and uplink protocol sensor data point table;

[0050] A three-level Map table is preset for the uplink protocol sensor data point data to store the corresponding data. The keyword of the first-level Map table is the Modbus communication address, the keyword of the second-level Map table is the Modbus register type, the keyword of the third-level Map table is the Modbus register address, and the value of the Map table is the register value;

[0051] When the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point, processes the sensor data according to the magnification, calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data, and stores the encapsulated data in the corresponding position of the three-level map table;

[0052] When the master station sends a Modbus query command, the gateway obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs a frame response according to the Modbus message format;

[0053] When the master station sends a Modbus control command, the gateway obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

[0054] When loading the sensor table, sensor data point table and uplink protocol sensor data point table, the Modbus communication address, Modbus register address, data type, data length, multiplication factor, data encapsulation method and read / write function code information of the uplink protocol sensor data point are parsed according to the address url configured by the uplink protocol sensor data point.

[0055] A Modbus uplink configuration system for a gateway device, comprising:

[0056] A gateway machine database dictionary table configuration module, which presets the uplink protocol type and data parsing method in the gateway machine's database dictionary table;

[0057] Model and model information point configuration module, which configures the model and model information point for each sensor in the gateway machine;

[0058] A sensor information configuration module configures sensor information in the gateway machine, including a sensor table and a sensor data point table;

[0059] An uplink protocol model information point configuration module creates an uplink protocol model information point corresponding to the model information point according to the model information point;

[0060] The uplink protocol sensor data point configuration module searches for the uplink protocol model information point corresponding to the model information point corresponding to the sensor data point according to the sensor table and sensor data point table of the gateway machine, and generates the uplink protocol sensor data point table.

[0061] A gateway device Modbus data processing system, comprising:

[0062] Data parsing and encapsulation dynamic library loading module, loads data parsing and encapsulation dynamic library, loads parsing functions and encapsulation functions in the dynamic library;

[0063] The Modbus uplink configuration loading module of the gateway device loads the sensor table, sensor data point table and uplink protocol sensor data point table configured by the gateway device;

[0064] The data storage map table module presets a three-level map table for the uplink protocol sensor data point data to store the corresponding data. The keyword of the first-level map table is the Modbus communication address, the keyword of the second-level map table is the Modbus register type, the keyword of the third-level map table is the Modbus register address, and the value of the map table is the register value;

[0065] Data encapsulation module: after the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point and calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data;

[0066] The query response module, when the master station sends a Modbus query command, obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs frame response according to the Modbus message format;

[0067] The control module, when the master station sends a Modbus control instruction, obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

[0068] Specifically, the uplink protocol type is preset in the database dictionary table of the gateway machine, as shown in Table 1:

[0069] Table 1 Preset uplink protocol in database dictionary table

[0070] Dictionary code Dictionary item id name describe agreementtype 10 ModbusRTU protocol ModbusRTU protocol agreementtype 11 ModbusTCP Protocol ModbusTCP Protocol

[0071] The data parsing method is preset in the database dictionary table and can be expanded, as shown in Table 2:

[0072] Table 2 Preset data parsing method for database dictionary table

[0073]

[0074] In the gateway machine, a model is added for each sensor type, a unique model ID is assigned to each sensor type, and the common data points of the sensor are defined as model information points. The model table includes but is not limited to the following fields, as shown in Table 3:

[0075] Table 3 Model table fields

[0076]

[0077]

[0078] The model information point table (modelpoint) includes but is not limited to the following fields, as shown in Table 4:

[0079] Table 4 Model information point table fields

[0080]

[0081] The address url in the model information point table contains parameter information of a certain data point of the sensor, including data type (including Boolean, short integer, integer, floating point, long integer, character, string, etc.), four remote types, data offset, conversion coefficient, data length, data parsing method, number of decimal places, etc. Data offset and conversion coefficient can be omitted in some embodiments.

[0082] Configure the sensor in the gateway machine and write the sensor configuration information into the database configuration table.

[0083] The sensor table (sensor) is shown in Table 5 below:

[0084] Table 5 Sensor table

[0085] Fields type illustrate id Number Sensor id, non-null, * name String Sensor Name commaddr String Sensor communication parameters modelid Number Model id, indicating which model the sensor belongs to

[0086] The data point information of the sensor is stored in the database configuration table:

[0087] The sensor data point table (sensorpoint) is shown in Table 6 below:

[0088] Table 6 Sensor data point table

[0089] Fields type illustrate id Number Sensor data point id, non-null, * name String Sensor data point name sensorid Number Sensor ID url Number Parameter information of sensor data points ModelPointId Number Model information point id

[0090] There is a corresponding relationship between sensor data points and model information points. The URL information of the sensor data point table directly inherits the URL information of the corresponding model information point id in the model information point table.

[0091] In the database of the gateway machine, add the uplink protocol model information point configuration table for each sensor:

[0092] The uplink protocol model information point table (protocolmodelpoint) is shown in Table 7 below:

[0093] Table 7 Uplink protocol model information point table

[0094]

[0095]

[0096] For the uplink Modbus protocol model information point (i.e., the uplink protocol model information point), the url information includes: Modbus register address, data length, multiplier, Bit / Byte flag, read / write function code, and data encapsulation method, that is, the sensor data collected by the gateway is translated into a hexadecimal integer value stored in the register through the content in the url information for use by the master station when querying.

[0097] The uplink protocol type is set in the uplink protocol model information point table, and the uplink protocol agreementtype can be ModbusRTU or ModbusTCP, so the present invention supports flexible switching between ModbusRTU and ModbusTCP.

[0098] Add an uplink protocol sensor data point configuration table for each sensor in the gateway database:

[0099] The uplink protocol sensor data point table (protocolsensorpoint) is shown in Table 8 below:

[0100] Table 8 Uplink protocol sensor data point table

[0101]

[0102] All the above tables are written to the gateway machine database.

[0103] Models and model information points are preset in the gateway for each sensor and sensor data point to represent the communication parameters and data characteristics of this type of sensor. Generally, the URL of each model information point contains parameter information of a certain data point of this type of sensor, including data type, data offset, conversion coefficient, number of decimal places, data length, data parsing method, etc. In addition, there will be different parameters depending on the access protocol. For example, wireless Lora will involve parameters; Modbus protocol involves register address, read and write function code, etc.

[0104] For the Modbus uplink protocol, the gateway acts as a Modbus slave station, responds to the Modbus query command from the uplink platform master station, and encapsulates and responds to the data collected by the gateway station according to the requirements of the Modbus message format. Therefore, it is necessary to map the data collected by the gateway machine into the Modbus data block to facilitate message assembly when the master station queries.

[0105] Perform one-key initialization of the uplink Modbus protocol model information point for the model and model information point archived in the gateway machine. The method is as follows:

[0106] like Figure 1 As shown, all models and model information points created in the gateway are obtained, the four remote types, data types, data parsing methods and other information of the model information points are obtained, and the uplink Modbus protocol model information points corresponding to the model information points are created respectively. The register address in the url in the uplink protocol model information point table is incremented in sequence according to the model information point serial number under the model (i.e., the model information point sequence, the serial number starts from 1 and increases in sequence). For general data and the two bytes of the register address, the value range fully meets the requirements. For some special values, it may be necessary to occupy multiple registers, and the register occupation may be expanded as appropriate; the data length is generally two bytes, and the corresponding data length is modified according to the occupied register address, for example, the data length = register address range length * 2. In order to retain the data precision, the floating point number determines the data precision according to the number of decimal places reserved in the previous model information point. The number of decimal places reserved in the model information point corresponds to the multiple of the uplink protocol model information point. For example, when the number of decimal places reserved is two, the multiple is 0.01; for example, the read and write function codes are initialized to 0x03 and 0x10, and the configuration can be preset in the gateway to modify the read and write function codes. The data encapsulation method for the uplink Modbus protocol model information point and sensor data point can be set to the method corresponding to the data parsing method of the model information point.

[0107] The specific content of the name field of the model information point is directly stored in the name field of the upstream Modbus protocol model information point, the specific content of the modelid field of the model information point is directly stored in the modelid field of the upstream Modbus protocol model information point, and the specific content of the id field of the model information point is directly stored in the modelpointid field of the upstream Modbus protocol model information point.

[0108] Among them, in the uplink Modbus protocol model information point, the register address in the url increases in sequence according to the order of the model information points under the model. The url of the uplink Modbus protocol model information point can determine the data encapsulation method according to the data parsing method in the model information point url, and determine the read and write function code according to the four remote types in the model information point url (the telemetry and telesignaling data can default to the function code 0x03 or 0x04, the remote control and remote adjustment data can default to the function code 0x0f or 0x10, and the function code can also be customized as needed), and the multiplication factor is determined according to the number of decimal places in the model information point url; usually, the data length in the url of the uplink Modbus protocol model information point is directly defaulted to 2 bytes, and the data length in the url of the uplink Modbus protocol model information point can also be determined according to the data length in the url in the model information point table.

[0109] like Figure 2 As shown in the figure, after the uplink Modbus protocol model information point is generated, the configuration of the uplink Modbus protocol model information point corresponding to the model information point corresponding to the sensor data point is found according to the existing sensors and sensor data points configured in the gateway machine, and the initialization operation is performed to generate the uplink protocol sensor data point configuration. For the uplink Modbus protocol, the url of the uplink protocol sensor data point not only inherits the url information of the corresponding uplink Modbus protocol model information point, but also needs to allocate a Modbus communication address to each sensor according to the sensor serial number (starting from 1 and increasing in sequence). The allocation rule can be increased in sequence according to the sensor serial number.

[0110] Specifically, according to the existing sensors and sensor data points configured in the gateway machine, the configuration of the uplink Modbus protocol model information point corresponding to the model information point corresponding to the sensor data point is found, the uplink protocol information and url information are obtained, and the uplink protocol sensor data point table is generated: the specific content of the name field in the sensor data point table is stored in the name field in the uplink protocol sensor data point, the specific content of the sensorid field in the sensor data point table is stored in the sensorid field in the uplink protocol sensor data point, the specific content of the id field in the sensor data point table is stored in the sensorpointid field in the uplink protocol sensor data point, and the specific content of the uplink protocol agreementtype field in the uplink protocol model information point table is stored in the agreementtype field in the uplink protocol sensor data point table, the url inherits the url information of the corresponding uplink Modbus protocol model information point, and a Modbus communication address is assigned to each sensor according to the sensor serial number.

[0111] The above method is applicable to the gateway device to convert sensor data of various access types into Modbus messages for output.

[0112] The preset data parsing and encapsulation library is a dynamic library. When processing data, the corresponding function interface in the dynamic library is called to translate the value of the sensor data point into the value in the Modbus register.

[0113] The Modbus data processing method of the gateway device comprises the following specific steps:

[0114] STEP1: After the Modbus data processing module of the gateway device is started, load the data parsing and encapsulation dynamic library, and load the parsing function and encapsulation function in the dynamic library;

[0115] STEP2: Load database configuration, including sensor configuration, sensor data point configuration, and uplink protocol sensor data point configuration. For the uplink Modbus protocol, according to the uplink protocol sensor data point configuration URL, parse the Modbus communication address, Modbus register address, data type, data length, magnification, data encapsulation method, read and write function code and other information of the uplink protocol sensor data point;

[0116] STEP3: Preset a three-level Map table for the uplink Modbus sensor data point (i.e., uplink protocol sensor data point) data to store the data corresponding to the data point. The keyword of the first-level Map table is the Modbus communication address, the keyword of the second-level Map table is the Modbus register type, the keyword of the third-level Map table is the Modbus register address, and the value is the register value.

[0117] According to the Modbus communication address, read / write function code, and Modbus register address of all loaded uplink Modbus sensor data points, calculate each Modbus communication address and the Modbus register address range of each register type, initialize the three-level Map table, and initialize the content of each Modbus register address; wherein the corresponding register type (coil register, discrete input register, holding register, input register) is determined according to the read / write function code;

[0118] STEP4: After the gateway collects sensor data, it finds the corresponding uplink Modbus protocol sensor data point (i.e., uplink protocol sensor data point), configures the URL according to the uplink protocol sensor data point, obtains the data encapsulation method, and calls the dynamic library encapsulation interface, which is the encapsulation function. The input parameters are the collected sensor data point value, data length, encapsulation method, etc., perform data encapsulation, obtain the encapsulated value, and use the encapsulated value to refresh the Map table register value.

[0119] Before encapsulation, the collected sensor data point value is divided by the multiplier to obtain an integer value. During encapsulation, the data encapsulation method is obtained according to the uplink protocol sensor data point configuration URL, and the corresponding encapsulation function is called according to the data encapsulation method to encapsulate the aforementioned integer value. Then it is added to the three-level map table.

[0120] The magnification is usually a value less than 1, usually 0.1, 0.01, etc., in order to retain the calculation accuracy. The slave end is divided by this magnification to enlarge the data; the master end reads this value and multiplies it by this magnification to get the value of decimal point precision. The advantage of this processing is that there is no need to consider floating-point values. All values ​​can be converted into integer values ​​before data encapsulation, and then the data is encapsulated.

[0121] STEP5: When the master sends a Modbus query command, obtain the Modbus communication address, read function code, and register address range in the query message, obtain the value of the corresponding register address from the Modbus level 3 Map table, and perform a frame response according to the Modbus message format. Figure 4 shown.

[0122] For frame response, if the uplink protocol is ModbusRTU, the frame is formed in the way of ModbusRTU; if the uplink protocol is ModbusTCP, the frame is formed in the way of ModbusRTU.

[0123] STEP6: When the master station sends a Modbus control instruction, obtain the Modbus communication address, write function code, register address and control value in the control message, find the corresponding uplink Modbus protocol sensor data point according to the Modbus communication address, write function code and register address, then find the corresponding sensor data point, write the control value into the sensor data point and send the control.

[0124] After the gateway obtains the control value in the control message, it calls the corresponding parsing function according to the encapsulation method of the corresponding uplink protocol sensor data point for parsing, and then writes the parsed control value into the sensor data point.

[0125] The present invention configures the uplink Modbus protocol model information point according to the sensor model information point, so as to achieve the consistency of Modbus protocol processing corresponding to the same sensor. Multiple sensor devices of the same type have only different Modbus communication addresses, and the parameters such as the register address and packaging method of the same data point are consistent, so that the uplink Modbus master station can process the data points of the same type of sensor conveniently. In addition, the sensor data is hierarchically stored (three-level Map table) according to the communication address, read-write function code and register address, and the register value is timely refreshed according to the parameter (multiplier) and packaging method when the data changes, and when the master station inquires, the frame is quickly formed to respond.

[0126] The present invention supports flexible switching of uplink protocols (ModbusRTU, ModbusTCP), establishes communication channels and processes response message framing according to the configured uplink protocols, supports exporting uplink Modbus configuration (uplink protocol model information point table and uplink protocol sensor data point table), uses data encapsulation dynamic library method for data processing, and supports encapsulation method expansion.

[0127] The above embodiments are only used to illustrate the technical solutions of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form, and any technical solutions obtained by equivalent replacement or equivalent transformation shall fall within the protection scope of the present invention.

Claims

1. A gateway device Modbus uplink configuration method, characterized in that: Preset the uplink protocol type and data parsing method in the database dictionary table of the gateway machine; Configure models and model information points for each sensor in the gateway machine; Configure sensor information in the gateway machine, including sensor table and sensor data point table; According to the model information point, create the uplink protocol model information point corresponding to the model information point; according to the sensor table and sensor data point table of the gateway machine, find the uplink protocol model information point corresponding to the model information point corresponding to the sensor data point, and generate the uplink protocol sensor data point table.

2. A gateway device Modbus uplink configuration method according to claim 1, characterized in that: The address url of the upstream protocol sensor data point inherits the address url information of the corresponding upstream protocol model information point, and allocates a Modbus communication address in the address url of the upstream protocol sensor data point to each sensor according to the sensor sequence number.

3. A gateway device Modbus uplink configuration method according to claim 2, characterized in that: The address url information of the uplink protocol model information point includes the Modbus register address, data length, multiplication rate, read and write function code, and data encapsulation method.

4. A gateway device Modbus data processing method, characterized in that: The steps include: Load the data parsing and encapsulation dynamic library, load the parsing functions and encapsulation functions in the data parsing and encapsulation dynamic library; Loading the sensor table, sensor data point table, and uplink protocol sensor data point table configured in claim 1; A three-level Map table is preset for the uplink protocol sensor data point data to store the corresponding sensor data. The keyword of the first-level Map table is the Modbus communication address, the keyword of the second-level Map table is the Modbus register type, and the keyword of the third-level Map table is the Modbus register address, and the value is the register value; When the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point, processes the sensor data according to the magnification, calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data, and stores the encapsulated data in the corresponding position of the three-level map table; When the master station sends a Modbus query command, the gateway obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs a frame response according to the Modbus message format; When the master station sends a Modbus control command, the gateway obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

5. A gateway device Modbus data processing method according to claim 4, characterized in that: When loading the sensor table, sensor data point table and uplink protocol sensor data point table, the Modbus communication address, Modbus register address, data type, data length, multiplication factor, data encapsulation method and read / write function code information of the uplink protocol sensor data point are parsed according to the address url configured by the uplink protocol sensor data point.

6. A Modbus uplink configuration system for a gateway device, characterized in that: include: A gateway machine database dictionary table configuration module, which presets the uplink protocol type and data parsing method in the gateway machine's database dictionary table; Model and model information point configuration module, which configures the model and model information point for each sensor in the gateway machine; A sensor information configuration module configures sensor information in the gateway machine, including a sensor table and a sensor data point table; An uplink protocol model information point configuration module creates an uplink protocol model information point corresponding to the model information point according to the model information point; The uplink protocol sensor data point configuration module searches for the uplink protocol model information point corresponding to the model information point corresponding to the sensor data point according to the sensor table and sensor data point table of the gateway machine, and generates the uplink protocol sensor data point table.

7. A gateway device Modbus data processing system, characterized in that: include: Data parsing and encapsulation dynamic library loading module, loading data parsing and encapsulation dynamic library, loading parsing functions and encapsulation functions in data parsing and encapsulation dynamic library; The Modbus uplink configuration loading module of the gateway device loads the sensor table, sensor data point table and uplink protocol sensor data point table configured by the gateway device; The data storage map table module presets a three-level map table for the sensor data of the uplink protocol sensor data point to store the corresponding data. The keyword of the first-level map table is the Modbus communication address, the keyword of the second-level map table is the Modbus register type, and the keyword of the third-level map table is the Modbus register address, and the value is the register value; Data encapsulation module: after the gateway collects sensor data, it finds the corresponding uplink protocol sensor data point and calls the encapsulation function of the data parsing and encapsulation dynamic library to encapsulate the data; The query response module, when the master station sends a Modbus query command, obtains the Modbus communication address, read function code, and register address range in the query message sent by the master station, obtains the value of the corresponding register address from the three-level Map table, and performs frame response according to the Modbus message format; The control module, when the master station sends a Modbus control instruction, obtains the Modbus communication address, write function code, register address and control value in the control message sent by the master station, finds the corresponding uplink protocol sensor data point according to the Modbus communication address, write function code and register address, and then finds the corresponding sensor data point, writes the control value into the sensor data point and sends the control.

8. A processor for running a computer program, characterized in that: When the computer program is running, the Modbus uplink configuration method of the gateway device as described in any one of claims 1 to 3 and the Modbus data processing method of the gateway device as described in claim 4 or 5 are executed.

9. A gateway machine, characterized in that: It includes the gateway device Modbus uplink configuration system as described in claim 6 and the gateway device Modbus data processing system as described in claim 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: The computer program is executed by the processor as the gateway device Modbus uplink configuration method as described in any one of claims 1-3, and the gateway device Modbus data processing method as described in claim 4 or 5.