Compare commits

...

5 Commits

Author SHA1 Message Date
Victor Woeltjen
a6c1660c02 [Data Products] Specify glyph in example 2016-05-20 15:45:47 -07:00
Victor Woeltjen
2753fc2069 [Data Products] Provide locations in example 2016-05-20 15:44:30 -07:00
Victor Woeltjen
9a7eda1b6c [Data Products] Provide MSL image telemetry 2016-05-20 15:43:04 -07:00
Victor Woeltjen
a69793b98c [Data Products] Provide models for example data products 2016-05-20 15:10:20 -07:00
Victor Woeltjen
d9990a7878 [Data Products] Add example bundle
Add example bundle which will contain telemetry sources providing
data products. #947
2016-05-20 14:56:40 -07:00
2 changed files with 191 additions and 1 deletions

189
example/products/bundle.js Normal file
View File

@@ -0,0 +1,189 @@
/*****************************************************************************
* Open MCT Web, Copyright (c) 2014-2015, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT Web includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
/*global define */
define ([
'legacyRegistry'
], function (legacyRegistry) {
var ROOT_ID = "msl:images",
TYPE = "msl.image",
PREFIX = "msl-images:",
SOURCE = "msl-images",
CAMERAS = {
fhaz: "Front Hazard Avoidance Camera",
rhaz: "Rear Hazard Avoidance Camera",
mast: "Mast Camera",
chemcam: "Chemistry and Camera Complex",
mahli: "Mars Hand Lens Imager",
mardi: "Mars Descent Imager",
navcam: "Navigation Camera"
};
function MSLImageModelProvider($q) {
this.$q = $q;
}
MSLImageModelProvider.prototype.getModels = function (ids) {
function modelFor(cam) {
return {
type: TYPE,
name: CAMERAS[cam],
location: ROOT_ID,
telemetry: { key: cam }
};
}
ids = ids.filter(function (id) {
return id.indexOf(PREFIX) === 0;
});
return this.$q.when(ids.reduce(function (result, id) {
var cam = id.split(":")[1];
result[id] = modelFor(cam);
return result;
}, {}));
};
function MSLImageTelemetrySeries(photos) {
this.photos = photos;
}
MSLImageTelemetrySeries.prototype.getPointCount = function () {
return this.photos.length;
};
MSLImageTelemetrySeries.prototype.getDomainValue = function (i, key) {
return new Date(this.photos[i][key || 'earth_date']).valueOf();
};
MSLImageTelemetrySeries.prototype.getRangeValue = function (i, key) {
return this.photos[i][key || 'img_src'];
};
function MSLImageTelemetryProvider($q, $http) {
this.$q = $q;
this.$http = $http;
}
MSLImageTelemetryProvider.prototype.subscribe = function () {
return function () {};
};
MSLImageTelemetryProvider.prototype.requestTelemetry = function (requests) {
var $http = this.$http;
function issueRequest(request) {
var cam = request.key;
var url =
"https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&camera=" +
cam +
"&api_key=DEMO_KEY";
return $http.get(url).then(function (result) {
return new MSLImageTelemetrySeries(result.data.photos);
});
}
function packageResponse(seriesArray) {
var result = {};
result[SOURCE] =
seriesArray.reduce(function (packaged, series, index) {
packaged[requests[index].key] = series;
return packaged;
}, {});
return result;
}
requests = requests.filter(function (request) {
return request.source === SOURCE;
});
return this.$q.all(requests.map(issueRequest)).then(packageResponse);
};
legacyRegistry.register("example/products", {
"extensions": {
"roots": [
{
"id": ROOT_ID,
"priority" : "preferred",
"model": {
"type": "folder",
"name": "Mars Science Laboratory Images",
"composition": Object.keys(CAMERAS).map(function (cam) {
return PREFIX + cam;
})
}
}
],
"components": [
{
"type": "provider",
"provides": "modelService",
"implementation": MSLImageModelProvider,
"depends": ["$q"]
},
{
"type": "provider",
"provides": "telemetryService",
"implementation": MSLImageTelemetryProvider,
"depends": ["$q", "$http"]
}
],
"types": [
{
"key": TYPE,
"name": "MSL Image",
"description": "Images from Curiosity",
"glyph": "T",
"telemetry": {
"source": SOURCE,
"domains": [
{
"key": "earth_date",
"name": "Earth date",
"format": "utc"
}
],
"ranges": [
{
"key": "id",
"name": "ID",
"format": "number"
},
{
"key": "img_src",
"name": "Image",
"format": "url"
}
]
}
}
]
}
});
});

View File

@@ -33,7 +33,8 @@
require([
'./example/imagery/bundle',
'./example/eventGenerator/bundle',
'./example/generator/bundle'
'./example/generator/bundle',
'./example/products/bundle'
], mct.run.bind(mct));
});
</script>