Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing neighbors in topology page, Mote 2 is set as DAGroot and Wireshark debug is enabled by default. #84

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions software/openvisualizer/bin/openVisualizerApp/openVisualizerWeb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/<filepath:path>', callback=self._serverStatic)

@view('moteview.tmpl')
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't agree with setting mote 2 as DAGroot. What if you have only one node? In general, I believe the convention "mote 1" is DAGroot is a bit clearer, no?

banner += ["Mote 2 was toggled to be as DAGroot."]

webapp._setWiresharkDebug('true')
banner += ["Wireshark debug was enabled by default"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very indirect way of enabling Wireshark debug. Why no simply changing the following line

self.wiresharkDebugEnabled     = False

In evenBusMonitor.py?


webapp._setGologicDebug("true")
banner += ["Logic Analizer debug was enabled by default"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I totally agree that having Wireshark debug on by default makes sense, the GoLogic trace generator is very very heavy (and not as used as Wireshark), so I would recommend to remove these lines altogether. Thoughts?


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)
os.kill(os.getpid(), signal.SIGTERM)
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@

}
)


//neighborStar
neighborStar = new google.maps.Polyline(
{
geodesic: true,
strokeOpacity: 0.8,
strokeWeight: 4,
strokeColor: '#9900bb'

}
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

// load mote data
getTopologyData();
}
Expand Down Expand Up @@ -172,6 +182,11 @@
'mouseout',
hideRoute
);
google.maps.event.addListener(
motes[id].marker,
'mouseout',
hideNeighbor
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please check your indentaton? In particular, please don't introduce any tabs anywhere. We use 4 spaces indentation everywhere.

attachMouseoverMarker(id);
attachRightClickCreateConnection(id);
}
Expand Down Expand Up @@ -289,6 +304,7 @@
'mouseover',
function(event){
getRoute(id);
getNeighbors(id);
}
);
}
Expand Down Expand Up @@ -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<neighborData.neighbors.length; i++) {
neighborStarPath.push(
new google.maps.LatLng(
motes[neighborData.mote].lat,
motes[neighborData.mote].lon
)
)
neighborStarPath.push(
new google.maps.LatLng(
motes[neighborData.neighbors[i]].lat,
motes[neighborData.neighbors[i]].lon
)
)
}

neighborStar.setPath(neighborStarPath);
neighborStar.setMap(map);
}

function hideRoute() {
routeLine.setMap(null);
}

function hideNeighbor() {
neighborStar.setMap(null);
}

function connectionCreationStep(id) {

Expand Down Expand Up @@ -625,4 +682,4 @@
</div>
</div>
</body>
</html>
</html>