Disclosure of Invention
In view of the above, the present invention provides a data communication method and apparatus to effectively overcome the above-mentioned drawbacks.
The embodiment of the invention is realized by the following modes:
in a first aspect, an embodiment of the present invention provides a data communication method, which is applied to a gateway device in a data communication system, where the data communication system further includes: x terminal devices connected to the gateway device, the X terminal devices including: m terminal devices and N terminal devices, wherein X is an integer greater than or equal to 2, M and N are integers greater than or equal to 1, and M + N is less than or equal to X. The method comprises the following steps: and when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device and the N terminal devices are in a low-power consumption state incapable of carrying out data transmission with the gateway device, acquiring first metering data acquired by each terminal device transmitted by each terminal device in the M terminal devices in the low-power consumption state. And in the process that the M terminal devices are in the low power consumption state and the N terminal devices are in the communication state, second metering data collected by each terminal device in the low power consumption state and transmitted by each terminal device in the N terminal devices are obtained.
Further, the first metering data collected by each terminal device in the M terminal devices in the low power consumption state is obtained. The method comprises the following steps: judging whether the first metering data collected by each terminal device in the M terminal devices in the low power consumption state is acquired or not; and if not, controlling each terminal device in the M terminal devices to retransmit the first metering data of each terminal device within a preset time length, and obtaining the first metering data of each terminal device in the M terminal devices, wherein the preset time length is the time length in the communication state.
Further, the judgment is performed to determine whether to obtain the first metering data, which is transmitted by each terminal device of the M terminal devices and is acquired by each terminal device in the low power consumption state. Further comprising: if not, adding 1 to the total number of transmission failures of each terminal device in the M terminal devices; judging whether the total times of the transmission failures meet threshold times or not; if yes, controlling each terminal device in the M terminal devices to perform fault self-detection; if not, executing the following steps: and controlling each terminal device of the M terminal devices to retransmit the first metering data of each terminal device within a preset time length, and obtaining the first metering data of each terminal device of the M terminal devices, wherein the preset time length is the time length in the communication state.
Further, the controlling of each terminal device of the M terminal devices retransmits the first metering data of each terminal device within a preset time duration is performed after the first metering data of each terminal device of the M terminal devices is obtained. The method further comprises the following steps: and synchronizing the timing time of each terminal device in the M terminal devices with the timing time of the gateway device, so that the preset time length timed to reach by each terminal device in the M terminal devices is kept synchronous with the preset time length timed to reach by the gateway device.
Further, in the process that the M terminal devices are in the low power consumption state and the N terminal devices are in the communication state, second metering data collected by each terminal device in the low power consumption state and transmitted by each terminal device in the N terminal devices is obtained. The method further comprises the following steps: judging whether metering data which is transmitted by any terminal equipment and is collected in the low power consumption state is not obtained or not based on a preset sampling sequence of the X terminal equipments in the gateway equipment; if not, returning to the execution step: and when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device and the N terminal devices are in a low-power consumption state incapable of carrying out data transmission with the gateway device, acquiring first metering data acquired by each terminal device transmitted by each terminal device in the M terminal devices in the low-power consumption state.
Further, the metering data includes, for the corresponding user: water usage data, gas usage data, or electricity usage data.
In a second aspect, an embodiment of the present invention provides a data communication apparatus, which is applied to a gateway device in a data communication system, where the data communication system further includes: x terminal devices connected to the gateway device, the X terminal devices including: m terminal devices and N terminal devices, wherein X is an integer greater than or equal to 2, M and N are integers greater than or equal to 1, and M + N is less than or equal to X. The device comprises: the first acquisition module is used for acquiring first metering data acquired by each terminal device transmitted by each terminal device in the M terminal devices in a low power consumption state when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device and the N terminal devices are in a low power consumption state incapable of carrying out data transmission with the gateway device. And the second acquisition module is used for acquiring second metering data acquired by each terminal device in the low power consumption state transmitted by each terminal device in the N terminal devices in the process that the M terminal devices are in the low power consumption state and the N terminal devices are in the communication state.
Further, the first acquisition module comprises: the first judging unit is configured to judge whether to obtain the first metering data, which is acquired when each terminal device in the M terminal devices is in the low power consumption state, transmitted by each terminal device. And an obtaining unit, configured to control, if the first measurement data is not received, each terminal device of the M terminal devices to retransmit the first measurement data of each terminal device within a preset time duration, and obtain the first measurement data of each terminal device of the M terminal devices, where the preset time duration is a time duration in the communication state.
Further, the first acquisition module further comprises: and a second judging unit, configured to add 1 to the total number of transmission failures of each of the M terminal devices if the number of transmission failures is negative. A third determining unit, configured to determine whether the total number of transmission failures satisfies a threshold number of times. The step executing unit is used for controlling each terminal device in the M terminal devices to carry out fault self-detection when the terminal device is in the positive state; if not, executing the following steps: and controlling each terminal device of the M terminal devices to retransmit the first metering data of each terminal device within a preset time length, and obtaining the first metering data of each terminal device of the M terminal devices, wherein the preset time length is the time length in the communication state.
Further, the first acquisition module further comprises: and the synchronization unit is used for synchronizing the timing time of each terminal device in the M terminal devices with the timing time of the gateway device, so that the preset time length reached by the timing of each terminal device in the M terminal devices and the preset time length reached by the timing of the gateway device are kept synchronous.
The embodiment of the invention has the beneficial effects that:
when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device, and the N terminal devices are in a low-power-consumption state incapable of carrying out data transmission with the gateway device, the gateway device obtains first metering data collected when each terminal device transmitted by each terminal device in the M terminal devices is in the low-power-consumption state. And after carrying out data communication with the M terminal devices, when the M terminal devices are in a low power consumption state and the N terminal devices are in a communication state, the gateway device obtains second metering data collected by each terminal device in the N terminal devices when the terminal devices are in the low power consumption state. Therefore, data acquisition in batches is carried out on the X terminal devices through the gateway device, and the load of the gateway device and the communication interference during acquisition are effectively reduced. In addition, because the terminal equipment which does not carry out data acquisition is in a low power consumption state, the power consumption of the X pieces of terminal equipment during data communication is effectively reduced.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the present invention without making any creative effort, shall fall within the protection scope of the present invention.
First embodiment
Referring to fig. 1, a first embodiment of the present invention provides a data communication system 10, where the data communication system 10 includes: x terminal devices 11, a gateway device 12, and a server 13. The gateway device 12 is connected to the server 13 and the X terminal devices 11, respectively.
In the X terminal devices 11, X is an integer greater than or equal to 2, so the X terminal devices 11 may include: m terminal devices 11 and N terminal devices 11, where M and N are integers greater than or equal to 1, and M + N is less than or equal to X. Further, the M terminal devices 11 and the N terminal devices 11 are connected to the gateway device 12, and form data interaction. In this embodiment, each terminal device 11 in the X terminal devices 11 may be configured to acquire metering data of a corresponding user, where the metering data includes: the data of water consumption, gas consumption or electricity consumption, i.e. each terminal device 11 may be an integrated meter reading device of a water meter, a gas meter and/or an electric meter or may be an independent water meter, gas meter or electric meter.
Gateway device 12 may be a conventional device model in the art. The gateway device 12 is connected to the X terminal devices 11, so as to form data interaction with each terminal device 11 of the X terminal devices 11, and then, the X terminal devices 11 may be subjected to sequential data acquisition in batches.
The server 13 is a data server, a web server, or the like, and the server 13 also forms data interaction with the gateway device 12 by connecting to the gateway device 12. Thus, after the gateway device 12 collects the data, the gateway device 12 may transmit the collected data to the server 13 so that the server 13 stores or displays the data.
Second embodiment
Referring to fig. 2, a second embodiment of the present invention provides a data communication method, which is applied to a gateway device in a data communication system. The data communication method comprises the following steps: step S100 and step S200.
Step S100: and when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device and the N terminal devices are in a low-power consumption state incapable of carrying out data transmission with the gateway device, acquiring first metering data acquired by each terminal device transmitted by each terminal device in the M terminal devices in the low-power consumption state.
When data acquisition is performed on the X terminal devices, the gateway device needs to be networked with the X terminal devices. Specifically, the operator may input device information of X terminal devices into the gateway device. The input mode may be that the device information of the X terminal devices is input to the gateway device through the server, or the input mode may be that the operator directly inputs the device information of the X terminal devices to the gateway device at the installation site of the gateway device. In the input device information of the X terminal devices, the device information of each of the X terminal devices includes: device ID and channel data. In the input process, the operator inputs the device information of each terminal device according to a certain sequence, the gateway device divides the data collected by the X terminal devices into at least two successive batches according to the sequence of obtaining the device information, and then the sequence of the batches is used as the preset sampling sequence. After all the device information of the X terminal devices is sequentially input, the gateway device stores all the device information, so as to configure the X terminal devices. And then the gateway device can establish connection with each terminal device according to the stored information and synchronize the time of each terminal device after connection, so that the time timing of each terminal device can be synchronized with the time timing of the gateway device.
In this embodiment, each of the X terminal devices has two operating states. One working state is a low power consumption state, when the terminal device is in the low power consumption state, the terminal device cannot perform data interaction with the gateway device due to low power consumption, but the terminal device can acquire metering data of a corresponding user when the terminal device is in the low power consumption state. The other working state is a communication state, when the terminal equipment is in the communication state, the power consumption of the state can ensure that the terminal equipment and the gateway equipment perform data interaction, but the terminal equipment can acquire the metering data of the corresponding user when in the low power consumption state.
The switching of the working states of the X terminal devices is corresponding to the batch corresponding to the preset sampling sequence, namely the working states of the terminal devices in at least two batches and only one batch are kept in a communication state, the other batches except the batch are all guaranteed to be in a low power consumption state, and the working states of the terminal devices in each batch are kept synchronous in real time.
In this embodiment, each terminal device of each batch is preset with a preset duration, and the preset duration is a duration in a communication state. In addition, each terminal device of each batch is also preset with a sleep time length, and the sleep time length is the time length in a low power consumption state. Since the time timings of the terminal devices in each batch are kept synchronous with the gateway device, taking the start of the communication state as an example, if the time duration of the time timings of the terminal devices in each batch is equal to the preset time duration, the terminal devices in each batch are synchronously switched from the communication state to the low power consumption state. And then, when the time length of the time timing of each batch of terminal equipment is equal to the dormancy time length, synchronously switching each batch of terminal equipment from the low power consumption state to the communication state, thereby forming a cycle.
And after networking, the gateway equipment can correspondingly sample in batches according to the configured preset sampling sequence and switch according to the working state of each batch of terminal equipment, and then the gateway equipment acquires data of X pieces of terminal equipment in batches.
In two continuous batches of at least two sampling batches, one batch sampled firstly is M terminal devices, one batch sampled later is N terminal devices, and M and N are integers which are more than or equal to 1.
When the sampling of the current batch of terminal equipment is finished and M terminal equipment of the current batch is sampled. It can be understood that, in this state, M terminal devices are in a communication state capable of performing data transmission with the gateway device, and all terminal devices, except for the M terminal devices, of the X terminal devices, including the N terminal devices, are in a low power consumption state incapable of performing data transmission with the gateway device. Further, in the process, based on the transmission of each of the M terminal devices, the gateway device may first determine whether to obtain first metering data, which is acquired when each of the M terminal devices transmits, in the low power consumption state.
And when the judgment result is yes, the characterization gateway device already obtains the first metering data corresponding to each terminal device. And the gateway device can continuously send a plurality of successful feedback information to each terminal device in the M terminal devices. Therefore, each terminal device in the M terminal devices can acquire the success of data transmission when acquiring any feedback information, and further data transmission is not needed.
And if not, characterizing that the gateway equipment does not obtain the first metering data corresponding to each terminal equipment. And then the gateway equipment adds 1 to the total number of transmission failures of each terminal equipment in the M terminal equipment, and judges whether the total number of transmission failures meets the threshold number of times. When the number of times of the threshold is judged to be met, it is indicated that each terminal device in the M terminal devices is in a fault state, and the gateway device controls each terminal device in the M terminal devices to perform fault self-detection, so that each terminal device in the M terminal devices performs device check with the gateway device. When error information is found and corrected in the process of checking the device information, it can be considered that each of the M terminal devices has a fault removed, and each of the M terminal devices is awakened. On the contrary, when no error information is found in the process of checking the equipment information, the fault can be considered as that the fault cannot be eliminated, and then the gateway equipment generates alarm information to the server to inform an operator of overhauling. And when the judgment result shows that the number of times does not meet the threshold value, controlling each terminal device in the M terminal devices to retransmit the first metering data of each terminal device within a preset time length. Further, when each of the M terminal devices is not faulty, the gateway device may obtain the first metering data of each of the M terminal devices.
It should be noted that, each time the first metering data is not received, the gateway device may execute the unreceived determination process. When the synchronous timing duration of each of the M terminal devices and the gateway device reaches the preset duration, no matter whether the gateway device receives the first metering data, each of the M terminal devices is switched from the communication state to the low power consumption state, and the gateway device correspondingly obtains the data of the next batch, i.e., N terminal devices, according to the preset sampling sequence.
As another implementation manner of this embodiment, after each terminal device in the M terminal devices sends the corresponding first metering data, each terminal device may determine whether to obtain any one of the plurality of successful feedback information fed back by the gateway device. And when the judgment result is yes, each terminal device acquires that the transmission is successful. And then each terminal device in the M terminal devices switches the state after the preset time length. And if the judgment result is negative, that is, each terminal device in the M terminal devices does not obtain any successful feedback information after waiting for a certain time, each terminal device knows that the transmission fails. And each of the M terminal devices adds 1 to the total number of failures, and judges whether the total number of failures meets the threshold number set by each of the M terminal devices. And if so, interacting each terminal device in the M terminal devices with the gateway device to execute fault self-detection. And if not, each terminal device in the M terminal devices retransmits the corresponding first metering data to the gateway device. And if the transmission of each terminal device in the M terminal devices is failed repeatedly all the time and the total failure times of each terminal device in the M terminal devices do not meet the threshold times, each terminal device in the M terminal devices is directly switched to the low-power-consumption state when the timing duration reaches the preset duration.
Step S200: and in the process that the M terminal devices are in the low power consumption state and the N terminal devices are in the communication state, second metering data collected by each terminal device in the low power consumption state and transmitted by each terminal device in the N terminal devices are obtained.
When the acquisition of the last batch of M terminal devices is finished, all the other terminal devices including the M terminal devices are in the corresponding low power consumption states except the N terminal devices in the X terminal devices, and further, the N terminal devices in the current batch are correspondingly switched from the low power consumption states and are in the communication states.
It can be understood that the gateway device obtains the second metering data corresponding to each of the N terminal devices in the same manner as in step S100, and a detailed description thereof is omitted here.
In addition, after the data acquisition is carried out on the N terminal devices, the gateway device can judge whether the sampling of the X terminal devices is completed according to a preset sampling sequence. If not, continuing to sample the next one, and if so, sampling each terminal device of the initial batch in the preset sampling sequence according to the preset sampling sequence, thereby forming a cycle.
Third embodiment
Referring to fig. 3, a third embodiment of the present invention provides a data communication apparatus 100, which is applied to a gateway device in a data communication system, wherein the data communication apparatus 100 includes:
a first collecting module 110, configured to obtain, when the M terminal devices are in a communication state capable of performing data transmission with the gateway device and the N terminal devices are in a low power consumption state incapable of performing data transmission with the gateway device, first metering data collected when each terminal device transmitted by each terminal device in the M terminal devices is in the low power consumption state;
a second collecting module 120, configured to obtain second metering data, which is collected when each terminal device of the N terminal devices is in the low power consumption state, and each terminal device of the M terminal devices is in the communication state.
Referring to fig. 4, in a data communication apparatus 100 according to a third embodiment of the present invention, a first collecting module 110 includes:
a first determining unit 111, configured to determine whether to obtain the first metering data, which is transmitted by each terminal device of the M terminal devices and is acquired by the each terminal device in the low power consumption state.
A second determining unit 112, configured to add 1 to the total number of transmission failures of each of the M terminal devices if the number is no.
A third determining unit 113, configured to determine whether the total number of transmission failures satisfies a threshold number.
A step executing unit 114, configured to control each terminal device of the M terminal devices to perform fault self-detection if the terminal device is a failed terminal device; if not, executing the following steps: and controlling each terminal device of the M terminal devices to retransmit the first metering data of each terminal device within a preset time length, and obtaining the first metering data of each terminal device of the M terminal devices, wherein the preset time length is the time length in the communication state.
An obtaining unit 115, configured to, if the time length is negative, control each terminal device of the M terminal devices to retransmit the first metering data of each terminal device within a preset time length, and obtain the first metering data of each terminal device of the M terminal devices, where the preset time length is a time length in the communication state.
A synchronizing unit 116, configured to synchronize a timing time of each terminal device of the M terminal devices with a timing time of the gateway device, so that the preset time length that each terminal device of the M terminal devices reaches in timing is kept synchronized with the preset time length that the gateway device reaches in timing.
It should be noted that, as those skilled in the art can clearly understand, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The computer program product of the computer-readable storage medium for performing the processor-executable nonvolatile program code according to the embodiment of the present invention includes a computer-readable storage medium storing the program code, where instructions included in the program code may be used to execute the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment, and is not described herein again.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In summary, embodiments of the present invention provide a data communication method and apparatus, which are applied to a gateway device in a data communication system, where the data communication system further includes: x terminal equipment who is connected with gateway device, X terminal equipment includes: m terminal devices and N terminal devices, wherein X is an integer greater than or equal to 2, M and N are integers greater than or equal to 1, and M + N is less than or equal to X. The method comprises the following steps: when the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device and the N terminal devices are in a low-power-consumption state incapable of carrying out data transmission with the gateway device, first metering data collected when each terminal device transmitted by each terminal device in the M terminal devices is in the low-power-consumption state are obtained. And in the process that the M terminal devices are in the low power consumption state and the N terminal devices are in the communication state, second metering data collected when each terminal device in the N terminal devices is in the low power consumption state is acquired, wherein the second metering data are transmitted by each terminal device in the N terminal devices.
When the M terminal devices are in a communication state capable of carrying out data transmission with the gateway device, and the N terminal devices are in a low-power-consumption state incapable of carrying out data transmission with the gateway device, the gateway device obtains first metering data collected when each terminal device transmitted by each terminal device in the M terminal devices is in the low-power-consumption state. And after carrying out data communication with the M terminal devices, when the M terminal devices are in a low power consumption state and the N terminal devices are in a communication state, the gateway device obtains second metering data collected by each terminal device in the N terminal devices when the terminal devices are in the low power consumption state. Therefore, data acquisition in batches is carried out on the X terminal devices through the gateway device, and the load of the gateway device and the communication interference during acquisition are effectively reduced. In addition, because the terminal equipment which does not carry out data acquisition is in a low power consumption state, the power consumption of the X pieces of terminal equipment during data communication is effectively reduced.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.