Data acquisition method, device and system and storage medium

By pre-storing and configuring slave addresses in the host device and performing different data acquisition methods based on different slave addresses, the problem of low data acquisition efficiency in the prior art is solved, and data transmission and acquisition efficiency are improved.

CN119652693APending Publication Date: 2025-03-18ZHEJIANG CHINT IOT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411709320.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

In the prior art, the host device has low data acquisition efficiency for multiple acquisition devices, especially when parameters need to be reconfigured to acquire data from different types of devices.

Method used

By pre-storing and configuring the slave address in the host device, the slave address of the acquisition device is judged, and different data acquisition methods are performed based on different addresses, including cyclic reading instructions and transparent transmission methods.

Benefits of technology

The data transmission efficiency of different types of acquisition equipment is improved, the overall efficiency of the data acquisition system is enhanced, and the configuration and repetitive operations are reduced required for the acquisition of multiple energy-efficient terminals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119652693A_ABST
    Figure CN119652693A_ABST
Patent Text Reader

Abstract

The invention discloses a data collection method, device and system and a storage medium. The data acquisition method is applied to the data acquisition system comprising a host device and at least one acquisition device. The method comprises the following steps of: when a data acquisition instruction of acquisition equipment is received, firstly performing category judgment on a slave address of the acquisition equipment received on a bus, and comparing the slave address with a pre-stored first address and a pre-configured second address; and when the slave address is the second address, performing data acquisition on the acquisition equipment based on the slave address. Therefore, the slave addresses of the different types of acquisition devices can be distinguished, the data transmission efficiency of the different types of acquisition devices is improved, and the data acquisition efficiency of the data acquisition system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a data acquisition method, device, system and storage medium. Background Art

[0002] At present, the data collection of multiple collection devices through the host device usually adopts a combination of gateways and other various types of products to collect data. Taking the data collection of energy efficiency terminals as an example, the gateway needs to configure the data of the collection devices of each energy efficiency terminal in the downstream, and then the gateway collects the data of each collection device through the configuration parameters. The gateway reports the data of the collection device to the platform through a specific protocol in the upstream. However, the configuration function of the gateway is limited, and the functions of various types of collection devices are different, which means that the data collected in the downstream is also different. If it is necessary to collect other data from each collection device, the gateway needs to reconfigure the parameters, resulting in low collection efficiency for multiple energy efficiency terminals. Summary of the invention

[0003] The purpose of the present application is to provide a data acquisition method, device, system and storage medium to solve the problem of low efficiency of data acquisition of multiple acquisition devices by a host device in the related art.

[0004] In order to achieve the above-mentioned object, the first aspect of the present application provides a data acquisition method, which is applied to a data acquisition system, wherein the data acquisition system includes a host device and at least one acquisition device, and the host device communicates with the acquisition device via a bus. The data acquisition method includes:

[0005] In response to receiving a data collection instruction for a collection device, acquiring a slave address of the collection device received on the bus;

[0006] Determining whether the slave address is a first address pre-stored in the host device;

[0007] If the slave address is not the first address, determining whether the slave address is a second address preconfigured in the host device;

[0008] If the slave address is the second address, data is collected from the collection device based on the slave address.

[0009] In the embodiment of the present application, the slave address includes a first data segment and a second data segment, and data acquisition is performed on the acquisition device based on the slave address, including:

[0010] Read the data of the first data segment by means of a loop reading instruction;

[0011] The data of the second data segment is read and written by transparent transmission.

[0012] In the embodiment of the present application, the first data segment includes a sub-information segment and a sub-data segment, and the data of the first data segment is read by means of a loop reading instruction, including:

[0013] Reading the first data segment according to a set cycle period;

[0014] Reading a sub-information segment of a first data segment in a first cycle;

[0015] Determine the identification information of the collection device corresponding to the first data segment having the first feedback data as the first identification, and determine the identification information of the collection device corresponding to the first data segment not having the first feedback data as the second identification;

[0016] In a second cycle, the first data segment is placed into a first message queue based on the identification information of the acquisition device;

[0017] The first message queue is sent to the bus, and identification information of the first data segment in the message queue is determined based on first response data of the host device to the first message queue.

[0018] In an embodiment of the present application, placing the first data segment into the first message queue based on the online flag of the acquisition device in the second cycle includes:

[0019] In the second cycle, the identification information of the acquisition device is read;

[0020] If the collection device has the first identifier, read the sub-data segment of the first data segment of the collection device, and put the sub-data segment into the first message queue;

[0021] If the collection device has a second identifier, the sub-information segment of the first data segment of the collection device is placed in the first message queue.

[0022] In an embodiment of the present application, determining identification information of a first data segment in a message queue based on first response data of a host device to a first message queue includes:

[0023] Determine whether the first data segment in the first message queue receives the first response data of the host device;

[0024] Determine identification information of a first data segment of first response data received from the host device as a third identification;

[0025] The identification information of the first data segment of the first response data not received from the host device is determined as a fourth identification, and the first data segment with the fourth identification is deleted from the message queue.

[0026] In the embodiment of the present application, reading and writing data of the second data segment by transparent transmission includes:

[0027] In response to a first transparent transmission instruction generated according to the second data segment, sending the first transparent transmission instruction to the acquisition device;

[0028] Based on the second feedback data generated for the first transparent transmission instruction and returned by the acquisition device, the second data segment is sent to the host device.

[0029] In an embodiment of the present application, the second data segment includes address data and check data, the address data includes a configuration address, and in response to a first transparent transmission instruction generated according to the second data segment, the first transparent transmission instruction is sent to the acquisition device, including:

[0030] Backing up the configuration address of the second data segment included in the first transparent transmission instruction, and determining the physical address of the second data segment according to the configuration address;

[0031] Update the check data of the second data segment based on the physical address to obtain a second transparent transmission instruction;

[0032] The second transparent transmission instruction is placed in the second message queue, and the second data segment in the second message queue is sent to the bus, so that the acquisition device receives the second transparent transmission instruction.

[0033] In an embodiment of the present application, based on the second feedback data generated for the first transparent transmission instruction returned by the acquisition device, the second data segment is sent to the host device, including:

[0034] Determine the identification information of the collection device corresponding to the second data segment of the received second feedback data as the fifth identification;

[0035] determining the identification information of the collection device corresponding to the second data segment of the second feedback data that has not been received as a sixth identification, and continuing to receive the second feedback data;

[0036] When all the second data segments in the second message queue are fifth identifiers, restoring the physical addresses of the second data segments in the second message queue to the configured addresses;

[0037] The configuration address of the second data segment is sent to the host device.

[0038] In an embodiment of the present application, based on the second feedback data generated for the first transparent transmission instruction returned by the acquisition device, the second data segment is sent to the host device, and further includes:

[0039] When there is still a second data segment with the sixth identifier in the second message queue after the set delay time, determining whether the set delay time exceeds the set overflow time;

[0040] If the set delay time exceeds the set overflow time, a first error prompt is sent to the host device.

[0041] In an embodiment of the present application, sending the configuration address of the second data segment in the second message queue to the host device includes:

[0042] If the identification information of the check data in the second data segment is the seventh identification, regenerate the check data in the second data segment;

[0043] If the identification information of the verification data of the second data segment is the eighth identification, the length of the second data segment is subtracted from the set length.

[0044] The updated second data segment is sent to the host device.

[0045] In the embodiment of the present application, it also includes:

[0046] If the slave address is the first address, second response data based on the slave address is generated by the host device to collect data from the collection device.

[0047] In the embodiment of the present application, it also includes:

[0048] If the slave address is not the first address or the second address, a second error prompt is returned to the host device. In an embodiment of the present application, the host device includes a plurality of interfaces, and the interface includes at least one of the following:

[0049] RS485 interface, Bluetooth interface, wireless communication interface and Ethernet interface.

[0050] A second aspect of the present application provides a data acquisition device, which is applied to a data acquisition system. The data acquisition system includes a host device and at least one acquisition device. The host device communicates with the acquisition device via a bus. The data acquisition device includes:

[0051] An acquisition module, configured to acquire a slave address of the acquisition device received on the bus in response to receiving a data acquisition instruction to the acquisition device;

[0052] A first judging module, used for judging whether the slave address is a first address pre-stored in the host device;

[0053] A second judgment module, used for judging whether the slave address is a second address preconfigured in the host device if the slave address is not the first address;

[0054] The acquisition module is used to acquire data from the acquisition device based on the slave address if the slave address is the second address.

[0055] The third aspect of the present application provides a data acquisition system, comprising:

[0056] Host device;

[0057] At least one acquisition device, the acquisition device communicates with the host device via a bus;

[0058] a memory configured to store instructions; and

[0059] The processor is configured to call instructions from the memory and implement the above data acquisition method when executing the instructions.

[0060] A fourth aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned data collection method.

[0061] The data acquisition method of the present application is applied to a data acquisition system including a host device and at least one acquisition device. When a data acquisition instruction for an acquisition device is received, the slave address of the acquisition device received on the bus is firstly classified, and the slave address is compared with a pre-stored first address and a pre-configured second address. When the slave address is the second address, data acquisition is performed on the acquisition device based on the slave address. In this way, the slave addresses of different types of acquisition devices can be distinguished, and the data transmission efficiency of different types of acquisition devices can be improved, thereby improving the data acquisition efficiency of the data acquisition system.

[0062] Other features and advantages of the present application will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present application, 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 application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0064] Figure 1 A schematic diagram of an application scenario of a data collection method provided in an embodiment of the present application;

[0065] Figure 2 A schematic diagram of a data collection method provided in an embodiment of the present application;

[0066] Figure 3 A flow chart of a data collection method provided in a specific embodiment of the present application;

[0067] Figure 4 A schematic diagram of the structure of a data acquisition device provided in an embodiment of the present application;

[0068] Figure 5 This is a structural block diagram of a data acquisition system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0070] In the description of the present application, it should be understood that the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined. In the present application, the word "exemplary" is used to mean "used as an example, illustration or description". Any embodiment described as "exemplary" in the present application is not necessarily interpreted as being more preferred or more advantageous than other embodiments. In order to enable any technician in the field to implement and use the present application, the following description is given. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can also be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid unnecessary details that make the description of the present application obscure. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the present application.

[0071] The data collection method in the embodiment of the present application is applied to a data collection system, which includes a host device 110 and at least one collection device 120. The collection device 120 can be used as a slave device of the host device 110 to collect data from multiple energy efficiency terminals. Figure 1 As shown, Figure 1Schematic diagram of an application scenario of a data acquisition method provided in an embodiment of the present application. Assume that the application scenario includes a host device 110 and M acquisition devices 120. The host device 110 and the acquisition device 120 can be connected via a bus. In one example, the bus can be an RS485 bus, the host device 110 includes a southbound RS485 interface, and the acquisition device 120 includes a northbound RS485 interface. Based on the RS485 bus, the host device 110 and the acquisition device 120 can communicate through a variety of communication protocols, such as ModbusRTU protocol, ModbusTCP protocol, etc. Among them, the ModbusRTU protocol has high reliability, flexible data definition, and important data can be designed to a continuous register address segment, and the acquisition data can be read through a frame of data. It is suitable for application scenarios that require high-speed data transmission and real-time control, thereby accelerating the data transmission speed between the host device 110 and the acquisition device 120. The ModbusTCP protocol can be transmitted across networks, and also has the characteristics of high reliability and flexible data definition, which is suitable for application scenarios of remote monitoring and control.

[0072] In the embodiment of the present application, the acquisition device 120 can be, but not limited to, a relay output device, a switch input device, a single-phase internal control metering device, a three-phase internal control metering device, a multi-circuit single-phase metering device, a multi-circuit three-phase metering device, a temperature acquisition device, and a residual current acquisition device. Based on the diversity of the acquisition device 120, multiple types of interfaces can be set in the host device 110, for example, RS485 interface (for example, northbound RS485 interface and southbound RS485 interface, etc.), Bluetooth interface, wireless communication interface (such as the fourth generation mobile communication technology (4G), the fifth generation mobile communication technology (5G) or Wi-Fi, etc.) and Ethernet interface, etc. The host device 110 can be provided with an upper application interface for sending the collected data of the acquisition device 120 to the upper application interface, so as to exchange data with the upper application for querying the collected data. In an example, the upper application interface can include but is not limited to an application programming interface (API), a driver and a database interface, etc.

[0073] The collection device 120 includes a function realization module for realizing data collection of the energy efficiency terminal corresponding to the collection device 120. The host device 110 and the collection device 120 are each provided with a microcontroller unit (MCU), and the MCUs of the host device 110 and the collection device 120 are connected through an RS485 bus. According to the type of the collection device 120, the interface of the host and the device 110 is selected to communicate with the collection device 120, so as to adapt to different types of collection devices.

[0074] Understandably, Figure 1 The devices in the application scenario of the data collection method shown, or the devices included in the devices, do not constitute a limitation on the embodiments of the present application. That is, the number of devices and types of devices included in the application scenario of the data collection method, or the number of devices and types of devices included in each device, do not affect the overall implementation of the technical solution in the embodiments of the present application, and can all be regarded as equivalent replacements or derivatives of the technical solution claimed to be protected by the embodiments of the present application.

[0075] The devices in the embodiments of the present application may be independent devices, or they may be a device network or device cluster composed of devices, for example, the host device 110 and the acquisition device 120 described in the embodiments of the present application include but are not limited to computers, network hosts, single network devices, multiple network device sets or cloud devices composed of multiple devices. Among them, cloud devices are composed of a large number of computers or network devices based on cloud computing.

[0076] Those skilled in the art will understand that Figure 1 The application scenario shown in the figure is only an application scenario corresponding to the technical solution of the present application, and does not constitute a limitation on the application scenario of the technical solution of the present application. Other application scenarios may also include Figure 1 More or fewer devices, or device network connections, as shown in Figure 1 Only one host device 110 is shown. It can be understood that the scenario of the data collection method can also include one or more other host devices 110, which is not specifically limited here.

[0077] It should be noted that Figure 1 The application scenario of the data collection method shown is merely an example. The application scenario of the data collection method described in the embodiment of the present application is intended to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application.

[0078] Based on the application scenario of the above data collection method, an embodiment of the data collection method is proposed, which is described in detail below with reference to the accompanying drawings.

[0079] Figure 2 Schematic diagram of a data collection method provided in an embodiment of the present application. Figure 2 As shown, the data acquisition method can be applied to Figure 1 In the application scenario shown, the application scenario includes a host device and at least one acquisition device, the host device communicates with the acquisition device via a bus, and the data acquisition method may include steps 201-204, which are described in detail below.

[0080] Step 201: In response to receiving a data collection instruction for a collection device, a slave address of the collection device received on a bus is obtained.

[0081] In an embodiment of the present application, a data acquisition instruction is an instruction to instruct a collection device to collect data, and the data acquisition instruction can be sent by a host device. When a data acquisition instruction to a collection device is received, a slave address of the collection device received on the bus can be obtained. The slave address is an address used to identify the collection device, and each collection device has a unique address so that the host device or the bus controller can accurately communicate with the collection device.

[0082] In an embodiment of the present application, the slave address may include a first address and a second address. Wherein, the first address is a local address. The local address refers to a slave address pre-stored in a host device, for example, it can be stored in a random access memory (Random Access Memory, RAM) of the host device. The second address is an external address. The external address refers to a slave address pre-configured in the host device, which is used to communicate with an external network according to the configured address format. Taking Modbus communication as an example, the host device can configure an external Modbus communication address of N, and each acquisition device is configured to be N+10, N+11, N+12, ..., N+M+10-1 according to the external Modbus communication address from near to far from the position of the host device, where M is the number of acquisition devices. In order to improve the efficiency of data acquisition, different data acquisition modes can be determined based on different types of slave addresses in an embodiment of the present application.

[0083] Step 202, determining whether the slave address is a first address pre-stored in the host device;

[0084] In an embodiment of the present application, firstly, it is determined whether the slave address is the first address. If the slave address is the first address, it means that the slave address is a slave address pre-stored in the host device, and the host device can directly generate second response data based on the slave address, and then send the second response data to the application interface on the host device to collect data for the acquisition device. Among them, the second response data refers to the response data obtained after reading the slave address pre-stored by the host device. In this way, for the slave address of the first address, it can be directly replied by the host device itself, which improves the efficiency of data collection.

[0085] Step 203: If the slave address is not the first address, determine whether the slave address is a second address pre-configured in the host device.

[0086] In the embodiment of the present application, when the slave address is not the first address, it is necessary to further determine whether the slave address is the second address pre-configured in the host device for communicating with the external network. If the slave address is not the first address or the second address, it means that the slave address is neither pre-stored in the host device, and the format of the slave address does not conform to the address format pre-configured by the host device. Therefore, the data cannot be collected, and a second error prompt needs to be returned to the host device. The second error prompt is an error indicating that the slave address does not support collection.

[0087] Step 204: If the slave address is the second address, data is collected from the collection device based on the slave address.

[0088] In an embodiment of the present application, if the slave address is the second address, it means that the format of the slave address conforms to the format pre-configured by the host device. Therefore, data acquisition can be performed on the acquisition device based on the slave address. The slave address can include multiple data segments, each of which carries different data information of the slave address. Based on the different types of data segments, the data in the data segments can also be read based on different data reading methods. In this way, the data transmission efficiency between the acquisition device and the host device can also be improved.

[0089] When receiving a data acquisition instruction for an acquisition device, the embodiment of the present application first classifies the slave address of the acquisition device received on the bus, and compares the slave address with a pre-stored first address and a pre-configured second address. When the slave address is the second address, data acquisition is performed on the acquisition device based on the slave address. In this way, the slave addresses of different types of acquisition devices can be distinguished, and the data transmission efficiency of different types of acquisition devices can be improved, thereby improving the data acquisition efficiency of the data acquisition system.

[0090] In the embodiment of the present application, the type of the data segment of the slave address can be divided into a first data segment and a second data segment. Among them, the first data segment can be an important data segment, indicating that the data segment is a data segment that needs to interact with the system frequently, and the data segment is a read data segment. The second data segment can be a non-important data segment, that is, a data segment that needs to send parameters to configure the slave and other read data segments.

[0091] In step 204 of the embodiment of the present application, for the first data segment, data of the first data segment can be read by means of a loop read instruction, and for the second data segment, data of the second data segment can be read and written by means of a transparent transmission.

[0092] In the embodiment of the present application, the cyclic read instruction refers to the host device continuously reading the data or status information of the acquisition device. For example, the host device sends a read request to the acquisition device, and after waiting for the feedback data of the acquisition device, sends a read request to the acquisition device again. This process is repeated until the termination condition is reached to realize continuous reading of data. Among them, the termination condition can be reaching a certain number of reads, meeting a specific condition, or receiving a specific termination instruction. Transparent transmission refers to transferring the collected data from the acquisition device to the host device, and not parsing or processing the collected data during the transmission process. Transmitting data by transparent transmission can simplify the process of data transmission, improve transmission efficiency, and ensure the integrity and accuracy of data. In an example, it is assumed that the host device fixes the slave address of the acquisition device to 11, 12, 13, 14, ..., 10+M, where M is the number of acquisition devices. The first data segment in the slave address is placed in the range of 0x8000 to 0x80AF, starting from 0x8000, and the second data segment is placed in other address segments without constraints. In this way, the first data segment and the second data segment can be distinguished according to the set address information.

[0093] In the embodiment of the present application, the first data segment may include a sub-information segment and a sub-data segment. The sub-information segment is the first data segment used to transmit command and response information, and may include control information such as identification of communication type, device address, function code, and data length. The sub-data segment is the first data segment used to transmit specific data information, and may include data to be read, such as sensor data and control commands.

[0094] For the first data segment, the embodiment of the present application can read it by means of a cyclic read instruction. Specifically, the first data segment is first read according to a set cycle period. The cycle period refers to the frequency at which the host device reads the first data segment. For example, the first data segment can be set to be read at a certain interval.

[0095] In the embodiment of the present application, two adjacent cycles can be regarded as a reading process of the first data segment. In the two adjacent cycles, the cycle in the previous sequence is the first cycle, and the cycle in the next sequence is the second cycle.

[0096] In the first cycle, the sub-information segment of the first data segment of the slave address of each acquisition device can be read first. Specifically, the host device can send a read instruction to each acquisition device, and then determine whether the acquisition device has the first feedback data. The first feedback data is the response of the acquisition device to the read instruction. Then, the identification information of the acquisition device corresponding to the first data segment with the first feedback data is determined as the first identification, and the identification information of the acquisition device corresponding to the first data segment without the first feedback data is determined as the second identification. The first identification indicates that the acquisition device has responded to the read instruction, and the second identification indicates that the acquisition device has not responded to the read instruction. For example, the first identification can be set to 1 and the second identification can be set to 0.

[0097] Then, in the second cycle, the first data segment is placed in the first message queue based on the identification information of the acquisition device. The first message queue refers to a message queue including the first data segment information. In one example, in the second cycle, the identification information of the acquisition device is first read. If the acquisition device has a first identification, indicating that the acquisition device has responded to the read instruction of the host device, the data information in the first data segment of the acquisition device can be read, that is, the sub-data segment of the first data segment of the acquisition device can be read, and the sub-data segment can be placed in the first message queue. For example, if the identification information of the acquisition device is the first identification, the data information in the slave address of the acquisition device can be pressed into the first message queue. If the acquisition device has a second identification, indicating that the acquisition device has no response to the read instruction of the host device, then in the second cycle, it is not necessary to read the data of the acquisition device, and only the sub-information segment of the first data segment of the acquisition device is placed in the first message queue to continue reading the slave address of the acquisition device.

[0098] Finally, the header message of the first message queue is taken out and sent to the bus. And the identification information of the first data segment in the message queue is determined based on the first response data of the host device to the first message queue. In an embodiment of the present application, the identification information of the first data segment in the first message queue can be determined based on the first response data of the host device to the first message queue. First, it is determined whether the first data segment in the first message queue receives the first response data of the host device. Among them, the first response data refers to the data that the host device has a response to the first data segment of the first message queue. Then, the identification information of the first data segment that receives the first response data of the host device is determined as the third identification. The identification information of the first data segment that does not receive the first response data of the host device is determined as the fourth identification, and the first data segment with the fourth identification is deleted from the message queue. Among them, the third identification indicates that the first data segment receives the first response data of the host device, and the fourth identification indicates that the first data segment does not receive the first response data of the host device. For example, the third identification can be set to 1, and the fourth identification can be set to 0. By setting different identifiers for the first data segment in the first message queue, the collection device can obtain the collection status of the data in the first data segment in the slave address sent by the host device, thereby processing the first data segment more efficiently.

[0099] The embodiment of the present application processes the important data segments in the slave address by means of a cyclic read instruction. The first data segment in the slave address of the acquisition device is buffered in the memory of the host device, and the data that needs to read the first data segment is transferred. There is no need to send the read instruction to the acquisition device and there is no need to wait for the acquisition device to return the corresponding reply information to obtain the data of the acquisition device. The host device directly replies to the slave address through the data in the memory, so that the host device can quickly obtain the acquired data, reducing the transmission time.

[0100] In an embodiment of the present application, the data of the second data segment can be read and written by transparent transmission. Specifically, first, in response to the first transparent transmission instruction generated according to the second data segment, the first transparent transmission instruction is sent to the acquisition device. Among them, the first transparent transmission instruction is an instruction generated based on the need of the host device to read and write the second data segment, and the data representing the second data segment needs to be sent to the host device by transparent transmission. After receiving the first transparent transmission instruction, the acquisition device generates second feedback data based on the first transparent transmission instruction. The second feedback data is a reply instruction frame of the acquisition device to the first transparent transmission instruction. Then, based on the second feedback data returned by the acquisition device, the second data segment is sent to the host device. In one example, the second data segment in the acquisition device that returns the second feedback data can be sent to the host device by transparent transmission. In this way, the second data segment of the acquisition device that needs data collection can be collected according to demand, thereby improving the efficiency of data collection.

[0101] In an embodiment of the present application, the second data segment is non-important data. The second data segment may include address data and check data, and the address data may include a configuration address. Among them, the address data does not directly affect the integrity and correctness of the data, and is used to characterize the data of the address information of the second data segment. Check data refers to the data of the check algorithm used to verify the integrity and consistency of the second data segment. For example, the check data may be cyclic redundancy check (CRC) data. Check data is usually not directly involved in the processing and application of data, but is used to detect transmission errors and does not directly affect the content and application of data.

[0102] In response to the first transparent transmission instruction generated according to the second data segment, the configuration address of the second data segment contained in the first transparent transmission instruction can be backed up first, and the physical address of the second data segment can be determined according to the configuration address. Among them, the configuration address refers to the address configured by the acquisition device used to distinguish the transparent transmission, and the physical address refers to the real slave address of the second data segment. Taking Modbus communication as an example, the configuration address of the second data segment is the Modbus address. In response to the first transparent transmission instruction, the Modbus address in the first transparent transmission instruction can be backed up to variable A first. Variable A refers to a variable named A, which is used to store the Modbus address of the second data segment. Then the Modbus address is replaced with the real slave address of the second data segment, that is, A-N+10. Among them, N is the number of the acquisition device to which the second data segment belongs, and 10 is the set offset value to ensure that the real slave address does not conflict with the reserved address in the Modbus communication protocol.

[0103] After the configuration address of the second data segment is replaced with the physical address, it is necessary to recalculate new verification data based on the physical address to obtain the second transparent transmission instruction. The second transparent transmission instruction is a transparent transmission instruction containing the updated verification data. Then, the second transparent transmission instruction is placed in the second message queue. The second message queue refers to a message queue storing the second transparent transmission instruction. For example, the header of the second transparent transmission instruction can be pushed into the header of the second message queue. Then, the second data segment in the second message queue is sent to the bus so that the acquisition device receives the second transparent transmission instruction and returns the second feedback data based on the second transparent transmission instruction.

[0104] In an embodiment of the present application, based on the second feedback data returned by the acquisition device, the identification information of the acquisition device corresponding to the second data segment that receives the second feedback data can be determined as the fifth identification. The identification information of the acquisition device corresponding to the second data segment that does not receive the second feedback data is determined as the sixth identification, and the second feedback data continues to be received. Among them, the fifth identification indicates that the acquisition device has responded to the second data segment and returned the second feedback data. The sixth identification indicates that the acquisition device has no response to the second data segment and does not return the second feedback data. For example, the fifth identification can be 0, and the sixth identification can be 1. When all the second data segments in the second message queue are the fifth identification, it means that all the second data segments in the second message queue have sent the second feedback data. Therefore, the physical address of the second data segment in the second message queue can be restored to the configuration address, and the configuration address of the second data segment can be sent to the host device by transparent transmission.

[0105] In an embodiment of the present application, since the response speed of each acquisition device is different, a set delay time can be set in advance. When there is still a second data segment with a sixth identifier in the second message queue after the set delay time, first, determine whether the set delay time exceeds the set overflow time, and the set overflow time refers to the maximum upper limit of the delay time of the acquisition device. If the set delay time exceeds the set overflow time, it means that there is an acquisition device with a transmission failure, and a first error prompt is sent to the host device. If the set delay time does not exceed the set overflow time, the first transparent transmission instruction is responded to again, and the transparent transmission process of the second data segment is performed again.

[0106] In an embodiment of the present application, the protocol between the acquisition device and the host device may include multiple protocols, for example, ModbusRTU protocol, or ModbusTCP protocol, etc. Data transmission under the ModbusTCP protocol does not require data verification, and data is directly returned through the second address buffer address segment. Data transmission under the ModbusRTU protocol requires data verification, and data processing is performed by the slave transparent transmission module. Therefore, after the physical address of the second data segment in the second message queue is restored to the configuration address, it is first determined whether data verification is required to determine the length of the second data segment. If the identification information of the verification data in the second data segment is the seventh identification, the seventh identification indicates that data verification is required. At this time, the verification data in the second data segment is regenerated. If the identification information of the verification data of the second data segment is the eighth identification, the eighth identification refers to the indication that data verification is not required, then the length of the second data segment is subtracted from the set length. The set length refers to the length occupied by the verification data. For example, the seventh identification is 1 and the eighth identification is 0. Finally, the updated second data segment is sent to the host device. In this way, the transmission of the second message queue can be made more efficient based on different transmission protocols.

[0107] The following example uses the communication between the host device and the acquisition device in Modbus communication. Figure 3 FIG. 1 is a flow chart of a data collection method provided in a specific embodiment of the present application. Figure 3 As shown, in a specific embodiment, the host device may include an Ethernet interface, a wireless networking interface, a Bluetooth interface, and an RS485 interface. The host device and the acquisition device can communicate through the ModbusRTU protocol and the ModbusTCP protocol. Both communication protocols include a slave address, and the second address configured by the host device is defined as N. The second addresses of the respective acquisition devices from the nearest to the farthest from the host device are N+10, N+11, N+12, ..., N+M+10-1, respectively, where M is the number of acquisition devices. Both the ModbusRTU protocol and the ModbusTCP protocol will call the ModbusAPDU parsing module.

[0108] The first data segment of the slave address is an important data segment, which is divided into a sub-information segment and a sub-data segment. Assume that the identification information of the acquisition device is an online identification, the first identification is 1, the second identification is 0, the third identification is 1, and the fourth identification is 0. The step of the host device reading the first data segment includes the following steps.

[0109] Step 1: In the first cycle, read the sub-information segments of each acquisition device, set the online flag of the acquisition device with the first feedback data to 1, otherwise set the flag to 0. Then jump to step 2.

[0110] For example, assuming that the loop read instruction only reads the first 8 registers of the 8000H segment, the device type, device serial number, and valid data length can be obtained. The host sends the command frame: slave address + 0380 00 00 08 + CRC16 check low byte + CRC16 check high byte, thus obtaining the type, serial number and valid data length of each acquisition device.

[0111] If the data length + the length of the sub-information segment is greater than 100, segmented reading is performed. For example, the six-loop single-phase address table is as follows: DataLen length is equal to 166 registers, the sub-information segment length is 8 registers, and the total number of registers is 174. When reading the first data segment of the acquisition device, the host needs to send and read 2 frames of data. Slave address + 03 80 00 0064 + CRC16 check low byte + CRC16 check high byte, and slave address + 03 80 64 00 4A + CRC16 check low byte + CRC16 check high byte. For example, in the address of the four-loop relay output module, the DataLen length is equal to 6 registers, the sub-information segment length is 8 registers, and the total number of registers is 16. When reading the acquisition device, the host device needs to send and read 1 frame of data: slave address + 03 80 00 00 0C + CRC16 check low byte + CRC16 check high byte.

[0112] Step 2: In the second cycle, determine whether the online flag of the acquisition device is 1. If it is 1, read all instructions of the first data segment and push the sub-information segment into the first message queue. If it is 0, it is necessary to continue to send the read instruction for the first data segment, so push the sub-information segment into the message queue.

[0113] Step 3: Take out the head message of the first message queue and send it to the bus. If the first response data of the host device is received, set the online flag of the acquisition device to 1. If the first response data of the host device is not received, set the online flag of the acquisition device to 0, delete the first data segment from the head of the first message queue, process all the messages in the first message queue in turn, and jump to step 2 after completion.

[0114] The host device cyclically reads the data of the first data segment using the first message queue, and the cyclic reading instruction is pushed into the first message queue in the form of a message at one time. The first message queue adopts a first-in-first-out method. If the acquisition device does not respond, the online flag of the acquisition device is set to 0. If there is a response, the online flag of the acquisition device is set to 1. After one cycle is completed, when a new cycle is performed to read the first data segment of the acquisition device data, it is determined whether the online flag is 1. If it is 1, the sub-data segment of the first data segment is read and pushed into the message queue. If it is 0, only the sub-information segment of the first data segment is read and pushed into the message queue.

[0115] The important first data segment is buffered in the memory of the host device. If the upper-layer application needs to read the data of the first data segment when transmitting the Modbus protocol, it does not need to send instructions to the acquisition device and wait for the acquisition device to return a reply frame to obtain the data. The host device will use the data in the memory to directly reply to the upper-layer application interface. In this way, the upper-layer application can quickly obtain the first data segment, that is, the important data segment, and reduce the time required for intermediate transparent transmission. However, if it is necessary to read the information of other non-important data segments in the slave address or write data in the slave address, it is necessary to send a transparent transmission instruction to the acquisition device, wait for the reply instruction frame of the acquisition device, and return it to the upper-layer application interface.

[0116] The host device and the acquisition device can include ModbusRTU protocol and ModbusTCP protocol. Both protocols will call the ModbusAPDU parsing module. The steps processed in the ModbusAPDU parsing module are as follows.

[0117] Step 1: Determine whether the slave address is the first address, that is, the address of the host device itself. If it is the address of the local device, directly use the data in the RAM of the host device to directly respond to the transparent transmission instruction, and return the data responding to the transparent transmission instruction to the upper application interface. If it is not the address of the host, jump to step 2.

[0118] Step 2: Determine whether it is the second address, that is, the external address configured by the host device. If it is not an external address, then generate an unsupported error through the unsupported error generation module, and return the unsupported error of the external address to the upper layer application. If it is an external address, proceed to step 3.

[0119] Step 3: Transparently transmit the second data segment that needs to be transparently transmitted. Specifically, the instruction frame that needs to be transparently transmitted can be transmitted through the slave transparent transmission module, and the identification information of whether the returned second feedback data needs CRC verification is set and transmitted to the module. For example, if it is an instruction transmitted by the ModbusTCP protocol, the identification information of the CRC verification data is the seventh identification, which can be set to 0. If it is an instruction transmitted by the ModbusRTU protocol, the identification information of the CRC verification data is the eighth identification, which can be set to 1.

[0120] The communication protocol of the above-mentioned northbound RS485 interface is the ModbusRTU protocol. Data from both the host device and the acquisition device can be read and written through this interface. The data received from the RS485 interface is passed to the ModbusAPDU parsing module for processing, and the processing flag of the incoming CRC check is 1. The downlink process is the ModbusAPDU parsing module processing process, and the received data and length processed by the ModbusAPDU parsing module are obtained, and the data is sent to the northbound RS485 interface through the direct memory access (DMA) channel of the serial port of the host's MCU.

[0121] The Bluetooth interface and MCU use serial port communication. The mode of the Bluetooth module corresponding to the Bluetooth interface is mainly divided into two parts. The first part is the Attention (AT) command processing, and the second part is the transparent transmission processing module. The steps of the Bluetooth interface data processing method are as follows.

[0122] Step 1: MCU controls the power supply of the Bluetooth module, powers off for a period of time, and then powers on the Bluetooth module.

[0123] Step 2: Execute AT command stage: Set the name of the Bluetooth module, the name of Bluetooth is ZTXXXXXXXXXXXX, where XXXXXXXXXXXX is the serial number of the host. Set the Bluetooth mode to enter the transparent transmission stage, and start timer 1 and timer 2 without data delivery. The timer counter is accumulated in the interrupt server of the basic timer.

[0124] Step 3: MCU starts to receive data from the Bluetooth module. If data from the Bluetooth module is received, the timer 1 counter and the timer 2 counter are cleared to determine whether the timer 1 counter exceeds the preset value 1. If it exceeds, it indicates that timer 1 overflows, and the host MCU sends an AT command to the serial port. If OK is returned, the current Bluetooth module is no longer in transparent transmission mode, and jump to step 1. Determine whether the timer 2 counter exceeds the preset value 2. If it exceeds, it indicates that timer 2 overflows, and there is no data interaction within the preset time value 2, and jump to step 1. At the same time, determine whether it is a ModbusRTU instruction. If it is a ModbusRTU instruction, go to step 4.

[0125] Step 4: Send the received ModbusRTU instruction to the ModbusAPDU parsing module for processing, and the incoming CRC processing flag is 1. After processing by the ModbusAPDU parsing module, the received data and length are obtained, and the data is sent to the Bluetooth module through the DMA channel of the Bluetooth serial port of the host MCU, and jump to step 3.

[0126] The Ethernet interface supports the MdobusTCP protocol and the device management protocol. The ModbusTCP protocol format is as follows: Transmitted on TCP / IP Ethernet, the data frame contains three parts: message header, function code and data. For example, the information frame format can be shown in Table 1. The MBAP (Modbus Application Protocol) message header is divided into 4 fields, a total of 7 bytes. By comparing the protocol format, there are two differences from ModbusRTU: the first is the first 6 bytes of ModbusTCP in MBAP; the second is that there is no CRC check in ModbusTCP. In the device management protocol, the start character (68H) marks the beginning of a data frame, and the end character (16H) marks the end of a data frame. The data packet is as follows: Cloud: Control field 00 00 30 02; Device: Control field 80 00 30 02.

[0127] Table 1

[0128] MBAP Header Function code Data Area 7 bytes 1 byte n bytes

[0129] The data processing process based on the Ethernet protocol is as follows.

[0130] Step 1: Control the power supply of the Ethernet module, power off for a period of time, and then power on the Ethernet module

[0131] Step 2: Perform Ethernet initialization configuration: local Ethernet IP address, subnet mask, gateway IP address, etc. The initialization process includes the following aspects.

[0132] 1. Ethernet no data interaction timer 1 is turned on. 2. ModbusTCP server socket cluster N, start listening for client connections. If there is a client connection and there is an idle server in the server cluster in the listening stage, the server socket enters the data establishment stage, and the server socket no data interaction timer is turned on. 3. Initialize a client socket to connect to the device management platform server. If connected, the interaction timer of the socket is turned on.

[0133] Step 3: Determine whether the counter of Ethernet no-data interaction timer 1 exceeds a preset threshold, and if so, jump to step 1.

[0134] Step 4: Start traversing all the socket connections that have been established. If the counter of the no data delivery timer of each socket exceeds the preset threshold, the connection will be automatically disconnected. If the server socket of the ModbusTCP protocol has timed out, it will re-enter the monitoring mode. If it is the device management platform, it will be disconnected and reconnect to the device management platform server after a preset time. If data interaction is detected on any socket, the Ethernet no data interaction timer 1 will be cleared.

[0135] Step 5: If data is transmitted from the ModbusTCP server socket cluster, first clear the socket timer no data interaction counter, extract the first 4 bytes in the ModbusTCP MBAP message header and back them up to temporary variable 1, extract the data frame from the 7th byte to the end, and then proceed to step 6. If data is transmitted from the device management connection socket, first clear the socket timer no data interaction counter and determine whether it is a ModbusRTU transparent transmission frame. If it is a ModbusRTU transparent transmission frame, jump to step 7.

[0136] Step 6: Pass the data to the ModbusAPDU parsing module for processing. The incoming CRC processing flag is 0. After processing by the ModbusAPDU parsing module, the received data and length are obtained. The backup temporary variable 1 is added to the header of the end data. After processing the added length field, the data is sent to the corresponding socket. Jump to step 3.

[0137] Step 7: The data is passed to the ModbusAPDU parsing module for processing. The incoming CRC processing flag is 1. After being processed by the ModbusAPDU parsing module, the received data and length are obtained. Then the data frame is packaged into a data transparent transmission reply frame corresponding to the device management platform protocol, and the data is sent to the corresponding socket. Jump to step 3.

[0138] The ModbusTCP protocol in the above Ethernet interface establishes N socket servers to listen to the client access status of port 502 of the ModbusTCP protocol. When one of these sockets is in the listen stage, the client can establish a connection with the ModbusTCP in the listen stage and switch to the connection establishment stage. If all N sockets are in the connection establishment stage, the new client will not be able to connect successfully when it applies to the server. By configuring a no-data interaction timer for each socket, the socket server that has not delivered data for more than a certain period of time can be promptly transferred from the establishment state to the listen stage, which facilitates new clients to connect to the server and exchange data. It also solves some abnormal network conditions, such as virtual connection conditions, and can repair network connections in a timely manner and release resources.

[0139] The wireless module interface supports lightweight message transmission protocols, such as the MQTT (Message Queuing Telemetry Transport) protocol and the device management protocol. The MQTT protocol includes the parameter setting instructions of the slave module and the transparent transmission Modbus RTU protocol instructions.

[0140] The parameter setting instruction of the acquisition device refers to the setting of parameters for some data items of the acquisition device. The host device does not save the values ​​of these parameters. The host device needs to set the values ​​of the parameters according to the MQTT protocol, generate the ModbusRTU frame write frame of the corresponding slave module, and generate the return frame of the MQTT protocol according to the return result of the acquisition device to indicate whether the setting parameters are correct. For example: a four-loop relay output module, MQTT serial numbers 2, 3, 4, and 5 support parameter settings. The steps of the data processing method of the wireless module corresponding to the wireless interface are as follows.

[0141] Step 1: Receive the MQTT parameter setting frame of the acquisition device transmitted by the wireless module. Extract the parameter type, extract the corresponding Modbus register address, register length, data type from the preset information table, and extract the SN code 1 of the slave module from the MQTT frame.

[0142] Step 2: Check if the SN code in the first data segment of each slave address in the RAM of the host device can be found with SN code 1. If not found, generate an error reply frame of the MQTT parameter setting frame, report it to the platform, and jump to step 1. If SN code 1 is found in the first data segment of the host device RAM, determine whether the parameters to be set are the same as the corresponding data in the RAM. If they are the same, jump to step 4, otherwise execute step 3.

[0143] Step 3: Find the position i of SN code 1 according to the first data segment of each slave address in the RAM of the host device, and get the communication address of the slave as i+10+N (slave external address), where N is the host Modbus external address. Generate a standard ModbusRTU write instruction frame based on the extracted Modbus register address, length, and data type, and pass it to the ModbusAPDU parsing module for processing, and the incoming CRC processing flag is 1. After processing by the ModbusAPDU parsing module, the received data and length are obtained. If the write is unsuccessful, generate an error reply frame of the MQTT parameter setting frame, report it to the platform, and jump to step 1. If the write is successful, execute step 4.

[0144] Step 4: Generate a successful reply frame for MQTT parameter settings, report it to the platform, and jump to step 1.

[0145] In the MQTT protocol, the host device uses the method in the message body as Trans / Modbus, indicating that the command is a transparent transmission command. 202408060401 is the unique code of the slave, 0103800000106DC6 is the transparent ModbusRTU frame, and 01 is the slave address. The MQTT platform does not need to know the real slave ModbusRTU slave address. When the host device processes the slave address, it will convert the 01 address to the ModbusRTU address.

[0146] When transparent transmission of ModbusRTU protocol instructions is required, it can be achieved through the following steps:

[0147] Step 1: Receive the MQTT transparent transmission protocol frame transmitted by the wireless module, and advance the transparent transmission protocol frame content and the corresponding device Sn code 1.

[0148] Step 2: Check whether SN code 1 is consistent with the host code. If it is consistent, set the Modbus communication address variable C to the Modbus communication address N (host address) of the host device. If it is inconsistent with the host code, traverse the SN codes in the first data segment of each acquisition device in the RAM of the host device to see if it can find SN code 1. If not found, generate an error reply frame of the MQTT transparent ModbusRTU frame, report it to the platform, and jump to step 1. If SN code 1 is found, set the Modbus communication address variable C to i+10+N (slave external address) obtained according to the position i where the SN code is found.

[0149] Step 3: Back up the slave address in the transparent ModbusRTU frame to the temporary variable D, then set the above Modbus communication address variable C to the communication address field in the transparent ModbusRTU frame, and regenerate the CRC check to obtain a new data communication frame;

[0150] Step 4: Data is passed to the ModbusAPDU parsing module for processing, and the incoming CRC processing flag is 1. After being processed by the ModbusAPDU parsing module, the received data and length are obtained. If there is no data transmitted from the ModbusAPDU parsing module, an error reply frame of the MQTT transparent ModbusRTU frame is generated, reported to the platform, and jumps to step 1; if there is data transmitted, the variable C is set to the address field of the reply frame, the CRC check is regenerated, and then an error reply frame of the MQTT transparent ModbusRTU frame is generated according to the MQTT protocol, reported to the platform, and jumps to step 1.

[0151] A no-data interaction timer can be designed during the initialization phase of the wireless module. For example, three timers will be initialized during the initialization phase of the wireless module: wireless module no-data interaction timer 1, MQTT protocol no-data interaction timer 2, and device management protocol no-data interaction timer 3. After the initialization of these three timers is completed, the counters of these three timers will be accumulated in the interrupt server of the basic timer.

[0152] When the MQTT protocol or device management protocol has data interaction, the counter of the wireless module no data interaction timer 1 is cleared. During the operation of the wireless module protocol parsing task, it will be determined whether the counter of the wireless module no data interaction timer 1 is greater than the preset threshold 1. If it is greater than the threshold 1, the task will jump to the initialization stage and restart the program from the power control reset of the wireless module.

[0153] When the MQTT protocol has data interaction, the counter of the MQTT protocol no data interaction timer 2 will be cleared. During the MQTT protocol parsing process, it will detect whether the counter of timer 2 exceeds the preset threshold 2. If it is greater than threshold 2, the connection with the MQTTBroke server will be actively disconnected, and then reconnected to the MQTTBroke server after a delay.

[0154] When the device management protocol has data interaction, the counter of the device management protocol no data interaction timer 3 will be cleared. During the standby management protocol parsing process, it will detect whether the counter of timer 3 exceeds the preset threshold 3. If it is greater than the threshold 3, the connection with the device management platform server will be actively disconnected, and then reconnected to the device management platform server after a delay.

[0155] Figure 4 Schematic diagram of the structure of a data acquisition device provided in an embodiment of the present application. Figure 4As shown, the data acquisition device 400 provided in the embodiment of the present application is applied to a data acquisition system, and the data acquisition system may include a host device and at least one acquisition device, and the host device communicates with the acquisition device through a bus. The data acquisition device 400 may include an acquisition module 401, a first judgment module 402, a second judgment module 403 and an acquisition module 404. The acquisition module 401 is used to obtain the slave address of the acquisition device received on the bus in response to receiving a data acquisition instruction for the acquisition device. The first judgment module 402 is used to determine whether the slave address is a first address pre-stored in the host device. The second judgment module 403 is used to determine whether the slave address is a second address pre-configured in the host device if the slave address is not the first address. The acquisition module 404 is used to perform data acquisition on the acquisition device based on the slave address if the slave address is the second address.

[0156] Among them, the acquisition module 401, the first judgment module 402, the second judgment module 403 and the collection module 404 can be used to execute steps 201-204 in the embodiments corresponding to the above-mentioned data collection method respectively. For the specific implementation methods of these modules and more details, please refer to the corresponding method part, which will not be repeated here one by one.

[0157] Figure 5 : is a structural block diagram of a data acquisition system provided in an embodiment of the present application. Figure 5 As shown, an embodiment of the present application provides a data acquisition system 500. The data acquisition system 500 may include a host device 110, at least one acquisition device 120, a memory 510 and a processor 520. The host device 110 and the at least one acquisition device 120 communicate via a bus. The memory 510 is configured to store instructions. The processor 520 is configured to call instructions from the memory and implement the above-mentioned data acquisition method when executing the instructions.

[0158] An embodiment of the present application also provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the above-mentioned data collection method.

[0159] Since the instructions stored in the data acquisition system and the machine-readable storage medium can execute the steps in any data acquisition method provided in the embodiments of the present application, the beneficial effects that can be achieved by any data acquisition method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0160] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, systems, storage media or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0161] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0162] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0164] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0165] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0166] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated communication signals and carrier waves.

[0167] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0168] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A data collection method, characterized in that: Applied to a data acquisition system, the data acquisition system includes a host device and at least one acquisition device, the host device communicates with the acquisition device via a bus, and the data acquisition method includes: In response to receiving a data collection instruction for the collection device, acquiring a slave address of the collection device received on the bus; Determining whether the slave address is a first address pre-stored in the host device; If the slave address is not the first address, determining whether the slave address is a second address preconfigured in the host device; If the slave address is the second address, data is collected from the collection device based on the slave address.

2. The data collection method according to claim 1, characterized in that: The slave address includes a first data segment and a second data segment, and the data acquisition of the acquisition device based on the slave address includes: Reading the data of the first data segment by means of a loop reading instruction; The data of the second data segment is read and written by transparent transmission.

3. The data collection method according to claim 2, characterized in that: The first data segment includes a sub-information segment and a sub-data segment, and the step of reading data of the first data segment by means of a loop reading instruction includes: Reading the first data segment according to a set cycle period; reading the sub-information segment of the first data segment in a first cycle; Determine identification information of a collection device corresponding to a first data segment having first feedback data as a first identification, and determine identification information of a collection device corresponding to a first data segment not having the first feedback data as a second identification; In a second cycle, the first data segment is placed into the first message queue based on the identification information of the acquisition device; The first message queue is sent to the bus, and identification information of the first data segment in the message queue is determined based on first response data of the host device to the first message queue.

4. The data collection method according to claim 3, characterized in that: The step of placing the first data segment into the first message queue based on the identification information of the acquisition device in the second cycle includes: Reading identification information of the acquisition device in the second cycle; If the acquisition device has the first identifier, read the sub-data segment of the first data segment of the acquisition device, and put the sub-data segment into the first message queue; If the collection device has the second identifier, the sub-information segment of the first data segment of the collection device is placed into the first message queue.

5. The data collection method according to claim 3, characterized in that: The determining, based on first response data of the host device to the first message queue, identification information of the first data segment in the message queue comprises: Determine whether the first data segment in the first message queue receives the first response data of the host device; Determine identification information of a first data segment of first response data received from the host device as a third identification; The identification information of the first data segment of the first response data not received from the host device is determined as a fourth identification, and the first data segment with the fourth identification is deleted from the message queue.

6. The data collection method according to claim 2, characterized in that: The step of reading and writing the data of the second data segment by transparent transmission includes: In response to a first transparent transmission instruction generated according to the second data segment, sending the first transparent transmission instruction to the acquisition device; Based on the second feedback data generated for the first transparent transmission instruction and returned by the acquisition device, the second data segment is sent to the host device.

7. The data collection method according to claim 6, characterized in that: The second data segment includes address data and check data, the address data includes a configuration address, and in response to a first transparent transmission instruction generated according to the second data segment, sending the first transparent transmission instruction to the acquisition device includes: Backing up the configuration address of the second data segment contained in the first transparent transmission instruction, and determining the physical address of the second data segment according to the configuration address; Update the check data of the second data segment based on the physical address to obtain a second transparent transmission instruction; The second transparent transmission instruction is placed in a second message queue, and the second data segment in the second message queue is sent to the bus, so that the acquisition device receives the second transparent transmission instruction.

8. The data collection method according to claim 7, characterized in that: The sending the second data segment to the host device based on the second feedback data generated for the first transparent transmission instruction and returned by the acquisition device includes: Determine identification information of a collection device corresponding to the second data segment of the received second feedback data as a fifth identification; determining identification information of a collection device corresponding to the second data segment of the second feedback data that has not been received as a sixth identification, and continuing to receive the second feedback data; When all the second data segments in the second message queue are the fifth identifiers, restoring the physical addresses of the second data segments in the second message queue to the configured addresses; The configuration address of the second data segment is sent to the host device.

9. The data collection method according to claim 8, characterized in that: The sending the second data segment to the host device based on the second feedback data generated for the first transparent transmission instruction returned by the acquisition device also includes: When the second data segment with the sixth identifier still exists in the second message queue after the set delay time, determining whether the set delay time exceeds the set overflow time; If the set delay time exceeds the set overflow time, a first error prompt is sent to the host device.

10. The data collection method according to claim 8, characterized in that: The sending the configuration address of the second data segment to the host device includes: If the identification information of the verification data in the second data segment is the seventh identification, regenerate the verification data in the second data segment; If the identification information of the check data of the second data segment is the eighth identification, subtracting a set length from the length of the second data segment; The updated second data segment is sent to the host device.

11. The data collection method according to claim 1, characterized in that: Also includes: If the slave address is the first address, second response data based on the slave address is generated by the host device to collect data from the collection device.

12. The data collection method according to claim 1, characterized in that: Also includes: If the slave address is neither the first address nor the second address, a second error prompt is returned to the host device.

13. The data collection method according to claim 1, characterized in that: The host device includes a plurality of interfaces, the interfaces including at least one of the following: RS485 interface, Bluetooth interface, wireless communication interface and Ethernet interface.

14. A data acquisition device, characterized in that: Applied to a data acquisition system, the data acquisition system includes a host device and at least one acquisition device, the host device communicates with the acquisition device via a bus, and the data acquisition device includes: an acquisition module, configured to acquire a slave address of the acquisition device received on the bus in response to receiving a data acquisition instruction for the acquisition device; A first judging module, configured to judge whether the slave address is a first address pre-stored in the host device; A second judgment module, configured to judge whether the slave address is a second address preconfigured in the host device if the slave address is not the first address; A collection module is used for collecting data from the collection device based on the slave address if the slave address is the second address.

15. A data acquisition system, characterized in that: include: Host device; at least one acquisition device, the acquisition device communicating with the host device via a bus; a memory configured to store instructions; as well as A processor is configured to call the instructions from the memory and implement the data collection method according to any one of claims 1 to 13 when executing the instructions.

16. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions, which, when executed by a processor, enable the processor to be configured to execute the data collection method according to any one of claims 1 to 13.