From a4eb9d6a94d8884163f848dda18103b14228fede Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 8 Mar 2016 13:29:16 -0800 Subject: [PATCH] [Tables] #707 Supporting realtime telemetry tables Added real-time table type --- .../src/EventTelemetryProvider.js | 8 +- platform/features/table/bundle.js | 37 ++++++-- .../table/res/templates/rt-table.html | 2 +- .../src/controllers/MCTTableController.js | 95 ++++++++++--------- ...oller.js => RTTelemetryTableController.js} | 17 ++-- .../controllers/TelemetryTableController.js | 4 +- 6 files changed, 94 insertions(+), 69 deletions(-) rename platform/features/table/src/controllers/{RTTableController.js => RTTelemetryTableController.js} (86%) diff --git a/example/eventGenerator/src/EventTelemetryProvider.js b/example/eventGenerator/src/EventTelemetryProvider.js index d014d95958..79bdec0c40 100644 --- a/example/eventGenerator/src/EventTelemetryProvider.js +++ b/example/eventGenerator/src/EventTelemetryProvider.js @@ -36,8 +36,7 @@ define( function EventTelemetryProvider($q, $timeout) { var subscriptions = [], - genInterval = 1000, - startTime = Date.now(); + genInterval = 1000; // function matchesSource(request) { @@ -80,7 +79,6 @@ define( function startGenerating() { $timeout(function () { - //console.log("startGenerating... " + Date.now()); handleSubscriptions(); if (subscriptions.length > 0) { startGenerating(); @@ -93,7 +91,8 @@ define( callback: callback, requests: requests }; - + console.log("subscribe... " + Date.now() / 1000 + " request:" + + " " + requests[0].id); function unsubscribe() { subscriptions = subscriptions.filter(function (s) { return s !== subscription; @@ -101,7 +100,6 @@ define( } subscriptions.push(subscription); - if (subscriptions.length === 1) { startGenerating(); } diff --git a/platform/features/table/bundle.js b/platform/features/table/bundle.js index 52a6211d9b..1ee305ac2d 100644 --- a/platform/features/table/bundle.js +++ b/platform/features/table/bundle.js @@ -23,7 +23,7 @@ define([ "./src/directives/MCTTable", - "./src/controllers/RTTableController", + "./src/controllers/RTTelemetryTableController", "./src/controllers/TelemetryTableController", "./src/controllers/TableOptionsController", '../../commonUI/regions/src/Region', @@ -31,8 +31,8 @@ define([ "legacyRegistry" ], function ( MCTTable, + RTTelemetryTableController, TelemetryTableController, - RTTableController, TableOptionsController, Region, InspectorRegion, @@ -61,7 +61,7 @@ define([ "types": [ { "key": "table", - "name": "Table", + "name": "Historical Telemetry Table", "glyph": "\ue605", "description": "A table for displaying telemetry data", "features": "creation", @@ -80,6 +80,29 @@ define([ "views": [ "table" ] + }, + { + "key": "rttable", + "name": "Real-time Telemetry Table", + "glyph": "\ue605", + "description": "A table for displaying realtime telemetry" + + " data", + "features": "creation", + "delegates": [ + "telemetry" + ], + "inspector": tableInspector, + "contains": [ + { + "has": "telemetry" + } + ], + "model": { + "composition": [] + }, + "views": [ + "realtime" + ] } ], "controllers": [ @@ -89,8 +112,8 @@ define([ "depends": ["$scope", "telemetryHandler", "telemetryFormatter"] }, { - "key": "RTTableController", - "implementation": RTTableController, + "key": "RTTelemetryTableController", + "implementation": RTTelemetryTableController, "depends": ["$scope", "telemetryHandler", "telemetryFormatter"] }, { @@ -102,7 +125,7 @@ define([ ], "views": [ { - "name": "Table", + "name": "Historical Table", "key": "table", "glyph": "\ue605", "templateUrl": "templates/table.html", @@ -113,7 +136,7 @@ define([ "editable": true }, { - "name": "Scrolling", + "name": "Real-time Table", "key": "realtime", "glyph": "\ue605", "templateUrl": "templates/rt-table.html", diff --git a/platform/features/table/res/templates/rt-table.html b/platform/features/table/res/templates/rt-table.html index 7ce0070200..599dc3fe8a 100644 --- a/platform/features/table/res/templates/rt-table.html +++ b/platform/features/table/res/templates/rt-table.html @@ -1,4 +1,4 @@ -
+
= this.$scope.displayRows.length) { + end = this.$scope.displayRows.length - 1; + start = end - this.maxDisplayRows + 1; + } + if (this.$scope.visibleRows[0].rowIndex === start && + this.$scope.visibleRows[this.$scope.visibleRows.length - 1] + .rowIndex === end) { + + return; // don't update if no changes are required. + } } - lastVisible = Math.ceil( - (bottomScroll - this.$scope.headerHeight) / this.$scope.rowHeight - ); - - totalVisible = lastVisible - firstVisible; - numberOffscreen = this.maxDisplayRows - totalVisible; - start = firstVisible - Math.floor(numberOffscreen / 2); - end = lastVisible + Math.ceil(numberOffscreen / 2); - - if (start < 0) { - start = 0; - end = this.$scope.visibleRows.length - 1; - } else if (end >= this.$scope.displayRows.length) { - end = this.$scope.displayRows.length - 1; - start = end - this.maxDisplayRows + 1; - } - if (this.$scope.visibleRows[0].rowIndex === start && - this.$scope.visibleRows[this.$scope.visibleRows.length-1] - .rowIndex === end) { - - return; // don't update if no changes are required. - } - + //Set visible rows from display rows, based on calculated offset. this.$scope.visibleRows = this.$scope.displayRows.slice(start, end) .map(function(row, i) { return { @@ -176,16 +188,7 @@ define( this.$scope.headerHeight = headerHeight; this.$scope.rowHeight = rowHeight; this.$scope.totalHeight = overallHeight; - - this.$scope.visibleRows = this.$scope.displayRows.slice(0, this.maxDisplayRows).map(function(row, i) { - return { - rowIndex: i, - offsetY: (i * self.$scope.rowHeight) + self.$scope.headerHeight, - contents: row - }; - }); - - this.onScroll(); + this.setVisibleRows(); this.$scope.overrideRowPositioning = true; }; @@ -316,13 +319,13 @@ define( * will be sorted before display. */ MCTTableController.prototype.updateRows = function (newRows) { - console.log('updateRows'); this.$scope.visibleRows = []; this.$scope.overrideRowPositioning = false; if (!this.$scope.displayHeaders) { return; } + this.filterAndSort(newRows || []); this.resize(); }; diff --git a/platform/features/table/src/controllers/RTTableController.js b/platform/features/table/src/controllers/RTTelemetryTableController.js similarity index 86% rename from platform/features/table/src/controllers/RTTableController.js rename to platform/features/table/src/controllers/RTTelemetryTableController.js index 7ad2132c81..4b5c0ac5ae 100644 --- a/platform/features/table/src/controllers/RTTableController.js +++ b/platform/features/table/src/controllers/RTTelemetryTableController.js @@ -27,8 +27,8 @@ */ define( [ - './TableController', - '../Table', + './TelemetryTableController', + '../TableConfiguration', '../NameColumn' ], function (TableController, Table, NameColumn) { @@ -44,16 +44,17 @@ define( * @param telemetryFormatter * @constructor */ - function RTTableController($scope, telemetryHandler, telemetryFormatter) { + function RTTelemetryTableController($scope, telemetryHandler, telemetryFormatter) { TableController.call(this, $scope, telemetryHandler, telemetryFormatter); } - RTTableController.prototype = Object.create(TableController.prototype); + RTTelemetryTableController.prototype = Object.create(TableController.prototype); /** - Create a new subscription. This is called when + Create a new telemetry subscription. */ - RTTableController.prototype.subscribe = function() { + RTTelemetryTableController.prototype.subscribe = function() { + console.trace(); var self = this; if (this.handle) { @@ -90,10 +91,10 @@ define( * be composed of multiple objects) * @param datum The data received from the telemetry source */ - RTTableController.prototype.updateRows = function (object, datum) { + RTTelemetryTableController.prototype.updateRows = function (object, datum) { this.$scope.$broadcast('newRow', this.table.getRowValues(object, datum)); }; - return RTTableController; + return RTTelemetryTableController; } ); diff --git a/platform/features/table/src/controllers/TelemetryTableController.js b/platform/features/table/src/controllers/TelemetryTableController.js index 2b66ee0568..b94cf5b8a9 100644 --- a/platform/features/table/src/controllers/TelemetryTableController.js +++ b/platform/features/table/src/controllers/TelemetryTableController.js @@ -82,7 +82,7 @@ define( this.changeListeners = []; // When composition changes, re-subscribe to the various // telemetry subscriptions - this.changeListeners.push(this.$scope.$watchCollection('domainObject.getModel().composition', this.subscribe.bind(this))); + //this.changeListeners.push(this.$scope.$watchCollection('domainObject.getModel().composition', this.subscribe.bind(this))); //Change of bounds in time conductor this.changeListeners.push(this.$scope.$on('telemetry:display:bounds', this.subscribe.bind(this))); @@ -103,7 +103,7 @@ define( Create a new subscription. This is called when */ TelemetryTableController.prototype.subscribe = function() { - + console.trace(); if (this.handle) { this.handle.unsubscribe(); }