diff --git a/software/openvisualizer/bin/openVisualizerApp/openVisualizerWeb.py b/software/openvisualizer/bin/openVisualizerApp/openVisualizerWeb.py index 8e5e24315..67278640e 100644 --- a/software/openvisualizer/bin/openVisualizerApp/openVisualizerWeb.py +++ b/software/openvisualizer/bin/openVisualizerApp/openVisualizerWeb.py @@ -42,6 +42,8 @@ from pydispatch import dispatcher +from time import sleep + class OpenVisualizerWeb(eventBusClient.eventBusClient): ''' Provides web UI for OpenVisualizer. Runs as a webapp in a Bottle web @@ -99,6 +101,7 @@ def _defineRoutes(self): self.websrv.route(path='/topology/connections', method='POST', callback=self._topologyConnectionsUpdate) self.websrv.route(path='/topology/connections', method='DELETE',callback=self._topologyConnectionsDelete) self.websrv.route(path='/topology/route', method='GET', callback=self._topologyRouteRetrieve) + self.websrv.route(path='/topology/neighbor', method='GET', callback=self._topologyNeighborRetrieve) self.websrv.route(path='/static/', callback=self._serverStatic) @view('moteview.tmpl') @@ -318,7 +321,26 @@ def _topologyRouteRetrieve(self): } return data - + + def _topologyNeighborRetrieve(self): + + data = bottle.request.query + + assert data.keys()==['mote'] + moteid = "%04d" % int(data['mote']) + + ms = self.app.getMoteState(moteid) + neighbors = json.loads(ms.getStateElem(ms.ST_NEIGHBORS).toJson('data')) + + #This is probably not a good idea! to convert ip to id like this + neighbors = [int(n['addr'][21:23]) for n in neighbors if n['stableNeighbor'] != 0] + + data = { + 'neighbors' : neighbors, + 'mote' : data['mote'], + } + return data + def _getEventData(self): response = { 'isDebugPkts' : 'true' if self.app.eventBusMonitor.wiresharkDebugEnabled else 'false', @@ -382,18 +404,29 @@ def _addParserArgs(parser): } ) webthread.start() - #===== add a cli (minimal) interface banner = [] banner += ['OpenVisualizer'] + + if (app.simulatorMode == True): + sleep(3) #Give me a moment to load! + webapp._toggleRoot('0002') + banner += ["Mote 2 was toggled to be as DAGroot."] + + webapp._setWiresharkDebug('true') + banner += ["Wireshark debug was enabled by default"] + + webapp._setGologicDebug("true") + banner += ["Logic Analizer debug was enabled by default"] + banner += ['web interface started at {0}:{1}'.format(argspace.host,argspace.port)] banner += ['enter \'q\' to exit'] banner = '\n'.join(banner) print banner - + while True: input = raw_input('> ') if input=='q': print 'bye bye.' - os.kill(os.getpid(), signal.SIGTERM) \ No newline at end of file + os.kill(os.getpid(), signal.SIGTERM) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/topology.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/topology.tmpl index 7521d06e4..20d344ac0 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/topology.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/topology.tmpl @@ -86,7 +86,17 @@ } ) - + + //neighborStar + neighborStar = new google.maps.Polyline( + { + geodesic: true, + strokeOpacity: 0.8, + strokeWeight: 4, + strokeColor: '#9900bb' + + } + ) // load mote data getTopologyData(); } @@ -172,6 +182,11 @@ 'mouseout', hideRoute ); + google.maps.event.addListener( + motes[id].marker, + 'mouseout', + hideNeighbor + ); attachMouseoverMarker(id); attachRightClickCreateConnection(id); } @@ -289,6 +304,7 @@ 'mouseover', function(event){ getRoute(id); + getNeighbors(id); } ); } @@ -402,10 +418,51 @@ routeLine.setPath(routePath); routeLine.setMap(map); } + + function getNeighbors(id){ + $.ajax({ + type: "GET", + url: "/topology/neighbor", + data: { + 'mote': id, + }, + success: handleNeighbor, + }) + .fail(function() { + console.log("ERROR: could not GET route from server."); + }) + } + + function handleNeighbor(neighborData){ + + var neighborStarPath = []; + + for (i=0; i - \ No newline at end of file +