mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 06:03:08 +00:00
Initial working version
This commit is contained in:
parent
1fcf900271
commit
0538d6e60f
@ -34,31 +34,31 @@ define(
|
|||||||
"measurements": [
|
"measurements": [
|
||||||
{
|
{
|
||||||
"name": "Min. Air Temperature",
|
"name": "Min. Air Temperature",
|
||||||
"identifier": "rems.min_temp",
|
"identifier": "min_temp",
|
||||||
"units": "degrees",
|
"units": "degrees",
|
||||||
"type": "float"
|
"type": "float"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Max. Air Temperature",
|
"name": "Max. Air Temperature",
|
||||||
"identifier": "rems.max_temp",
|
"identifier": "max_temp",
|
||||||
"units": "degrees",
|
"units": "degrees",
|
||||||
"type": "float"
|
"type": "float"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Atmospheric Pressure",
|
"name": "Atmospheric Pressure",
|
||||||
"identifier": "rems.pressure",
|
"identifier": "pressure",
|
||||||
"units": "pascals",
|
"units": "pascals",
|
||||||
"type": "float"
|
"type": "float"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Min. Ground Temperature",
|
"name": "Min. Ground Temperature",
|
||||||
"identifier": "rems.min_gts_temp",
|
"identifier": "min_gts_temp",
|
||||||
"units": "degrees",
|
"units": "degrees",
|
||||||
"type": "float"
|
"type": "float"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Max. Ground Temperature",
|
"name": "Max. Ground Temperature",
|
||||||
"identifier": "rems.max_gts_temp",
|
"identifier": "max_gts_temp",
|
||||||
"units": "degrees",
|
"units": "degrees",
|
||||||
"type": "float"
|
"type": "float"
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ define (
|
|||||||
|
|
||||||
function addToPackage(history) {
|
function addToPackage(history) {
|
||||||
packaged[SOURCE][history.id] =
|
packaged[SOURCE][history.id] =
|
||||||
new RemsTelemetrySeries(history.value);
|
new RemsTelemetrySeries(history.values);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRequest(request) {
|
function handleRequest(request) {
|
||||||
|
@ -27,8 +27,7 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var TERRESTRIAL_DATE = "terrestrial_date",
|
var TERRESTRIAL_DATE = "terrestrial_date",
|
||||||
NO_DATA = "--",
|
NO_DATA = "--";
|
||||||
PREFIX = "rems.";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For now just returns a hard-coded data dictionary, but in future
|
* For now just returns a hard-coded data dictionary, but in future
|
||||||
@ -37,31 +36,37 @@ define(
|
|||||||
*/
|
*/
|
||||||
function RemsTelemetryServerAdapter($q, $http, REMS_WS_URL){
|
function RemsTelemetryServerAdapter($q, $http, REMS_WS_URL){
|
||||||
var histories = {},
|
var histories = {},
|
||||||
deferred;
|
deferreds = {};
|
||||||
function requestHistory (id) {
|
function requestHistory (id) {
|
||||||
$http.get(REMS_WS_URL).then(
|
$http.get(REMS_WS_URL).then(
|
||||||
function(response){
|
function(response){
|
||||||
/**
|
/**
|
||||||
* All history is fetched in one go, cache it all to save round trips to the server on subsequent requests
|
* All history is fetched in one go, cache it all to save round trips to the server on subsequent requests
|
||||||
*/
|
*/
|
||||||
|
var lastGoodValue=0;
|
||||||
response.data.soles.forEach(function(solData){
|
response.data.soles.forEach(function(solData){
|
||||||
for (var prop in solData){
|
for (var prop in solData){
|
||||||
var propName = PREFIX + prop;
|
histories[prop] = histories[prop] || [];
|
||||||
histories[propName] = histories[propName] || [];
|
var value = isNaN(solData[prop]) ? lastGoodValue : (lastGoodValue = solData[prop]);
|
||||||
histories[propName].push({date: Date.parse(solData[TERRESTRIAL_DATE]), value: solData[prop]=== NO_DATA ? undefined : solData[prop]});
|
histories[prop].unshift({date: Date.parse(solData[TERRESTRIAL_DATE]), value: value});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
deferred.resolve(histories[id]);
|
|
||||||
|
deferreds[id].resolve({id: id, values: histories[id]});
|
||||||
}, function (error){
|
}, function (error){
|
||||||
deferred.reject(error);
|
deferreds[id].reject(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
dictionary: RemsDataDictionary,
|
dictionary: RemsDataDictionary,
|
||||||
history: function(id) {
|
history: function(id) {
|
||||||
deferred = deferred || $q.defer();
|
deferreds[id] = deferreds[id] || $q.defer();
|
||||||
requestHistory(id);
|
if (histories[id]) {
|
||||||
return deferred.promise;
|
deferreds[id].resolve({id: id, values: histories[id]});
|
||||||
|
} else {
|
||||||
|
requestHistory(id);
|
||||||
|
}
|
||||||
|
return deferreds[id].promise;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user