Internet of things data acquisition method

文档序号:1835059 发布日期:2021-11-12 浏览:8次 中文

阅读说明:本技术 一种物联网数据采集方法 (Internet of things data acquisition method ) 是由 李帅 逄振 马鹏程 刘晶晶 于 2021-08-11 设计创作,主要内容包括:本发明涉及一种物联网数据采集方法,通过获取物联网网络中各个点位的数据采集频率;将采集频率相同的位点划分至同一集合中;基于多线程对集合中的点位进行数据的采集,其中每个线程只采集与其对应的集合中的点位。实现了将相同频率的点位整合后在使用线程进行采集,从而减少线程的数量。并且在一个点位出现问题,只会影响该组的点位采集,而不会影响所有的点位;若某个点位采集时频繁出现问题,则可以降低采集频率,从而提高程序的运行速率。提高了物联网数据采集的效率。(The invention relates to a data acquisition method of the Internet of things, which is characterized in that the data acquisition frequency of each point position in the network of the Internet of things is obtained; dividing the sites with the same acquisition frequency into the same set; and acquiring data of the point locations in the set based on multiple threads, wherein each thread only acquires the point locations in the set corresponding to the thread. The point locations with the same frequency are integrated and then collected in the thread, so that the number of threads is reduced. And a problem occurs at one point location, only the point location collection of the group is influenced, and all the point locations are not influenced; if a problem frequently occurs when a certain point location is collected, the collection frequency can be reduced, and therefore the running speed of the program is increased. The efficiency of thing networking data acquisition has been improved.)

1. A data acquisition method of the Internet of things is characterized by comprising the following steps:

acquiring data acquisition frequency of each point location in the Internet of things network;

dividing the sites with the same acquisition frequency into the same set;

and acquiring data of the point locations in the set based on multiple threads, wherein each thread only acquires the point locations in the set corresponding to the thread.

2. The internet of things data acquisition method of claim 1, wherein the acquiring of the data acquisition frequency of each point location in the internet of things network comprises:

and determining the data acquisition frequency of each point location based on the point location change frequency of each point location.

3. The internet of things data acquisition method of claim 2, wherein the determining the data acquisition frequency of each point location based on the change frequency of the point location value of each point location comprises:

if the frequency of point location value change of a point location changes frequently within a preset time, the data acquisition frequency of the point location needs to be faster.

4. The internet of things data acquisition method of claim 2, wherein determining the data acquisition frequency of each point location based on the change frequency of the point location value of each point location further comprises:

if the frequency of point location value change of the point location changes slowly within the preset time, the data acquisition frequency of the point location is slow.

5. The internet of things data acquisition method of claim 2, wherein the obtaining of the data acquisition frequency of each point location in the internet of things further comprises:

acquiring preset acquisition frequency input by a user, and acquiring data of corresponding point locations based on the preset acquisition frequency.

6. The internet of things data acquisition method of claim 1, further comprising:

and releasing the corresponding thread after completing data acquisition at the point position each time so as to release the corresponding memory and avoid memory overflow.

7. The internet of things data collection method of any one of claims 1 to 6, wherein the collecting data of the point locations in the set based on multiple threads comprises:

and if the communication protocol of the point locations supports batch collection, integrating the data collected by all the point locations into the same message for sending.

8. The internet of things data collection method of claim 1, wherein the collecting data of the point locations in the set based on multithreading further comprises:

and if the point communication protocol does not support batch acquisition or the message length is limited, sending the messages singly or in batch.

Technical Field

The invention belongs to the technical field of data acquisition, and particularly relates to a data acquisition method of an Internet of things.

Background

IoT (internet of things) refers to a state in which various things are connected with the internet. By connecting to the internet, various things can store acquired information (data) on a specific server or cloud by human operation and sensors. By analyzing these stored information and providing optimal control of the item and optimal methods of use for the person using the item, a more comfortable society can be constructed. With the continuous development of communication technology, especially the development of 5G communication technology in recent years, a powerful technical support is provided for the high-speed development of the Internet of things.

Data acquisition of various devices and sensors in the convenient internet of things brought by the internet of things is the first step, and if the data acquisition is in a problem or the data acquisition efficiency is low, the subsequent data processing, application and the like can be affected. Especially in a scene with a high acquisition frequency, a large number of point locations need to be acquired, and in the prior art, multithreading is generally adopted for acquisition, and the acquisition method can solve the problem that other point locations cannot be acquired due to the fact that a certain point location has a problem, so that the acquisition rate is influenced, but the consumption of a memory and an IO interface is increased; the other acquisition method adopts the same rate to acquire data, the method can only acquire data one by one, the consumption of a memory and an IO interface is reduced, but a problem occurs in the acquisition process of a certain point, so that the rate of the whole acquisition program is influenced.

Therefore, how to more efficiently acquire data of the internet of things has become a technical problem which needs to be solved urgently.

Disclosure of Invention

In order to solve the problems of low data acquisition efficiency, low speed and high memory consumption in the prior art, the invention provides the data acquisition method of the Internet of things, which has the characteristics of high acquisition efficiency, higher speed and the like.

The data acquisition method for the Internet of things comprises the following steps:

acquiring data acquisition frequency of each point location in the Internet of things network;

dividing the sites with the same acquisition frequency into the same set;

and acquiring data of the point locations in the set based on multiple threads, wherein each thread only acquires the point locations in the set corresponding to the thread.

Further, the acquiring the data acquisition frequency of each point location in the internet of things network includes:

and determining the data acquisition frequency of each point location based on the point location change frequency of each point location.

Further, the determining the data acquisition frequency of each point location based on the change frequency of the point location value of each point location includes:

if the frequency of point location value change of a point location changes frequently within a preset time, the data acquisition frequency of the point location needs to be faster.

Further, the determining the data acquisition frequency of each point location based on the change frequency of the point location value of each point location further includes:

if the frequency of point location value change of the point location changes slowly within the preset time, the data acquisition frequency of the point location is slow.

Further, acquiring the data acquisition frequency of each point location in the internet of things network further includes:

acquiring preset acquisition frequency input by a user, and acquiring data of corresponding point locations based on the preset acquisition frequency.

Further, the internet of things data acquisition method further comprises the following steps:

and releasing the corresponding thread after completing data acquisition at the point position each time so as to release the corresponding memory and avoid memory overflow.

Further, the collecting data of the point locations in the set based on the multithreading includes:

and if the communication protocol of the point locations supports batch collection, integrating the data collected by all the point locations into the same message for sending.

Further, the collecting data of the point locations in the set based on multiple threads further includes:

and if the point communication protocol does not support batch acquisition or the message length is limited, sending the messages singly or in batch. The invention has the beneficial effects that: acquiring data acquisition frequency of each point location in the Internet of things network; dividing the sites with the same acquisition frequency into the same set; and acquiring data of the point locations in the set based on multiple threads, wherein each thread only acquires the point locations in the set corresponding to the thread. The point locations with the same frequency are integrated and then collected in the thread, so that the number of threads is reduced. And a problem occurs at one point location, only the point location collection of the group is influenced, and all the point locations are not influenced; if a problem frequently occurs when a certain point location is collected, the collection frequency can be reduced, and therefore the running speed of the program is increased. The efficiency of thing networking data acquisition has been improved.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

Fig. 1 is a flow chart of a method for data collection of the internet of things provided according to an exemplary embodiment;

fig. 2 is another flowchart of a data collection method for the internet of things according to an exemplary embodiment.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the examples given herein without any inventive step, are within the scope of the present invention.

Referring to fig. 1, an embodiment of the present invention provides an internet of things data acquisition method, which specifically includes:

101. acquiring data acquisition frequency of each point location in the Internet of things network;

because each internet of things is composed of various devices, the data acquisition frequency or the interaction frequency of the data interaction of the various devices is different, so that the data acquisition frequency of each device can be determined according to the information data interaction between the devices.

102. Dividing the sites with the same acquisition frequency into the same set;

and classifying the devices with the same data acquisition frequency into the same set for management by classifying and planning the data acquisition frequency of each acquired device. I.e. different sets correspond to different data acquisition frequencies.

103. And acquiring data of the point locations in the set based on multiple threads, wherein each thread only acquires the point locations in the set corresponding to the thread.

The data can be acquired by creating a thread pool in advance, circularly traversing the well integrated point location set and calling a thread to run a set with different acquisition frequencies. Thus, the number of threads can be reduced by integrating the point locations with the same frequency and then using the threads. If one point location has a problem, only the point location collection of the group is influenced, and all the point locations are not influenced; if a problem frequently occurs when a certain point location is collected, the collection frequency can be reduced, and therefore the running speed of the program is increased.

In another specific embodiment of the present invention, the obtaining of the data acquisition frequency of each point in the internet of things network includes:

and determining the data acquisition frequency of each point location based on the point location change frequency of each point location.

Determining the data acquisition frequency of each point location based on the point location change frequency of each point location comprises:

if the frequency of point location value change of a point location changes frequently within a preset time, the data acquisition frequency of the point location needs to be faster.

Determining the data acquisition frequency of each point location based on the point location change frequency of each point location further comprises:

if the frequency of point location value change of the point location changes slowly within the preset time, the data acquisition frequency of the point location is slow.

Acquiring the data acquisition frequency of each point location in the internet of things further comprises:

acquiring preset acquisition frequency input by a user, and acquiring data of corresponding point locations based on the preset acquisition frequency.

The data acquisition method of the Internet of things further comprises the following steps:

and releasing the corresponding thread after completing data acquisition at the point position each time so as to release the corresponding memory and avoid memory overflow.

The data collection of the point positions in the set based on the multithreading comprises the following steps:

and if the communication protocol of the point locations supports batch collection, integrating the data collected by all the point locations into the same message for sending.

Collecting data for the point locations in the set based on multithreading further comprises:

and if the point communication protocol does not support batch acquisition or the message length is limited, sending the messages singly or in batch.

Specifically, referring to fig. 2, for the integration of the acquisition frequency, the frequency of point location value change can be determined by acquiring data of the point location for a period of time, if the value change is frequent, the acquisition frequency needs to be faster, so that better real-time performance can be achieved, and conversely, if the value change frequency is slow, the acquisition frequency does not need to be too fast, so that the consumption of a memory and an IO interface can be reduced; or the user can input the frequency at which each point location needs to be acquired by himself, because the acquisition frequencies of each point location are different, the point locations are classified according to the acquired acquisition frequencies obtained by judgment or the frequencies configured by the user, the point locations with the same frequency are integrated together to form a set with the same frequency, and the point locations with the same acquisition frequency need to be integrated into a set, so that the point locations can be acquired in batches.

Then a thread pool is created in advance, the well integrated point location set is traversed in a circulating mode, a thread is called to run a set with different acquisition frequencies to acquire data, if a protocol supports batch acquisition, all point locations in the set can be integrated into one message to be sent out, received response messages can also be data of all the point locations, if the protocol does not support batch acquisition or the message length is limited, the messages can be combined in a single or batch mode again (the message length cannot be exceeded), and the received response messages are data of a single point location or data of part of the point locations; the thread is released immediately after the data acquisition is completed, and if the thread is not released, the memory overflow can be caused, so that the running of the program is influenced. By using multiple threads to collect point positions in the sets, several sets start several threads, and data can be collected in parallel; when data is sent, the data in the whole set can be sent, so that the situation that other point locations cannot be collected due to the fact that a certain point location has a problem can be avoided, the collection rate is influenced, and IO consumption can be reduced to a certain extent.

According to the data acquisition method of the Internet of things provided by the embodiment of the invention, the point positions with the same frequency are integrated and then the threads are used, so that the number of the threads can be reduced. Meanwhile, if one point location has a problem, only the point location collection of the group is influenced, and all the point locations are not influenced; if a problem frequently occurs when a certain point location is collected, the collection frequency can be reduced, and therefore the running speed of the program is increased.

It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.

In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.

The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.

In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

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 all 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 appended claims.

7页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于节点退避算法的Lora自组网数据传输系统及方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类