The method of sensor handling routine is dynamically added in things-internet gateway equipment
Technical field
The method that the present invention relates to a kind of to add sensor handling routine in things-internet gateway equipment, especially one kind exist
The method of sensor handling routine is dynamically added in things-internet gateway equipment.
Background technique
The Internet of Things country is also known as Sensor Network, the purpose is to acquire a large amount of sensing data, then upload the data to interconnection
Net cloud server, the foundation as people's decision.And bridge of the things-internet gateway equipment as sensor and server, it plays
Data translation, transfer effect, its performance and adaptability also influence whether whole system, thus one fast and stable of design,
The things-internet gateway equipment of wide adaptability is extremely important.The method of pervious things-internet gateway equipment addition sensor handling routine
It is using the exploitation directly against property, i.e. some client sensor for needing some brand, then being just directed to this brand
Sensor develops special main program and acquires data, devotes a tremendous amount of time and debugs repeatedly, if the demand of client changes, uses
In addition the sensor of brand it is necessary to developing main program according to new demand again.When there are many main program waste of exploitation new version
Between, and new mistake may be brought, allow controllable process to become not easy to control.
Summary of the invention
The technical problems to be solved by the present invention are: providing a kind of main program for being not required to modification things-internet gateway equipment, dynamic
The method of state addition sensor handling routine.
The present invention adopts the technical scheme that solve above-mentioned technical problem:
The first step enumerates sensor package, and the information of plug-in unit is specially saved with a file, and plugin information includes plug-in unit
Title, plug-in unit occupy hardware resource, plug-in unit for input or export or output and input, plug-in code position, main journey
Sequence is by the disposable loading system of these information;
Second step loads sensor package, according to the information of previous step " enumerating sensor package step ", storage allocation money
Source, distribution peripheral hardware resource, distribution thread resources, allocation database resource;
Third step, into major cycle, this step has represented system formally " race is got up ", this step as distinguish front
The time point of preproduction phase and below operation phase;
4th step calls sensor package, error detection and processing, and main program is obtained by the interface function of calling plug-in unit
Sensing data is taken, or writes information into sensor, since plug-in unit itself, operating system, bottom layer driving etc. are unstable, is caused
Program error need to unify to carry out error detection, and be handled, and treated, and program enters back into major cycle;Or new sensor
Plug-in unit detection enters back into loading sensor package, can receive network dynamic configuration for reading the part of file change.
In the above technical solution, described to enumerate this context initialization step that advanced travel far and wide before sensor package step
Suddenly, script environment can enhance the stability of whole system, and main program and sensor handling routine are all run under script environment,
Before all processing routines, script environment is initialized.
Beneficial effects of the present invention: 1, the compiling formula language of this easy error of the C/C++ to discard tradition, use can be moved
State execution script formula language, makes things-internet gateway stable equipment operation;2, main program does not have to acquire any data, but according to
Configuration file is increased by the processing routine of a sensor, dynamically load plug-in unit is complete by plug-in unit if increasing a sensor
At acquisition data function;3, main program unified allocation of resources plug-in unit, and the mistake of plug-in unit generation is captured, it not will lead to whole system and go out
It is wrong;4, increase new sensor, do not need to redesign new main program, time and manpower is saved.
Detailed description of the invention
Fig. 1 is work step figure of the invention.
Specific embodiment
Embodiment 1
Work step figure of the invention as shown in Figure 1, the first step carry out script environment initialization step, script environment
The stability of whole system can be enhanced, main program and sensor handling routine are all run under script environment, in all processing
Before program, script environment is initialized.Second step enumerates sensor package, and the information of plug-in unit is specially saved with a file,
Plugin information include plugin name, plug-in unit occupy hardware resource, plug-in unit for input or export or output and input,
Plug-in code position, main program is by the disposable loading system of these information.Third step loads sensor package, according to previous step
The information of " enumerating plug-in unit step ", storage allocation resource, distribution peripheral hardware resource, distribution thread resources, allocation database money
Source.4th step, into major cycle, this step has represented system formally " race is got up ", this step as distinguish front preparation
The time point of stage and below operation phase.5th step calls sensor package, the interface letter that main program passes through calling plug-in unit
Number reads the part of file change, obtains sensing data, or write information into sensor;Or to new sensor plug-in unit into
Row detection if there is new sensor package, and enters and loads sensor package step.6th step, error detection and processing " are adjusted
With sensor package " the step for, may or operating system unstable due to plug-in unit itself, bottom layer driving etc. it is unstable, lead
Cause program error.Program crashing in order to prevent, this step carries out error detection for unified, and is handled, journey that treated
Sequence enters back into major cycle step, this step mainly realizes the function of " dynamic importing ".
The present invention simulates AVID Sniffer Simulator analog sensor, AVID Sniffer Simulator
Sensor, Libelium series sensor, NEMOTO series sensor are applicable.
The present invention calls sensor package step and the detection of new sensor plug-in unit that can also carry out simultaneously.