Equipment data reading method and device, electronic equipment and storage medium

The master device actively obtains slave device information and measurement point data storage address and directly reads the device data, solving the problems of complex equipment data reading and high error rate in the prior art, and achieving more efficient and reliable data reading.

CN119440644AActive Publication Date: 2025-02-14ZHEJIANG CHINT IOT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202310945860.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-28
Publication Date
2025-02-14
Estimated Expiration
2043-07-28

AI Technical Summary

Technical Problem

The existing device data reading method requires the modbus address table and parameters to be configured through the gateway or the master device, resulting in complex reading methods and high error rates.

Method used

The master device actively sends commands to the slave device, obtains device information and collects the measurement point data storage address by itself, and directly reads the device data to avoid the gateway configuration process.

Benefits of technology

Simplifies the device data reading process, reduces error rate, improves read efficiency, and reduces the complexity of gateway configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an equipment data reading method and device, electronic equipment and a storage medium, and relates to the technical field of computer information, equipment information reading instructions are sent to slave equipment according to equipment addresses of the slave equipment, and equipment information of the slave equipment is determined; sending a data address reading instruction to each slave device according to the device information of each slave device, and determining a measuring point data storage address of each slave device; sending a data reading instruction to each slave device according to the measuring point data storage address in each slave device, and obtaining device data returned by each slave device based on the data reading instruction; according to the method, the master device actively sends the response instruction to the slave devices, the measuring point data storage addresses of the slave devices are automatically collected, and then the device data in the slave devices are read, so that the problems that the reading mode is complex and the error rate is high due to the fact that a gateway or the master device needs to be configured in an existing device data reading method are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer information technology, and in particular to a device data reading method, device, electronic device and storage medium. Background Art

[0002] At present, most of the device detection and analysis based on the modbus communication protocol need to collect device data, such as measuring temperature, humidity, and power parameters. Because the modbus address tables defined by different devices are different, that is, the addresses and data formats of the device data to be collected are different in different devices, for systems connected to different devices, when obtaining device data from different devices, the master device or gateway needs to collect the data of each device.

[0003] The current device data reading method requires configuring the gateway or master device to define some key parameters of the measurement points that need to be collected, such as the modbus start position address, data format, and the upper and lower limit parameters of the measurement points, which often need to be configured in the gateway. This method increases the complexity of gateway configuration, has many parameters, and is prone to errors. Summary of the invention

[0004] The embodiments of the present application provide a device data reading method, apparatus, electronic device and storage medium to improve the problem that the existing device data reading method needs to configure a gateway or a main device, which causes the reading method to be complex and the error rate to be high.

[0005] On the one hand, an embodiment of the present application provides a device data reading method, the method is applied to a device data reading system, the device data reading system includes a master device and at least one slave device connected to the master device, the method is applicable to the master device, and the method includes:

[0006] According to the device address of each slave device, a device information reading instruction is sent to each slave device to determine the device information of each slave device;

[0007] Sending a data address read instruction to each of the slave devices according to the device information of each of the slave devices, and determining a measurement point data storage address of each of the slave devices according to address feedback information returned by each of the slave devices based on the data address read instruction;

[0008] A data reading instruction is sent to each of the slave devices according to the measurement point data storage address in each of the slave devices, and device data returned by each of the slave devices based on the data reading instruction is obtained.

[0009] On the other hand, an embodiment of the present application provides a device data reading apparatus, the apparatus comprising:

[0010] A device information acquisition module, used to send a device information reading instruction to each slave device according to the device address of each slave device, and determine the device information of each slave device;

[0011] An address acquisition module is used to send a data address reading instruction to each of the slave devices according to the device information of each of the slave devices, and determine the measurement point data storage address of each of the slave devices according to the address feedback information returned by each of the slave devices based on the data address reading instruction;

[0012] The data acquisition module is used to send a data reading instruction to each of the slave devices according to the measurement point data storage address in each of the slave devices, and obtain the device data returned by each of the slave devices based on the data reading instruction.

[0013] On the other hand, an embodiment of the present application provides an electronic device, including a memory and a processor; the memory stores an application, and the processor is used to run the application in the memory to perform the operations in the above-mentioned device data reading method.

[0014] On the other hand, an embodiment of the present application provides a storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in the above-mentioned device data reading method.

[0015] The embodiments of the present application provide a device data reading method, apparatus, electronic device and storage medium, which relate to the field of computer information technology and are applied to a device data reading system. The device data reading system includes a master device and at least one slave device connected to the master device. The device information of each slave device is determined by sending a device information reading instruction to each slave device according to the device address of each slave device; a data address reading instruction is sent to each slave device according to the device information of each slave device, and the measuring point data storage address of each slave device is determined according to the address feedback information returned by each slave device based on the data address reading instruction; a data reading instruction is sent to each slave device according to the measuring point data storage address in each slave device, and the device data returned by each slave device based on the data reading instruction is obtained; the embodiments of the present application obtain the device information in the slave device by actively sending a response instruction to the slave device, collect the measuring point data storage address of each slave device according to the device information, and read the device data in the slave device based on the measuring point data storage address of each slave device, so that the process of configuring the parameters of each slave device by the gateway is not required, and the problem of complex reading mode and high error rate caused by the need to configure the gateway or the master device in the existing device data reading method is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0017] Figure 1 It is a schematic diagram of an application scenario of the device data reading method provided in an embodiment of the present application;

[0018] Figure 2 It is a flowchart of a method for reading device data provided by an embodiment of the present application;

[0019] Figure 3 It is a schematic diagram of storage partitions of a linked list storage structure provided in an embodiment of the present application;

[0020] Figure 4 It is a schematic diagram of the measurement point address area in the slave device provided in the embodiment of the present application;

[0021] Figure 5 It is a flow chart of a method for obtaining a measurement point data storage address provided in an embodiment of the present application;

[0022] Figure 6 It is a schematic diagram of allocation of storage partitions of a slave device provided in an embodiment of the present application;

[0023] Figure 7 It is a flowchart of a method for acquiring device data provided in an embodiment of the present application;

[0024] Figure 8 It is a schematic diagram of the flow of sending a data reading instruction provided in an embodiment of the present application;

[0025] Fig. 9 It is a structural schematic diagram of a device data reading apparatus provided in an embodiment of the present application;

[0026] Fig.10 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the present invention will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.

[0028] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.

[0029] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0030] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.

[0031] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0032] As described in the background technology, when device data is read based on the Modbus protocol, there are differences in the Modbus address tables and parameter formats corresponding to different devices. When a master device or a gateway device is needed to read device data in a system based on the Modbus protocol, it is necessary to pre-configure the parameters of the master device or the gateway device based on the Modbus address tables and parameter formats corresponding to different devices, which will increase the complexity of the gateway configuration and thus increase the complexity of device data reading; when there are many devices connected to the system, it involves the configuration of multiple parameters, and there may be parameter mismatches, thereby increasing the probability of failure or errors in device data reading.

[0033] Based on this, in order to reduce the complexity of device data reading in a system based on the Modbus protocol, and at the same time reduce the probability of failure or error in device data reading, an embodiment of the present application provides a device data reading method, in which the master device actively sends a response instruction to the slave device to obtain device information in the slave device, collects the measurement point data storage address of each slave device according to the device information, and reads the device data in the slave device based on the measurement point data storage address of each slave device. In this way, there is no need for the gateway to configure the parameters of each slave device, thereby improving the problem of complex reading method and high error rate caused by the need to configure the gateway or master device in the existing device data reading method.

[0034] In order to facilitate understanding of the technical solution of the present application, the device data reading method provided in the embodiment of the present application will be introduced below in combination with actual application scenarios.

[0035] For example, take the application of the read device data to analyze the device operation status as an example, see Figure 1 , Figure 1 1 is a schematic diagram of an application scenario of the device data reading method provided in an embodiment of the present application. The application scenario shown includes a data processing device 101 and a device data reading system 102.

[0036] Among them, the device data reading system 102 is used to send a device information reading instruction to each slave device according to the device address of each slave device to determine the device information of each slave device; send a data address reading instruction to each slave device according to the device information of each slave device, and determine the measurement point data storage address of each slave device according to the address feedback information returned by each slave device based on the data address reading instruction; send a data reading instruction to each slave device according to the measurement point data storage address in each slave device, obtain the device data returned by each slave device based on the data reading instruction, and upload the device data returned by each slave device based on the data reading instruction to the data processing device 101.

[0037] The data processing device 101 is used to perform data analysis based on the device data obtained by the device data reading system 102 to determine the operating status of each slave device. The data analysis includes but is not limited to obtaining statistical features and comparing with reference values. The statistical features include but are not limited to range, standard deviation, mean, maximum, minimum, median, etc.

[0038] Optionally, the data processing device 101 may be a computer device, such as an industrial computer, a server, etc.

[0039] In some implementations, the device data reading system 102 includes a master device and at least one slave device connected to the master device. For example, the device data reading system 102 includes a master device and three slave devices connected to the master device. Figure 1As shown, slave devices 1022, 1023, and 1024 are respectively connected to the master device 1021, and the master device 1021 is connected to the data processing device 101. The slave devices include but are not limited to sensors, electrical appliances, industrial equipment, etc. It can be understood that the device data includes but is not limited to sensor data, current, voltage, resistance, power, speed, etc.

[0040] In some implementations, each slave device 1022 , 1023 , 1024 is provided with a device information area, a measurement point address area, and a measurement point data area.

[0041] Specifically, the master device 1021 is used to send a device information reading instruction to each slave device 1022, 1023, 1024 according to the device address of each slave device;

[0042] Each slave device 1022, 1023, 1024 is used to respond to the device information read instruction, obtain the device information from the corresponding device information area, and return the device information to the master device 1021;

[0043] The master device 1021 is used to obtain device information returned by each slave device 1022, 1023, 1024 based on the device read instruction, and send a data address read instruction to each slave device 1022, 1023, 1024 according to the device information of each slave device;

[0044] Each slave device 1022, 1023, 1024 is used to respond to the data address read instruction, obtain the starting address of the measuring point data from the corresponding measuring point address area, and return address feedback information to the master device 1021 based on the starting address of the measuring point data;

[0045] The master device 1021 is used to determine the measurement point data storage address of each slave device according to the address feedback information returned by each slave device 1022, 1023, 1024 based on the data address read instruction, and send a data read instruction to each slave device 1022, 1023, 1024 according to the measurement point data storage address in each slave device 1022, 1023, 1024;

[0046] Each slave device 1022, 1023, 1024 is used to respond to the data read instruction, obtain the device data corresponding to the measuring point data storage address in the corresponding measuring point data area, and return the device data to the master device 1021;

[0047] The master device is used to obtain the device data returned by each slave device based on the data read instruction, and send the device data of each slave device to the data processing device 101.

[0048] Optionally, the main device 1021 may be a gateway device, a computer device, or a functional module with data processing capabilities.

[0049] In some implementations, the main device 1021 may be arranged on the data processing device 101; in some implementations, the main device 1021 is connected to the data processing device 101 via a network. The network may be the Internet or any network, including but not limited to a wide area network, a metropolitan area network, a regional network, a mobile communication of the 3rd Generation Partnership Project (3GPP), Long Term Evolution (LTE), Worldwide Interoperability for Microwave Access (WiMAX), or a computer network communication based on the TCP / IP Protocol Suite (TCP / IP), the User Datagram Protocol (UDP), etc.

[0050] In the application scenario provided by the embodiment of the present application, the master device actively sends a response instruction to the slave device to obtain device information in the slave device, automatically collects the measurement point data storage address of each slave device according to the device information, and reads the device data in the slave device based on the measurement point data storage address of each slave device. In this way, there is no need for the gateway to configure the parameters of each slave device, which improves the problem of complex reading method and high error rate caused by the need to configure the gateway or master device in the existing device data reading method.

[0051] based on Figure 1 The application scenario provided herein provides a device data reading method, which is applied to Figure 1 The main device in the device data reading system shown can also be applied to an electronic device with data processing capabilities, and the present application embodiment does not specifically limit this. For example, taking the main device as an example, Figure 2 As shown, Figure 2 2 is a flow chart of a device data reading method provided in an embodiment of the present application. The device data reading method shown includes at least steps 210 to 230:

[0052] Step 210: Send a device information read instruction to each slave device according to the device address of each slave device to determine the device information of each slave device.

[0053] The device address refers to an access address of a slave device, such as a URL address, an interface address, a MAC address, an IP address, etc.

[0054] In some implementations, the device address of each slave device may be obtained from pre-stored address record data, wherein the address record data includes a plurality of slave devices connected to the master device and the device address of each slave device.

[0055] Optionally, when a new slave device is connected to the master device, the master device obtains the device address of the new slave device and writes the new slave device into pre-stored address record data.

[0056] In some implementations, considering that the slave device may be unable to respond to the instruction sent by the master device due to power failure, operation failure, etc. during operation, if the instruction is sent repeatedly to the slave device that cannot respond to the instruction, the processing efficiency of device data reading will be affected. Based on this, each candidate slave device connected to the master device can be determined, the device status of each candidate slave device can be determined, and the candidate slave device with the device status of the running state can be determined as a slave device. The device address of each slave device is obtained based on the pre-stored address record data, and the device information reading instruction is sent to each slave device to determine the device information of each slave device. Among them, the device status includes the running state and the offline state.

[0057] Optionally, the pre-stored device status data may be queried to obtain the device status of each candidate slave device. The pre-stored device status data includes each candidate slave device connected to the master device and the device status of each candidate slave device. It is understandable that the master device may send a device status query instruction to each candidate slave device at a preset period interval. If the feedback information returned by the candidate slave device based on the device status query instruction is received within the preset time, the device status of the candidate slave device is determined to be a running state. If the feedback information returned by the candidate slave device based on the device status query instruction is not received within the preset time, the device status of the candidate slave device is determined to be an offline state, and the device status of each candidate slave device in the pre-stored device status data is adjusted based on the current device status of each candidate slave device.

[0058] The device information includes but is not limited to the device type, the number of measurement points from the device, the device model, the device serial number, etc. The number of measurement points is used to characterize the number of measurement point data collected from the device. For example, the measurement point data includes but is not limited to sensor data, voltage, current, resistance, function, speed, etc., wherein the sensor data includes but is not limited to temperature, humidity, brightness, etc.

[0059] In some embodiments, a device information area is provided in the slave device, and the device information area is used to store the device information of the slave device. Exemplarily, the master device sends a device information read instruction to the slave device based on the device address of the slave device, and the slave device responds to the device information read instruction, reads the device information of the slave device from the slave device, and returns the device information to the master device.

[0060] In some implementations, to ensure the storage address of the measurement point data and the storage of the device data, after obtaining the device information, the storage partitions corresponding to each slave device can be allocated in the storage area of ​​the master device based on the byte size of the device information of each slave device, and the storage partitions can be connected in the form of a linked list to form a storage linked list, such as Figure 3 As shown, Figure 3 It is a schematic diagram of storage partitions of a linked list storage structure provided in an embodiment of the present application, wherein a linked list head pointer points to a storage partition of the next slave device, and a pointer is provided in each storage partition to point to the next storage partition. For the last storage partition in the linked list, the pointer of the storage partition is a pointer with a content of 0 or NULL. It is understandable that when the measurement point data storage address and device data of each slave device are obtained, the measurement point data storage address and device data of each slave device are written into the storage partition corresponding to each slave device.

[0061] Optionally, for each slave device, after obtaining the device information of the slave device, the storage partition of the slave device is determined according to a preset storage partition rule, the storage linked list is updated based on the storage address of the storage partition, and the device information of the slave device is written into the storage partition of the slave device.

[0062] Step 220 , sending a data address read instruction to each slave device according to the device information of each slave device, and determining the measurement point data storage address of each slave device according to the address feedback information returned by each slave device based on the data address read instruction.

[0063] In some embodiments, the address feedback information includes the starting address, data precision, and data range corresponding to the measuring point data. The starting address corresponding to the measuring point data refers to the starting address of the measuring point data stored in the storage area of ​​the slave device; the data precision includes the data format and coefficient, wherein the data format is used to characterize the word length and data form of the measuring point data, wherein the data form includes integer data and floating point data, and the coefficient is used to characterize the unit value of the measuring point data; the data range includes an upper limit and a lower limit, wherein the upper limit is used to characterize the upper limit of the range of the measuring point data, and the lower limit is used to characterize the lower limit of the range of the measuring point data. It can be understood that when the slave device is operating normally, the collected measuring point data is within the data range formed by the upper limit and the lower limit corresponding to the measuring point data.

[0064] In some embodiments, for each slave device, the number of times a data address read instruction is sent to the slave device is determined based on the number of measurement points in the device information of the slave device, a data address read instruction is sent to the slave device based on the number of instructions, and the measurement point data storage address of each slave device is determined based on the starting address of the measurement point data in the address feedback information returned by each slave device based on the data address read instruction.

[0065] Optionally, when there are multiple measuring point data, a data address read instruction is sent to the slave device once for each measuring point data, and the starting address of each measuring point data is determined according to the address feedback information returned by the slave device based on the data address read instruction, and the address set composed of the starting address of each measuring point data is determined as the measuring point data storage address of the slave device.

[0066] In some implementations, each slave device is provided with a measuring point address area, wherein the measuring point address area stores the starting address of the register of the measuring point data in the slave device. It is understandable that when the slave device receives the data address read instruction, it responds to the data address read instruction, queries the measuring point address area, obtains the starting address of the register of the measuring point data in the slave device, the data range of the measuring point data, and the data precision, and returns the address feedback information to the master device based on the starting address of the register of the measuring point data in the slave device, the data range of the measuring point data, and the data precision.

[0067] Optionally, to ensure convenient reading of device data, in the slave device, the measuring point address area can be divided into multiple measuring point data storage areas, each measuring point data storage area is used to store the starting address of a register of measuring point data, the data range of the measuring point data and the data accuracy. For example, Figure 4 As shown, Figure 4 1 is a schematic diagram of a measuring point address area in a slave device provided in an embodiment of the present application. The measuring point address area shown includes n measuring point data storage areas. The measuring point data storage areas store the starting address of a register of measuring point data, the upper limit and lower limit of the data range of the measuring point data, and the data precision. The start address occupies 2 bytes, the data precision occupies 1 byte, the upper limit of the data range occupies 8 bytes, and the lower limit of the data range occupies 8 bytes. n is a positive integer greater than 1.

[0068] In some embodiments, in order to improve the processing efficiency of the device data reading method, the measuring point data of the slave device can be grouped according to the number of measuring points of the slave device to obtain at least one measuring point group, and for each measuring point group, a data address read instruction is sent to the slave device once; the slave device responds to the data address read instruction, determines the number of measuring points to be read corresponding to the data address read instruction, accesses the measuring point address area in the slave device, determines the starting measuring point data storage area in the measuring point address area, and starts from the starting measuring point data storage area to obtain the starting address of the register of the measuring point data stored in the measuring point data storage area of ​​the number of measuring points to be read, the data range of the measuring point data, and the data precision, and generates address feedback information based on the starting address of the register of the measuring point data stored in the measuring point data storage area of ​​the number of measuring points to be read, the data range of the measuring point data, and the data precision, and returns the address feedback information to the master device. It can be understood that the address feedback information includes multiple measuring point data storage areas, and at least one measuring point data storage area stores the starting address, data precision, and data range corresponding to the measuring point data.

[0069] Optionally, when the slave device receives a data address read instruction for the first time, the first measuring point data storage area in the measuring point address area is determined as the starting measuring point data storage area; when the slave device does not receive a data address read instruction for the first time, the last measuring point data storage area read last time + 1 is determined as the starting measuring point data storage area.

[0070] Optionally, when the master device receives feedback information containing a measurement point data storage area with empty data, it is determined that the reading of the measurement point data storage address in the slave device is completed.

[0071] Step 230 , sending a data read instruction to each slave device according to the measurement point data storage address in each slave device, and obtaining device data returned by each slave device based on the data read instruction.

[0072] In some embodiments, the device data represents real-time data from the device, including but not limited to voltage, current, electrical energy, power, rotation speed, temperature, humidity, etc.

[0073] In some embodiments, the slave device is provided with a measuring point data area, and the measuring point data area is used to store the real-time data collected by the slave device. Optionally, a plurality of registers are provided in the measuring point data area, and each register stores 2 bytes of data. It can be understood that the starting address of the measuring point data represents the starting address of the register storing the measuring point data in the test data area.

[0074] In some implementations, for each slave device, a data read instruction may be sent to the slave device starting from the measurement point data storage address of the first measurement point data of the slave device, and device data may be obtained based on the data at the measurement point data storage address returned by the slave device.

[0075] Optionally, the data at the measurement point data storage address returned from the device may be determined as device data.

[0076] In some implementations, for each slave device, starting from the measuring point data storage address of the first measuring point data of the slave device, the number of registers occupied by the measuring point data can be determined according to the data accuracy of the first measuring point data, and a data read instruction can be sent to the slave device based on the measuring point data storage address and the number of registers. The slave device responds to the data read instruction and returns the data in the register with the measuring point data storage address as the starting address and the number of registers to the master device; the master device obtains the device data based on the data at the measuring point data storage address returned by the slave device.

[0077] In some implementations, after obtaining the device data of the slave device, the device data of the slave device is written into a corresponding storage partition.

[0078] The device data reading method provided in the embodiment of the present application obtains the device information in the slave device by means of the master device actively sending a response instruction to the slave device, automatically collects the measuring point data storage address of each slave device according to the device information, and reads the device data in the slave device based on the measuring point data storage address of each slave device. In this way, there is no need for the gateway to configure the parameters of each slave device, thereby improving the problem of complex reading method and high error rate caused by the need to configure the gateway or master device in the existing device data reading method.

[0079] Considering the existing device data reading method, it is necessary to pre-configure the master device or gateway device to define the starting position, data format, data range, etc. of the measurement point data to be collected from the slave device. When there are a large number of slave devices or a large number of measurement point data to be collected from the slave device, it will take a lot of time to configure the master device or gateway device, increasing the device data reading time and cost; and the pre-configuration method will cause data reading errors or reading failures when there are configuration errors.

[0080] Based on this, in order to improve the efficiency of device data reading, reduce the cost of device data reading, and reduce the configuration complexity of the gateway or master device, and at the same time reduce the error rate of data reading, in some embodiments, the master device actively sends instructions to the slave device to obtain the starting position, data format, data range and other information of the measurement point data to be collected from the slave device, thereby avoiding the configuration of the master device or gateway device, reducing the cost of device data reading and reducing the configuration complexity of the gateway or master device, thereby avoiding data reading errors or reading failures caused by configuration errors, thereby reducing the error rate of data reading.

[0081] Specifically, Figure 5As shown, Figure 5 22 is a flow chart of a method for obtaining a measurement point data storage address provided in an embodiment of the present application. The method for obtaining a measurement point data storage address shown includes steps 221 to 226:

[0082] Step 221 : for each slave device, a data address read instruction is sent to the slave device based on the device information of the slave device, and address feedback information returned by the slave device based on the data address read instruction is obtained.

[0083] In some implementations, a data address read instruction may be sent to the slave device according to the above step 220 to obtain address feedback information returned by the slave device based on the data address read instruction.

[0084] In some implementations, the measurement point data of the slave device may be grouped based on the number of measurement points in the device information of the device to obtain at least one measurement point group, and a data address read instruction may be sequentially sent to the slave device based on the number of measurement point groups to obtain each address feedback information returned by the slave device based on the data address read instruction. Each measurement point group includes at least one measurement point data.

[0085] Optionally, the measurement point data of the slave device may be grouped according to a preset quantity threshold and the number of measurement points in the device information of the device, wherein the preset quantity threshold is used to represent the maximum number of measurement point data included in a group of measurement point groups.

[0086] Exemplarily, the preset number threshold is 10, and the slave device A includes 31 measurement point data. That is, the master device needs to send 3 data address read instructions to the slave device A. After the master device sends the first data address read instruction to the slave device A, the 10 measurement point data storage areas in the slave device A are obtained. If there is no measurement point data storage area with empty data in the 10 measurement point data storage areas, the data stored in the 10 measurement point data storage areas are read to obtain the starting address, data accuracy and data range corresponding to the 10 measurement point data; and then the second data address read instruction is sent to obtain the 10 measurement point data in the slave device A. If there is no empty data in the 10 measuring point data storage areas, then read the data stored in the 10 measuring point data storage areas to obtain the starting address, data precision and data range corresponding to the 10 measuring point data; and then send the third data address read instruction. Since the second measuring point data storage area in the address feedback information returned by the third data address read instruction is empty, read the data in the first measuring point data storage area in the address feedback information returned by the third data address read instruction to obtain the starting address, data precision and data range corresponding to 1 measuring point data. And start sending data address read instructions to slave device B.

[0087] Step 222: Write the starting address, data precision and data range corresponding to the measurement point data into the storage partition of the slave device.

[0088] In some implementations, after obtaining the starting address, data precision and data range corresponding to each measuring point data in the slave device, the starting address, data precision and data range corresponding to each measuring point data may be written into a storage partition of the slave device.

[0089] In some embodiments, when there are a large number of measurement point data in a slave device, in order to facilitate the storage of device data and the query of the starting address of the measurement point data, after obtaining the device information of the slave device, the storage partition of the slave device in the master device can be allocated according to the number of measurement points in the device information of the slave device to obtain the storage sub-partition occupied by each measurement point data; after obtaining the starting address, data precision and data range corresponding to each measurement point data, the starting address, data precision and data range corresponding to each measurement point data are written into the storage sub-partition occupied by each measurement point data in the storage partition of the slave device.

[0090] Optionally, taking the device address, device type, device signal, device serial number, and number of measuring points in the device information occupying 48 bytes as an example, the size of the storage sub-partition corresponding to the measuring point data can be obtained according to the number of measuring points and the preset unit measuring point data byte length, and the size of the storage partition can be obtained by 48 bytes + storage sub-partition size. Exemplarily, taking the example that the slave device A includes 21 measuring point data and the preset unit measuring point data byte length is 32, that is, each measuring point data occupies 32 bytes, and 48+32*21=720 bytes, that is, the size of the storage partition of the slave device A is 720 bytes.

[0091] In some implementations, in order to further improve the device data reading efficiency, for the measuring point data with continuous storage addresses, the device data can be obtained by sending a data reading instruction to the slave device once, thereby improving the device data reading efficiency by reducing the number of data reading instructions. Therefore, when writing the starting address, data precision and data range corresponding to each measuring point data into the storage sub-partition occupied by each measuring point data in the storage partition of the slave device, the continuous marker of the measuring point data can be determined according to the starting address and data precision corresponding to each measuring point data, and the data precision, starting address, data range and continuous marker of each measuring point data are written into the storage sub-partition corresponding to each measuring point data in the storage partition of the slave device, so that when sending a data reading instruction to the slave device, the measuring point data with continuous storage addresses can be identified. Among them, the continuous marker is used to indicate whether the starting address of the measuring point data is continuous with the ending address of the previous measuring point data.

[0092] Specifically, step 222 includes steps a1 to a3:

[0093] Step a1, determining the storage sub-partition corresponding to each measuring point data in the storage partition of the slave device.

[0094] In some implementations, the storage sub-partition corresponding to the measuring point data can be determined from the storage partition of the slave device according to the data identifier of the measuring point data, wherein the data identifier can be the serial number of the measuring point data.

[0095] In some implementations, for each measurement point data, the storage partition of the slave device may be accessed, and the first idle storage sub-partition may be determined as the storage sub-partition corresponding to the measurement point data.

[0096] Step a2, determining the continuous marker of each measuring point data according to the data accuracy and the starting address of each measuring point data.

[0097] In some implementations, for each measuring point data, if the measuring point data is the first measuring point data, the second preset value may be determined as a continuous marker of the measuring point data; if the measuring point data is not the first measuring point data, the end address of the previous measuring point data of the measuring point data may be determined, the starting address of the measuring point data is compared with the end address of the previous measuring point data of the measuring point data, the end address of the previous measuring point data is determined, and whether the starting address of the measuring point data and the end address of the previous measuring point data are continuous; if the starting address of the measuring point data and the end address of the previous measuring point data are continuous, the first preset value is determined as the continuous marker of the measuring point data; if the starting address of the measuring point data and the end address of the previous measuring point data are not continuous, the second preset value is determined as the continuous marker of the measuring point data. The first preset value may be 1, indicating that the storage address of the measuring point data is continuous with that of the previous measuring point data; the second preset value may be 0, indicating that the storage address of the measuring point data and the previous measuring point data are not continuous.

[0098] Step a3, writing the data precision, starting address, data range, and continuous marker of each measuring point data into the storage sub-partition corresponding to each measuring point data in the storage partition of the slave device.

[0099] For example, Figure 6 As shown, Figure 6This is a schematic diagram of the allocation of storage partitions of a slave device provided in an embodiment of the present application, wherein the storage partition includes a device information sub-partition and n storage sub-partitions, and the storage addresses of adjacent storage sub-partitions are continuous. Among them, the device information sub-partition occupies 48 bytes, and stores the device address, device type, device signal, device serial number, number of device measurement points, and device status of the slave device in sequence; each storage sub-partition occupies 32 bytes, and the addresses are, from low to high, an identifier bit, a start address bit, a data precision bit, an upper limit bit, a lower limit bit, a real-time data bit, and a reserved area, wherein the identifier bit, the start address bit, the data precision bit, the upper limit bit, and the lower limit bit are used to store the continuous identifier, the start address, the data precision, the upper limit, and the lower limit of the measurement point data respectively; the real-time data bit is used to store the real-time measurement point data.

[0100] In some implementations, it can be determined based on address feedback information whether the reading of the measuring point data storage address of the slave device has been completed. When the reading of the measuring point data storage address of the slave device has been completed, the starting address, data precision, and data range corresponding to the measuring point data are written into the storage partition of the slave device. If the reading of the measuring point data storage address of the slave device has not been completed, a data address read instruction is sent to the slave device based on the device information of the slave device until the reading of the measuring point data storage address of the slave device has been completed, and the starting address, data precision, and data range corresponding to the measuring point data are written into the storage partition of the slave device.

[0101] Optionally, considering that the measuring point data storage area is stored continuously in the measuring point address area of ​​the slave device, the measuring point data storage area that does not store the data precision, starting address, and data range corresponding to the measuring point data is empty. Therefore, it is possible to determine that the measuring point data storage address of the slave device is incomplete by detecting whether there is a measuring point data storage area with empty data in the returned address feedback information.

[0102] Specifically, the method for detecting that the reading of the measurement point data storage address is completed includes:

[0103] (1) For each address feedback information, if the data in the multiple measurement point data storage areas corresponding to the address feedback information are not empty, it is determined that the measurement point data storage address of the slave device is not completed.

[0104] (2) If there is a measuring point data storage area with empty data among the multiple measuring point data storage areas corresponding to the address feedback information, it is determined that the reading of the measuring point data storage address of the slave device is completed.

[0105] Step 223: Determine the starting address of the measurement point data in the slave device based on the address feedback information.

[0106] Step 224: determine the starting address of the measurement point data in the slave device as the storage address of the measurement point data of the slave device.

[0107] The method for obtaining the measurement point data storage address provided in the embodiment of the present application actively sends a data address reading instruction to the slave device through the master device, does not require complex master device or gateway device configuration, reduces the device data reading cost and reduces the configuration complexity of the gateway or master device, thereby avoiding data reading errors or reading failures caused by configuration errors, thereby reducing the error rate of data reading.

[0108] In some embodiments, when sending a data read instruction to a slave device, the starting address and number of registers where the device data to be obtained from the slave device are located are determined based on the byte size of the measurement point data in the slave device and the starting address of the measurement point data, and a data read instruction is sent to the slave device based on the starting address and number of registers where the device data to be obtained from the slave device is located, and the device data returned by the slave device based on the data read instruction is obtained.

[0109] Specifically, Figure 7 As shown, Figure 7 2 is a flow chart of a device data acquisition method provided in an embodiment of the present application. The device data acquisition method shown includes steps 231 to 234:

[0110] Step 231, for each slave device, determine the byte size of each measurement point data in the slave device.

[0111] In some implementations, the storage sub-partitions corresponding to each measuring point data in the storage partition corresponding to the slave device may be traversed to obtain the data precision corresponding to each measuring point data, and the byte size of each measuring point data in the slave device may be determined based on the data precision of each measuring point data.

[0112] Optionally, the number of bits of the measuring point data can be determined according to the data accuracy corresponding to the measuring point data, and the byte size of the measuring point data can be obtained based on the number of bits of the measuring point data. Exemplarily, if the measuring point data is 16-bit integer data, the byte size of the measuring point data is determined to be 2.

[0113] Step 232, determining the starting address of each measuring point data according to the measuring point data storage address in the slave device.

[0114] Step 233: Send a data read instruction to the slave device based on the byte size and the start address of the data at each measuring point in the slave device.

[0115] In some implementations, for each measurement point data, the master device determines the number of registers according to the byte size of the measurement point data, sends a data read instruction to the slave device based on the number of registers, the starting address, and the device address of the slave device, and the slave device responds to the data read instruction, reads data based on the starting address and the number of registers, obtains device data, and returns the device data to the master device. It is understandable that the data read instruction includes the device address, the number of registers to be read, and the starting address of the register.

[0116] In some embodiments, when communicating based on the Modbus protocol, for each measuring point data, the master device determines the number of registers according to the byte size of the measuring point data, generates a data read instruction for each measuring point data based on the number of registers, the starting address, and the device address of the slave device, writes the data read instruction into the communication storage area, and determines whether the current measuring point data is the last measuring point data; if the current measuring point data is the last measuring point data, generates a storage area instruction based on the device address of the master device, the starting address of the first measuring point data, and the total number of registers, writes the storage area instruction into the communication storage area, and broadcasts the instruction in the communication storage area to the slave device through the Modbus protocol. The storage area instruction is used to indicate the communication address when the slave device returns the device data.

[0117] Optionally, after the data reading instructions for each measuring point data of each slave device and the storage area instructions of each slave device are written into the communication storage area, starting from the first instruction in the communication storage area, instructions are sent to the slave devices with corresponding device addresses in sequence, and device data returned by the slave devices based on the instructions are received.

[0118] In some implementations, considering that when there are a large number of measurement points in the slave device, if each measurement point data generates a corresponding data read instruction, the bandwidth of the master device will be consumed and the device data reading time will be increased. Therefore, in order to improve the device data reading efficiency, for the measurement point data with continuous storage addresses, the same data read instruction can be used to read the device data, and for the measurement point data with discontinuous storage addresses, different data read instructions can be used to read the device data, thereby improving the device data reading efficiency.

[0119] Specifically, Figure 8 As shown, Figure 8 23 is a flow chart of sending a data read instruction provided by an embodiment of the present application. The data read instruction sending method shown includes steps 2331 to 2335:

[0120] Step 2331, divide the data of each measuring point to obtain at least one measuring point data group.

[0121] Each measuring point data group includes at least one measuring point data.

[0122] In some implementations, whether the storage addresses of the measurement point data are continuous can be determined based on the starting address and byte size of each measurement point data, and the measurement point data with continuous storage addresses can be divided into a measurement point data group. For each measurement point data group, a data read instruction is sent to the slave device.

[0123] Specifically, the method for determining the measurement point data group includes steps b1 to b3:

[0124] Step b1, determining whether the storage addresses of the data at each measuring point in the slave device are continuous according to the starting addresses and byte sizes of the data at each measuring point in the slave device.

[0125] In some implementations, for each measuring point data, the end address of the measuring point data is determined based on the starting address and byte size of the measuring point data, and the starting address of the next measuring point data of the measuring point data is determined; if the end address of the measuring point data is continuous with the starting address of the next measuring point data of the measuring point data, then the storage address of the measuring point data is determined to be continuous; if the end address of the measuring point data is discontinuous with the starting address of the next measuring point data of the measuring point data, then the storage address of the measuring point data is determined to be discontinuous.

[0126] Step b2: if the storage addresses of the measuring point data in the slave device are continuous, the measuring point data in the slave device are divided into a measuring point data group.

[0127] Step b3, if the storage addresses of the measuring point data in the slave device are not completely continuous, then determine the target measuring point data with continuous storage addresses in the slave device, divide the target measuring point data into a measuring point data group, and determine the remaining measuring points in the measuring point data in the slave device except the target measuring point data as a measuring point data group.

[0128] In some implementations, in order to further improve the device data reading efficiency, a continuous marker of each measuring point data can be determined from the storage sub-partition of each measuring point data in the storage partition of the slave device, and an address continuity check is performed on each measuring point data according to the continuous marker corresponding to each measuring point data, and the measuring point data with continuous storage addresses are divided into a measuring point data group. For each measuring point data group, a data reading instruction is sent to the slave device.

[0129] Specifically, the method for determining the measurement point data group includes steps c1 to c4:

[0130] Step c1, traverse the storage sub-partitions corresponding to each measuring point data in the storage partition corresponding to the slave device, and obtain the continuous markers corresponding to each measuring point data.

[0131] Step c2: performing address continuity detection on each measuring point data according to the continuous marker corresponding to each measuring point data, and determining whether the storage addresses of each measuring point data in the slave device are continuous.

[0132] In some implementations, if the continuous marker corresponding to the measurement point data is a first preset value, the storage address of the measurement point data is determined to be continuous; if the continuous marker corresponding to the measurement point data is a second preset value, the storage address of the measurement point data is determined to be discontinuous.

[0133] Optionally, if the continuous marker corresponding to the measuring point data is a second preset value, it is determined whether the measuring point data is the first measuring point data; if the measuring point data is not the first measuring point data, it is determined that the storage address of the measuring point data is discontinuous; if the measuring point data is the first measuring point data, it is determined whether the continuous marker of the next measuring point data of the measuring point data is the first preset value; if the continuous marker of the next measuring point data of the measuring point data is the first preset value, it is determined that the storage addresses of the measuring point data and the next measuring point data of the measuring point data are continuous; if the continuous marker of the next measuring point data of the measuring point data is not the first preset value, it is determined that the storage addresses of the measuring point data and the next measuring point data of the measuring point data are discontinuous.

[0134] Step c3: if the storage addresses of the measuring point data in the slave device are continuous, the measuring point data in the slave device are divided into a measuring point data group.

[0135] Step c4, if the storage addresses of the measuring point data in the slave device are not completely continuous, then determine the target measuring point data with continuous storage addresses in the slave device, divide the target measuring point data into a measuring point data group, and determine the remaining measuring points in the measuring point data in the slave device except the target measuring point data as a measuring point data group.

[0136] Step 2332, determining the data length of each measuring point data group according to the byte size of each measuring point data in the slave device.

[0137] In some implementations, for each measuring point data group, the byte size of each measuring point data in the measuring point data group may be summarized to obtain the data length of the measuring point data group.

[0138] Step 2333, determining the starting address of each measuring point data group according to the starting address of each measuring point data in the slave device.

[0139] In some implementations, for each measuring point data group, the starting addresses of each measuring point data in the measuring point data group are compared to determine the lowest starting address, and the lowest starting address is determined as the starting address of the measuring point data group.

[0140] Step 2334: Generate a data read instruction for each measuring point data group based on the starting address and data length of each measuring point data group.

[0141] In some implementations, for each measuring point data group, the number of registers is determined according to the data length of the measuring point data group, and a data reading instruction for the measuring point data group is generated based on the number of registers and the starting address of the measuring point data group according to a preset instruction generation rule.

[0142] Step 2335: Send a data read instruction for each measurement point data group to the slave device based on the device address of the slave device.

[0143] Step 234, obtaining device data returned by the slave device based on the data read instruction.

[0144] In some implementations, after the device data is acquired, the device data is stored in a storage sub-partition corresponding to each measuring point data in the storage partition corresponding to the slave device.

[0145] In some embodiments, after storing the device data in the storage sub-partition corresponding to each measuring point data in the storage partition corresponding to the slave device, it is determined whether the device data of each slave device connected to the master device has been read. If the device data of each slave device connected to the master device has been read, the device data reading is terminated. If the device data of each slave device connected to the master device has not been read, the storage partition of the next slave device is accessed according to the linked list of the storage partition of the slave device, the measuring point data storage address and data accuracy of the next slave device are obtained, and the above steps 231 to 234 are executed to obtain the device data.

[0146] Optionally, it can be determined whether the device data of each slave device connected to the master device has been read out based on the linked list pointer of the storage partition of the slave device. Exemplarily, if the linked list pointer of the storage partition of the slave device is 0, it is determined that the device data of each slave device connected to the master device has been read out, and if the linked list pointer of the storage partition of the slave device is not 0, it is determined that the device data of each slave device connected to the master device has not been read out.

[0147] The device data reading method provided in the embodiment of the present application obtains the device information in the slave device by means of the master device actively sending a response instruction to the slave device, automatically collects the measuring point data storage address of each slave device according to the device information, and reads the device data in the slave device based on the measuring point data storage address of each slave device. In this way, there is no need for the gateway to configure the parameters of each slave device, thereby improving the problem of complex reading method and high error rate caused by the need to configure the gateway or master device in the existing device data reading method.

[0148] In order to better implement the device data reading method provided in the embodiment of the present application, based on the embodiment of the device data reading method, the embodiment of the present application provides a device data reading apparatus, specifically, as follows Fig. 9 As shown, Fig. 9 : is a schematic diagram of the structure of a device data reading device provided in an embodiment of the present application, and the device data reading device shown includes:

[0149] The device information acquisition module is used to send a device information reading instruction to each slave device according to the device address of each slave device to determine the device information of each slave device;

[0150] An address acquisition module is used to send a data address reading instruction to each slave device according to the device information of each slave device, and determine the measurement point data storage address of each slave device according to the address feedback information returned by each slave device based on the data address reading instruction;

[0151] The data acquisition module is used to send a data reading instruction to each slave device according to the data storage address of the measurement point in each slave device, and obtain the device data returned by each slave device based on the data reading instruction.

[0152] In some embodiments, the data acquisition module is used to:

[0153] For each slave device, determine the byte size of each measurement point data in the slave device;

[0154] Determine the starting address of each measuring point data according to the measuring point data storage address in the slave device;

[0155] Based on the byte size and the starting address of each measuring point data in the slave device, sending a data read instruction to the slave device;

[0156] Get the device data returned by the slave device based on the data read instruction.

[0157] In some embodiments, the data acquisition module is used to:

[0158] Traversing the storage sub-partitions corresponding to each measuring point data in the storage partition corresponding to the slave device to obtain the data precision corresponding to each measuring point data; the storage partition is established according to the number of bytes of the device information of the slave device;

[0159] According to the data accuracy of each measuring point data, the byte size of each measuring point data in the slave device is determined.

[0160] In some embodiments, the data acquisition module is used to:

[0161] Dividing each measuring point data to obtain at least one measuring point data group; each measuring point data group includes at least one measuring point data;

[0162] Determine the data length of each measuring point data group according to the byte size of each measuring point data in the slave device;

[0163] Determine the starting address of each measuring point data group according to the starting address of each measuring point data in the slave device;

[0164] Generate a data read instruction for each measuring point data group based on the starting address and data length of each measuring point data group;

[0165] A data read instruction for each measurement point data group is sent to the slave device based on the device address of the slave device.

[0166] In some embodiments, the data acquisition module is used to:

[0167] Determine whether the storage addresses of the data at each measuring point in the slave device are continuous according to the starting addresses and byte sizes of the data at each measuring point in the slave device;

[0168] If the storage addresses of the measuring point data in the slave device are continuous, the measuring point data in the slave device are divided into a measuring point data group;

[0169] If the storage addresses of the measuring point data in the slave device are not completely continuous, the target measuring point data with continuous storage addresses in the slave device are determined, the target measuring point data are divided into a measuring point data group, and the remaining measuring points in the measuring point data in the slave device except the target measuring point data are determined as a measuring point data group.

[0170] In some embodiments, the data acquisition module is used to:

[0171] Traversing the storage sub-partitions corresponding to each measuring point data in the storage partition corresponding to the slave device, and obtaining the continuous markers corresponding to each measuring point data; the storage partitions are established according to the number of bytes of the device information of the slave device; the continuous marker is used to indicate whether the starting address of the measuring point data is continuous with the ending address of the previous measuring point data;

[0172] According to the continuous marker corresponding to each measuring point data, the address continuity detection is performed on each measuring point data to determine whether the storage address of each measuring point data in the slave device is continuous;

[0173] If the storage addresses of the measuring point data in the slave device are continuous, the measuring point data in the slave device are divided into a measuring point data group;

[0174] If the storage addresses of the measuring point data in the slave device are not completely continuous, the target measuring point data with continuous storage addresses in the slave device are determined, the target measuring point data are divided into a measuring point data group, and the remaining measuring points in the measuring point data in the slave device except the target measuring point data are determined as a measuring point data group.

[0175] In some implementations, the address acquisition module is used to:

[0176] For each slave device, a data address read instruction is sent to the slave device based on the device information of the slave device, and address feedback information returned by the slave device based on the data address read instruction is obtained; the address feedback information includes a plurality of measuring point data storage areas, at least one measuring point data storage area stores a starting address, data precision and data range corresponding to the measuring point data;

[0177] Write the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device;

[0178] Determine the starting address of the measurement point data in the slave device based on the address feedback information;

[0179] The starting address of the measurement point data in the slave device is determined as the measurement point data storage address of the slave device.

[0180] In some implementations, the device information includes the number of measurement points, and an address acquisition module is used to:

[0181] The measuring point data of the slave device are grouped according to the number of measuring points to obtain at least one measuring point group; each measuring point group includes at least one measuring point data;

[0182] Based on the number of measurement point groups, data address read instructions are sent to the slave device in sequence, and each address feedback information returned by the slave device based on the data address read instructions is obtained.

[0183] In some implementations, the address acquisition module is used to:

[0184] Determine the storage sub-partition corresponding to each measuring point data in the storage partition of the slave device;

[0185] Determine the continuous marker of each measuring point data according to the data accuracy and starting address of each measuring point data;

[0186] The data precision, starting address, data range, and continuous marker of each measuring point data are written into the storage sub-partition corresponding to each measuring point data in the storage partition of the slave device.

[0187] In some implementations, the address acquisition module is used to:

[0188] For each measuring point data, if the measuring point data is the first measuring point data, the second preset value is determined as a continuous marker of the measuring point data;

[0189] If the measuring point data is not the first measuring point data, then according to the starting address of the measuring point data, the starting address of the previous measuring point data and the data precision, the ending address of the previous measuring point data is determined, and whether the starting address of the measuring point data is continuous with the ending address of the previous measuring point data;

[0190] If the starting address of the measuring point data is continuous with the ending address of the previous measuring point data, the first preset value is determined as the continuous marker of the measuring point data;

[0191] If the starting address of the measuring point data is not continuous with the ending address of the previous measuring point data, the second preset value is determined as the continuous marker of the measuring point data.

[0192] In some implementations, the address acquisition module is used to:

[0193] According to the address feedback information, determine whether the reading of the measurement point data storage address of the slave device is completed;

[0194] If the reading of the storage address of the measuring point data of the slave device is completed, the step of writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device is executed;

[0195] If the reading of the measurement point data storage address of the slave device is not completed, a data address reading instruction is sent to the slave device based on the device information of the slave device until the reading of the measurement point data storage address of the slave device is completed, and then the step of writing the starting address, data precision and data range corresponding to the measurement point data into the storage partition of the slave device is executed.

[0196] In some implementations, the address acquisition module is used to:

[0197] For each address feedback information, if the data in the multiple measuring point data storage areas corresponding to the address feedback information are not empty, it is determined that the measuring point data storage address of the slave device is not completed;

[0198] If there is a measuring point data storage area with empty data among the multiple measuring point data storage areas corresponding to the address feedback information, it is determined that the reading of the measuring point data storage address of the slave device is completed.

[0199] In some implementations, each slave device corresponds to a storage partition, and the device data reading apparatus further includes:

[0200] The data storage module is used to write the device data returned by each slave device based on the data read instruction into the storage partition corresponding to each slave device.

[0201] The device data reading apparatus provided in the embodiment of the present application obtains device information in the slave device by means of a master device actively sending a response instruction to the slave device, automatically collects the measuring point data storage address of each slave device according to the device information, and reads the device data in the slave device based on the measuring point data storage address of each slave device. In this way, there is no need for the gateway to configure the parameters of each slave device, thereby improving the problem of complex reading method and high error rate caused by the need to configure the gateway or master device in the existing device data reading method.

[0202] The embodiment of the present invention further provides an electronic device, such as Fig.10 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:

[0203] The electronic device may include components such as a processor 1001 with one or more processing cores, a memory 1002 with one or more computer-readable storage media, a power supply 1003, and an input unit 1004. Those skilled in the art will appreciate that Fig.10 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0204] The processor 1001 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 1002 and calling data stored in the memory 1002, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 1001 may include one or more processing cores; preferably, the processor 1001 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1001.

[0205] The memory 1002 can be used to store software programs and modules. The processor 1001 executes various functional applications and data processing by running the software programs and modules stored in the memory 1002. The memory 1002 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1002 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1002 may also include a memory controller to provide the processor 1001 with access to the memory 1002.

[0206] The electronic device also includes a power supply 1003 for supplying power to each component. Preferably, the power supply 1003 can be logically connected to the processor 1001 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 1003 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0207] The electronic device may further include an input unit 1004, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0208] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 1001 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 1002 according to the following instructions, and the processor 1001 will run the application programs stored in the memory 1002, thereby realizing various functions, as follows:

[0209] According to the device address of each slave device, a device information reading instruction is sent to each slave device to determine the device information of each slave device;

[0210] According to the device information of each slave device, a data address read instruction is sent to each slave device, and according to the address feedback information returned by each slave device based on the data address read instruction, a measurement point data storage address of each slave device is determined;

[0211] A data reading instruction is sent to each slave device according to the data storage address of the measurement point in each slave device, and the device data returned by each slave device based on the data reading instruction is obtained.

[0212] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0213] To this end, an embodiment of the present invention provides a storage medium in which a plurality of instructions are stored. The instructions can be loaded by a processor to execute the steps in any device data reading method provided in an embodiment of the present invention. For example, the instructions can execute the following steps:

[0214] According to the device address of each slave device, a device information reading instruction is sent to each slave device to determine the device information of each slave device;

[0215] According to the device information of each slave device, a data address read instruction is sent to each slave device, and according to the address feedback information returned by each slave device based on the data address read instruction, a measurement point data storage address of each slave device is determined;

[0216] A data reading instruction is sent to each slave device according to the data storage address of the measurement point in each slave device, and the device data returned by each slave device based on the data reading instruction is obtained.

[0217] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0218] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0219] Since the instructions stored in the storage medium can execute the steps in any device data reading method provided in the embodiments of the present invention, the beneficial effects that can be achieved by any device data reading method provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0220] The above is a detailed introduction to a device data reading method, apparatus, electronic device and storage medium provided in an embodiment of the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for reading device data, characterized in that: The method is applied to a device data reading system, the device data reading system includes a master device and at least one slave device connected to the master device, the method is applicable to the master device, and the method includes: According to the device address of each slave device, a device information reading instruction is sent to each slave device to determine the device information of each slave device; Sending a data address read instruction to each of the slave devices according to the device information of each of the slave devices, and determining a measurement point data storage address of each of the slave devices according to address feedback information returned by each of the slave devices based on the data address read instruction; A data reading instruction is sent to each of the slave devices according to the measurement point data storage address in each of the slave devices, and device data returned by each of the slave devices based on the data reading instruction is obtained.

2. The method according to claim 1, characterized in that The step of sending a data read instruction to each of the slave devices according to the measurement point data storage address in each of the slave devices, and obtaining device data returned by each of the slave devices based on the data read instruction, comprises: For each of the slave devices, determining the byte size of each measuring point data in the slave device; Determine the starting address of each measuring point data according to the measuring point data storage address in the slave device; Based on the byte size and the starting address of each measuring point data in the slave device, sending a data read instruction to the slave device; The device data returned by the slave device based on the data read instruction is obtained.

3. The method according to claim 2, characterized in that Determining the byte size of each measuring point data in the slave device includes: Traversing the storage sub-partitions corresponding to the measuring point data in the storage partition corresponding to the slave device to obtain the data precision corresponding to the measuring point data; the storage partitions are established according to the number of bytes of the device information of the slave device; The byte size of each of the measuring point data in the slave device is determined according to the data accuracy of each of the measuring point data.

4. The method according to claim 2, characterized in that: The step of sending a data read instruction to the slave device based on the byte size and the starting address of each measuring point data in the slave device comprises: Dividing each of the measuring point data to obtain at least one measuring point data group; each of the measuring point data groups includes at least one measuring point data; Determining the data length of each measuring point data group according to the byte size of each measuring point data in the slave device; Determine the starting address of each measuring point data group according to the starting address of each measuring point data in the slave device; Based on the starting address and data length of each of the measuring point data groups, generating a data reading instruction for each of the measuring point data groups; A data read instruction for each of the measuring point data groups is sent to the slave device based on the device address of the slave device.

5. The method according to claim 4, characterized in that The step of dividing the measuring point data to obtain at least one measuring point data group includes: Traversing the storage sub-partitions corresponding to the measuring point data in the storage partition corresponding to the slave device to obtain the continuous markers corresponding to the measuring point data; the storage partitions are established according to the number of bytes of the device information of the slave device; the continuous markers are used to indicate whether the starting address of the measuring point data is continuous with the ending address of the previous measuring point data; According to the continuous markers corresponding to the measuring point data, address continuity detection is performed on the measuring point data to determine whether the storage addresses of the measuring point data in the slave device are continuous; If the storage addresses of the measuring point data in the slave device are continuous, the measuring point data in the slave device are divided into a measuring point data group; If the storage addresses of the measuring point data in the slave device are not completely continuous, target measuring point data with continuous storage addresses in the slave device are determined, the target measuring point data are divided into a measuring point data group, and the remaining measuring points in the measuring point data in the slave device except the target measuring point data are determined as a measuring point data group.

6. The method according to claim 1, characterized in that The step of sending a data address read instruction to each of the slave devices according to the device information of each of the slave devices comprises: For each of the slave devices, a data address read instruction is sent to the slave device based on the device information of the slave device, and address feedback information returned by the slave device based on the data address read instruction is obtained; the address feedback information includes a plurality of measuring point data storage areas, at least one of the measuring point data storage areas stores a starting address, data precision and data range corresponding to the measuring point data; Writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device; Determine the starting address of the measurement point data in the slave device based on the address feedback information; The starting address of the measurement point data in the slave device is determined as the measurement point data storage address of the slave device.

7. The method according to claim 6, characterized in that The device information includes the number of measurement points, and the sending of a data address read instruction to the slave device based on the device information of the slave device, and obtaining address feedback information returned by the slave device based on the data address read instruction, includes: The measuring point data of the slave device are grouped according to the number of measuring points to obtain at least one measuring point group; each measuring point group includes at least one measuring point data; Based on the number of the measurement point groups, data address read instructions are sent to the slave device in sequence, and each address feedback information returned by the slave device based on the data address read instructions is obtained.

8. The method according to claim 6, characterized in that The step of writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device comprises: Determine the storage sub-partition corresponding to each of the measurement point data in the storage partition of the slave device; Determining a continuous marker of each of the measuring point data according to the data accuracy and the starting address of each of the measuring point data; The data precision, starting address, data range, and continuous marker of each of the measuring point data are written into the storage sub-partition corresponding to each of the measuring point data in the storage partition of the slave device.

9. The method according to claim 8, characterized in that Determining the continuous marker of each of the measuring point data according to the data accuracy and the starting address of each of the measuring point data includes: For each of the measuring point data, if the measuring point data is the first measuring point data, the second preset value is determined as a continuous marker of the measuring point data; If the measuring point data is not the first measuring point data, determining the end address of the previous measuring point data according to the starting address of the measuring point data, the starting address of the previous measuring point data and the data accuracy, and determining whether the starting address of the measuring point data is continuous with the end address of the previous measuring point data; If the starting address of the measuring point data is continuous with the ending address of the previous measuring point data, the first preset value is determined as the continuous marker of the measuring point data; If the starting address of the measuring point data is not continuous with the ending address of the previous measuring point data, the second preset value is determined as the continuous marker of the measuring point data.

10. The method according to claim 6, characterized in that Before writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device, the method includes: Determine whether the reading of the measurement point data storage address of the slave device is completed according to the address feedback information; If the reading of the storage address of the measuring point data of the slave device is completed, the step of writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device is executed; If the reading of the measuring point data storage address of the slave device is not completed, a data address reading instruction is sent to the slave device based on the device information of the slave device until the reading of the measuring point data storage address of the slave device is completed, and the step of writing the starting address, data precision and data range corresponding to the measuring point data into the storage partition of the slave device is executed.

11. The method according to claim 10, characterized in that The determining, according to the address feedback information, whether the reading of the measurement point data storage address of the slave device is completed includes: For each of the address feedback information, if the data in the multiple measuring point data storage areas corresponding to the address feedback information are not empty, it is determined that the measuring point data storage address of the slave device is not completed; If there is a measuring point data storage area with empty data among the multiple measuring point data storage areas corresponding to the address feedback information, it is determined that the reading of the measuring point data storage address of the slave device is completed.

12. The method according to any one of claims 1 to 11, characterized in that: Each of the slave devices corresponds to a storage partition; After sending a data read instruction to each of the slave devices according to the data storage address of the measurement point in each of the slave devices, and obtaining the device data returned by each of the slave devices based on the data read instruction, the method further includes: The device data returned by each of the slave devices based on the data read instruction is written into the storage partition corresponding to each of the slave devices.

13. A device data reading apparatus, characterized in that: The device comprises: A device information acquisition module, used to send a device information reading instruction to each slave device according to the device address of each slave device, and determine the device information of each slave device; An address acquisition module is used to send a data address reading instruction to each of the slave devices according to the device information of each of the slave devices, and determine the measurement point data storage address of each of the slave devices according to the address feedback information returned by each of the slave devices based on the data address reading instruction; The data acquisition module is used to send a data reading instruction to each of the slave devices according to the measurement point data storage address in each of the slave devices, and obtain the device data returned by each of the slave devices based on the data reading instruction.

14. An electronic device, characterized in that: The method comprises a memory and a processor; the memory stores an application program, and the processor is used to run the application program in the memory to perform the operation in the method described in any one of claims 1 to 12.

15. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Equipment data acquisition method and device, storage medium and electronic device

    CN111162983A

  • Communication method and device based on Modbus protocol and communication equipment

    CN112073280A

  • Terminal communication configuration system, method, device and medium

    CN113114667A

  • Data acquisition method and device, Modbus system and storage medium

    CN114391234A

  • Communication method, device and system, electronic equipment and storage medium

    CN115314370A