Added telemetry request ID prefix

This commit is contained in:
Andrew Henry 2015-10-12 10:41:21 -07:00
parent 183468fcbf
commit 1fcf900271
4 changed files with 41 additions and 12 deletions

View File

@ -19,7 +19,7 @@
"glyph": "T",
"model": {"telemetry": {}},
"telemetry": {
"source": "msl.source",
"source": "rems.source",
"domains": [
{
"name": "Time",
@ -29,6 +29,12 @@
}
}
],
"constants": [
{
"key": "REMS_WS_URL",
"value": "http://cab.inta-csic.es/rems/wp-content/plugins/marsweather-widget/api.php"
}
],
"roots": [
{
"id": "msl:curiosity",
@ -44,7 +50,7 @@
{
"key":"rems.adapter",
"implementation": "RemsTelemetryServerAdapter.js",
"depends": ["$q", "$http"]
"depends": ["$q", "$http", "REMS_WS_URL"]
}
],
"runs": [

View File

@ -39,7 +39,7 @@ define(
"type": "float"
},
{
"name": "Max. Air Temperatyre",
"name": "Max. Air Temperature",
"identifier": "rems.max_temp",
"units": "degrees",
"type": "float"

View File

@ -27,13 +27,13 @@ define(
function RemsTelemetrySeries(data) {
return {
getPointCount: function(){
return 100;
return data.length;
},
getDomainValue: function(index) {
return index + 45 * 365 * 24 * 60 * 60 * 1000;
return data[index].date;
},
getRangeValue: function(index){
return index * 10;
return data[index].value;
}
}
}

View File

@ -25,20 +25,43 @@ define(
["./RemsDataDictionary"],
function (RemsDataDictionary) {
"use strict";
var TERRESTRIAL_DATE = "terrestrial_date",
NO_DATA = "--",
PREFIX = "rems.";
/**
* For now just returns a hard-coded data dictionary, but in future
* could be adapted to provide data from remote source.
* @constructor
*/
function RemsTelemetryServerAdapter($q, $http){
var histories = {};
function RemsTelemetryServerAdapter($q, $http, REMS_WS_URL){
var histories = {},
deferred;
function requestHistory (id) {
$http.get(REMS_WS_URL).then(
function(response){
/**
* All history is fetched in one go, cache it all to save round trips to the server on subsequent requests
*/
response.data.soles.forEach(function(solData){
for (var prop in solData){
var propName = PREFIX + prop;
histories[propName] = histories[propName] || [];
histories[propName].push({date: Date.parse(solData[TERRESTRIAL_DATE]), value: solData[prop]=== NO_DATA ? undefined : solData[prop]});
}
});
deferred.resolve(histories[id]);
}, function (error){
deferred.reject(error);
});
}
return {
dictionary: RemsDataDictionary,
history: function(id) {
histories[id] = histories[id] || $q.defer();
return histories[id].promise;
deferred = deferred || $q.defer();
requestHistory(id);
return deferred.promise;
}
};
}