2015-05-13 16:42:35 -07:00
|
|
|
/*****************************************************************************
|
2016-07-12 16:21:58 -07:00
|
|
|
* Open MCT, Copyright (c) 2014-2016, United States Government
|
2015-05-13 16:42:35 -07:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
2016-07-12 16:21:58 -07:00
|
|
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
2015-05-13 16:42:35 -07:00
|
|
|
* "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.
|
|
|
|
*
|
2016-07-12 16:21:58 -07:00
|
|
|
* Open MCT includes source code licensed under additional open source
|
2015-05-13 16:42:35 -07:00
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
2014-12-29 13:57:20 -08:00
|
|
|
|
|
|
|
define(
|
2014-12-30 13:27:28 -08:00
|
|
|
["./TelemetrySubscription"],
|
|
|
|
function (TelemetrySubscription) {
|
2014-12-29 13:57:20 -08:00
|
|
|
|
2014-12-30 17:54:54 -08:00
|
|
|
/**
|
|
|
|
* The TelemetrySubscriber is a service which allows
|
|
|
|
* subscriptions to be made for new data associated with
|
|
|
|
* domain objects. It is exposed as a service named
|
|
|
|
* `telemetrySubscriber`.
|
|
|
|
*
|
|
|
|
* Subscriptions may also be made directly using the
|
|
|
|
* `telemetry` capability of a domain objcet; the subscriber
|
|
|
|
* uses this as well, but additionally handles delegation
|
|
|
|
* (e.g. for telemetry panels) as well as latest-value
|
|
|
|
* extraction.
|
|
|
|
*
|
2015-08-07 11:44:54 -07:00
|
|
|
* @memberof platform/telemetry
|
2014-12-30 17:54:54 -08:00
|
|
|
* @constructor
|
|
|
|
* @param $q Angular's $q
|
|
|
|
* @param $timeout Angular's $timeout
|
|
|
|
*/
|
2014-12-30 13:27:28 -08:00
|
|
|
function TelemetrySubscriber($q, $timeout) {
|
2015-08-14 16:47:20 -07:00
|
|
|
this.$q = $q;
|
|
|
|
this.$timeout = $timeout;
|
2014-12-29 13:57:20 -08:00
|
|
|
}
|
|
|
|
|
2015-08-14 16:47:20 -07:00
|
|
|
/**
|
|
|
|
* Subscribe to streaming telemetry updates
|
|
|
|
* associated with this domain object (either
|
|
|
|
* directly or via capability delegation.)
|
|
|
|
*
|
|
|
|
* @param {DomainObject} domainObject the object whose
|
|
|
|
* associated telemetry data is of interest
|
|
|
|
* @param {Function} callback a function to invoke
|
|
|
|
* when new data has become available.
|
|
|
|
* @param {boolean} lossless flag to indicate whether the
|
|
|
|
* callback should be notified for all values
|
|
|
|
* (otherwise, multiple values in quick succession
|
|
|
|
* will call back with only the latest value.)
|
|
|
|
* @returns {platform/telemetry.TelemetrySubscription} the
|
|
|
|
* subscription, which will provide access to latest values.
|
|
|
|
*/
|
|
|
|
TelemetrySubscriber.prototype.subscribe = function (domainObject, callback, lossless) {
|
|
|
|
return new TelemetrySubscription(
|
|
|
|
this.$q,
|
|
|
|
this.$timeout,
|
|
|
|
domainObject,
|
|
|
|
callback,
|
|
|
|
lossless
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2014-12-29 13:57:20 -08:00
|
|
|
return TelemetrySubscriber;
|
|
|
|
}
|
2015-08-07 11:44:54 -07:00
|
|
|
);
|