Summary of the invention
(1) technical problem that will solve
In view of this, main purpose of the present invention is to provide a kind of realization wireless sensor network visualization method, the sensing data that the user can be obtained in the Local or Remote Real Time Observation, and the process of transmitting of wireless sensor network network configuration and network internal sensing data bag.
(2) technical scheme
For achieving the above object, technical scheme of the present invention is achieved in that
A kind of realization wireless sensor network visualization method, this method comprises:
A, startup monitor process are obtained the sensing data bag that gateway node sends to main frame by serial ports in the wireless sensor network;
B, the sensing data bag that obtains is resolved, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag;
The source address field of the sensing data bag that C, basis parse makes up the visual node of node distribution view and distributes, on described node distribution view, draw the process of transmitting of the next visual sensing data bag of route curve of sensing data bag according to each node ID number on the sensing data packet transmission path that parses, make up the sensing data view according to the sensing data that parses, the variation that comes visual sensing data by the real-time curve of on described sensing data view, drawing each node sensing data.
Obtain the sensing data bag described in the steps A and be the beginning of sensing data bag in the binary data stream of judging reception with the opening flag and the end mark of each sensing data bag and end.
Described sensing data is unwrapped and is begun to be masked as 0x8e, and end mark is 0x7e, no longer occurs opening flag and end mark in the sensing data bag; As needing transmission opening flag 0x8e, then 0x8e is converted to 0x8d 0x6e in sensing data bag inside, converts 0x8d to 0x8d 0x6d during transmission 0x8d; The end of transmission sign 0x7e if desired in sensing data bag inside then converts 0x7e to 0x7d0x6e, converts 0x7d to 0x7d 0x5d during transmission 0x7d; Byte reduction after when receiving, will changing again.
The visual node distribution of source address field structure node distribution view according to the sensing data bag that parses described in the step C comprises: find to exist which node in the current network according to the source address field of the sensing data bag that parses, and the node the found form with a bead shown, indicate the address of node on the bead next door; Select a picture that characterizes the actual environment that node distributed as map background, the node of finding is dragged to and the corresponding position of actual distribution, make up node distribution view.
In the process of described structure node distribution view, the mode of double buffering is adopted in the drafting of map background and all nodes, promptly draws in internal memory earlier, directly the view data in the internal memory is directly outputed in the screen then.
The process of transmitting of drawing the visual sensing data bag of route curve of sensing data bag according to each node ID number on the sensing data packet transmission path that parses on described node distribution view described in the step C comprises: when the sensing data bag arrives, parse the route data in the sensing data bag, obtain this sensing data bag ID number of each node of process, on described node distribution view, draw the route curve of sensing data bag then, and highlighted demonstration sends the node of sensing data bag.
When drawing described route curve, directly on screen, draw, has drawn startup timer afterwards, when timer message arrives, wipe the drafting effect.Described wiping in the double buffering mode carried out.
Make up the sensing data view according to the sensing data that parses described in the step C, by coming the variation of visual sensing data to comprise:, and set up the timer of a curve plotting to sensing data chained list of each node configuration and the curve array on the described node distribution view at the real-time curve of drawing each node sensing data on the described sensing data view; When sensing data that parsing makes new advances, the sensing data that parses is cached in the chained list of each node correspondence; When timer message arrives, taking out data from the sensing data chained list of node is put in the curve array of node correspondence, from described curve array, take out the data of each node correspondence again, draw the real-time curve of node sensing data according to the data of from described curve array, taking out.
Described curve array is used to preserve the nearest N that drew a sensing data value, and N is an empirical value of setting according to visual effect; When each drafting message arrives, from the sensing data chained list of node, take out data and be put in the curve array of node correspondence; If the curve array is full, then insert new data, the data that deletion deposits at first.
The real-time curve of described drafting node sensing data is to draw according to the data of preserving in the curve array; When the speed of obtaining of sensing data is slower than the speed of drawing, always get last data when from the sensing data chained list of node, fetching data; When reading sensing data, surpass user's preset threshold if find sensing data, information then gives a warning.
When carrying out remote visualization, further comprise between described step B and the step C: each node ID number and sensing data are saved in the database on the source address field of each sensing data bag that will parse, the sensing data packet transmission path, and each node ID number and sensing data on the long-range source address field that obtains each sensing data bag of preserving in the database, sensing data packet transmission path.
The ActiveX control of visual service is provided in terminal configuration in advance, the described long-range source address field that obtains each sensing data bag of preserving in the database, each node ID number comprises with sensing data on the sensing data packet transmission path: described ActiveX control at first is connected the database on the remote server, check the current network data if desired, then regularly from database, read the service data information of current network, promptly read each sensing data bag that receives, extract the source address field of each sensing data bag, each node ID number and sensing data on the sensing data packet transmission path; Check network historical act information if desired, then from the historical data table of database, read the historical data information of network, promptly from historical data tabulation, select the historical data that to check, from the database corresponding, read the sensing data bag of some, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag with the historical data of selecting.
This method further comprises: show the data in the sensing data bag that parses, the content of visual raw sensory packet.
Data in the sensing data bag that described demonstration parses comprise: adopt the mode of subfield that the data in the sensing data bag that parses are shown with hexadecimal numerical value, each row is being represented the field of certain implication, and each row is represented a sensing data bag; When the user chooses certain data line, show the hierarchical structure of choosing the sensing data bag in tree-like mode again, show the content of raw sensory packet.
(3) beneficial effect
From technique scheme as can be seen, the present invention has following beneficial effect:
1, utilizes the present invention, can resolve the data that send over from gateway node (or being called the base station) automatically, and show sensing data packet communication process between each sensor node of network internal in patterned mode, make things convenient for the active situation of the real-time observation wireless sensor network of network manager or user.
2, this realization wireless sensor network visualization method provided by the invention, the dynamic changing process of the environmental parameter that is monitored with the mode display network of real-time curve, and threshold value can be set, when sensing data that certain node monitored surpasses this threshold value, the output alarm information.Assist the user to analyze sensing data by this approach.
3, this realization wireless sensor network visualization method provided by the invention, when drawing the active situation of network, adopted the double buffering mode of drawing to combine with direct the drafting, effectively prevent scintillation, and higher than simple with double buffering efficient.
4, this realization wireless sensor network visualization method provided by the invention adds the support to network, and the user registers on the website, after the login, asks visual service.Can allow more people like this, the situation of observing same wireless sensor network in different places simultaneously.
5, this realization wireless sensor network visualization method provided by the invention, the user can drag node identification in the software view in this locality according to the distribution situation of sensor node in actual environment when visual, make the node location in the software roughly corresponding with actual node distribution, lacking under the situation of placement technology the active situation of observation network that also can image like this.The user drags the node distributed intelligence that node forms simultaneously, also can deposit in the database, so that the long-distance user also can observe same effect.
6, this realization wireless sensor network visualization method provided by the invention, owing to introduced the database support, the collected data of each experiment all will be deposited in the middle of the database, can by top mention method go to analyze data, both made things convenient for playback history data, the representation of the historical scene also is the diagnostic network mistake simultaneously, and the phase-split network performance provides initial data.
Embodiment
For making the purpose, technical solutions and advantages of the present invention clearer, below in conjunction with specific embodiment, and with reference to accompanying drawing, the present invention is described in more detail.
As shown in Figure 1, Fig. 1 is the realization flow figure of the visual overall technological scheme of realization wireless sensor network provided by the invention, and this method may further comprise the steps:
Step 101: start monitor process and obtain the sensing data bag that gateway node sends to main frame by serial ports in the wireless sensor network;
Step 102: the sensing data bag that obtains is resolved, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag;
Step 103: the source address field according to the sensing data bag that parses makes up the visual node distribution of node distribution view, on described node distribution view, draw the process of transmitting of the next visual sensing data bag of route curve of sensing data bag according to each node ID number on the sensing data packet transmission path that parses, make up the sensing data view according to the sensing data that parses, the variation that comes visual sensing data by the real-time curve of on described sensing data view, drawing each node sensing data.
Obtain the sensing data bag described in the above-mentioned steps 101 and be the beginning of sensing data bag in the binary data stream of judging reception with the opening flag and the end mark of each sensing data bag and end.Described sensing data is unwrapped and is begun to be masked as 0x8e, and end mark is 0x7e, no longer occurs opening flag and end mark in the sensing data bag; As needing transmission opening flag 0x8e, then 0x8e is converted to 0x8d 0x6e in sensing data bag inside, converts 0x8d to 0x8d 0x6d during transmission 0x8d; The end of transmission sign 0x7e if desired in sensing data bag inside then converts 0x7e to 0x7d 0x6e, converts 0x7d to 0x7d 0x5d during transmission 0x7d; Byte reduction after when receiving, will changing again.
The visual node distribution of source address field structure node distribution view according to the sensing data bag that parses described in the above-mentioned steps 103 comprises: find to exist which node in the current network according to the source address field of the sensing data bag that parses, and the node the found form with a bead shown, indicate the address of node on the bead next door; Select a picture that characterizes the actual environment that node distributed as map background, the node of finding is dragged to and the corresponding position of actual distribution, make up node distribution view, the network formed of each node in the view just has been mapped with the network of reality like this.In the process of described structure node distribution view, the mode of double buffering is adopted in the drafting of map background and all nodes, promptly in internal memory, draw earlier, directly the view data in the internal memory is outputed in the screen then, can effectively prevent to occur when frequently drawing scintillation like this.
The process of transmitting of drawing the visual sensing data bag of route curve of sensing data bag according to each node ID number on the sensing data packet transmission path that parses on described node distribution view described in the above-mentioned steps 103 comprises: when the sensing data bag arrives, parse the route data in the sensing data bag, obtain this sensing data bag ID number of each node of process, on described node distribution view, draw the route curve of sensing data bag then, and the node of highlighted demonstration transmission sensing data bag, observe the active situation of network internal with this.When drawing described route curve, directly on screen, draw, has drawn startup timer afterwards, when timer message arrives, wipe the drafting effect.Described wiping in the double buffering mode carried out, and this erase process is actually the node that repaints map background and found, and visual effect just forms and wipes.
Come the variation of visual sensing data to comprise according to the sensing data that parses at the real-time curve of drawing the node sensing data on the described node distribution view described in the above-mentioned steps 103:, and to set up the timer of a curve plotting to sensing data chained list of each node configuration and the curve array on the described node distribution view; When sensing data that parsing makes new advances, the sensing data that parses is cached in the chained list of each node correspondence; When timer message arrives, taking out data from the sensing data chained list of node is put in the curve array of node correspondence, from described curve array, take out the data of each node correspondence again, draw the real-time curve of node sensing data according to the data of from described curve array, taking out.
Described curve array is used to preserve the nearest N that drew a sensing data value, and N is an empirical value of setting according to visual effect; When each drafting message arrives, from the sensing data chained list of node, take out data and be put in the curve array of node correspondence; If the curve array is full, then insert new data, the data that deletion deposits at first.
The real-time curve of described drafting node sensing data, be to draw according to the data of preserving in the curve array, only draw the data of preserving in the corresponding curve array, utilize the persistence of vision to make curve have the effect of rolling like this, give the sensation of a kind of real-time of people.When the speed of obtaining of sensing data is slower than the speed of drawing, always get last data when from the sensing data chained list of node, fetching data; When reading sensing data, surpass user's preset threshold if find sensing data, information then gives a warning.
This method further comprises after step 103: show the data in the sensing data bag that parses, the content of visual raw sensory packet.Data in the sensing data bag that described demonstration parses comprise: adopt the mode of subfield that the data in the sensing data bag that parses are shown with hexadecimal numerical value.Each row is being represented the field of certain implication, and each row is represented a sensing data bag; When the user chooses certain data line, show the hierarchical structure of choosing the sensing data bag in tree-like mode again, show the content of raw sensory packet.
As shown in Figure 2, Fig. 2 is the structural representation of the visual general frame of realization wireless sensor network provided by the invention.This general frame comprises the wireless sensor network (should comprise a gateway node in the network, all data will send to gateway node) of a certain scale, a station server main frame, the client computer of several request services.Wherein the software configuration on the server host as shown in Figure 3.It comprises data collection and local visual software, mysql database, apache (remote access is provided), and the php interpreter provides the procedure site of visual service.
Based on the realization flow figure of the visual overall technological scheme of the described realization wireless sensor network of Fig. 1 and the structural representation of the visual general frame of the described realization wireless sensor network of Fig. 2, the present invention is realized that the wireless sensor network visualization method further describes below in conjunction with specific embodiment.
Embodiment one
In the present embodiment, to realize that wireless sensor network local is visualized as example, further specify realization visual detailed method of wireless sensor network local and step below in conjunction with accompanying drawing.
As shown in Figure 4, Fig. 4 realizes wireless sensor network local visualization method flow chart according to first embodiment of the invention, and this method may further comprise the steps:
Step 401: obtain the sensing data bag that gateway node in the wireless sensor network (or being called the base station) sends to main frame by serial ports by starting a monitor process.
Define each sensing data unwrap the beginning be masked as 0x8e, the definition end mark is 0x7e, indicates beginning and the end of judging sensing data bag in the binary data stream that receives by serial ports with this.In the sensing data bag, can not occur unwrapping beginning and end mark again, as needing transmission package opening flag 0x8e, then 0x8e is converted to 0x8d 0x6e, convert 0x8d to 0x8d 0x6d during transmission 0x8d in sensing data bag inside; Transmission package end mark 0x7e then converts 0x7e to 0x7d0x6e if desired, converts 0x7d to 0x7d 0x5d during transmission 0x7d.When receiving, again the byte after the escape is reduced.
Step 402: the sensing data bag that receives is resolved, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag.
Step 403: the source address field by the sensing data bag is found the sensor node that exists in the network, and the node of finding is presented in the node distribution view with a bead.After a period of time, most of or whole nodes all have been found that.The user can drag node identification in the view (representing with bead), makes in the view node distribution identical with the actual distribution of sensor node, is convenient to observe.
Step 404: by each node ID number on the transmission path of the sensing data bag that obtains, with the coordinate of these nodes on view is that the datum mark drafting fits curve, the source node that simultaneously highlighted demonstration sensing data bag sends, and, come the process of transmitting of visual sensing data bag with this with the destination node that arrow points sensing data bag sends.
Step 405: sensing data visual, then use the curve relevant to represent with time shaft, can so that observe sensing data in time fluctuation change.
Embodiment two
In the present embodiment, turn to example, further specify detailed method and the step that realizes the wireless sensor network remote visualization below in conjunction with accompanying drawing to realize the wireless sensor network remote visible.
As shown in Figure 5, Fig. 5 is a method flow diagram of realizing the wireless sensor network remote visualization according to second embodiment of the invention, and this method may further comprise the steps:
Step 501: collect data from gateway node.Obtain the sensing data bag that gateway node in the wireless sensor network (or being called the base station) sends to main frame by serial ports by starting a monitor process.
Each sensing data is unwrapped the beginning sign and is defined as 0x8e, and end mark is defined as 0x7e, indicates beginning and the end of judging sensing data bag in the binary data stream that receives by serial ports with this.In the sensing data bag, can not occur unwrapping beginning and end mark again, as needing transmission package opening flag 0x8e, then 0x8e is converted to 0x8d 0x6e, convert 0x8d to 0x8d 0x6d during transmission 0x8d in sensing data bag inside; Transmission package end mark 0x7e then converts 0x7e to 0x7d0x6e if desired, converts 0x7d to 0x7d 0x5d during transmission 0x7d.When receiving, again the byte after the escape is reduced.
Step 502: the sensing data bag that receives is resolved, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag, the data that parse are deposited in the database.
In this step, it is that the needed data of remote visualization are saved in the mysql database that the data that just parse are deposited in the database, for remote visualization provides a data interface.The main preservation through the data after resolving, comprise the node address that sends the sensing data bag, data through the address of node on the path, the value of entrained sensing data in the sensing data bag, also have visual stage to allow the user drag the relative position information that each node that each sensor node obtains distributes in this locality, in remote visualization, the node of finding directly can be presented at corresponding position like this, the convenient network behavior of observing visually.
Step 503: the user selects to check the data of current network after registration login on the website.After the user sends request, provide the ActiveX control of visual service to download in the subscriber's main station automatically.ActiveX control at first connects the database on the remote server, and is in service if current network is in, and then regularly reads the operation information of current network from database.Mainly be to read each sensing data bag that receives, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag.
Step 504: the source address field by the sensing data bag is found the sensor node that exists in the network, and the node of finding is presented in the node distribution view with a bead.After a period of time, most of or whole nodes all have been found that.After the user dragged node in local view, node distribution information can be deposited in the database.Long-range ACTIVEX control can regularly read these distributed intelligences, and is mapped in the middle of the view of control.
Step 505: by each node ID number on the transmission path of the sensing data bag that obtains, with the coordinate of these nodes on view is that the datum mark drafting fits curve, the source node that simultaneously highlighted demonstration sensing data bag sends, and, come the process of transmitting of visual sensing data bag with this with the destination node that arrow points sensing data bag sends.
Step 506: sensing data visual, then use the curve relevant to represent with time shaft, can so that observe sensing data in time fluctuation change.
Realize in the process of remote visualization in above-mentioned steps 503 to 506, at first provide remote access function by means of server software apache, then utilize PHP to realize a WEB interface, in the mysql database, set up a subscriber's meter, be used for the user's of authentication-access website legitimacy.Then with visual function package in ActiveX control the inside, and the INF file of making control correspondence (being used on visit this website user's machine, control being installed), control and needed dynamic link library file are packaged into CAB form (compression control file, reduce because the time-delay that transmission causes), in the html web page file, call.When the user uses the visual service of WEB browse request, can download the CAB file automatically and point out also whether this control is installed, just can observe effect of visualization after installing.
Remote visualization also provides three functions: node distribution view, real-time curve view, initial data view.Performing step is with local visual approximate substantially.For we must know the node distribution situation in the long-range behavior of observing network easily, so the relative coordinate information that also need distribute by the node of preserving in the database herein.Because the space on the WEB page is smaller relatively, nor may be corresponding one by one with the visual view in this locality, so also must carry out some conversions herein to coordinate.Transfer process is as follows:
database=ylocal*localWidth+xlocal;
XWeb=((float)(database%localWidth)/localWidth)*webWidth;
YWeb=((float)(database/localWidth)/localHeight)*webWidth;
Database is illustrated in the coordinate figure in the database, type is an integer, xlocal and ylocal are corresponding x, the y coordinate of node in local view, xWeb and yWeb x, y coordinate in the WEB control, showing through corresponding node after converting, localWidth and localHeight are the width and the height of local view, and webWidth and webHeight are width and the height of control on the page.
Show when the sensing data bag sends situation, the sensing data bag of reading from database is carried out buffer memory, so just can reproduce the active procedure of whole network basically.In curve plotting,, then only from database, take out up-to-date sensing data of each node and demonstration in order to guarantee real-time.When in addition might the user asking the real-time visual service, may store a large amount of historical datas in the database, visual these historical datas can expend a large amount of time, and can not react the situation of current network.So in first time during accessing database, generally only get and read the some groups of data of collecting recently, be generally 15 groups of data.
Embodiment three
In the present embodiment, be visualized as example to realize the long-range historical data of wireless sensor network, how set forth playback history data, reproducing network is the active situation of certain period in the past.Before playback history data, should store in the database and test collected historical data.Further specify realization visual detailed method of the long-range historical data of wireless sensor network and step below in conjunction with accompanying drawing.
As shown in Figure 6, Fig. 6 realizes the long-range historical data visualization method of wireless sensor network flow chart according to third embodiment of the invention, and this method may further comprise the steps:
Step 601: the user registers providing on the website of visual service, after checking, just can arrive and login the website that visual service is provided.
Step 602: the historical data that selection will be checked from the historical data tabulation.After the user sends request, provide the ActiveX control of visual service to download in the subscriber's main station automatically.
Step 603:ActiveX control at first connects the database on the remote server, regularly from the database corresponding, read the sensing data bag of some, extract each node ID number and sensing data on the source address field, sensing data packet transmission path of each sensing data bag with the historical data selected the step 602.
Step 604: the source address field by the sensing data bag is found the sensor node that exists in the network, and the node of finding is presented in the node distribution view with a bead.After a period of time, most of or whole nodes all have been found that.After the user dragged node in local view, node distribution information can be deposited in the database.Long-range ACTIVEX control can regularly read these distributed intelligences, and is mapped in the middle of the view of control.
Step 605: by each node ID number on the transmission path of the sensing data bag that obtains, with the coordinate of these nodes on view is that the datum mark drafting fits curve, the source node that simultaneously highlighted demonstration sensing data bag sends, and, come the process of transmitting of visual sensing data bag with this with the destination node that arrow points sensing data bag sends.
Step 606: sensing data visual, then use the curve relevant to represent with time shaft, can so that observe sensing data in time fluctuation change.
Above-described specific embodiment; purpose of the present invention, technical scheme and beneficial effect are further described; institute is understood that; the above only is specific embodiments of the invention; be not limited to the present invention; within the spirit and principles in the present invention all, any modification of being made, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.