Summary of the invention
The purpose of the embodiment of the present invention is that providing one kind can improve in order to overcome drawbacks described above existing in the prior art
The case where system crash is led to as resource overload and as data be transmitted across it is slow caused by system resource cannot abundant benefit
The case where with user experience effect is reduced.
To achieve the goals above, first aspect of the embodiment of the present invention provides a kind of environmental quality detection device, the environment
Quality detection apparatus includes:
Detection module, for detecting environmental quality index;
Receiving module, for receiving the gateway system resource utilization S of network locating for the environmental quality detection device;
Threshold setting module, for data sending threshold value Ve to be arranged according to the gateway system resource utilization S;And
Data transmission blocks, for before and after the detection module detects the difference of environmental quality index twice it is exhausted
When being greater than the data sending threshold value Ve to value, the environmental quality index of time detection after transmission.
Preferably, the threshold setting module increases the data in the gateway system resource utilization S > 70%
Sending threshold value Ve;
In gateway system resource utilization S >=30% and≤70%, the data sending threshold value Ve is not carried out
Adjustment;And
In the gateway system resource utilization S < 30%, reduce the data sending threshold value Ve.
Preferably, the threshold setting module is one or more of for performing the following operations:
In the gateway system resource utilization S > 90%, the data sending threshold value Ve=V is set0+α×β×
(S-0.5);
In gateway system resource utilization S > 70% and≤90%, the data sending threshold value Ve=V is set0+
β×(S-0.5);
In gateway system resource utilization S >=30% and≤70%, it is V that the data sending threshold value, which is arranged,0;With
And
In the gateway system resource utilization S < 30%, the data sending threshold value Ve=V is set0-β×(0.5-
S);
Wherein, α is the coefficient greater than 1, and β is weighting coefficient, and the value range of β is 0~2, V0Threshold is sent for primary data
Value.
Preferably, the gateway system resource utilization S is gateway system resource utilization S flat within a setting period
Mean value.
Second aspect of the embodiment of the present invention provides a kind of data transmission method of environmental quality detection device, the environmental quality
Detection device is for detecting environmental quality index, which comprises
Receive the gateway system resource utilization S of network locating for the environmental quality detection device;
According to the gateway system resource utilization S, data sending threshold value Ve is set;And
When the absolute value of the difference of environmental quality index is greater than the data sending threshold value Ve twice before and after detecting,
The environmental quality index of time detection after transmission.
Preferably, described to include: according to gateway system resource utilization S setting data sending threshold value Ve
In the gateway system resource utilization S > 70%, increase the data sending threshold value Ve;
In gateway system resource utilization S >=30% and≤70%, the data sending threshold value Ve is not carried out
Adjustment;And
In the gateway system resource utilization S < 30%, reduce the data sending threshold value Ve.
Preferably, the method also includes:
In the gateway system resource utilization S > 90%, the data sending threshold value Ve=V is set0+α×β×
(S-0.5);And/or
In gateway system resource utilization S > 70% and≤90%, the data sending threshold value Ve=V is set0+
β×(S-0.5);And/or
In gateway system resource utilization S >=30% and≤70%, it is V that the data sending threshold value, which is arranged,0;
And/or
In the gateway system resource utilization S < 30%, the data sending threshold value Ve=V is set0-β×(0.5-
S);
Wherein, α is the coefficient greater than 1, and β is weighting coefficient, and the value range of β is 0~2, V0Threshold is sent for primary data
Value.
Preferably, the gateway system resource utilization S is gateway system resource utilization S flat within a setting period
Mean value.
The third aspect of the embodiment of the present invention provides a kind of environmental monitoring system, and the environmental monitoring system includes:
Intelligent gateway, for sending gateway system resource utilization S;
Environmental quality detection device described in first aspect according to embodiments of the present invention, for receiving the gateway system money
Source utilization rate S and the environmental quality index for sending detection to the intelligent gateway according to the gateway system resource utilization S.
Fourth aspect of the embodiment of the present invention provides a kind of machine readable storage medium, stores on the machine readable storage medium
There is instruction, which is used for so that machine executes environmental quality detection device described in second aspect according to embodiments of the present invention
Data transmission method.
Technical solution provided in an embodiment of the present invention has the following beneficial effects:
Number can be arranged according to gateway system resource utilization S in environmental quality detection device provided in an embodiment of the present invention
According to sending threshold value Ve;So as to dynamically adjust and change the frequency for sending data, and then can be in gateway system resource benefit
When with rate S higher, with the environmental quality index that lower frequency reception inputs, and when gateway system resource utilization S is lower
With the environmental quality index that higher frequency reception inputs, so as to effectively inhibit due to a large amount of environmental quality detection device frequencies
Network congestion caused by data is uploaded to the same intelligent gateway numerously, is improved since resource overload leads to the feelings of system crash
Condition, furthermore it is also possible to improve as data be transmitted across it is slow caused by system resource be not fully utilized and reduce user experience effect
The case where fruit.
The other feature and advantage of the embodiment of the present invention will the following detailed description will be given in the detailed implementation section.
Specific embodiment
It is described in detail below in conjunction with specific embodiment of the attached drawing to the embodiment of the present invention.It should be understood that this
Locate described specific embodiment and be merely to illustrate and explain the present invention embodiment, is not intended to restrict the invention embodiment.
Refering to fig. 1, first aspect of the embodiment of the present invention provides a kind of environmental quality detection device, and environmental quality detection is set
Standby includes detection module, receiving module, threshold setting module and data transmission blocks.Wherein, detection module is for detecting environment
Performance figure, the environmental quality index can for example refer to for the concentration of the harmful substance such as PM2.5 or formaldehyde etc. in air
Mark;Receiving module is used to receive the gateway system resource utilization S of network locating for the environmental quality detection device;Threshold value setting
Module is used to that data sending threshold value Ve to be arranged according to the gateway system resource utilization S;Data transmission blocks are used for described
The front and back that detection module detects twice the difference of environmental quality index absolute value be greater than the data sending threshold value Ve when, hair
Send the environmental quality index of rear detection.
It can be seen from the above description that data sending threshold value Ve setting is bigger, data transmission blocks send environment matter
The frequency of volume index is higher, since data sending threshold value Ve is arranged according to gateway system resource utilization, data hair
It send threshold value Ve that can generate corresponding dynamic with different gateway system resource utilization S to adjust.It specifically, can be in gateway
When resource utilization ratio S higher, with the environmental quality index that lower frequency reception inputs, and in the gateway system utilization of resources
The environmental quality index inputted when rate S is lower with higher frequency reception, so as to effectively inhibit due to a large amount of environmental qualities
Detection device continually to the same intelligent gateway upload data caused by network congestion, improve due to resource overload cause be
The case where system collapse, furthermore it is also possible to improve as data be transmitted across it is slow caused by system resource be not fully utilized reduction
The case where user experience effect.
In system initialization, a primary data sending threshold value V is set0, when the environmental quality that front and back detects twice
The absolute value of the difference of index is greater than V0When, after transmission then the secondary environmental quality index detected passes through intelligence to intelligent gateway
Energy gateway is sent to user APP, so as to user APP more new data.Intelligent gateway is periodically to all environmental qualities inspection in network
Measurement equipment broadcasts that the bigger expression current gateway resource of current gateway system resource utilization S, S is more nervous, and the value range of S is
0~100%.
In a preferred embodiment, the threshold setting module can be in the following way according to the gateway system resource benefit
With rate S, the data sending threshold value Ve is set:
In gateway system resource utilization S > 70%, increase data sending threshold value Ve;Specifically, in the feelings of S > 70%
Under condition, illustrate that gateway resource is nervous at this time, the environmental quality detection device in network is more, and data transmit-receive is frequent, at this point, relatively
Increase the data sending threshold value Ve of environmental quality detection device in current data sending threshold value Ve, can reduce environmental quality detection
Equipment sends the frequency of data to intelligent gateway, to alleviate system loading;
In gateway system resource utilization S >=30% and≤70%, illustrate that gateway resource is reasonably utilized, currently
The setting of data sending threshold value Ve is reasonable, at this point, not being adjusted to current data sending threshold value Ve;
In gateway system resource utilization S < 30%, indicating that gateway resource is well-to-do, the equipment in network is less, at this point,
Data sending threshold value Ve suitably can be reduced relative to current data sending threshold value Ve, increase environmental quality detection device to intelligent network
The frequency for sending data is closed, and then improves the timeliness that data update.
By the above-mentioned means, how the data of the environmental quality detection device no matter accessed in network change, it can be by net
It closes resource utilization ratio S effectively to maintain between 30% to 70%, and then improves since resource overload leads to system crash
The case where or improve as data be transmitted across it is slow caused by system resource be not fully utilized and reduce user experience effect
Situation.
Under normal circumstances, the quantity for accessing the environmental quality detection device of intelligent gateway is relatively fixed, in system initialization
Afterwards, primary data sending threshold value is arranged to V0, environment matter that every environmental quality detection device is detected in front and back twice
Volume index is greater than V0In the case where, the environmental quality index that time is detected after transmission to intelligent gateway.Intelligent gateway, which receives, to be corresponded to
Environmental quality index, and regularly to environmental quality detection device send current gateway resource utilization ratio S.In this base
On plinth,
When gateway system resource utilization S >=30% and≤70%, illustrate primary data sending threshold value V0Setting is reasonable,
Data sending threshold value Ve is not adjusted, i.e. holding data sending threshold value Ve=V0, environmental quality detection device is according to the threshold
Value V0Send data.
As gateway system resource utilization S < 30%, illustrate that gateway resource is well-to-do, primary data sending threshold value V0Setting
It is excessive, at this point, can be relative to primary data sending threshold value V0Reducing data sending threshold value Ve specifically can pass through formula Ve=
V0Data sending threshold value Ve is arranged in-β × (0.5-S), wherein β is weighting coefficient, the value range of β is 0~2, it is preferable that β
Generally taking initial value is 1, and taking for β is then adjusted in the range of 0~2 according to the gateway system resource utilization S actually returned
Value.
As gateway system resource utilization S > 70%, illustrate gateway resource anxiety, primary data sending threshold value V0Setting
It is too small, at this point, can be relative to primary data sending threshold value V0Increasing data sending threshold value Ve specifically can pass through formula Ve=V0
Data sending threshold value Ve is arranged in+β × (S-0.5), wherein β is weighting coefficient, the value range of β is 0~2, it is preferable that β mono-
As take initial value be 1, the value of β is then adjusted in the range of 0~2 according to the gateway system resource utilization S actually returned.
In some cases, emergency case may also occur in intelligent gateway or environmental quality detection device, and gateway is caused to provide
Source epitonos, such as S > 90% at a certain moment, as S > 90%, intelligent gateway is tight to all environmental quality detection devices
Anxious broadcast S, environmental quality detection device promptly adjusts data sending threshold value Ve after receiving urgent broadcast, and adjustment amplitude needs to increase
Add, specifically, the data sending threshold value Ve=V is set0+α×β×(S-0.5);Wherein, α is the coefficient greater than 1, and β is to add
Weight coefficient, the value range of β are 0~2, it is preferable that the value of β is 1.
It further, can be above-mentioned by adjusting when the quantity of the environmental quality detection device accessed in network changes
V in calculation formula0Value change current data sending threshold value Ve.
In a preferred embodiment, the gateway system resource utilization S is gateway system resource utilization S in a setting
Average value in period.Specifically, intelligent gateway sends current gateway to environmental quality detection device according to certain frequency f
Resource utilization ratio S, includes computing module in environmental quality detection device, which connects every setting time T calculating
Receive the average value of module received all gateway system resource utilizations in setting time T
Wherein, n be the receiving module received all gateway system resource utilizations in setting time T number, n=T ×
F, Sn ' it is n-th of gateway system resource utilization that receiving module receives in setting time T;Threshold setting module is according to
The average value that computing module is calculatedBe arranged data sending threshold value Ve, setting method with it is similar above, herein no longer
It repeats.
In one embodiment, the value range for inputting frequency f for example can be 1/6 time per hour~1/24 time per small
When.The value range of setting time T for example can be 6 hours~24 hours, and setting time T > 1/f.
It should be noted that if number is arranged according to average value of the gateway system resource utilization S within a setting period
According to sending threshold value Ve, then when emergency case occur in intelligent gateway or environmental quality detection device, i.e., in S > 90%, immediately
Adjust current data sending threshold value Ve=V0+ α × β × (S-0.5), without waiting for setting time T.
In a preferred embodiment, in order to guarantee user's APP data update timeliness, setting data sending threshold value Ve have
There is minimum value Vmin, in addition, in order to avoid gateway resource is overstretched, setting data are sent from the point of view of gateway resource
Threshold value Ve has maximum value Vmax;The specific value of maximum value and minimum value is related to the concrete type of environmental quality index, example
Such as, (the unit ug/m by taking environmental quality index is PM2.5 as an example3), Vmin value for example can be for 1~2, Vmax value for example
It can be 18~23;(the unit ug/m by taking environmental quality index is formaldehyde as an example3), Vmin value for example can be 9~12,
Vmax value for example can be 58~63.
Summarizing above-mentioned environmental quality detection device provided in an embodiment of the present invention can be seen that the tune of data sending threshold value Ve
Section occurs mainly on following timing node:
1. after 1 collection period of system electrification (i.e. above-mentioned setting time T);
2. environmental quality detection device quantity increases or decreases system by a relatively large margin in operation;
3. due to occurring emergency case in above-mentioned 1 and 2, to cause data sending threshold value Ve to adjust not in place, so that gateway system
Resource utilization S is still unable to get reasonable utilization;
4. emergency case, which occur, in intelligent gateway or environmental quality detection device leads to gateway resource epitonos.
Referring to Fig.2, based on the environmental quality detection device that first aspect of the embodiment of the present invention provides, the embodiment of the present invention the
Two aspects provide a kind of data transmission method of environmental quality detection device, and the environmental quality detection device is for detecting environment matter
Volume index, this method comprises: receiving the gateway system resource utilization S of network locating for the environmental quality detection device;According to
Data sending threshold value Ve is arranged in the gateway system resource utilization S;And the environmental quality index twice before and after detecting
The absolute value of difference when being greater than the data sending threshold value Ve, the environmental quality index of detection after transmission time.
Since data sending threshold value Ve is arranged according to gateway system resource utilization, data sending threshold value Ve
Corresponding dynamic can be generated with different gateway system resource utilization S to adjust.It specifically, can be in gateway system resource
It is and lower in gateway system resource utilization S with the environmental quality index that lower frequency reception inputs when utilization rate S higher
When with higher frequency reception input environmental quality index, so as to effectively inhibit due to a large amount of environmental quality detection devices
Network congestion caused by data continually is uploaded to the same intelligent gateway, is improved since resource overload leads to system crash
Situation, furthermore it is also possible to improve as data be transmitted across it is slow caused by system resource be not fully utilized and reduce user experience
The case where effect.
In system initialization, a primary data sending threshold value V is set0, when the environmental quality that front and back detects twice
The absolute value of the difference of index is greater than V0When, after transmission then the secondary environmental quality index detected passes through intelligence to intelligent gateway
Energy gateway is sent to user APP, so as to user APP more new data.Intelligent gateway is periodically to all environmental qualities inspection in network
Measurement equipment broadcasts that the bigger expression current gateway resource of current gateway system resource utilization S, S is more nervous, and the value range of S is
0~100%.
Refering to Fig. 3, in a preferred embodiment, can be set in the following way according to the gateway system resource utilization S
Set the data sending threshold value Ve:
In gateway system resource utilization S > 70%, increase data sending threshold value Ve;Specifically, in the feelings of S > 70%
Under condition, illustrate that gateway resource is nervous at this time, the environmental quality detection device in network is more, and data transmit-receive is frequent, at this point, increasing
The current data sending threshold value Ve of environmental quality detection device can reduce environmental quality detection device to intelligent gateway and send number
According to frequency, to alleviate system loading;
In gateway system resource utilization S >=30% and≤70%, illustrate that gateway resource is reasonably utilized, currently
The setting of data sending threshold value Ve is reasonable, at this point, not being adjusted to current data sending threshold value Ve;
In gateway system resource utilization S < 30%, indicating that gateway resource is well-to-do, the equipment in network is less, at this point,
Current data sending threshold value Ve can suitably be reduced, increase the frequency that environmental quality detection device sends data to intelligent gateway, into
And improve the timeliness of data update.
By the above-mentioned means, how the data of the environmental quality detection device no matter accessed in network change, it can be by net
It closes resource utilization ratio S effectively to maintain between 30% to 70%, and then improves since resource overload leads to system crash
The case where or improve as data be transmitted across it is slow caused by system resource be not fully utilized and reduce user experience effect
Situation.
Refering to Fig. 4, under normal circumstances, the quantity for accessing the environmental quality detection device of intelligent gateway is relatively fixed, is being
After system initialization, primary data sending threshold value is arranged to V0, every environmental quality detection device detects in front and back twice
Environmental quality index be greater than V0In the case where, the environmental quality index that time is detected after transmission to intelligent gateway.Intelligent gateway
Corresponding environmental quality index is received, and regularly sends current gateway resource utilization ratio to environmental quality detection device
S.On this basis,
When gateway system resource utilization S >=30% and≤70%, illustrate primary data sending threshold value V0Setting is reasonable,
Data sending threshold value Ve is not adjusted, i.e. holding data sending threshold value Ve=V0, environmental quality detection device is according to the threshold
Value V0Send data.
As gateway system resource utilization S < 30%, illustrate that gateway resource is well-to-do, primary data sending threshold value V0Setting
It is excessive, at this point, can be relative to primary data sending threshold value V0Reducing data sending threshold value Ve specifically can pass through formula Ve=
V0Data sending threshold value Ve is arranged in-β × (0.5-S), wherein β is weighting coefficient, the value range of β is 0~2, it is preferable that β
Generally taking initial value is 1, and taking for β is then adjusted in the range of 0~2 according to the gateway system resource utilization S actually returned
Value.
As gateway system resource utilization S > 70%, illustrate gateway resource anxiety, primary data sending threshold value V0 setting
It is too small, at this point, can be relative to primary data sending threshold value V0Increasing data sending threshold value Ve specifically can pass through formula Ve=V0
Data sending threshold value Ve is arranged in+β × (S-0.5), wherein β is weighting coefficient, the value range of β is 0~2, it is preferable that β mono-
As take initial value be 1, the value of β is then adjusted in the range of 0~2 according to the gateway system resource utilization S actually returned.
With continued reference to Fig. 4, in some cases, burst feelings may also occur in intelligent gateway or environmental quality detection device
Condition leads to gateway resource epitonos at a certain moment, such as S > 90%, and as S > 90%, intelligent gateway is to all environment
Quality detection apparatus urgent broadcast S, environmental quality detection device promptly adjust data sending threshold value Ve after receiving urgent broadcast,
And adjustment amplitude needs to increase, and specifically, the data sending threshold value Ve=V is arranged0+α×β×(S-0.5);Wherein, α be greater than
1 coefficient, β are weighting coefficient, and the value range of β is 0~2, it is preferable that the value of β is 1.
It further, can be above-mentioned by adjusting when the quantity of the environmental quality detection device accessed in network changes
V in calculation formula0Value change current data sending threshold value Ve.
In a preferred embodiment, the gateway system resource utilization S is gateway system resource utilization S in a setting
Average value in period.Specifically, intelligent gateway sends current gateway to environmental quality detection device according to certain frequency f
Resource utilization ratio S, environmental quality detection device calculate received all nets in setting time T every setting time T
Close the average value of resource utilization ratio SWherein, n is that environmental quality detection device exists
The number of received all gateway system resource utilization S, n=T × f, Sn in setting time T ' it is that environmental quality detection is set
Standby n-th of the gateway system resource utilization received in setting time T;Then according to the average valueData are set and send threshold
Value Ve, specific setting method can be likely to occur emergency case according to above, such as in intelligent gateway or environmental quality detection device,
Data sending threshold value is set
In one embodiment, the value range for inputting frequency f for example can be 1/6 time per hour~1/24 time per small
When.The value range of setting time T for example can be 6 hours~24 hours, and setting time T > 1/f.
It should be noted that if number is arranged according to average value of the gateway system resource utilization S within a setting period
According to sending threshold value Ve, then when emergency case occur in intelligent gateway or environmental quality detection device, i.e., in S > 90%, immediately
Adjust current data sending threshold value Ve=V0+ α × β × (S-0.5), without waiting for setting time T.
In a preferred embodiment, in order to guarantee user's APP data update timeliness, setting data sending threshold value Ve have
There is minimum value Vmin, in addition, in order to avoid gateway resource is overstretched, setting data are sent from the point of view of gateway resource
Threshold value Ve has maximum value Vmax;The specific value of maximum value and minimum value is related to the concrete type of environmental quality index, example
Such as, (the unit ug/m by taking environmental quality index is PM2.5 as an example3), Vmin value for example can be for 1~2, Vmax value for example
It can be 18~23;(the unit ug/m by taking environmental quality index is formaldehyde as an example3), Vmin value for example can be 9~12,
Vmax value for example can be 58~63.
The data transmission method for summarizing above-mentioned environmental quality detection device provided in an embodiment of the present invention can be seen that data
The adjusting of sending threshold value Ve occurs mainly on following timing node:
1. after 1 collection period of system electrification (i.e. above-mentioned setting time T);
2. environmental quality detection device quantity increases or decreases system by a relatively large margin in operation;
3. due to occurring emergency case in above-mentioned 1 and 2, to cause data sending threshold value Ve to adjust not in place, so that gateway system
Resource utilization S is still unable to get reasonable utilization;
4. emergency case, which occur, in intelligent gateway or environmental quality detection device leads to gateway resource epitonos
Refering to Fig. 5, the third aspect of the embodiment of the present invention provides a kind of environmental monitoring system, which includes:
Intelligent gateway and environmental quality detection device, wherein environmental quality detection device is according to first aspect of the embodiment of the present invention
Environmental quality detection device, after system electrification operation, intelligent gateway regularly sends to environmental quality detection device current
Gateway system resource utilization S, environmental quality detection device are arranged according to the gateway system resource utilization S that intelligent gateway is sent
Data sending threshold value Ve, and environmental quality index is uploaded to intelligent gateway according to the data sending threshold value Ve, send data
Method is as it was noted above, details are not described herein again.
In addition, it will be appreciated by those skilled in the art that implement the method for the above embodiments be can be with
Relevant hardware is instructed to complete by program, which is stored in a storage medium, including some instructions are to make
Obtain all or part of the steps that single-chip microcontroller, chip or processor (processor) execute each embodiment the method for the application.
And storage medium above-mentioned includes: that USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic or disk.
The optional embodiment of the embodiment of the present invention is described in detail in conjunction with attached drawing above, still, the embodiment of the present invention is simultaneously
The detail being not limited in above embodiment can be to of the invention real in the range of the technology design of the embodiment of the present invention
The technical solution for applying example carries out a variety of simple variants, these simple variants belong to the protection scope of the embodiment of the present invention.
It is further to note that specific technical features described in the above specific embodiments, in not lance
In the case where shield, it can be combined in any appropriate way.In order to avoid unnecessary repetition, the embodiment of the present invention pair
No further explanation will be given for various combinations of possible ways.
In addition, any combination can also be carried out between a variety of different embodiments of the embodiment of the present invention, as long as it is not
The thought of the embodiment of the present invention is violated, equally should be considered as disclosure of that of the embodiment of the present invention.