this._super(options, element);
this.elmt().on('show', this, this.on_show);
-
+
+ var query = manifold.query_store.find_analyzed_query(options.query_uuid);
this.method = query.object;
+ this.key = manifold.metadata.get_key(this.method);
/* Setup query and record handlers */
this.listen_query(options.query_uuid);
this.listen_query(options.query_all_uuid, 'all');
-
- /* GUI setup and event binding */
- this.initialize_map();
- },
-
- initialize_map: function() {
- this.nodes = [];
- this.id = 0;
- init();
- },
-
- refresh: function() {
- console.log("refresh");
- myrender();
+
+ this.sites = [];
+ this.nodes = {};
},
on_show: function(e) {
e.data.refresh();
},
- on_all_new_record: function(n) {
- // format is : [name, x, y, z, uid, state]
- // state = "Busy", "Alive" or "Suspected"
- if (n.x == null || n.y == null || n.z == null) {
- console.log("Warning: no coord for " + n.hrn);
- return;
+ on_all_new_record: function(node) {
+ Senslab.normalize(node);
+ if (node.normalized) {
+ var site = node.site;
+ if ($.inArray(site, this.sites) == -1) {
+ this.sites.push(site);
+ this.nodes[site] = [];
+ }
+ this.nodes[site].push(node);
+ } else {
+// xxx would need a smarter way to report these only on nodes that deserve it
+// these messages are all over the place in a PL setup and tend to hide helpful signal
+// console.warn("node has no site:");
+// console.warn(node);
}
- this.id++;
- node = [this.id, n.x, n.y, n.z, this.id, n.boot_state];
- this.nodes.push(node);
},
on_all_query_done: function() {
- drawNodes(this.nodes);
- parseNodebox();
+ var self = this;
+
+ Senslab.createMaps($('#maps-container'), this.sites, this.nodes);
+ Senslab.notify = function(node) {
+ manifold.raise_event(self.options.query_uuid,
+ node.boot_state == "Alive" ? SET_REMOVED : SET_ADD,
+ node[self.key]
+ );
+ }
}
});
$.plugin('SensLabMap', SensLabMap);