CN110505596B - Sensor data self-adaptive acquisition real-time reporting method - Google Patents

Sensor data self-adaptive acquisition real-time reporting method Download PDF

Info

Publication number
CN110505596B
CN110505596B CN201910659815.3A CN201910659815A CN110505596B CN 110505596 B CN110505596 B CN 110505596B CN 201910659815 A CN201910659815 A CN 201910659815A CN 110505596 B CN110505596 B CN 110505596B
Authority
CN
China
Prior art keywords
sensor
sensors
sampling
acquisition
internet
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910659815.3A
Other languages
Chinese (zh)
Other versions
CN110505596A (en
Inventor
孙菲艳
张燕
王娜
汪辰
闵建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinling Institute of Technology
Original Assignee
Jinling Institute of Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinling Institute of Technology filed Critical Jinling Institute of Technology
Priority to CN201910659815.3A priority Critical patent/CN110505596B/en
Publication of CN110505596A publication Critical patent/CN110505596A/en
Application granted granted Critical
Publication of CN110505596B publication Critical patent/CN110505596B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/30Services specially adapted for particular environments, situations or purposes
    • H04W4/38Services specially adapted for particular environments, situations or purposes for collecting sensor information

Abstract

The invention discloses a sensor data self-adaptive acquisition real-time reporting method, which comprises the following steps: initializing a sampling thread, and judging whether the number of sensors accessed in the Internet of things system is less than or equal to a preset number threshold; if yes, judging whether the number of the sensors is 0 or not; if not, initializing sampling sleep time according to the number of the sensors, wherein the sampling sleep time is the time interval between every two sensor value acquisition; the sampling thread circularly traverses the value of the sensor by taking the sampling sleep time as a time interval to obtain a collection value; and when the preset reporting period comes, the periodic reporting thread preprocesses the two or more acquisition values, calculates an acquisition average value, encodes the acquisition average value and reports the encoded acquisition average value to the server. Compared with the prior art, the method can be used for realizing data acquisition in different application scenes of the Internet of things, and has the characteristics of self-adaptability, real-time performance, high stability and the like.

Description

Sensor data self-adaptive acquisition real-time reporting method
Technical Field
The invention relates to the field of Internet of things, in particular to a sensor data self-adaptive acquisition real-time reporting method.
Background
In the data acquisition process of the internet of things system, if the gateway acquires the sensors for a certain number of times in a reporting period, when the number of times of acquisition is small, for example, when the sensors are acquired for one time in a reporting period, along with the increase of the number of the sensors, the phenomenon that some sensors in a reporting period are not acquired may occur, then the data received by the server cannot accurately reflect the states of all sensors accessed in the current internet of things system, and therefore, the integrity of the data acquired by all accessed sensor equipment by the gateway is ensured to be necessary. Further, if the gateway only collects the sensors once in a reporting period, the accuracy of the data received by the server is not high enough due to accidental errors of the sensors, and therefore, each sensor needs to be collected for multiple times to achieve the deburring effect. Furthermore, if the gateway collects too many times to the sensor in a reporting period, the operation to the sensor is too frequent, so that the sensor is more easily damaged, the service life of the sensor is shortened, and the working efficiency of the gateway of the internet of things is reduced.
In addition, in the data reporting process of the internet of things system, if the internet of things gateway reports data with delay and unstable reporting period, the data stored at the server end is irregular, and the later data processing and data analysis are affected. Therefore, on the premise of ensuring the integrity and accuracy of data acquired by the access sensor equipment, the realization of the real-time property of reported data is very important for the internet of things system.
Disclosure of Invention
The invention provides a sensor data self-adaptive acquisition real-time reporting method, which aims to solve the problem that the work efficiency of an Internet of things gateway is low due to the fact that the data stored at a server end is irregular, such as unstable period, the acquisition values of some sensors are missing, data burrs are serious and the like, which affect the data processing and data analysis at the later stage due to the fact that the existing Internet of things gateway can generate time delay, unstable reporting period and other factors when reporting data.
The embodiment of the invention provides a sensor data self-adaptive acquisition real-time reporting method, which comprises the following steps:
step 1, initializing a sampling thread, and judging whether the number of sensors accessed in an Internet of things system is less than or equal to a preset number threshold of the sensors accessible in the Internet of things system;
step 2, if the number of the sensors is smaller than or equal to a preset number threshold, judging whether the number of the sensors is 0;
step 3, if the number of the sensors is not 0, initializing sampling sleep time according to the number of the sensors, wherein the sampling sleep time is the time interval between the acquisition of the sensor values every two times;
step 4, circularly traversing the value of the sensor by a sampling thread to obtain a collected value;
and 5, preprocessing the two or more acquisition values of each sensor by the periodic reporting thread when a preset reporting period comes, calculating an acquisition average value of each sensor, coding the acquisition average value, and reporting to the server.
Further, the step 1 comprises:
the preset number threshold of the sensors which can be accessed to the Internet of things system is as follows:
Figure BDA0002138130800000021
the method comprises the following steps that Nmax is a preset number threshold of sensors which can be accessed to the Internet of things system, Tperiod is a preset reporting period, Cmin is the minimum acquisition frequency of each sensor in one preset reporting period, the minimum acquisition frequency Cmin is greater than or equal to 2, and Ttranaction is the minimum time required for acquiring the value of the sensor once;
in a preset reporting period, the acquisition frequency of the value of each sensor at least reaches the minimum acquisition frequency Cmin, namely:
Figure BDA0002138130800000022
and N is the number of sensors accessing the Internet of things system.
Further, the sampling sleep time in step 4 is defined as:
Figure BDA0002138130800000023
wherein, Tsleep is the sampling sleep time, and Cmax is the maximum collection frequency of each sensor in a preset reporting period.
Further, when the sampling sleep time Tsleep is 0, the sampling thread calls sched _ yield () to voluntarily abandon the CPU.
Further, the step 4 includes: and circularly acquiring the value of each sensor by the sampling thread, and temporarily storing the value of each sensor in the data buffer area.
Further, in the step 5, the collected values of the sensor in two or more times in a preset reporting period are preprocessed, and the preprocessing includes deburring.
Further, the step 1 comprises:
and if the number of the sensors accessed in the Internet of things system is larger than the preset number threshold of the sensors accessible in the Internet of things system, the sampling thread gives an alarm and exits.
Further, the step 2 comprises:
and if the number of the sensors accessed in the Internet of things system is 0, the sampling thread exits.
According to the technical scheme, the embodiment of the invention provides a sensor data self-adaptive acquisition real-time reporting method. The method comprises the following steps: step 1, initializing a sampling thread, and judging whether the number of sensors accessed in an Internet of things system is less than or equal to a preset number threshold of the sensors accessible in the Internet of things system; step 2, if the number of the sensors is smaller than or equal to a preset number threshold, judging whether the number of the sensors is 0; step 3, if the number of the sensors is not 0, initializing sampling sleep time according to the number of the sensors, wherein the sampling sleep time is the time interval between the acquisition of the sensor values every two times; step 4, the sampling thread circularly acquires the value of the sensor by taking the sampling sleep time as a time interval to obtain an acquisition value; and 5, preprocessing the two or more acquisition values of each sensor by the periodic reporting thread when a preset reporting period comes, calculating an acquisition average value of each sensor, coding the acquisition average value, and reporting to the server.
When the existing internet of things gateway reports data, factors such as time delay and unstable reporting period can occur, which causes the data stored at the server end to be irregular, such as unstable period, missing of the acquisition values of some sensors, serious data burrs and the like, and influences the data processing and data analysis at the later stage, thereby causing the problem of low working efficiency of the internet of things gateway.
By adopting the method, the following beneficial effects can be achieved:
(1) the invention independently opens a sampling task and a periodic reporting task, and the sampling task acquires data according to a certain period; the periodic reporting is carried out according to a fixed period, so that the stability of the period and the real-time performance of the reporting can be ensured, and the periodic reporting is not influenced by uncertain time such as the delay of a sampling task.
(2) The invention can ensure that all the values of the accessed sensors are reported in one reporting period. The integrity of the reported data in a reporting period is ensured by requiring the number of the accessed sensors to be within a theoretical value range and ensuring that the values of all the sensors are collected at least twice in the reporting period.
(3) The invention sets the sleep time between two times of sampling to dynamically change along with the change of the number of the access sensors, thereby not only meeting the requirement that all accessed sensor equipment can be collected in a reporting period, but also enabling the gateway to access the sensors as much as possible, and simultaneously avoiding the large loss of the sensors caused by frequent operation of the sensors.
(4) The invention temporarily stores the acquired value of the sensor obtained by sampling in the data buffer area and provides next access for use, so that the subsequent reporting thread can use the sensor data more quickly, and the reporting instantaneity is improved.
(5) According to the invention, the deburring processing is carried out on the sampled data before the data is reported, the reporting period is ensured to be stable, and the method has obvious benefits on the analysis of the big data in the later period.
Therefore, the sensor data self-adaptive acquisition real-time reporting method provided by the invention can ensure the integrity of sampling all accessed sensors by the gateway of the Internet of things, realizes the effect of deburring the sampled data, can avoid the phenomenon that the sensors are operated too frequently, achieves the effect of protecting the service life of the sensors, can realize the real-time reporting of the data, and further improves the working efficiency of the gateway of the Internet of things.
Drawings
In order to more clearly illustrate the technical solution of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious to those skilled in the art that other drawings can be obtained according to the drawings without any inventive exercise.
Fig. 1 is a schematic structural diagram of a system of a method for adaptively acquiring and reporting sensor data in real time according to an embodiment of the present invention;
fig. 2 is a schematic view of a workflow of a sampling thread in a method for adaptively acquiring and reporting sensor data in real time according to an embodiment of the present invention;
fig. 3 is a schematic view of a workflow of a reporting thread in a method for reporting sensor data in a self-adaptive manner according to an embodiment of the present invention;
fig. 4 is a schematic view of a working flow of a sampling algorithm in a method for adaptively acquiring and reporting sensor data in real time according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
The embodiment of the invention discloses a sensor data self-adaptive acquisition real-time reporting method, which is applied to an Internet of things gateway system, is used as a data transmission method of a sensing network and a traditional communication network, and plays a role in data transmission, wherein the sensing network refers to various sensor devices such as a temperature sensor, a PH value sensor, a wind speed sensor and the like in working scenes such as industrial and agricultural production and the like; whereas conventional communication networks refer to some application servers in the internet. Fig. 1 is a schematic diagram of a system structure of a method for adaptively acquiring and reporting sensor data in real time according to an embodiment of the present invention.
In this embodiment, the gateway of the internet of things performs adaptive acquisition and real-time reporting on sensor data by two threads, namely a sampling thread and a reporting thread, wherein the sampling thread is mainly responsible for circularly acquiring data of the sensor, and the reporting thread is mainly responsible for regularly reporting an average value of the sensor data to the server.
The method comprises the following steps: step 1, initializing a sampling thread, judging whether the number of sensors accessed in an Internet of things system is less than or equal to a preset number threshold of the sensors accessible to the Internet of things system, if so, executing step 2, and if not, alarming and exiting the sampling thread;
step 2, if the number of the sensors is smaller than or equal to a preset number threshold, judging whether the number of the sensors is 0;
step 3, if the number of the sensors is not 0, initializing sampling sleep time according to the number of the sensors, wherein the sampling sleep time is the time interval between the acquisition of the sensor values every two times;
specifically, in this step, if the number of sensors is less than the number of sensors
Figure BDA0002138130800000051
Then order
Figure BDA0002138130800000052
Figure BDA0002138130800000053
If it is
Figure BDA0002138130800000054
Let Tsleep be 0.
The method comprises the steps that N is the number of sensors which are accessed to an Internet of things system, Nmax is a preset number threshold of the sensors which are accessed to the Internet of things system, Tperiod is a preset reporting period, Cmin is the minimum acquisition time of each sensor in the preset reporting period, the minimum acquisition time Cmin is greater than or equal to 2, Cmax is the maximum acquisition time of each sensor in the preset reporting period, Ttransaction is the shortest time required for acquiring the value of each sensor once, and Tsleep is sampling sleep time.
And 4, circularly acquiring the value of the sensor by the sampling thread by taking the sampling sleep time as a time interval to obtain an acquisition value.
In this step, if the sampling sleep time is equal to 0, the value of the next sensor is collected immediately; and if the sampling sleep time is not equal to 0, acquiring the value of the next sensor after the sleep time of the sensor reaches the sampling sleep time. Specifically, the system comprises a plurality of sensors, the value of one sensor is acquired each time, then the value of the next sensor is acquired, and after the acquisition is finished, the acquisition for the second time is carried out.
In this embodiment, in order to perform debounce on sampling data, a sampling thread performs multiple sampling on a sensor within a preset reporting period, as shown in fig. 2, which is a schematic diagram of a workflow of the sampling thread in the method for adaptively acquiring and reporting sensor data in real time provided in the embodiment of the present invention, and the specific implementation is as follows:
judging whether the number of the sensors accessed in the system is larger than a preset number threshold Nmax of the sensors which can be accessed in the Internet of things system;
if the number of the sensors connected into the system is larger than a preset number threshold Nmax, alarming, and exiting the sampling thread abnormally;
if the number of the sensors accessed in the system is less than or equal to a preset number threshold Nmax, judging whether the number of the sensors in the system is 0;
if the number of the sensors in the system is 0, normally terminating the sampling thread;
if the number of sensors in the system is not 0, initializing the sampling sleep time Tsleep between two consecutive samplings according to the number N of sensors, which is as follows:
the real-time reporting of the gateway of the Internet of things meets the following formula, which corresponds to the attached figure 4:
Tperiod=C*N*(Ttransaction+Tsleep) (1.1)
as shown in fig. 4, a sampling period T1, C represents the number of acquisition times in the preset reporting period, N represents the number of sensors accessing the internet of things system, and Tsleep represents the sampling sleep time. Where Ttransaction represents the minimum time it takes to acquire the sensor value once, including Tdata and Tmute for the 485 bus, as described by:
Ttransaction=Tdata+Tmute
wherein, Tdata refers to the time spent on collecting data of a sensor, and the specific subdivision logic includes:
write (…); select (…, T-timeout); read (…); tdata does not evolve in the actual formula derivation.
Tmute refers to a quiet time, the Modbus is shared, and a quiet time Tmute needs to be maintained on the bus between two read operations to avoid interference, the sleep operation being performed immediately after the bus operation.
In this embodiment, the quiet time Tmute is a fixed value obtained empirically, and normal operation of the Modbus bus can be ensured through the sleep operation.
As for the formula (1.1), in the actual operation, the preset reporting period Tperiod is determined by the requirement, and the shortest time Ttransaction required to collect the value of the sensor once is determined by the hardware performance, wherein the variable parameters are the collection times C, the number N of sensors, and the sampling sleep time Tsleep in one preset reporting period.
And when the number N of the sensors is smaller, the maximum acquisition times Cmax of each sensor in a preset reporting period is guaranteed to be processed.
For the acquisition times C in a preset reporting period, a method of acquiring sensor data once and reporting the sensor data once is not adopted, but a method of acquiring data for multiple times before reporting once is adopted, and the main purpose is to remove burrs, and it is one of the requirements that the sensor is sampled for multiple times before reporting once. However, the number of times of sampling for multiple times is limited, and in the present invention, the maximum number of times of sampling Cmax for each sensor in a preset reporting period is recorded, and in the case that the conditions allow, in the present invention, it is desirable to sample Cmax for multiple times in a preset reporting period. In the case of ensuring that C is Cmax, the time to sample the sleep time Tsleep decreases as the number N of devices increases, as follows:
Figure BDA0002138130800000071
when the sampling sleep time Tsleep is decreased to the limit, that is, 0, the number N of sensors accessing the internet of things system has a limit value that satisfies the maximum acquisition time Cmax for each sensor in a preset reporting period, which is denoted as Nmid (Tperiod/(Cmax) Ttransaction), so that when the number N of sensors accessing the internet of things system is smaller, the following relationship is obtained:
Figure BDA0002138130800000072
when the number N of the sensors accessed to the Internet of things system is large, the acquisition times C are changed along with the change of the number N of the sensors accessed to the Internet of things system.
If the number N of sensors accessing the internet of things system is to be supported more, the sampling sleep time Tsleep is fixed to 0 in formula (1.1), and when the number N of sensors accessing the internet of things system becomes large, it is not necessary to insert the sampling sleep time Tsleep between the minimum time Ttransaction taken to acquire the value of the sensor once each time, and then formula (1.1) is simplified to obtain:
tperiod N Ttransmission, which yields, after deformation:
Figure BDA0002138130800000081
the formula (1.4) shows that as the number N of sensors accessing the internet of things system continues to increase, the acquisition time C is necessarily reduced, and the acquisition time C may be a decimal, which indicates that the algorithm in the present invention does not require that the sampling period in a preset reporting period Tperiod is an integer, and the actual meaning is that the number of times each sensor is allowed to be accessed in a preset reporting period is different in the present invention. But the number of acquisition times C may not be less than 1, otherwise it means that a sensor is not accessed in a preset reporting period, which is not allowed. At present, in order to remove burrs, the minimum acquisition time C specified and supported in the present invention is recorded as the maximum acquisition time Cmin of each sensor in a preset reporting period being 2, and the corresponding Nmax is the maximum number of sensors that can be supported by the system in the present invention:
Figure BDA0002138130800000082
in actual development, after the preset reporting period Tperiod is known, the minimum time Ttransaction required for acquiring the value of the sensor once, the maximum acquisition time Cmax for each sensor in one preset reporting period, and the acquisition time of each sensor in one preset reporting period at least reach the minimum acquisition time Cmin, the number N of sensors to be accessed to the internet of things system obtained by the invention can be more, and the sampling sleep time Tsleep at this time satisfies the following formula:
Figure BDA0002138130800000083
in summary, the sampled sleep time Tsleep is as follows:
Figure BDA0002138130800000084
the time Tdata and the silent time Tcut for acquiring the data of the primary sensor in a preset reporting period Tperiod, the minimum time Ttransmission required for acquiring the value of the primary sensor, the maximum acquisition frequency Cmax of each sensor in the preset reporting period, and the acquisition frequency of each sensor in the preset reporting period at least reach the minimum acquisition frequency Cmin can be configured, and are usually set as experience values obtained through testing.
Because the sampling thread always occupies the CPU when the sampling sleep time Tsleep is 0, and a certain delay is caused to the periodic reporting and the communication response, when the sampling sleep time Tsleep is 0, the sampling thread calls the sched _ yield () to actively abandon the CPU, so that other threads have a chance to be scheduled in time.
After the sampling sleep time Tsleep is initialized, values of the sensors are collected in a circulating manner, sequential sampling is carried out, the value of each sensor obtained through sampling, namely the collected value, is temporarily stored in a data buffer area and is used for next access, so that the sensor data can be used more quickly by a subsequent reporting thread, the reporting instantaneity is improved, the collected value of the sensor refers to data obtained by reading the sensor, for example, the temperature obtained by reading the temperature sensor once is 28.3 ℃, and the collected value of the temperature sensor this time is 28.3. And after sampling one sensor, judging whether the sampling sleep time Tsleep is 0, and if the sampling sleep time Tsleep is not 0, enabling the sampling thread to perform the acquisition of the next sensor again at the time of sleeping Tsleep. And if the sampling sleep time Tsleep is 0, the sampling thread directly performs the acquisition of the next sensor without sleeping.
Fig. 3 is a schematic diagram of a workflow of a reporting thread in a method for reporting sensor data in a self-adaptive manner according to an embodiment of the present invention.
And 5, preprocessing the two or more acquisition values of each sensor by the periodic reporting thread when a preset reporting period comes, calculating an acquisition average value of each sensor, coding the acquisition average value, and reporting to the server. In this step, the two or more acquisition values refer to two or more acquisition values of the sensor, and the sensor is a sensor in a preset reporting period.
In the method for adaptively acquiring and reporting sensor data in real time according to this embodiment, the step 1 includes:
the preset number threshold of the sensors which can be accessed into the Internet of things system is as follows:
Figure BDA0002138130800000091
the method comprises the following steps that Nmax is a preset number threshold of sensors which can be accessed to an Internet of things system, Tperiod is a preset reporting period, Cmin is the minimum acquisition frequency of each sensor in one preset reporting period, the minimum acquisition frequency Cmin is greater than or equal to 2, and Ttranaction is the minimum time required for acquiring the value of the sensor once;
in a preset reporting period, the acquisition frequency of the value of each sensor at least reaches the minimum acquisition frequency Cmin, namely:
Figure BDA0002138130800000092
and N is the number of sensors accessing the Internet of things system. In this embodiment, the minimum acquisition time Cmin for each sensor in a preset reporting period takes a value of 2.
In the method for adaptively acquiring and reporting sensor data in real time according to this embodiment, the sleep time for sampling in step 4 is defined as:
Figure BDA0002138130800000101
wherein, Tsleep is the sampling sleep time, and Cmax is the maximum collection frequency of each sensor in a preset reporting period. In this embodiment, the minimum acquisition time Cmin for each sensor in a preset reporting period is 2, and the maximum acquisition time Cmax for each sensor in a preset reporting period is 5.
In the method for adaptively acquiring and reporting sensor data in real time according to this embodiment, when the sampling sleep time Tsleep is 0, the sampling thread always occupies the CPU, and a certain delay is caused to periodic reporting and communication response, so that when the sampling sleep time Tsleep is 0, the sampling thread calls sched _ yield () to actively abandon the CPU, so that other threads have a chance to be scheduled in time.
In the method for adaptively acquiring and reporting sensor data in real time of this embodiment, step 4 includes: and circularly acquiring the value of each sensor by the sampling thread, and temporarily storing the acquired value of each sensor in the data buffer area. In this step, the acquisition value of each sensor is temporarily stored in the data buffer area, so that next access can be provided for use, the sensor data can be used more quickly by a subsequent reporting thread, and the real-time performance of data reporting is improved.
In the method for adaptively acquiring and reporting sensor data in real time according to this embodiment, in step 5, two or more acquired values of the sensor within a preset reporting period are preprocessed, where the preprocessing includes deburring.
In this step, the deburring, that is, filtering the abnormal value, means that a maximum value and a minimum value within a normal working range of the sensor are defined according to experience in combination with the current environment, time and season, if the acquired value is determined to be within a predetermined normal range, the acquired value of this time is retained, and if the acquired value is not within the range, the acquired value of this time is not retained. For example, the water temperature range of the predetermined summer Nanjing aquaculture area is (6-45 ℃), the data reported to the remote server is kept within the normal range (6-45) after the data is preprocessed, and obvious abnormal values are filtered out.
In this embodiment of the method for adaptively acquiring and reporting sensor data in real time, the step 1 includes: and if the number of the sensors accessed in the Internet of things system is larger than the preset number threshold of the sensors accessible in the Internet of things system, the sampling thread gives an alarm and exits.
In this step, the sampling thread alarms and exits as abnormal exits, and specifically, alarms may be given by printing alarm information.
In the method for adaptively acquiring and reporting sensor data in real time according to this embodiment, the step 2 includes: and if the number of the sensors accessed in the Internet of things system is 0, the sampling thread exits.
In this step, the sampling thread exit is a normal exit.
When the existing internet of things gateway reports data, factors such as time delay and unstable reporting period can occur, which causes the data stored at the server end to be irregular, such as unstable period, missing sampling values of some sensors, serious data burrs and the like, and influences data processing and data analysis at the later stage, thereby causing the problem of low working efficiency of the internet of things gateway.
By adopting the method, the following beneficial effects can be achieved:
(1) the invention independently opens a sampling task and a periodic reporting task, and the sampling task acquires data according to a certain period; the periodic reporting is carried out according to a fixed period, so that the stability of the period and the real-time property of the reporting can be ensured, and the periodic reporting is not influenced by uncertain time such as the delay of a sampling task and the like
(2) The invention can ensure that all the acquisition values of all the accessed sensors are reported in one reporting period. The number of the accessed sensors is required to be within a theoretical value range, and the condition that all the sensors are collected at least twice in one reporting period is ensured, so that the integrity of the reported data in one reporting period is ensured.
(3) The invention sets the sleep time between two times of sampling to dynamically change along with the change of the number of the access sensors, thereby not only meeting the requirement that all the accessed devices can be acquired in a reporting period, but also enabling the gateway to access the sensors as much as possible, and simultaneously avoiding the large loss of the sensors caused by frequent operation of the sensors.
(4) The invention temporarily stores the sampled sensor value in the data buffer area and provides next access for use, so that the sensor data can be used more quickly by the subsequent reporting thread, and the reporting instantaneity is improved.
(5) According to the invention, the deburring processing is carried out on the sampled data before the data is reported, the reporting period is ensured to be stable, and the method has obvious benefits on the analysis of the big data in the later period.
Therefore, the sensor data self-adaptive acquisition real-time reporting method provided by the invention can ensure the integrity of sampling all accessed sensors by the gateway of the Internet of things, realizes the effect of deburring the sampled data, can avoid the phenomenon that the sensors are operated too frequently, achieves the effect of protecting the service life of the sensors, can realize the real-time reporting of the data, and further improves the working efficiency of the gateway of the Internet of things.
In a specific implementation, the present invention further provides a computer storage medium, where the computer storage medium may store a program, and the program may include some or all of the steps in each embodiment of the method for adaptively acquiring and reporting sensor data in real time provided by the present invention when executed. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM).
Those skilled in the art will readily appreciate that the techniques of the embodiments of the present invention may be implemented as software plus a required general purpose hardware platform. Based on such understanding, the technical solutions in the embodiments of the present invention may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments.
The same and similar parts in the various embodiments in this specification may be referred to each other. The above-described embodiments of the present invention should not be construed as limiting the scope of the present invention.

Claims (6)

1. A sensor data self-adaptive acquisition real-time reporting method is characterized by comprising the following steps:
step 1, initializing a sampling thread, and judging whether the number of sensors accessed in an Internet of things system is less than or equal to a preset number threshold of the sensors accessible in the Internet of things system;
step 2, if the number of the sensors is smaller than or equal to a preset number threshold, judging whether the number of the sensors is 0;
step 3, if the number of the sensors is not 0, initializing sampling sleep time according to the number of the sensors, wherein the sampling sleep time is the time interval between the acquisition of the sensor values every two times;
step 4, the sampling thread circularly acquires the value of the sensor by taking the sampling sleep time as a time interval to obtain an acquisition value;
step 5, when a preset reporting period comes, the periodic reporting thread preprocesses the two or more acquisition values of each sensor, calculates the acquisition average value of each sensor, codes the acquisition average value and reports the acquisition average value to a server;
the step 1 comprises the following steps:
the preset number threshold of the sensors which can be accessed to the Internet of things system is as follows:
Figure FDA0003474153340000011
the method comprises the following steps that Nmax is a preset number threshold of sensors which can be accessed to the Internet of things system, Tperiod is a preset reporting period, Cmin is the minimum acquisition frequency of each sensor in one preset reporting period, the minimum acquisition frequency Cmin is greater than or equal to 2, and Ttranaction is the minimum time required for acquiring the value of the sensor once;
in a preset reporting period, the acquisition frequency of the value of each sensor at least reaches the minimum acquisition frequency Cmin, namely:
Figure FDA0003474153340000012
wherein N is the number of sensors accessing the Internet of things system;
the sampling sleep time in the step 4 is defined as:
Figure FDA0003474153340000021
wherein, Tsleep is the sampling sleep time, and Cmax is the maximum collection frequency of each sensor in a preset reporting period.
2. The method as claimed in claim 1, wherein when the sampling sleep time Tsleep is 0, the sampling thread calls sched _ yield () to voluntarily give up the CPU.
3. The method according to claim 1, wherein the step 4 comprises: and circularly acquiring the value of each sensor by the sampling thread, and temporarily storing the acquired value of each sensor in the data buffer area.
4. The method as claimed in claim 1, wherein in step 5, two or more collected values of the sensor within a preset reporting period are preprocessed, and the preprocessing includes deburring.
5. The method according to claim 1, wherein the step 1 comprises:
and if the number of the sensors accessed in the Internet of things system is larger than the preset number threshold of the sensors accessible in the Internet of things system, the sampling thread gives an alarm and exits.
6. The method according to claim 1, wherein the step 2 comprises:
and if the number of the sensors accessed in the Internet of things system is 0, the sampling thread exits.
CN201910659815.3A 2019-07-22 2019-07-22 Sensor data self-adaptive acquisition real-time reporting method Active CN110505596B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910659815.3A CN110505596B (en) 2019-07-22 2019-07-22 Sensor data self-adaptive acquisition real-time reporting method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910659815.3A CN110505596B (en) 2019-07-22 2019-07-22 Sensor data self-adaptive acquisition real-time reporting method

Publications (2)

Publication Number Publication Date
CN110505596A CN110505596A (en) 2019-11-26
CN110505596B true CN110505596B (en) 2022-03-29

Family

ID=68586669

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910659815.3A Active CN110505596B (en) 2019-07-22 2019-07-22 Sensor data self-adaptive acquisition real-time reporting method

Country Status (1)

Country Link
CN (1) CN110505596B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113709591B (en) * 2021-07-15 2023-09-29 国网安徽省电力有限公司超高压分公司 Ad hoc network data transmission method and system for transformer substation radio frequency sensor
CN113959569A (en) * 2021-10-25 2022-01-21 京东方科技集团股份有限公司 Temperature measurement method and device, temperature measurement equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103249127A (en) * 2013-05-22 2013-08-14 清华大学 Energy-saving data transmission method for Internet of things
CN105101277A (en) * 2015-09-01 2015-11-25 中国联合网络通信集团有限公司 Method, device and system for judging abnormalities of monitoring area and sensing node

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5163935B2 (en) * 2007-05-17 2013-03-13 ソニー株式会社 Image sensor
CN101609168B (en) * 2009-07-07 2011-08-03 上海真灼电子技术有限公司 Vehicle detecting system and method based on wireless earth induction
US9077183B2 (en) * 2011-09-06 2015-07-07 Portland State University Distributed low-power wireless monitoring
JP5906295B1 (en) * 2014-09-17 2016-04-20 Kyb株式会社 Displacement sensor inspection apparatus and inspection method thereof
CN108419206A (en) * 2018-02-28 2018-08-17 北京邮电大学 A kind of target homing system and method
CN109919748A (en) * 2019-03-06 2019-06-21 中汇信息技术(上海)有限公司 A kind of data processing method and system based on block chain

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103249127A (en) * 2013-05-22 2013-08-14 清华大学 Energy-saving data transmission method for Internet of things
CN105101277A (en) * 2015-09-01 2015-11-25 中国联合网络通信集团有限公司 Method, device and system for judging abnormalities of monitoring area and sensing node

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Juan Xiao ; Fei Yin.Energy-efficient data collection in WSN-MCN convergence architecture.《IEEE》.2013, *
农田无线传感器网络数据服务器的设计与实现;刘永生等;《农业工程学报》;20090930;全文 *
基于无线传感器网络的信息采集监测系统设计;张杰等;《传感技术学报》;20090620(第06期);全文 *

Also Published As

Publication number Publication date
CN110505596A (en) 2019-11-26

Similar Documents

Publication Publication Date Title
CN110505596B (en) Sensor data self-adaptive acquisition real-time reporting method
EP2490090A1 (en) Wind turbine generator system fault processing method and system
CN111782491B (en) Disk failure prediction method, device, equipment and storage medium
CN105718748A (en) Online monitoring data processing method
CN116108402A (en) Method, equipment and storage medium based on electric power multi-source heterogeneous data fusion analysis
CN116501475B (en) Thread scheduling method, system and medium
CN113123955B (en) Plunger pump abnormity detection method and device, storage medium and electronic equipment
CN110647086B (en) Intelligent operation and maintenance monitoring system based on operation big data analysis
CN116232935B (en) Big data transmission method for monitoring Internet of things
CN112612587A (en) Spark platform dynamic resource allocation method for flow analysis
CN109150819B (en) A kind of attack recognition method and its identifying system
WO2021017280A1 (en) Data processing method and apparatus
CN111563543B (en) Method and device for cleaning wind speed-power data of wind turbine generator
CN106789720B (en) Dynamic token bucket generation method based on system hardware utilization rate
CN115660314A (en) Shadow shielding diagnosis method and device, electronic equipment and storage medium
CN110488772B (en) DCS centralized monitoring method and device and centralized monitoring terminal
CN111866924B (en) Performance index monitoring method and device, computing equipment and computer storage medium
CN111563078A (en) Data quality detection method and device based on time sequence data and storage device
CN113741815B (en) Storage system management and control method, device and equipment and readable storage medium
CN109145824B (en) Stacker current signal denoising method
CN113407409B (en) Node state detection method and device of distributed storage system
CN112130991A (en) Application program control method and system based on machine learning
CN117092526A (en) Training method and device of battery fault early warning model and electronic equipment
CN110727648A (en) High-efficiency data compression method of industrial equipment and data server
CN117134982A (en) Cloud storage server system of intelligent lock

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant