Compare commits

..

15 Commits

Author SHA1 Message Date
57abac96b2 Implement basic plot synchronization 2018-02-24 12:03:38 -08:00
204f6be9d0 [Tests] Exclude plot from coverage requirement
Per discussions about backfilling tests with conversion away from
angular, removing plot plugin from coverage requirement so as to
allow build to complete.

https://github.com/nasa/openmct/pull/1557#issuecomment-364239059
2018-02-19 17:20:35 -08:00
c988c6c43b install plot in openmct instead of mct type 2018-02-19 17:15:00 -08:00
c143475f3e Add and update copyright notices 2018-02-19 17:02:27 -08:00
b248f57daa [ExportImage] Restore 3669e776a9
Restore changes from 3669e776a9,
such that exported image color can be overridden if desired.
2018-02-19 16:46:12 -08:00
f4e8c5ecf6 [Style] make code style compliant 2018-02-19 16:38:15 -08:00
11ef7c0ccd [Frontend] Added missing flex declaration
Fixes #1557
- Fixes disappearing plot chart area when legend is hidden;
2018-02-19 16:38:15 -08:00
9c125e0454 [Frontend] Fixed indiscriminate selector in Style Guide CSS
Fixes #1557
- Was fubaring palette example in Style Guide
2018-02-19 16:38:15 -08:00
439a654f6d [Frontend] More fixes for Sum Widgets and FP
Fixes #1557
- Fixed Palettes in Summary Widgets and Fixed Position
- Renamed .l-inline-color-palette to .l-inline-palette
2018-02-19 16:38:15 -08:00
9d32a3f1c3 [Frontend] Fixed inline palette in plots series config
Fixes #1557
- Brought back missing .inline-color-palette class
- Tweaks in _palette.scss

TODO: fix palettes in Summary Widgets
2018-02-19 16:38:15 -08:00
705e25df8a correct pallette reference 2018-02-19 16:38:15 -08:00
787d6887dc Add LAD support and state type to generators 2018-02-19 16:38:15 -08:00
1d516240a8 Telemetry API Updates 2018-02-19 16:38:15 -08:00
90ee0a309f New Plot
* Remove Old Plot Code
* Remove Telemetry Panel Type
* UTCFormat.parse: passthrough numbers
* TelemetryAPI: default request arguments
* TelemetryAPI: fix enum formatting

pass value instead of trying to create datum
Set max precision to avoid errors
Install plot by default
Make sure plots are always plots
Set default yKey on series
Use new time API
Update hints
proper id formats
Only redraw on change
Set x axis on bounds change

while MCTChart can handle inserting points in the middle of the
chart series, this is not performant with a large insert volume.

So, when merging historical requests with existing data, do a batch
sort and uniq check up front and then reset the data such that MCTChart
only has to do appends.  This is significantly faster than doing
large volumes of inserts.

[CSS] Plot Styles

Moved .view-control out of tree.scss and
generalized as a control prior to implementing
it as the expand/collapse control in plot legends
for #584 and #618.

Major layout changes to enable flex approach for
legend and plot display area; table styling for
expanded legend; legend on top, bottom, right
and left support added but still a bunch to do.

Style and markup normalization for legend elements.

Significant mods to layout in Inspector while
editing, using new .compact-form class;
mod to ul.tree li to allow .compact-form layout
class within tree scope;

Significant layout cleanup, mainly for stacked plots
and expanded legend;
Config options hide/show controls fully ported from
Pete's original version;

New 12px crosshair glyph added;
'hover-value-enabled' markup and class refinements;

Generalized .t-alert-unsynced, moved to _icons.scss;
Moved .t-object-alert to proper location in plot markup;
Added new .t-stacked-plot class;

Moved location of padding for .hover-value-enabled
elements

Minor refactor to use explicit legend-collapsed and -expanded CSS
classes, replacing ng-show statements;
Removed ng-style that was setting column widths based on char
count of column name;

lobal rename of `compact-form` to `inspector-config`;
Applied same to plot-options-browse.html for tree items;

Renamed `plot-legend-on-*` selector;
Fixed layout for plot-legend-hidden, involved
returning `plot-wrapper-axis-and-display-area` to
use position: absolute;

Fixes #584
Fixes #618
Fixes #1590

Fix for renamed view-control classes

Fixes #1795
Also removed .has-children from plot-options html files;

Don't try and recreate datums

Clear highlights when leaving plot

Simplify Plot Series Interface

Update Plot Options to match new Inspectors

Use edit context to support subobject editing
2018-02-19 16:38:15 -08:00
72d05283da Remove Old Plot 2018-02-19 16:37:29 -08:00
111 changed files with 989 additions and 3987 deletions

171
API.md
View File

@ -1,57 +1,3 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**
- [Building Applications With Open MCT](#building-applications-with-open-mct)
- [Scope and purpose of this document](#scope-and-purpose-of-this-document)
- [Building From Source](#building-from-source)
- [Starting an Open MCT application](#starting-an-open-mct-application)
- [Plugins](#plugins)
- [Defining and Installing a New Plugin](#defining-and-installing-a-new-plugin)
- [Domain Objects and Identifiers](#domain-objects-and-identifiers)
- [Object Attributes](#object-attributes)
- [Domain Object Types](#domain-object-types)
- [Root Objects](#root-objects)
- [Object Providers](#object-providers)
- [Composition Providers](#composition-providers)
- [Adding Composition Providers](#adding-composition-providers)
- [Default Composition Provider](#default-composition-provider)
- [Telemetry API](#telemetry-api)
- [Integrating Telemetry Sources](#integrating-telemetry-sources)
- [Telemetry Metadata](#telemetry-metadata)
- [Values](#values)
- [Value Hints](#value-hints)
- [The Time Conductor and Telemetry](#the-time-conductor-and-telemetry)
- [Telemetry Providers](#telemetry-providers)
- [Telemetry Requests and Responses.](#telemetry-requests-and-responses)
- [Request Strategies **draft**](#request-strategies-draft)
- [`latest` request strategy](#latest-request-strategy)
- [`minmax` request strategy](#minmax-request-strategy)
- [Telemetry Formats **draft**](#telemetry-formats-draft)
- [Registering Formats](#registering-formats)
- [Telemetry Data](#telemetry-data)
- [Telemetry Datums](#telemetry-datums)
- [Limit Evaluators **draft**](#limit-evaluators-draft)
- [Telemetry Consumer APIs **draft**](#telemetry-consumer-apis-draft)
- [Time API](#time-api)
- [Time Systems and Bounds](#time-systems-and-bounds)
- [Defining and Registering Time Systems](#defining-and-registering-time-systems)
- [Getting and Setting the Active Time System](#getting-and-setting-the-active-time-system)
- [Time Bounds](#time-bounds)
- [Clocks](#clocks)
- [Defining and registering clocks](#defining-and-registering-clocks)
- [Getting and setting active clock](#getting-and-setting-active-clock)
- [Stopping an active clock](#stopping-an-active-clock)
- [Clock Offsets](#clock-offsets)
- [Time Events](#time-events)
- [List of Time Events](#list-of-time-events)
- [The Time Conductor](#the-time-conductor)
- [Time Conductor Configuration](#time-conductor-configuration)
- [Example conductor configuration](#example-conductor-configuration)
- [Included Plugins](#included-plugins)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
# Building Applications With Open MCT
## Scope and purpose of this document
@ -208,7 +154,7 @@ registry.
eg.
```javascript
openmct.types.addType('example.my-type', {
openmct.types.addType('my-type', {
name: "My Type",
description: "This is a type that I added!",
creatable: true
@ -216,9 +162,8 @@ openmct.types.addType('example.my-type', {
```
The `addType` function accepts two arguments:
* A `string` key identifying the type. This key is used when specifying a type
for an object. We recommend prefixing your types with a namespace to avoid
conflicts with other plugins.
* A `string` key identifying the type. This key is used when specifying a type
for an object.
* An object type specification. An object type definition supports the following
attributes
* `name`: a `string` naming this object type
@ -249,7 +194,7 @@ To do so, use the `addRoot` method of the object API.
eg.
```javascript
openmct.objects.addRoot({
namespace: "example.namespace",
namespace: "my-namespace",
key: "my-key"
});
```
@ -290,12 +235,13 @@ It is expected that the `get` function will return a
[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
that resolves with the object being requested.
In future, object providers will support other methods to enable other operations with persistence stores, such as creating, updating, and deleting objects.
In future, object providers will support other methods to enable other operations
with persistence stores, such as creating, updating, and deleting objects.
## Composition Providers
The _composition_ of a domain object is the list of objects it contains, as
shown (for example) in the tree for browsing. Open MCT provides a
The _composition_ of a domain object is the list of objects it contains, as shown
(for example) in the tree for browsing. Open MCT provides a
[default solution](#default-composition-provider) for composition, but there
may be cases where you want to provide the composition of a certain object
(or type of object) dynamically.
@ -309,7 +255,7 @@ Composition Provider:
```javascript
openmct.composition.addProvider({
appliesTo: function (domainObject) {
return domainObject.type === 'example.my-type';
return domainObject.type === 'my-type';
},
load: function (domainObject) {
return Promise.resolve(myDomainObjects);
@ -327,9 +273,8 @@ These identifiers will be used to fetch Domain Objects from an [Object Provider]
### Default Composition Provider
The default composition provider applies to any domain object with a
`composition` property. The value of `composition` should be an array of
identifiers, e.g.:
The default composition provider applies to any domain object with a `composition`
property. The value of `composition` should be an array of identifiers, e.g.:
```javascript
var domainObject = {
@ -350,17 +295,13 @@ var domainObject = {
## Telemetry API
The Open MCT telemetry API provides two main sets of interfaces-- one for
integrating telemetry data into Open MCT, and another for developing Open MCT
visualization plugins utilizing the telemetry API.
The Open MCT telemetry API provides two main sets of interfaces-- one for integrating telemetry data into Open MCT, and another for developing Open MCT visualization plugins utilizing telemetry API.
The APIs for visualization plugins are still a work in progress and docs may
change at any time. However, the APIs for integrating telemetry metadata into
Open MCT are stable and documentation is included below.
The APIs for visualization plugins are still a work in progress and docs may change at any time. However, the APIs for integrating telemetry metadata into Open MCT are stable and documentation is included below.
### Integrating Telemetry Sources
There are two main tasks for integrating telemetry sources-- describing telemetry objects with relevant metadata, and then providing telemetry data for those objects. You'll use an [Object Provider](#object-providers) to provide objects with the necessary [Telemetry Metadata](#telemetry-metadata), and then register a [Telemetry Provider](#telemetry-providers) to retrieve telemetry data for those objects. Alternatively, you can register a telemetry metadata provider to provide the necessary telemetry metadata.
There are two main tasks for integrating telemetry sources-- describing telemetry objects with relevant metadata, and then providing telemetry data for those objects. You'll use an [Object Provider](#object-providers) to provide objects with the necessary [Telemetry Metadata](#telemetry-metadata), and then register a [Telemetry Provider](#telemetry-providers) to retrieve telemetry data for those objects.
For a step-by-step guide to building a telemetry adapter, please see the
[Open MCT Tutorials](https://github.com/nasa/openmct-tutorial).
@ -414,7 +355,7 @@ attribute | type | flags | notes
--- | --- | --- | ---
`key` | string | required | unique identifier for this field.
`hints` | object | required | Hints allow views to intelligently select relevant attributes for display, and are required for most views to function. See section on "Value Hints" below.
`name` | string | optional | a human readable label for this field. If omitted, defaults to `key`.
`name` | string | optional | a human readible label for this field. If omitted, defaults to `key`.
`source` | string | optional | identifies the property of a datum where this value is stored. If omitted, defaults to `key`.
`format` | string | optional | a specific format identifier, mapping to a formatter. If omitted, uses a default formatter. For enumerations, use `enum`. For timestamps, use `utc` if you are using utc dates, otherwise use a key mapping to your custom date format.
`units` | string | optional | the units of this value, e.g. `km`, `seconds`, `parsecs`
@ -442,18 +383,14 @@ In order for the time conductor to work, there will always be an active "time sy
#### Telemetry Providers
Telemetry providers are responsible for providing historical and real-time telemetry data for telemetry objects. Each telemetry provider determines which objects it can provide telemetry for, and then must implement methods to provide telemetry for those objects.
Telemetry providers are responsible for providing historical and real time telemetry data for telemetry objects. Each telemetry provider determines which objects it can provide telemetry for, and then must implement methods to provide telemetry for those objects.
A telemetry provider is a javascript object with up to four methods:
* `supportsSubscribe(domainObject, callback, options)` optional. Must be implemented to provide realtime telemetry. Should return `true` if the provider supports subscriptions for the given domain object (and request options).
* `subscribe(domainObject, callback, options)` required if `supportsSubscribe` is implemented. Establish a subscription for realtime data for the given domain object. Should invoke `callback` with a single telemetry datum every time data is received. Must return an unsubscribe function. Multiple views can subscribe to the same telemetry object, so it should always return a new unsubscribe function.
* `supportsRequest(domainObject, options)` optional. Must be implemented to provide historical telemetry. Should return `true` if the provider supports historical requests for the given domain object.
* `request(domainObject, options)` required if `supportsRequest` is implemented. Must return a promise for an array of telemetry datums that fulfills the request. The `options` argument will include a `start`, `end`, and `domain` attribute representing the query bounds. See [Telemetry Requests and Responses](#telemetry-requests-and-responses) for more info on how to respond to requests.
* `supportsMetadata(domainObject)` optional. Implement and return `true` for objects that you want to provide dynamic metadata for.
* `getMetadata(domainObject)` required if `supportsMetadata` is implemented. Must return a valid telemetry metadata definition that includes at least one valueMetadata definition.
* `supportsLimits(domainObject)` optional. Implement and return `true` for domain objects that you want to provide a limit evaluator for.
* `getLimitEvaluator(domainObject)` required if `supportsLimits` is implemented. Must return a valid LimitEvaluator for a given domain object.
* `request(domainObject, options)` required if `supportsRequest` is implemented. Must return a promise for an array of telemetry datums that fulfills the request. The `options` argument will include a `start`, `end`, and `domain` attribute representing the query bounds. For more request properties, see Request Properties below.
Telemetry providers are registered by calling `openmct.telemetry.addProvider(provider)`, e.g.
@ -461,15 +398,14 @@ Telemetry providers are registered by calling `openmct.telemetry.addProvider(pro
openmct.telemetry.addProvider({
supportsRequest: function (domainObject, options) { /*...*/ },
request: function (domainObject, options) { /*...*/ },
supportsSubscribe: function (domainObject, callback, options) { /*...*/ },
subscribe: function (domainObject, callback, options) { /*...*/ }
})
```
Note: it is not required to implement all of the methods on every provider. Depending on the complexity of your implementation, it may be helpful to instantiate and register your realtime, historical, and metadata providers separately.
#### Telemetry Requests and Responses.
#### Telemetry Requests
Telemetry requests support time bounded queries. A call to a _Telemetry Provider_'s `request` function will include an `options` argument. These are simply javascript objects with attributes for the request parameters. An example of a telemetry request object with a start and end time is included below:
```javascript
{
start: 1487981997240,
@ -478,53 +414,7 @@ Telemetry requests support time bounded queries. A call to a _Telemetry Provider
}
```
In this case, the `domain` is the currently selected time-system, and the start and end dates are valid dates in that time system.
A telemetry provider's `request` method should return a promise for an array of telemetry datums. These datums must be sorted by `domain` in ascending order.
#### Request Strategies **draft**
To improve performance views may request a certain strategy for data reduction. These are intended to improve visualization performance by reducing the amount of data needed to be sent to the client. These strategies will be indicated by additional parameters in the request options. You may choose to handle them or ignore them.
Note: these strategies are currently being tested in core plugins and may change based on developer feedback.
##### `latest` request strategy
This request is a "depth based" strategy. When a view is only capable of
displaying a single value (or perhaps the last ten values), then it can
use the `latest` request strategy with a `size` parameter that specifies
the number of results it desires. The `size` parameter is a hint; views
must not assume the response will have the exact number of results requested.
example:
```javascript
{
start: 1487981997240,
end: 1487982897240,
domain: 'utc',
strategy: 'latest',
size: 1
}
```
This strategy says "I want the lastest data point in this time range". A provider which recognizes this request should return only one value-- the latest-- in the requested time range. Depending on your back-end implementation, performing these queries in bulk can be a large performance increase. These are generally issued by views that are only capable of displaying a single value and only need to show the latest value.
##### `minmax` request strategy
example:
```javascript
{
start: 1487981997240,
end: 1487982897240,
domain: 'utc',
strategy: 'minmax',
size: 720
}
```
MinMax queries are issued by plots, and may be issued by other types as well. The aim is to reduce the amount of data returned but still faithfully represent the full extent of the data. In order to do this, the view calculates the maximum data resolution it can display (i.e. the number of horizontal pixels in a plot) and sends that as the `size`. The response should include at least one minimum and one maximum value per point of resolution.
#### Telemetry Formats **draft**
#### Telemetry Formats
Telemetry format objects define how to interpret and display telemetry data.
They have a simple structure:
@ -594,17 +484,6 @@ The key-value pairs of this object are described by the telemetry metadata of
a domain object, as discussed in the [Telemetry Metadata](#telemetry-metadata)
section.
#### Limit Evaluators **draft**
Limit evaluators allow a telemetry integrator to define how limits should be
applied to telemetry from a given domain object. For an example of a limit
evaluator, take a look at `examples/generator/SinewaveLimitProvider.js`.
### Telemetry Consumer APIs **draft**
The APIs for requesting telemetry from Open MCT -- e.g. for use in custom views -- are currently in draft state and are being revised. If you'd like to experiement with them before they are finalized, please contact the team via the contact-us link on our website.
## Time API
Open MCT provides API for managing the temporal state of the application.
@ -712,7 +591,7 @@ openmct.time.bounds({start: now - ONE_HOUR, now);
To respond to bounds change events, listen for the [`'bounds'`](#time-events)
event.
### Clocks
## Clocks
The Time API can be set to follow a clock source which will cause the bounds
to be updated automatically whenever the clock source "ticks". A clock is simply
@ -731,7 +610,7 @@ be defined to tick on some remote timing source.
The values provided by clocks are simple `number`s, which are interpreted in the
context of the active [Time System](#defining-and-registering-time-systems).
#### Defining and registering clocks
### Defining and registering clocks
A clock is an object that defines certain required metadata and functions:
@ -845,7 +724,7 @@ __Note:__ Setting the clock offsets will trigger an immediate bounds change, as
new bounds will be calculated based on the `currentValue()` of the active clock.
Clock offsets are only relevant when a clock source is active.
### Time Events
## Time Events
The Time API is a standard event emitter; you can register callbacks for events using the `on` method and remove callbacks for events with the `off` method.
@ -887,7 +766,7 @@ The events emitted by the Time API are:
* `clockOffsets`: The new [clock offsets](#clock-offsets).
### The Time Conductor
## The Time Conductor
The Time Conductor provides a user interface for managing time bounds in Open
MCT. It allows a user to select from configured time systems and clocks, and to set bounds and clock offsets.

View File

@ -17,7 +17,7 @@
"screenfull": "^3.0.0",
"node-uuid": "^1.4.7",
"comma-separated-values": "^3.6.4",
"file-saver": "1.3.3",
"file-saver": "^1.3.3",
"zepto": "^1.1.6",
"eventemitter3": "^1.2.0",
"lodash": "3.10.1",

View File

@ -1,6 +1,6 @@
machine:
node:
version: 8.11.0
version: 4.7.0
dependencies:
pre:
@ -24,4 +24,4 @@ test:
general:
branches:
ignore:
- gh-pages
- gh-pages

View File

@ -1,108 +0,0 @@
define([
'lodash'
], function (
_
) {
var METADATA_BY_TYPE = {
'generator': {
values: [
{
key: "name",
name: "Name"
},
{
key: "utc",
name: "Time",
format: "utc",
hints: {
domain: 1
}
},
{
key: "yesterday",
name: "Yesterday",
format: "utc",
hints: {
domain: 2
}
},
{
key: "sin",
name: "Sine",
hints: {
range: 1
}
},
{
key: "cos",
name: "Cosine",
hints: {
range: 2
}
}
]
},
'example.state-generator': {
values: [
{
key: "name",
name: "Name"
},
{
key: "utc",
name: "Time",
format: "utc",
hints: {
domain: 1
}
},
{
key: "state",
source: "value",
name: "State",
format: "enum",
enumerations: [
{
value: 0,
string: "OFF"
},
{
value: 1,
string: "ON"
}
],
hints: {
range: 1
}
},
{
key: "value",
name: "Value",
hints: {
range: 2
}
}
]
}
}
function GeneratorMetadataProvider() {
}
GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) {
return METADATA_BY_TYPE.hasOwnProperty(domainObject.type);
};
GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) {
return _.extend(
{},
domainObject.telemetry,
METADATA_BY_TYPE[domainObject.type]
);
};
return GeneratorMetadataProvider;
});

View File

@ -66,7 +66,7 @@ define([
if (request && request.hasOwnProperty(prop)) {
workerRequest[prop] = request[prop];
}
if (!workerRequest.hasOwnProperty(prop)) {
if (!workerRequest[prop]) {
workerRequest[prop] = REQUEST_DEFAULTS[prop];
}
workerRequest[prop] = Number(workerRequest[prop]);

View File

@ -0,0 +1,87 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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(
[],
function () {
"use strict";
var RED = 0.9,
YELLOW = 0.5,
LIMITS = {
rh: {
cssClass: "s-limit-upr s-limit-red",
low: RED,
high: Number.POSITIVE_INFINITY,
name: "Red High"
},
rl: {
cssClass: "s-limit-lwr s-limit-red",
high: -RED,
low: Number.NEGATIVE_INFINITY,
name: "Red Low"
},
yh: {
cssClass: "s-limit-upr s-limit-yellow",
low: YELLOW,
high: RED,
name: "Yellow High"
},
yl: {
cssClass: "s-limit-lwr s-limit-yellow",
low: -RED,
high: -YELLOW,
name: "Yellow Low"
}
};
function SinewaveLimitCapability(domainObject) {
return {
limits: function (range) {
return LIMITS;
},
evaluate: function (datum, range) {
range = range || 'sin';
if (datum[range] > RED) {
return LIMITS.rh;
}
if (datum[range] < -RED) {
return LIMITS.rl;
}
if (datum[range] > YELLOW) {
return LIMITS.yh;
}
if (datum[range] < -YELLOW) {
return LIMITS.yl;
}
}
};
}
SinewaveLimitCapability.appliesTo = function (model) {
return model.type === 'generator';
};
return SinewaveLimitCapability;
}
);

View File

@ -1,88 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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([
], function (
) {
var RED = 0.9,
YELLOW = 0.5,
LIMITS = {
rh: {
cssClass: "s-limit-upr s-limit-red",
low: RED,
high: Number.POSITIVE_INFINITY,
name: "Red High"
},
rl: {
cssClass: "s-limit-lwr s-limit-red",
high: -RED,
low: Number.NEGATIVE_INFINITY,
name: "Red Low"
},
yh: {
cssClass: "s-limit-upr s-limit-yellow",
low: YELLOW,
high: RED,
name: "Yellow High"
},
yl: {
cssClass: "s-limit-lwr s-limit-yellow",
low: -RED,
high: -YELLOW,
name: "Yellow Low"
}
};
function SinewaveLimitProvider() {
}
SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) {
return domainObject.type === 'generator';
};
SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) {
return {
evaluate: function (datum, valueMetadata) {
var range = valueMetadata ? valueMetadata.key : 'sin'
if (datum[range] > RED) {
return LIMITS.rh;
}
if (datum[range] < -RED) {
return LIMITS.rl;
}
if (datum[range] > YELLOW) {
return LIMITS.yh;
}
if (datum[range] < -YELLOW) {
return LIMITS.yl;
}
}
};
};
return SinewaveLimitProvider;
});

View File

@ -47,9 +47,7 @@ define([
var interval = setInterval(function () {
var now = Date.now();
var datum = pointForTimestamp(now, duration, domainObject.name);
datum.value += "";
callback(datum);
callback(pointForTimestamp(now, duration, domainObject.name));
}, duration);
return function () {

View File

@ -23,17 +23,31 @@
define([
"./GeneratorProvider",
"./SinewaveLimitProvider",
"./StateGeneratorProvider",
"./GeneratorMetadataProvider"
"./SinewaveLimitCapability",
"./StateGeneratorProvider"
], function (
GeneratorProvider,
SinewaveLimitProvider,
StateGeneratorProvider,
GeneratorMetadataProvider
SinewaveLimitCapability,
StateGeneratorProvider
) {
var legacyExtensions = {
"capabilities": [
{
"key": "limit",
"implementation": SinewaveLimitCapability
}
]
};
return function(openmct){
//Register legacy extensions for things not yet supported by the new API
Object.keys(legacyExtensions).forEach(function (type){
var extensionsOfType = legacyExtensions[type];
extensionsOfType.forEach(function (extension) {
openmct.legacyExtension(type, extension)
})
});
openmct.types.addType("example.state-generator", {
name: "State Generator",
@ -56,7 +70,47 @@ define([
],
initialize: function (object) {
object.telemetry = {
duration: 5
duration: 5,
values: [
{
key: "name",
name: "Name"
},
{
key: "utc",
name: "Time",
format: "utc",
hints: {
domain: 1
}
},
{
key: "state",
source: "value",
name: "State",
format: "enum",
enumerations: [
{
value: 0,
string: "OFF"
},
{
value: 1,
string: "ON"
}
],
hints: {
range: 1
}
},
{
key: "value",
name: "Value",
hints: {
range: 2
}
}
]
}
}
});
@ -71,58 +125,63 @@ define([
form: [
{
name: "Period",
control: "numberfield",
control: "textfield",
cssClass: "l-input-sm l-numeric",
key: "period",
required: true,
property: [
"telemetry",
"period"
]
],
pattern: "^\\d*(\\.\\d*)?$"
},
{
name: "Amplitude",
control: "numberfield",
control: "textfield",
cssClass: "l-input-sm l-numeric",
key: "amplitude",
required: true,
property: [
"telemetry",
"amplitude"
]
],
pattern: "^\\d*(\\.\\d*)?$"
},
{
name: "Offset",
control: "numberfield",
control: "textfield",
cssClass: "l-input-sm l-numeric",
key: "offset",
required: true,
property: [
"telemetry",
"offset"
]
],
pattern: "^\\d*(\\.\\d*)?$"
},
{
name: "Data Rate (hz)",
control: "numberfield",
control: "textfield",
cssClass: "l-input-sm l-numeric",
key: "dataRateInHz",
required: true,
property: [
"telemetry",
"dataRateInHz"
]
],
pattern: "^\\d*(\\.\\d*)?$"
},
{
name: "Phase (radians)",
control: "numberfield",
control: "textfield",
cssClass: "l-input-sm l-numeric",
key: "phase",
required: true,
property: [
"telemetry",
"phase"
]
],
pattern: "^\\d*(\\.\\d*)?$"
}
],
initialize: function (object) {
@ -131,14 +190,48 @@ define([
amplitude: 1,
offset: 0,
dataRateInHz: 1,
phase: 0
phase: 0,
values: [
{
key: "name",
name: "Name"
},
{
key: "utc",
name: "Time",
format: "utc",
hints: {
domain: 1
}
},
{
key: "yesterday",
name: "Yesterday",
format: "utc",
hints: {
domain: 2
}
},
{
key: "sin",
name: "Sine",
hints: {
range: 1
}
},
{
key: "cos",
name: "Cosine",
hints: {
range: 2
}
}
]
};
}
});
openmct.telemetry.addProvider(new GeneratorProvider());
openmct.telemetry.addProvider(new GeneratorMetadataProvider());
openmct.telemetry.addProvider(new SinewaveLimitProvider());
};
});

View File

@ -0,0 +1,146 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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',
'../../platform/commonUI/browse/src/InspectorRegion',
'../../platform/commonUI/regions/src/Region'
], function (
legacyRegistry,
InspectorRegion,
Region
) {
"use strict";
/**
* Add a 'plot options' region part to the inspector region for the
* Telemetry Plot type only. {@link InspectorRegion} is a default region
* implementation that is added automatically to all types. In order to
* customize what appears in the inspector region, you can start from a
* blank slate by using Region, or customize the default inspector
* region by using {@link InspectorRegion}.
*/
var plotInspector = new InspectorRegion(),
/**
* Two region parts are defined here. One that appears only in browse
* mode, and one that appears only in edit mode. For not they both point
* to the same representation, but a different key could be used here to
* include a customized representation for edit mode.
*/
plotOptionsBrowseRegion = new Region({
name: "plot-options",
title: "Plot Options",
modes: ['browse'],
content: {
key: "plot-options-browse"
}
}),
plotOptionsEditRegion = new Region({
name: "plot-options",
title: "Plot Options",
modes: ['edit'],
content: {
key: "plot-options-browse"
}
});
/**
* Both parts are added, and policies of type 'region' will determine
* which is shown based on domain object state. A default policy is
* provided which will check the 'modes' attribute of the region part
* definition.
*/
plotInspector.addRegion(plotOptionsBrowseRegion);
plotInspector.addRegion(plotOptionsEditRegion);
legacyRegistry.register("example/plotType", {
"name": "Plot Type",
"description": "Example illustrating registration of a new object type",
"extensions": {
"types": [
{
"key": "plot",
"name": "Example Telemetry Plot",
"cssClass": "icon-telemetry-panel",
"description": "For development use. A plot for displaying telemetry.",
"priority": 10,
"delegates": [
"telemetry"
],
"features": "creation",
"contains": [
{
"has": "telemetry"
}
],
"model": {
"composition": []
},
"inspector": plotInspector,
"telemetry": {
"source": "generator",
"domains": [
{
"key": "time",
"name": "Time"
},
{
"key": "yesterday",
"name": "Yesterday"
},
{
"key": "delta",
"name": "Delta",
"format": "example.delta"
}
],
"ranges": [
{
"key": "sin",
"name": "Sine"
},
{
"key": "cos",
"name": "Cosine"
}
]
},
"properties": [
{
"name": "Period",
"control": "textfield",
"cssClass": "l-input-sm l-numeric",
"key": "period",
"required": true,
"property": [
"telemetry",
"period"
],
"pattern": "^\\d*(\\.\\d*)?$"
}
]
}
]
}
});
});

View File

@ -101,11 +101,11 @@
padding-top: 1em;
.cols {
display: flex;
flex-direction: row;
@include display(flex);
@include flex-direction(row);
.col {
flex: 1 1 auto;
@include flex(1 1 auto);
&:not(:last-child) {
$v: $interiorMargin * 4;
border-right: 1px solid $colorInteriorBorder;
@ -199,7 +199,7 @@
border-radius: 15%;
position: absolute;
left: 50%;
transform: translateX(-50%);
@include transform(translateX(-50%));
}
}
}

View File

@ -37,13 +37,14 @@ module.exports = function(config) {
{pattern: 'bower_components/**/*.js', included: false},
{pattern: 'node_modules/d3-*/**/*.js', included: false},
{pattern: 'node_modules/vue/**/*.js', included: false},
{pattern: 'src/**/*', included: false},
{pattern: 'src/**/*.js', included: false},
{pattern: 'example/**/*.html', included: false},
{pattern: 'example/**/*.js', included: false},
{pattern: 'example/**/*.json', included: false},
{pattern: 'platform/**/*.js', included: false},
{pattern: 'warp/**/*.js', included: false},
{pattern: 'platform/**/*.html', included: false},
{pattern: 'src/**/*.html', included: false},
'test-main.js'
],

View File

@ -1,18 +1,18 @@
{
"name": "openmct",
"version": "0.14.0-SNAPSHOT",
"version": "0.12.1-SNAPSHOT",
"description": "The Open MCT core platform",
"dependencies": {
"d3-array": "1.2.x",
"d3-axis": "1.0.x",
"d3-collection": "1.0.x",
"d3-color": "1.0.x",
"d3-format": "1.2.x",
"d3-interpolate": "1.1.x",
"d3-scale": "1.0.x",
"d3-selection": "1.3.x",
"d3-time": "1.0.x",
"d3-time-format": "2.1.x",
"d3-array": "^1.0.2",
"d3-axis": "^1.0.4",
"d3-collection": "^1.0.2",
"d3-color": "^1.0.2",
"d3-format": "^1.0.2",
"d3-interpolate": "^1.1.3",
"d3-scale": "^1.0.4",
"d3-selection": "^1.0.3",
"d3-time": "^1.0.4",
"d3-time-format": "^2.0.3",
"express": "^4.13.1",
"minimist": "^1.1.1",
"request": "^2.69.0",
@ -28,7 +28,7 @@
"gulp-jshint-html-reporter": "^0.1.3",
"gulp-rename": "^1.2.2",
"gulp-requirejs-optimize": "^0.3.1",
"gulp-sass": "^3.1.0",
"gulp-sass": "^2.2.0",
"gulp-sourcemaps": "^1.6.0",
"jasmine-core": "^2.3.0",
"jscs-html-reporter": "^0.1.0",

View File

@ -38,7 +38,6 @@
ng-class="{ last:($index + 1) === contextualParents.length }">
<mct-representation key="'label'"
mct-object="parent"
ng-click="parent.getCapability('action').perform('navigate')"
class="location-item">
</mct-representation>
</span>
@ -50,7 +49,6 @@
ng-class="{ last:($index + 1) === primaryParents.length }">
<mct-representation key="'label'"
mct-object="parent"
ng-click="parent.getCapability('action').perform('navigate')"
class="location-item">
</mct-representation>
</span>

View File

@ -38,7 +38,6 @@ define([
"./src/policies/EditableLinkPolicy",
"./src/policies/EditableMovePolicy",
"./src/policies/EditContextualActionPolicy",
"./src/policies/RemoveActionPolicy",
"./src/representers/EditRepresenter",
"./src/representers/EditToolbarRepresenter",
"./src/capabilities/EditorCapability",
@ -78,7 +77,6 @@ define([
EditableLinkPolicy,
EditableMovePolicy,
EditContextualActionPolicy,
RemoveActionPolicy,
EditRepresenter,
EditToolbarRepresenter,
EditorCapability,
@ -270,10 +268,6 @@ define([
"category": "action",
"implementation": EditableLinkPolicy
},
{
"category": "action",
"implementation": RemoveActionPolicy
},
{
"implementation": CreationPolicy,
"category": "creation"

View File

@ -88,15 +88,11 @@ define(
* @private
*/
ElementsController.prototype.refreshComposition = function (domainObject) {
var refreshTracker = {};
this.currentRefresh = refreshTracker;
var selectedObjectComposition = domainObject && domainObject.useCapability('composition');
if (selectedObjectComposition) {
selectedObjectComposition.then(function (composition) {
if (this.currentRefresh === refreshTracker) {
this.scope.composition = composition;
}
this.scope.composition = composition;
}.bind(this));
} else {
this.scope.composition = [];

View File

@ -1,62 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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(
[],
function () {
function RemoveActionPolicy() {
function isAnyViewEditable(views) {
var isEditable = false;
views.forEach(function (view) {
if (view.editable) {
isEditable = true;
return;
}
});
return isEditable;
}
return {
/**
* Disallow the Remove action on objects that are not editable
*/
allow: function (action, context) {
var domainObject = (context || {}).domainObject,
views = domainObject.useCapability('view'),
metadata = action.getMetadata() || {};
if (metadata.key === 'remove') {
return isAnyViewEditable(views);
}
return true;
}
};
}
return RemoveActionPolicy;
}
);

View File

@ -88,6 +88,12 @@ define(
commit("Changes from toolbar.");
}
}
// Avoid attaching scope to this;
// http://errors.angularjs.org/1.2.26/ng/cpws
this.setSelection = function (s) {
scope.selection = s;
};
this.clearExposedToolbar = function () {
// Clear exposed toolbar state (if any)
if (attrs.toolbar) {
@ -104,7 +110,6 @@ define(
this.toolbar = undefined;
this.toolbarObject = {};
this.openmct = openmct;
this.scope = scope;
// If this representation exposes a toolbar, set up watches
// to synchronize with it.
@ -125,23 +130,26 @@ define(
// Represent a domain object using this definition
EditToolbarRepresenter.prototype.represent = function (representation) {
// Get the newest toolbar definition from the view
var definition = (representation || {}).toolbar || {};
var definition = (representation || {}).toolbar || {},
self = this;
// If we have been asked to expose toolbar state...
if (this.attrs.toolbar) {
// Initialize toolbar object
this.toolbar = new EditToolbar(definition, this.commit);
// Ensure toolbar state is exposed
this.exposeToolbar();
// Initialize toolbar (expose object to parent scope)
function initialize(def) {
// If we have been asked to expose toolbar state...
if (self.attrs.toolbar) {
// Initialize toolbar object
self.toolbar = new EditToolbar(def, self.commit);
// Ensure toolbar state is exposed
self.exposeToolbar();
}
}
// Add toolbar selection to scope.
this.scope.selection = new EditToolbarSelection(
this.scope,
this.openmct
);
// Initialize toolbar to current selection
this.updateSelection(this.scope.selection.all());
// Expose the toolbar object to the parent scope
initialize(definition);
// Create a selection scope
this.setSelection(new EditToolbarSelection(this.openmct));
// Initialize toolbar to an empty selection
this.updateSelection([]);
};
// Destroy; remove toolbar object from parent scope

View File

@ -38,37 +38,24 @@ define(
* @memberof platform/commonUI/edit
* @constructor
*/
function EditToolbarSelection($scope, openmct) {
function EditToolbarSelection(openmct) {
this.selection = [{}];
this.selecting = false;
this.selectedObj = undefined;
this.openmct = openmct;
var self = this;
function setSelection(selection) {
openmct.selection.on('change', function (selection) {
var selected = selection[0];
if (selected && selected.context.toolbar) {
self.select(selected.context.toolbar);
this.select(selected.context.toolbar);
} else {
self.deselect();
this.deselect();
}
if (selected && selected.context.viewProxy) {
self.proxy(selected.context.viewProxy);
this.proxy(selected.context.viewProxy);
}
setTimeout(function () {
$scope.$apply();
});
}
$scope.$on("$destroy", function () {
self.openmct.selection.off('change', setSelection);
});
this.openmct.selection.on('change', setSelection);
setSelection(this.openmct.selection.get());
}.bind(this));
}
/**

View File

@ -31,34 +31,11 @@ define(
mockSelection,
mockDomainObject,
mockMutationCapability,
mockCompositionCapability,
mockCompositionObjects,
mockComposition,
mockUnlisten,
selectable = [],
controller;
function mockPromise(value) {
return {
then: function (thenFunc) {
return mockPromise(thenFunc(value));
}
};
}
function createDomainObject() {
return {
useCapability: function () {
return mockCompositionCapability;
}
};
}
beforeEach(function () {
mockComposition = ["a", "b"];
mockCompositionObjects = mockComposition.map(createDomainObject);
mockCompositionCapability = mockPromise(mockCompositionObjects);
mockUnlisten = jasmine.createSpy('unlisten');
mockMutationCapability = jasmine.createSpyObj("mutationCapability", [
"listen"
@ -68,7 +45,7 @@ define(
"getCapability",
"useCapability"
]);
mockDomainObject.useCapability.andReturn(mockCompositionCapability);
mockDomainObject.useCapability.andCallThrough();
mockDomainObject.getCapability.andReturn(mockMutationCapability);
mockScope = jasmine.createSpyObj("$scope", ['$on']);
@ -88,7 +65,7 @@ define(
}
};
spyOn(ElementsController.prototype, 'refreshComposition').andCallThrough();
spyOn(ElementsController.prototype, 'refreshComposition');
controller = new ElementsController(mockScope, mockOpenMCT);
});
@ -160,25 +137,6 @@ define(
expect(mockDomainObject.getCapability).not.toHaveBeenCalledWith('mutation');
});
it("checks concurrent changes to composition", function () {
var secondMockComposition = ["a", "b", "c"],
secondMockCompositionObjects = secondMockComposition.map(createDomainObject),
firstCompositionCallback,
secondCompositionCallback;
spyOn(mockCompositionCapability, "then").andCallThrough();
controller.refreshComposition(mockDomainObject);
controller.refreshComposition(mockDomainObject);
firstCompositionCallback = mockCompositionCapability.then.calls[0].args[0];
secondCompositionCallback = mockCompositionCapability.then.calls[1].args[0];
secondCompositionCallback(secondMockCompositionObjects);
firstCompositionCallback(mockCompositionObjects);
expect(mockScope.composition).toBe(secondMockCompositionObjects);
});
});
}
);

View File

@ -36,7 +36,7 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
['$on', '$watch', '$watchCollection', "commit", "$apply"]
['$on', '$watch', '$watchCollection', "commit"]
);
mockElement = {};
testAttrs = { toolbar: 'testToolbar' };

View File

@ -30,8 +30,7 @@ define(
otherElement,
selection,
mockSelection,
mockOpenMCT,
mockScope;
mockOpenMCT;
beforeEach(function () {
testProxy = { someKey: "some value" };
@ -47,12 +46,7 @@ define(
mockOpenMCT = {
selection: mockSelection
};
mockScope = jasmine.createSpyObj('$scope', [
'$on',
'$apply'
]);
selection = new EditToolbarSelection(mockScope, mockOpenMCT);
selection = new EditToolbarSelection(mockOpenMCT);
selection.proxy(testProxy);
});
@ -109,20 +103,6 @@ define(
expect(selection.all()).toEqual([testProxy]);
});
it("cleans up selection on scope destroy", function () {
expect(mockScope.$on).toHaveBeenCalledWith(
'$destroy',
jasmine.any(Function)
);
mockScope.$on.mostRecentCall.args[1]();
expect(mockOpenMCT.selection.off).toHaveBeenCalledWith(
'change',
jasmine.any(Function)
);
});
});
}
);

View File

@ -1,91 +1,91 @@
@include keyframes(rotation) {
100% { transform: rotate(360deg); }
100% { @include transform(rotate(360deg)); }
}
@include keyframes(rotation-centered) {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
0% { @include transform(translate(-50%, -50%) rotate(0deg)); }
100% { @include transform(translate(-50%, -50%) rotate(360deg)); }
}
@include keyframes(clock-hands) {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
0% { @include transform(translate(-50%, -50%) rotate(0deg)); }
100% { @include transform(translate(-50%, -50%) rotate(360deg)); }
}
@include keyframes(clock-hands-sticky) {
0% {
transform: translate(-50%, -50%) rotate(0deg);
@include transform(translate(-50%, -50%) rotate(0deg));
}
7% {
transform: translate(-50%, -50%) rotate(0deg);
@include transform(translate(-50%, -50%) rotate(0deg));
}
8% {
transform: translate(-50%, -50%) rotate(30deg);
@include transform(translate(-50%, -50%) rotate(30deg));
}
15% {
transform: translate(-50%, -50%) rotate(30deg);
@include transform(translate(-50%, -50%) rotate(30deg));
}
16% {
transform: translate(-50%, -50%) rotate(60deg);
@include transform(translate(-50%, -50%) rotate(60deg));
}
24% {
transform: translate(-50%, -50%) rotate(60deg);
@include transform(translate(-50%, -50%) rotate(60deg));
}
25% {
transform: translate(-50%, -50%) rotate(90deg);
@include transform(translate(-50%, -50%) rotate(90deg));
}
32% {
transform: translate(-50%, -50%) rotate(90deg);
@include transform(translate(-50%, -50%) rotate(90deg));
}
33% {
transform: translate(-50%, -50%) rotate(120deg);
@include transform(translate(-50%, -50%) rotate(120deg));
}
40% {
transform: translate(-50%, -50%) rotate(120deg);
@include transform(translate(-50%, -50%) rotate(120deg));
}
41% {
transform: translate(-50%, -50%) rotate(150deg);
@include transform(translate(-50%, -50%) rotate(150deg));
}
49% {
transform: translate(-50%, -50%) rotate(150deg);
@include transform(translate(-50%, -50%) rotate(150deg));
}
50% {
transform: translate(-50%, -50%) rotate(180deg);
@include transform(translate(-50%, -50%) rotate(180deg));
}
57% {
transform: translate(-50%, -50%) rotate(180deg);
@include transform(translate(-50%, -50%) rotate(180deg));
}
58% {
transform: translate(-50%, -50%) rotate(210deg);
@include transform(translate(-50%, -50%) rotate(210deg));
}
65% {
transform: translate(-50%, -50%) rotate(210deg);
@include transform(translate(-50%, -50%) rotate(210deg));
}
66% {
transform: translate(-50%, -50%) rotate(240deg);
@include transform(translate(-50%, -50%) rotate(240deg));
}
74% {
transform: translate(-50%, -50%) rotate(240deg);
@include transform(translate(-50%, -50%) rotate(240deg));
}
75% {
transform: translate(-50%, -50%) rotate(270deg);
@include transform(translate(-50%, -50%) rotate(270deg));
}
82% {
transform: translate(-50%, -50%) rotate(270deg);
@include transform(translate(-50%, -50%) rotate(270deg));
}
83% {
transform: translate(-50%, -50%) rotate(300deg);
@include transform(translate(-50%, -50%) rotate(300deg));
}
90% {
transform: translate(-50%, -50%) rotate(300deg);
@include transform(translate(-50%, -50%) rotate(300deg));
}
91% {
transform: translate(-50%, -50%) rotate(330deg);
@include transform(translate(-50%, -50%) rotate(330deg));
}
99% {
transform: translate(-50%, -50%) rotate(330deg);
@include transform(translate(-50%, -50%) rotate(330deg));
}
100% {
transform: translate(-50%, -50%) rotate(360deg);
@include transform(translate(-50%, -50%) rotate(360deg));
}
}

View File

@ -1,11 +0,0 @@
// At the last, hide .l-splash-holder and show .holder-all
.l-splash-holder.fadeout {
@include trans-prop-nice($props: opacity, $dur: 1000ms);
opacity: 0;
pointer-events: none;
}
.user-environ .holder-all {
opacity: 1;
pointer-events: inherit;
}

View File

@ -94,19 +94,19 @@
/********************************************* FLEX STYLES */
.l-flex-row,
.l-flex-col {
display: flex;
flex-wrap: nowrap;
@include display(flex);
@include flex-wrap(nowrap);
.flex-elem {
min-height: 0; // Needed to allow element to shrink within parent
position: relative;
&:not(.grows) {
flex: 0 0 auto;
@include flex(0 0 auto);
&.flex-can-shrink {
flex: 0 1 auto;
@include flex(0 1 auto);
}
}
&.grows {
flex: 1 1 auto;
@include flex(1 1 auto);
}
&.contents-align-right {
text-align: right;
@ -114,25 +114,25 @@
}
.flex-container {
// Apply to wrapping elements, mct-includes, etc.
display: flex;
flex-wrap: nowrap;
flex: 1 1 auto;
@include display(flex);
@include flex-wrap(nowrap);
@include flex(1 1 auto);
min-height:0;
}
}
.l-flex-row {
flex-direction: row;
&.flex-elem { flex: 1 1 auto; }
@include flex-direction(row);
&.flex-elem { @include flex(1 1 auto); }
> .flex-elem {
min-width: 0;
&.holder:not(:last-child) { margin-right: $interiorMargin; }
}
.flex-container { flex-direction: row; }
.flex-container { @include flex-direction(row); }
}
.l-flex-col {
flex-direction: column;
@include flex-direction(column);
> .flex-elem {
min-height: 0;
&.holder:not(:last-child) { margin-bottom: $interiorMarginLg; }
@ -142,15 +142,15 @@
flex-direction: column;
//overflow: hidden !important;
}
.flex-container { flex-direction: column; }
.flex-container { @include flex-direction(column); }
}
.flex-fixed {
flex: 0 0 auto;
@include flex(0 0 auto);
}
.flex-justify-end {
justify-content: flex-end;
@include justify-content(flex-end);
}
/********************************************* POPUPS */

View File

@ -83,8 +83,8 @@
height: auto; width: auto;
position: absolute;
left: 0; top: 0; right: 0; bottom: 20%;
transform-origin: bottom left;
transform: scale(0.3);
@include transform-origin(bottom left);
@include transform(scale(0.3));
z-index: 2;
}
}

View File

@ -53,6 +53,7 @@
.l-inspector-part {
box-sizing: border-box;
padding-right: $interiorMargin;
.tree .form {
margin-left: $treeVCW + $interiorMarginLg;
}
@ -78,7 +79,8 @@
}
}
.form-row {
align-items: center;
// To be replaced with .inspector-config, see below.
@include align-items(center);
border: none !important;
margin-bottom: 0 !important;
padding: $interiorMarginSm 0;
@ -99,15 +101,12 @@
position: relative;
}
ul li {
margin-bottom: $interiorMarginLg;
}
em.t-inspector-part-header {
border-radius: $basicCr;
background-color: $colorInspectorSectionHeaderBg;
color: $colorInspectorSectionHeaderFg;
margin-bottom: $interiorMargin;
margin-top: $interiorMarginLg;
//margin-bottom: $interiorMargin;
padding: floor($formTBPad * .75) $formLRPad;
text-transform: uppercase;
}
@ -201,3 +200,102 @@ mct-representation:not(.s-status-editing) .l-inspect {
pointer-events: inherit;
}
}
// NEW COMPACT FORM, FOR USE IN INSPECTOR
// ul > li > label, control
// Make a new UL for each form section
// Allow control-first, controls-below
.l-inspect .tree ul li,
.inspector-config ul li {
padding: 2px 0;
}
.inspector-config {
$labelW: 40%;
$minW: $labelW;
ul {
margin-bottom: $interiorMarginLg;
li {
@include display(flex);
@include flex-wrap(wrap);
@include align-items(center);
label,
.control {
@include display(flex);
min-width: $minW;
}
label {
line-height: inherit;
padding: $interiorMarginSm 0;
width: $labelW;
}
.control {
@include flex-grow(1);
}
&:not(.section-header) {
&:not(.connects-to-previous) {
//border-top: 1px solid $colorFormLines;
}
}
&.connects-to-previous {
padding-top: 0 !important;
}
&.section-header {
margin-top: $interiorMarginLg;
border-top: 1px solid $colorFormLines;
}
&.controls-first {
.control {
@include flex-grow(0);
margin-right: $interiorMargin;
min-width: 0;
order: 1;
width: auto;
}
label {
@include flex-grow(1);
order: 2;
width: auto;
}
}
&.controls-under {
display: block;
.control, label {
display: block;
width: auto;
}
ul li {
border-top: none !important;
padding: 0;
}
}
}
}
.form-error {
// Block element that visually flags an error and contains a message
background-color: $colorFormFieldErrorBg;
color: $colorFormFieldErrorFg;
border-radius: $basicCr;
display: block;
padding: 1px 6px;
&:before {
content: $glyph-icon-alert-triangle;
display: inline;
font-family: symbolsfont;
margin-right: $interiorMarginSm;
}
}
}
.tree .inspector-config {
margin-left: $treeVCW + $interiorMarginLg;
}

View File

@ -76,11 +76,9 @@
@import "items/item";
@import "mobile/item";
/********************************* TO BE MOVED */
@import "autoflow";
@import "features/imagery";
@import "features/time-display";
@import "widgets";
/********************************* APP STARTUP */
@import "app-start";

View File

@ -382,7 +382,7 @@
/* This doesn't work on an element inside an element with absolute positioning that has height: auto */
//position: relative;
top: 50%;
transform: translateY(-50%);
@include transform(translateY(-50%));
}
@mixin verticalCenterBlock($holderH, $itemH) {

View File

@ -22,8 +22,8 @@
// mct-representation surrounding an object-label key="'label'"
.rep-object-label {
flex-direction: row;
flex: 1 1 auto;
@include flex-direction(row);
@include flex(1 1 auto);
height: inherit;
line-height: inherit;
min-width: 0;

View File

@ -55,7 +55,7 @@
.widget-rule-header {
@extend .l-flex-row;
align-items: center;
@include align-items(center);
margin-bottom: $interiorMargin;
> .flex-elem {
&:not(:first-child) {
@ -103,7 +103,7 @@
.l-compact-form label {
$ruleLabelW: 40%;
$ruleLabelMaxW: 150px;
display: flex;
@include display(flex);
max-width: $ruleLabelMaxW;
width: $ruleLabelW;
}
@ -177,8 +177,8 @@
ul {
&:last-child { margin: 0; }
li {
align-items: flex-start;
flex-wrap: nowrap;
@include align-items(flex-start);
@include flex-wrap(nowrap);
line-height: 230%; // Provide enough space when controls wrap
padding: 2px 0;
&:not(.widget-rule-header) {
@ -233,7 +233,7 @@
.l-widget-thumb-wrapper {
@extend .l-flex-row;
align-items: center;
@include align-items(center);
> span { display: block; }
.grippy-holder,
.view-control {
@ -243,18 +243,18 @@
}
.widget-thumb {
flex: 1 1 auto;
@include flex(1 1 auto);
width: 100%;
}
}
.rule-title {
flex: 0 1 auto;
@include flex(0 1 auto);
color: pullForward($colorBodyFg, 50%);
}
.rule-description {
flex: 1 1 auto;
@include flex(1 1 auto);
@include ellipsize();
color: pushBack($colorBodyFg, 20%);
}

View File

@ -356,7 +356,7 @@ input[type="text"].s-input-inline,
}
}
&:before {
transform: translateY(-50%);
@include transform(translateY(-50%));
color: rgba($colorInvokeMenu, percentToDecimal($contrastInvokeMenuPercent));
display: block;
pointer-events: none;
@ -434,7 +434,7 @@ input[type="text"].s-input-inline,
.context-available {
font-size: 0.7em;
flex: 0 0 1;
@include flex(0 0 1);
}
.t-object-alert {
@ -675,14 +675,14 @@ input[type="range"] {
.l-calendar {
$colorMuted: pushBack($colorMenuFg, 30%);
ul.l-cal-row {
display: flex;
flex-flow: row nowrap;
@include display(flex);
@include flex-flow(row nowrap);
margin-top: 1px;
&:first-child {
margin-top: 0;
}
li {
flex: 1 0;
@include flex(1 0);
margin-left: 1px;
padding: $interiorMargin;
text-align: center;
@ -763,10 +763,10 @@ textarea {
&:before {
position: absolute;
@include trans-prop-nice(transform, 100ms);
transform-origin: center;
@include transform-origin(center);
}
&.expanded:before {
transform: rotate(90deg);
@include transform(rotate(90deg));
}
}

View File

@ -77,14 +77,6 @@
position: relative;
}
.s-menu {
border-radius: $basicCr;
@include containerSubtle($colorMenuBg, $colorMenuFg);
@include boxShdw($shdwMenu);
@include txtShdw($shdwMenuText);
padding: $interiorMarginSm 0;
}
.menu {
border-radius: $basicCr;
@include containerSubtle($colorMenuBg, $colorMenuFg);

View File

@ -157,16 +157,16 @@
$lh: $ueFooterH - ($m*2) - 1;
box-sizing: border-box;
@include ellipsize();
display: flex;
flex-direction: row;
align-items: center;
@include display(flex);
@include flex-direction(row);
@include align-items(center);
position: absolute;
top: $m; right: auto; bottom: $m; left: 50%;
height: auto; width: auto;
line-height: $lh;
max-width: 300px;
padding: 0 $interiorMargin 0 $interiorMargin;
transform: translateX(-50%);
@include transform(translateX(-50%));
&.minimized {
@include transition-property(left, opacity);
@ -185,7 +185,7 @@
}
.banner-elem {
flex: 0 1 auto;
@include flex(0 1 auto);
margin-left: $interiorMargin;
}
a {
@ -250,14 +250,14 @@
// Archetypal message
.l-message {
$iconW: 32px;
display: flex;
flex-direction: row;
align-items: stretch;
@include display(flex);
@include flex-direction(row);
@include align-items(stretch);
padding: $interiorMarginLg;
&:before {
// Icon
flex: 0 1 auto;
@include flex(0 1 auto);
@include txtShdw($shdwStatusIc);
@extend .icon-bell;
color: $colorStatusDefault;
@ -283,9 +283,9 @@
.w-message-contents {
flex: 1 1 auto;
display: flex;
flex-direction: column;
@include flex(1 1 auto);
@include display(flex);
@include flex-direction(column);
> div,
> span {
@ -294,7 +294,7 @@
}
.message-body {
flex: 1 1 100%;
@include flex(1 1 100%);
}
}
@ -331,8 +331,8 @@
// In a list
.t-message-list {
@include absPosDefault();
display: flex;
flex-direction: column;
@include display(flex);
@include flex-direction(column);
> div,
> span {
@ -340,7 +340,7 @@
}
.w-messages {
flex: 1 1 100%;
@include flex(1 1 100%);
overflow-y: auto;
padding-right: $interiorMargin;
}
@ -360,7 +360,7 @@
@include phonePortrait {
.t-message-single .l-message,
.t-message-single.l-message {
flex-direction: column;
@include flex-direction(column);
&:before {
margin-right: 0;
margin-bottom: $interiorMarginLg;

View File

@ -15,7 +15,7 @@
margin-bottom: $interiorMargin;
}
.l-image-main-controlbar {
&.l-flex-row { align-items: center; }
&.l-flex-row { @include align-items(center); }
}
}

View File

@ -34,10 +34,13 @@
}
.btns-add-remove {
// background: rgba(#ff0000, 0.3);;
margin-top: 150px;
.s-button {
display: block;
//font-size: 1.5em;
margin-bottom: $interiorMargin;
//padding: 10px;
text-align: center;
}
}

View File

@ -45,7 +45,7 @@
&.grows {
.l-section-body,
.form-row {
flex: 1 1 auto;
@include flex(1 1 auto);
.wrapper {
height: 100%;
}
@ -87,7 +87,7 @@
.controls {
order: 2;
position: relative;
flex: 1 1 auto;
@include flex(1 1 auto);
.l-composite-control {
&.l-checkbox {
@ -124,16 +124,16 @@
>.label,
>.controls {
line-height: inherit;
min-height: inherit;
min-height: inherit;;
}
>.label {
flex: 1 1 auto;
@include flex(1 1 auto);
min-width: 0;
width: auto;
order: 2;
}
>.controls {
flex: 0 0 auto;
@include flex(0 0 auto);
margin-right: $interiorMargin;
order: 1;
}
@ -141,7 +141,7 @@
.l-controls-under.l-flex-row {
// Change to use column layout
flex-direction: column;
@include flex-direction(column);
.flex-elem {
margin-bottom: $interiorMarginLg;
}
@ -190,19 +190,19 @@
ul {
margin-bottom: $interiorMarginLg;
li {
display: flex;
flex-wrap: wrap;
align-items: center;
@include display(flex);
@include flex-wrap(wrap);
@include align-items(center);
label,
.control {
display: flex;
@include display(flex);
}
label {
line-height: inherit;
width: $labelW;
}
.controls {
flex-grow: 1;
@include flex-grow(1);
margin-left: $interiorMargin;
input[type="text"],
input[type="search"],
@ -232,14 +232,14 @@
&.controls-first {
.control {
flex-grow: 0;
@include flex-grow(0);
margin-right: $interiorMargin;
min-width: 0;
order: 1;
width: auto;
}
label {
flex-grow: 1;
@include flex-grow(1);
order: 2;
width: auto;
}

View File

@ -101,7 +101,7 @@
line-height: inherit;
position: absolute;
top: 50%;
transform: translateY(-50%);
@include transform(translateY(-50%));
z-index: 1;
}

View File

@ -20,7 +20,7 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
@mixin spinner($b: 5px, $c: $colorKey) {
transform-origin: center;
@include transform-origin(center);
@include animation-name(rotation-centered);
@include animation-duration(0.5s);
@include animation-iteration-count(infinite);

View File

@ -85,14 +85,14 @@
z-index: 1;
.item-type,
.t-item-icon {
transform: translateX(-50%) translateY(-55%);
@include transform(translateX(-50%) translateY(-55%));
position: absolute;
top: 50%; left: 50%;
font-size: $iconD * 0.95;
&.l-icon-link {
.t-item-icon-glyph {
&:after {
transform: scale(0.25);
@include transform(scale(0.25));
}
}
}

View File

@ -138,7 +138,7 @@ body.phone.portrait {
}
.pane.right.items {
left: 0 !important;
transform: translateX($proporMenuOnly);
@include transform(translateX($proporMenuOnly));
.holder-object-and-inspector {
opacity: 0;
}

View File

@ -34,18 +34,7 @@ body.touch {
line-height: $mobileTreeItemH !important;
.view-control {
font-size: 1em;
margin-right: $interiorMargin;
width: ceil($mobileTreeItemH * 0.75);
&.has-children {
&:before {
content: $glyph-icon-arrow-down;
left: 50%;
transform: translateX(-50%) rotate(-90deg);
}
&.expanded:before {
transform: translateX(-50%) rotate(0deg);
}
}
width: ceil($mobileTreeItemH * 0.5);
}
.t-object-label {
line-height: inherit;

View File

@ -89,7 +89,7 @@
> .abs.outer-holder {
@include desktopandtablet {
$max: 1280px;
transform: translate(-50%, -50%);
@include transform(translateX(-50%) translateY(-50%));
border-radius: $overlayCr;
top: 50%; right: auto; bottom: auto; left: 50%;
width: 70%; height: 70%;
@ -101,7 +101,7 @@
.editor .form .form-row.l-flex-row {
// Display elements in a columnar view
flex-direction: column;
@include flex-direction(column);
> .flex-elem {
&:not(:first-child) {
margin-top: $interiorMargin;

View File

@ -152,8 +152,8 @@
&.l-plot-y-label {
$x: -50%;
$r: -90deg;
transform-origin: 50% 0;
transform: translateX($x) rotate($r);
@include transform-origin(50% 0);
@include transform(translateX($x) rotate($r));
display: inline-block;
margin-left: $interiorMargin; // Kick off the left edge
left: 0;
@ -172,13 +172,13 @@
}
.gl-plot-x-options {
transform: translateX(-50%);
@include transform(translateX(-50%));
bottom: 0;
left: 50%;
}
.gl-plot-y-options {
transform: translateY(-50%);
@include transform(translateY(-50%));
min-width: 150px; // Need this due to enclosure of .select
top: 50%;
left: $plotYLabelW + $interiorMargin * 2;

View File

@ -152,7 +152,7 @@
opacity: 1;
}
.load-more-button {
transform: translateX(-50%);
@include transform(translateX(-50%));
display: inline-block;
margin-top: $interiorMargin;
padding: 0 $interiorMarginLg;

View File

@ -32,7 +32,11 @@ body, html {
}
.l-splash-holder {
// Main outer holder for splash.
// Main outer holder.
@include transition-property(opacity);
@include transition-duration(500ms);
@include transition-timing-function(ease-in-out);
@include transition-delay(1s);
position: absolute;
top: 0;
right: 0;
@ -40,18 +44,16 @@ body, html {
left: 0;
z-index: 10000;
opacity: 1;
&.fadeout {
opacity: 0;
pointer-events: none;
}
.l-splash {
// The splash element.
@include splashElem();
}
}
.user-environ .holder-all {
// Gets shown again by main CSS, once loaded
opacity: 0;
pointer-events: none;
}
@media only screen and (max-device-width: 767px) {
.l-splash-holder .l-splash {
@include splashElem(0);

View File

@ -142,7 +142,7 @@
.l-hyperlink.s-button {
.label {
@include ellipsize();
transform: translateY(-50%);
@include transform(translateY(-50%));
padding: 0 $interiorMargin;
position: absolute;
min-width: 0;

View File

@ -159,20 +159,20 @@ body.desktop .pane .mini-tab-icon.toggle-pane {
&.toggle-tree.anchor-left {
left: 0;
transform: translateX(-1 * $paneExpandedOffset);
@include transform(translateX(-1 * $paneExpandedOffset));
&.collapsed {
transform: translateX(-1 * $ueCollapsedPaneEdgeM);
@include transform(translateX(-1 * $ueCollapsedPaneEdgeM));
}
}
&.toggle-inspect.anchor-right {
right: 0;
transform: translateX($paneExpandedOffset);
@include transform(translateX($paneExpandedOffset));
&.flush-right {
transform: translateX(($uePaneMiniTabW + ceil($splitterD / 2)));
@include transform(translateX(($uePaneMiniTabW + ceil($splitterD / 2))));
}
&.collapsed {
transform: translateX($ueCollapsedPaneEdgeM);
@include transform(translateX($ueCollapsedPaneEdgeM));
}
}
}

View File

@ -40,18 +40,10 @@ define([
return type.getCssClass();
}
function removePreviousIconClass(el) {
$(el).removeClass(function (index, className) {
return (className.match (/\bicon-\S+/g) || []).join(' ');
});
}
TreeLabelView.prototype.updateView = function (domainObject) {
var titleEl = this.el.find('.t-title-label'),
iconEl = this.el.find('.t-item-icon');
removePreviousIconClass(iconEl);
titleEl.text(domainObject ? domainObject.getModel().name : "");
iconEl.addClass(domainObject ? getClass(domainObject) : "");

View File

@ -55,7 +55,7 @@
div[class*="hand"] {
$handW: 2px;
$handH: $d * 0.4;
transform: translate(-50%, -50%);
@include transform(translate(-50%, -50%));
@include animation-iteration-count(infinite);
@include animation-timing-function(linear);
position: absolute;
@ -258,7 +258,7 @@
align-items: center;
margin-top: $interiorMargin;
.l-time-conductor-zoom-w {
justify-content: flex-end;
@include justify-content(flex-end);
.time-conductor-zoom {
height: $r3H;
min-width: 100px;
@ -327,7 +327,7 @@
$i: $glyph-icon-calendar;
.time-conductor-icon div[class*="hand"] {
&.hand-little {
transform: rotate(120deg);
@include transform(rotate(120deg));
}
}
.mode-selector .s-menu-button:before {

View File

@ -29,7 +29,7 @@ mct-include.l-toi-holder,
mct-include.l-toi-holder {
$blockerFadeW: $toiBlockerFadeW;
transform: translateX(-50%);
@include transform(translateX(-50%));
color: $toiColorBg;
position: absolute;
top: 0;
@ -66,7 +66,7 @@ mct-include.l-toi-holder {
box-sizing: content-box;
height: $toiH;
left: $toiPad * -2;
transform: translateY(-50%); top: 50%;
@include transform(translateY(-50%)); top: 50%;
padding: $toiPad;
z-index: 1;
@ -207,7 +207,7 @@ table {
border-radius: 20%;
height: auto;
padding: $toiPad;
transform: translate(-50%, -50%);
@include transform(translate(-50%, -50%));
left: 50%; right: auto; top: 0;
.l-toi-buttons {
padding: 1px;
@ -233,7 +233,7 @@ table {
z-index: 3;
.l-toi {
transform: translateY(100%);
@include transform(translateY(100%));
}
@ -257,13 +257,13 @@ table {
}
&:before {
transform: translate(-50%, $linesVOffset * -1);
@include transform(translate(-50%, $linesVOffset * -1));
top: 0px;
bottom: auto;
}
&:after {
transform: translate(-50%, $linesVOffset);
@include transform(translate(-50%, $linesVOffset));
top: auto;
bottom: 0px;
}

View File

@ -92,7 +92,7 @@ define(
this.updateHistory(datum);
this.updateValues(datum);
}.bind(this));
this.requestLad(false);
this.requestHistory(this.openmct.time.bounds());
}.bind(this));
};
@ -107,15 +107,36 @@ define(
if (this.requestCount > requestId) {
return Promise.resolve('Stale request');
}
values.forEach(function (datum) {
this.updateHistory(datum);
}, this);
this.updateValues(values[values.length - 1]);
this.requestLad(true);
}.bind(this));
};
/**
* Makes a request for the most recent datum in the
* telelmetry store. Optional addToHistory argument
* determines whether the requested telemetry should
* be added to history or only used to update the current
* image url and timestamp.
* @private
* @param {boolean} [addToHistory] if true, adds to history
*/
ImageryController.prototype.requestLad = function (addToHistory) {
this.openmct.telemetry
.request(this.domainObject, {
strategy: 'latest',
size: 1
})
.then(function (values) {
this.updateValues(values[0]);
if (addToHistory !== false) {
this.updateHistory(values[0]);
}
}.bind(this));
};
ImageryController.prototype.stopListening = function () {
this.openmct.time.off('bounds', this.onBoundsChange);
this.scrollable.off('scroll', this.onScroll);

View File

@ -59,8 +59,7 @@ define(
'timeSystem',
'clock',
'on',
'off',
'bounds'
'off'
]),
telemetry: jasmine.createSpyObj('telemetryAPI', [
'subscribe',
@ -119,8 +118,7 @@ define(
describe("when loaded", function () {
var callback,
boundsListener,
bounds;
boundsListener;
beforeEach(function () {
waitsFor(function () {
@ -139,9 +137,13 @@ define(
});
});
it("requests history", function () {
it("uses LAD telemetry", function () {
expect(openmct.telemetry.request).toHaveBeenCalledWith(
newDomainObject, bounds
newDomainObject,
{
strategy: 'latest',
size: 1
}
);
expect(controller.getTime()).toEqual(prefix + 1434600258123);
expect(controller.getImageUrl()).toEqual('some/url');
@ -202,7 +204,7 @@ define(
it("requests telemetry", function () {
expect(openmct.telemetry.request).toHaveBeenCalledWith(
newDomainObject,
bounds
jasmine.any(Object)
);
});

View File

@ -315,8 +315,6 @@ define(
this.openmct.time.on("bounds", updateDisplayBounds);
this.openmct.selection.on('change', setSelection);
this.$element.on('click', this.bypassSelection.bind(this));
setSelection(this.openmct.selection.get());
}
/**
@ -375,10 +373,10 @@ define(
*/
FixedController.prototype.updateView = function (telemetryObject, datum) {
var metadata = this.openmct.telemetry.getMetadata(telemetryObject);
var valueMetadata = this.chooseValueMetadataToDisplay(metadata);
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(valueMetadata, datum);
var telemetryKeyToDisplay = this.chooseTelemetryKeyToDisplay(metadata);
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(telemetryKeyToDisplay, datum, metadata);
var limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, valueMetadata);
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, telemetryKeyToDisplay);
this.setDisplayedValue(
telemetryObject,
@ -391,28 +389,29 @@ define(
/**
* @private
*/
FixedController.prototype.getFormattedTelemetryValueForKey = function (valueMetadata, datum) {
FixedController.prototype.getFormattedTelemetryValueForKey = function (telemetryKeyToDisplay, datum, metadata) {
var valueMetadata = metadata.value(telemetryKeyToDisplay);
var formatter = this.openmct.telemetry.getValueFormatter(valueMetadata);
return formatter.format(datum);
return formatter.format(datum[valueMetadata.key]);
};
/**
* @private
*/
FixedController.prototype.chooseValueMetadataToDisplay = function (metadata) {
FixedController.prototype.chooseTelemetryKeyToDisplay = function (metadata) {
// If there is a range value, show that preferentially
var valueMetadata = metadata.valuesForHints(['range'])[0];
var telemetryKeyToDisplay = metadata.valuesForHints(['range'])[0];
// If no range is defined, default to the highest priority non time-domain data.
if (valueMetadata === undefined) {
if (telemetryKeyToDisplay === undefined) {
var valuesOrderedByPriority = metadata.values();
valueMetadata = valuesOrderedByPriority.filter(function (values) {
return !(values.hints.domain);
telemetryKeyToDisplay = valuesOrderedByPriority.filter(function (valueMetadata) {
return !(valueMetadata.hints.domain);
})[0];
}
return valueMetadata;
return telemetryKeyToDisplay.source;
};
/**
@ -466,7 +465,7 @@ define(
function filterForTelemetryObjects(objects) {
return objects.filter(function (object) {
return self.openmct.telemetry.isTelemetryObject(object);
return self.openmct.telemetry.canProvideTelemetry(object);
});
}

View File

@ -106,8 +106,8 @@ define(
'telemetryFormatter',
['format']
);
mockFormatter.format.andCallFake(function (valueMetadata) {
return "Formatted " + valueMetadata.value;
mockFormatter.format.andCallFake(function (value) {
return "Formatted " + value;
});
mockDomainObject = jasmine.createSpyObj(
@ -150,13 +150,13 @@ define(
[
'subscribe',
'request',
'isTelemetryObject',
'canProvideTelemetry',
'getMetadata',
'limitEvaluator',
'getValueFormatter'
]
);
mockTelemetryAPI.isTelemetryObject.andReturn(true);
mockTelemetryAPI.canProvideTelemetry.andReturn(true);
mockTelemetryAPI.request.andReturn(Promise.resolve([]));
testGrid = [123, 456];
@ -201,7 +201,7 @@ define(
'off',
'get'
]);
mockSelection.get.andReturn([]);
mockSelection.get.andCallThrough();
mockOpenMCT = {
time: mockConductor,
@ -596,7 +596,7 @@ define(
expect(controller.getSelectedElementStyle()).not.toEqual(oldStyle);
});
it("cleans up selection on scope destroy", function () {
it("cleans up slection on scope destroy", function () {
expect(mockScope.$on).toHaveBeenCalledWith(
'$destroy',
jasmine.any(Function)
@ -697,7 +697,7 @@ define(
source: 'range'
}
]);
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
expect(key).toEqual('range');
});
@ -719,7 +719,7 @@ define(
}
}
]);
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
expect(key).toEqual('image');
});

View File

@ -399,14 +399,14 @@ define(
var compositionApi = this.openmct.composition;
function filterForTelemetry(objects) {
return objects.filter(telemetryApi.isTelemetryObject.bind(telemetryApi));
return objects.filter(telemetryApi.canProvideTelemetry.bind(telemetryApi));
}
/*
* If parent object is a telemetry object, subscribe to it. Do not
* test composees.
*/
if (telemetryApi.isTelemetryObject(this.domainObject)) {
if (telemetryApi.canProvideTelemetry(this.domainObject)) {
return Promise.resolve([this.domainObject]);
} else {
/*

View File

@ -91,7 +91,7 @@ define(
mockScope.domainObject = mockDomainObject;
mockTelemetryAPI = jasmine.createSpyObj("telemetryAPI", [
"isTelemetryObject",
"canProvideTelemetry",
"subscribe",
"getMetadata",
"commonValuesForHints",
@ -117,7 +117,7 @@ define(
return formatter;
});
mockTelemetryAPI.isTelemetryObject.andReturn(false);
mockTelemetryAPI.canProvideTelemetry.andReturn(false);
mockTimeout = jasmine.createSpy("timeout");
mockTimeout.andReturn(1); // Return something
@ -199,7 +199,7 @@ define(
mockComposition.load.andReturn(Promise.resolve(mockChildren));
mockCompositionAPI.get.andReturn(mockComposition);
mockTelemetryAPI.isTelemetryObject.andCallFake(function (obj) {
mockTelemetryAPI.canProvideTelemetry.andCallFake(function (obj) {
return obj.identifier.key === mockTelemetryObject.identifier.key;
});
@ -287,7 +287,7 @@ define(
mockChildren = mockChildren.concat(mockTelemetryChildren);
mockComposition.load.andReturn(Promise.resolve(mockChildren));
mockTelemetryAPI.isTelemetryObject.andCallFake(function (object) {
mockTelemetryAPI.canProvideTelemetry.andCallFake(function (object) {
if (object === mockTelemetryObject) {
return false;
} else {

View File

@ -53,7 +53,7 @@
width: $d;
position: absolute;
top: 0;
transform: translateX(-50%);
@include transform(translateX(-50%));
}
&:before {
// Icon blocker

View File

@ -177,7 +177,7 @@
top: 20px; bottom: 5px;
.l-labels-holder {
@include absPosDefault();
justify-content: space-between;
@include justify-content(space-between);
left: $m;
.t-resource-graph-tick-label {
font-size: 0.9em;

View File

@ -31,8 +31,7 @@ define([
'./policies/AdapterCompositionPolicy',
'./policies/AdaptedViewPolicy',
'./runs/AlternateCompositionInitializer',
'./runs/TimeSettingsURLHandler',
'./runs/TypeDeprecationChecker'
'./runs/TimeSettingsURLHandler'
], function (
legacyRegistry,
ActionDialogDecorator,
@ -44,8 +43,7 @@ define([
AdapterCompositionPolicy,
AdaptedViewPolicy,
AlternateCompositionInitializer,
TimeSettingsURLHandler,
TypeDeprecationChecker
TimeSettingsURLHandler
) {
legacyRegistry.register('src/adapter', {
"extensions": {
@ -109,10 +107,6 @@ define([
}
],
runs: [
{
implementation: TypeDeprecationChecker,
depends: ["types[]"]
},
{
implementation: AlternateCompositionInitializer,
depends: ["openmct"]

View File

@ -1,47 +0,0 @@
/*****************************************************************************
* Open openmct, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open openmct 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 openmct 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 console */
define([
], function (
) {
function checkForDeprecatedFunctionality(typeDef) {
if (typeDef.hasOwnProperty('telemetry')) {
console.warn(
'DEPRECATION WARNING: Telemetry data on type ' +
'registrations will be deprecated in a future version, ' +
'please convert to a custom telemetry metadata provider ' +
'for type: ' + typeDef.key
);
}
}
function TypeDeprecationChecker(types) {
types.forEach(checkForDeprecatedFunctionality);
}
return TypeDeprecationChecker;
});

View File

@ -1,269 +0,0 @@
define([
'./CompositionAPI',
'./CompositionCollection'
], function (
CompositionAPI,
CompositionCollection
) {
describe('The Composition API', function () {
var publicAPI;
var compositionAPI;
var topicService;
var mutationTopic;
beforeEach(function () {
mutationTopic = jasmine.createSpyObj('mutationTopic', [
'listen'
]);
topicService = jasmine.createSpy('topicService');
topicService.andReturn(mutationTopic);
publicAPI = {};
publicAPI.objects = jasmine.createSpyObj('ObjectAPI', [
'get'
]);
publicAPI.objects.get.andCallFake(function (identifier) {
return Promise.resolve({identifier: identifier});
});
publicAPI.$injector = jasmine.createSpyObj('$injector', [
'get'
]);
publicAPI.$injector.get.andReturn(topicService);
compositionAPI = new CompositionAPI(publicAPI);
});
it('returns falsy if an object does not support composition', function () {
expect(compositionAPI.get({})).toBeFalsy();
});
describe('default composition', function () {
var domainObject;
var composition;
beforeEach(function () {
domainObject = {
name: 'test folder',
identifier: {
namespace: 'test',
key: '1'
},
composition: [
{
namespace: 'test',
key: 'a'
}
]
};
composition = compositionAPI.get(domainObject);
});
it('returns composition collection', function () {
expect(composition).toBeDefined();
expect(composition).toEqual(jasmine.any(CompositionCollection));
});
it('loads composition from domain object', function () {
var listener = jasmine.createSpy('addListener');
var loaded = false;
composition.on('add', listener);
composition.load()
.then(function () {
loaded = true;
});
waitsFor(function () {
return loaded;
});
runs(function () {
expect(listener.calls.length).toBe(1);
expect(listener).toHaveBeenCalledWith({
identifier: {namespace: 'test', key: 'a'}
});
});
});
// TODO: Implement add/removal in new default provider.
xit('synchronizes changes between instances', function () {
var otherComposition = compositionAPI.get(domainObject);
var addListener = jasmine.createSpy('addListener');
var removeListener = jasmine.createSpy('removeListener');
var otherAddListener = jasmine.createSpy('otherAddListener');
var otherRemoveListener = jasmine.createSpy('otherRemoveListener');
composition.on('add', addListener);
composition.on('remove', removeListener);
otherComposition.on('add', otherAddListener);
otherComposition.on('remove', otherRemoveListener);
var loaded = false;
Promise.all([composition.load(), otherComposition.load()])
.then(function () {
loaded = true;
});
waitsFor(function () {
return loaded;
});
runs(function () {
expect(addListener).toHaveBeenCalled();
expect(otherAddListener).toHaveBeenCalled();
expect(removeListener).not.toHaveBeenCalled();
expect(otherRemoveListener).not.toHaveBeenCalled();
var object = addListener.mostRecentCall.args[0];
composition.remove(object);
expect(removeListener).toHaveBeenCalled();
expect(otherRemoveListener).toHaveBeenCalled();
addListener.reset();
otherAddListener.reset();
composition.add(object);
expect(addListener).toHaveBeenCalled();
expect(otherAddListener).toHaveBeenCalled();
removeListener.reset();
otherRemoveListener.reset();
otherComposition.remove(object);
expect(removeListener).toHaveBeenCalled();
expect(otherRemoveListener).toHaveBeenCalled();
addListener.reset();
otherAddListener.reset();
otherComposition.add(object);
expect(addListener).toHaveBeenCalled();
expect(otherAddListener).toHaveBeenCalled();
});
});
});
describe('static custom composition', function () {
var customProvider;
var domainObject;
var composition;
beforeEach(function () {
// A simple custom provider, returns the same composition for
// all objects of a given type.
customProvider = {
appliesTo: function (object) {
return object.type === 'custom-object-type';
},
load: function (object) {
return Promise.resolve([
{
namespace: 'custom',
key: 'thing'
}
]);
}
};
domainObject = {
identifier: {
namespace: 'test',
key: '1'
},
type: 'custom-object-type'
};
compositionAPI.addProvider(customProvider);
composition = compositionAPI.get(domainObject);
});
it('supports listening and loading', function () {
var listener = jasmine.createSpy('addListener');
var loaded = false;
composition.on('add', listener);
composition.load()
.then(function () {
loaded = true;
});
waitsFor(function () {
return loaded;
});
runs(function () {
expect(listener.calls.length).toBe(1);
expect(listener).toHaveBeenCalledWith({
identifier: {namespace: 'custom', key: 'thing'}
});
});
});
});
describe('dynamic custom composition', function () {
var customProvider;
var domainObject;
var composition;
beforeEach(function () {
// A dynamic provider, loads an empty composition and exposes
// listener functions.
customProvider = jasmine.createSpyObj('dynamicProvider', [
'appliesTo',
'load',
'on',
'off'
]);
customProvider.appliesTo.andReturn('true');
customProvider.load.andReturn(Promise.resolve([]));
domainObject = {
identifier: {
namespace: 'test',
key: '1'
},
type: 'custom-object-type'
};
compositionAPI.addProvider(customProvider);
composition = compositionAPI.get(domainObject);
});
it('supports listening and loading', function () {
var addListener = jasmine.createSpy('addListener');
var removeListener = jasmine.createSpy('removeListener');
var loaded = false;
composition.on('add', addListener);
composition.on('remove', removeListener);
expect(customProvider.on).toHaveBeenCalledWith(
domainObject,
'add',
jasmine.any(Function),
jasmine.any(CompositionCollection)
);
expect(customProvider.on).toHaveBeenCalledWith(
domainObject,
'remove',
jasmine.any(Function),
jasmine.any(CompositionCollection)
);
var add = customProvider.on.calls[0].args[2];
var remove = customProvider.on.calls[1].args[2];
composition.load()
.then(function () {
loaded = true;
});
waitsFor(function () {
return loaded;
});
runs(function () {
expect(addListener).not.toHaveBeenCalled();
expect(removeListener).not.toHaveBeenCalled();
add({namespace: 'custom', key: 'thing'});
});
waitsFor(function () {
return addListener.calls.length > 0;
});
runs(function () {
expect(addListener).toHaveBeenCalledWith({
identifier: {namespace: 'custom', key: 'thing'}
});
remove(addListener.mostRecentCall.args[0]);
});
waitsFor(function () {
return removeListener.calls.length > 0;
});
runs(function () {
expect(removeListener).toHaveBeenCalledWith({
identifier: {namespace: 'custom', key: 'thing'}
});
});
});
});
});
});

View File

@ -1,128 +0,0 @@
/*****************************************************************************
* Open openmct, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open openmct 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 openmct 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.
*****************************************************************************/
define([
'lodash'
], function (
_
) {
/**
* This is the default metadata provider; for any object with a "telemetry"
* property, this provider will return the value of that property as the
* telemetry metadata.
*
* This provider also implements legacy support for telemetry metadata
* defined on the type. Telemetry metadata definitions on type will be
* depreciated in the future.
*/
function DefaultMetadataProvider(openmct) {
this.openmct = openmct;
}
/**
* Applies to any domain object with a telemetry property, or whose type
* definition has a telemetry property.
*/
DefaultMetadataProvider.prototype.supportsMetadata = function (domainObject) {
return !!domainObject.telemetry || !!this.typeHasTelemetry(domainObject);
};
/**
* Retrieves valueMetadata from legacy metadata.
* @private
*/
function valueMetadatasFromOldFormat(metadata) {
var valueMetadatas = [];
valueMetadatas.push({
key: 'name',
name: 'Name'
});
metadata.domains.forEach(function (domain, index) {
var valueMetadata = _.clone(domain);
valueMetadata.hints = {
domain: index + 1
};
valueMetadatas.push(valueMetadata);
});
metadata.ranges.forEach(function (range, index) {
var valueMetadata = _.clone(range);
valueMetadata.hints = {
range: index,
priority: index + metadata.domains.length + 1
};
if (valueMetadata.type === 'enum') {
valueMetadata.key = 'enum';
valueMetadata.hints.y -= 10;
valueMetadata.hints.range -= 10;
valueMetadata.enumerations =
_.sortBy(valueMetadata.enumerations.map(function (e) {
return {
string: e.string,
value: +e.value
};
}), 'e.value');
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
valueMetadata.max = _.max(valueMetadata.values);
valueMetadata.min = _.min(valueMetadata.values);
}
valueMetadatas.push(valueMetadata);
});
return valueMetadatas;
}
/**
* Returns telemetry metadata for a given domain object.
*/
DefaultMetadataProvider.prototype.getMetadata = function (domainObject) {
var metadata = domainObject.telemetry || {};
if (this.typeHasTelemetry(domainObject)) {
var typeMetadata = this.typeService.getType(domainObject.type).typeDef.telemetry;
_.extend(metadata, typeMetadata);
if (!metadata.values) {
metadata.values = valueMetadatasFromOldFormat(metadata);
}
}
return metadata;
};
/**
* @private
*/
DefaultMetadataProvider.prototype.typeHasTelemetry = function (domainObject) {
if (!this.typeService) {
this.typeService = this.openmct.$injector.get('typeService');
}
return !!this.typeService.getType(domainObject.type).typeDef.telemetry;
};
return DefaultMetadataProvider;
});

View File

@ -141,21 +141,18 @@ define([
return capability.subscribe(callbackWrapper, request);
};
LegacyTelemetryProvider.prototype.supportsLimits = function (domainObject) {
LegacyTelemetryProvider.prototype.limitEvaluator = function (domainObject) {
var oldObject = this.instantiate(
utils.toOldFormat(domainObject),
utils.makeKeyString(domainObject.identifier)
);
return oldObject.hasCapability("limit");
};
LegacyTelemetryProvider.prototype.getLimitEvaluator = function (domainObject) {
var oldObject = this.instantiate(
utils.toOldFormat(domainObject),
utils.makeKeyString(domainObject.identifier)
);
utils.makeKeyString(domainObject.identifier));
var limitEvaluator = oldObject.getCapability("limit");
if (!limitEvaluator) {
return {
evaluate: function () {}
};
}
return {
evaluate: function (datum, property) {
return limitEvaluator.evaluate(datum, property.key);
@ -169,7 +166,6 @@ define([
openmct.telemetry.legacyProvider = provider;
openmct.telemetry.requestProviders.push(provider);
openmct.telemetry.subscriptionProviders.push(provider);
openmct.telemetry.limitProviders.push(provider);
};
});

View File

@ -3,7 +3,7 @@
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open openmct is licensed under the Apache License, Version 2.0 (the
* Open MCT 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.
@ -14,22 +14,20 @@
* License for the specific language governing permissions and limitations
* under the License.
*
* Open openmct includes source code licensed under additional open source
* Open MCT 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 console*/
define([
'./TelemetryMetadataManager',
'./TelemetryValueFormatter',
'./DefaultMetadataProvider',
'../objects/object-utils',
'lodash'
], function (
TelemetryMetadataManager,
TelemetryValueFormatter,
DefaultMetadataProvider,
objectUtils,
_
) {
@ -124,6 +122,7 @@ define([
*/
/**
* An interface for retrieving telemetry data associated with a domain
* object.
@ -132,29 +131,15 @@ define([
* @augments module:openmct.TelemetryAPI~TelemetryProvider
* @memberof module:openmct
*/
function TelemetryAPI(openmct) {
this.openmct = openmct;
function TelemetryAPI(MCT) {
this.MCT = MCT;
this.requestProviders = [];
this.subscriptionProviders = [];
this.metadataProviders = [new DefaultMetadataProvider(this.openmct)];
this.limitProviders = [];
this.metadataCache = new WeakMap();
this.formatMapCache = new WeakMap();
this.valueFormatterCache = new WeakMap();
}
/**
* Return true if the given domainObject is a telemetry object. A telemetry
* object is any object which has telemetry metadata-- regardless of whether
* the telemetry object has an available telemetry provider.
*
* @param {module:openmct.DomainObject} domainObject
* @returns {boolean} true if the object is a telemetry object.
*/
TelemetryAPI.prototype.isTelemetryObject = function (domainObject) {
return !!this.findMetadataProvider(domainObject);
};
/**
* Check if this provider can supply telemetry data associated with
* this domain object.
@ -166,11 +151,6 @@ define([
* @memberof module:openmct.TelemetryAPI~TelemetryProvider#
*/
TelemetryAPI.prototype.canProvideTelemetry = function (domainObject) {
console.warn(
'DEPRECATION WARNING: openmct.telemetry.canProvideTelemetry ' +
'will not be supported in future versions of Open MCT. Please ' +
'use openmct.telemetry.isTelemetryObject instead.'
);
return !!this.findSubscriptionProvider(domainObject) ||
!!this.findRequestProvider(domainObject);
};
@ -190,12 +170,6 @@ define([
if (provider.supportsSubscribe) {
this.subscriptionProviders.unshift(provider);
}
if (provider.supportsMetadata) {
this.metadataProviders.unshift(provider);
}
if (provider.supportsLimits) {
this.limitProviders.unshift(provider);
}
};
/**
@ -222,36 +196,18 @@ define([
return this.requestProviders.filter(supportsDomainObject)[0];
};
/**
* @private
*/
TelemetryAPI.prototype.findMetadataProvider = function (domainObject) {
return this.metadataProviders.filter(function (p) {
return p.supportsMetadata(domainObject);
})[0];
};
/**
* @private
*/
TelemetryAPI.prototype.findLimitEvaluator = function (domainObject) {
return this.limitProviders.filter(function (p) {
return p.supportsLimits(domainObject);
})[0];
};
/**
* @private
*/
TelemetryAPI.prototype.standardizeRequestOptions = function (options) {
if (!options.hasOwnProperty('start')) {
options.start = this.openmct.time.bounds().start;
options.start = this.MCT.time.bounds().start;
}
if (!options.hasOwnProperty('end')) {
options.end = this.openmct.time.bounds().end;
options.end = this.MCT.time.bounds().end;
}
if (!options.hasOwnProperty('domain')) {
options.domain = this.openmct.time.timeSystem().key;
options.domain = this.MCT.time.timeSystem().key;
}
};
@ -344,15 +300,12 @@ define([
*/
TelemetryAPI.prototype.getMetadata = function (domainObject) {
if (!this.metadataCache.has(domainObject)) {
var metadataProvider = this.findMetadataProvider(domainObject);
if (!metadataProvider) {
return;
if (!this.typeService) {
this.typeService = this.MCT.$injector.get('typeService');
}
var metadata = metadataProvider.getMetadata(domainObject);
this.metadataCache.set(
domainObject,
new TelemetryMetadataManager(metadata)
new TelemetryMetadataManager(domainObject, this.typeService)
);
}
return this.metadataCache.get(domainObject);
@ -390,7 +343,7 @@ define([
TelemetryAPI.prototype.getValueFormatter = function (valueMetadata) {
if (!this.valueFormatterCache.has(valueMetadata)) {
if (!this.formatService) {
this.formatService = this.openmct.$injector.get('formatService');
this.formatService = this.MCT.$injector.get('formatService');
}
this.valueFormatterCache.set(
valueMetadata,
@ -422,7 +375,7 @@ define([
* @param {Format} format the
*/
TelemetryAPI.prototype.addFormat = function (format) {
this.openmct.legacyExtension('formats', {
this.MCT.legacyExtension('formats', {
key: format.key,
implementation: function () {
return format;
@ -432,9 +385,7 @@ define([
/**
* Get a limit evaluator for this domain object.
* Limit Evaluators help you evaluate limit and alarm status of individual
* telemetry datums for display purposes without having to interact directly
* with the Limit API.
* Limit Evaluators help you evaluate limit and alarm status of individual telemetry datums for display purposes without having to interact directly with the Limit API.
*
* This method is optional.
* If a provider does not implement this method, it is presumed
@ -446,34 +397,8 @@ define([
* @method limitEvaluator
* @memberof module:openmct.TelemetryAPI~TelemetryProvider#
*/
TelemetryAPI.prototype.limitEvaluator = function (domainObject) {
return this.getLimitEvaluator(domainObject);
};
/**
* Get a limit evaluator for this domain object.
* Limit Evaluators help you evaluate limit and alarm status of individual
* telemetry datums for display purposes without having to interact directly
* with the Limit API.
*
* This method is optional.
* If a provider does not implement this method, it is presumed
* that no limits are defined for this domain object's telemetry.
*
* @param {module:openmct.DomainObject} domainObject the domain
* object for which to evaluate limits
* @returns {module:openmct.TelemetryAPI~LimitEvaluator}
* @method limitEvaluator
* @memberof module:openmct.TelemetryAPI~TelemetryProvider#
*/
TelemetryAPI.prototype.getLimitEvaluator = function (domainObject) {
var provider = this.findLimitEvaluator(domainObject);
if (!provider) {
return {
evaluate: function () {}
};
}
return provider.getLimitEvaluator(domainObject);
TelemetryAPI.prototype.limitEvaluator = function () {
return this.legacyProvider.limitEvaluator.apply(this.legacyProvider, arguments);
};
return TelemetryAPI;

View File

@ -1,25 +1,3 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define([
'./TelemetryAPI'
], function (

View File

@ -27,6 +27,51 @@ define([
_
) {
function valueMetadatasFromOldFormat(metadata) {
var valueMetadatas = [];
valueMetadatas.push({
key: 'name',
name: 'Name'
});
metadata.domains.forEach(function (domain, index) {
var valueMetadata = _.clone(domain);
valueMetadata.hints = {
domain: index + 1
};
valueMetadatas.push(valueMetadata);
});
metadata.ranges.forEach(function (range, index) {
var valueMetadata = _.clone(range);
valueMetadata.hints = {
range: index,
priority: index + metadata.domains.length + 1
};
if (valueMetadata.type === 'enum') {
valueMetadata.key = 'enum';
valueMetadata.hints.y -= 10;
valueMetadata.hints.range -= 10;
valueMetadata.enumerations =
_.sortBy(valueMetadata.enumerations.map(function (e) {
return {
string: e.string,
value: +e.value
};
}), 'e.value');
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
valueMetadata.max = _.max(valueMetadata.values);
valueMetadata.min = _.min(valueMetadata.values);
}
valueMetadatas.push(valueMetadata);
});
return valueMetadatas;
}
function applyReasonableDefaults(valueMetadata, index) {
valueMetadata.source = valueMetadata.source || valueMetadata.key;
valueMetadata.hints = valueMetadata.hints || {};
@ -74,14 +119,24 @@ define([
}
/**
* Utility class for handling and inspecting telemetry metadata. Applies
* reasonable defaults to simplify the task of providing metadata, while
* also providing methods for interrogating telemetry metadata.
* Utility class for handling telemetry metadata for a domain object.
* Wraps old format metadata to new format metadata.
* Provides methods for interrogating telemetry metadata.
*/
function TelemetryMetadataManager(metadata) {
this.metadata = metadata;
function TelemetryMetadataManager(domainObject, typeService) {
this.metadata = domainObject.telemetry || {};
this.valueMetadatas = this.metadata.values.map(applyReasonableDefaults);
if (this.metadata.values) {
this.valueMetadatas = this.metadata.values;
} else {
var typeMetadata = typeService
.getType(domainObject.type).typeDef.telemetry;
_.extend(this.metadata, typeMetadata);
this.valueMetadatas = valueMetadatasFromOldFormat(this.metadata);
}
this.valueMetadatas = this.valueMetadatas.map(applyReasonableDefaults);
}
/**

View File

@ -57,8 +57,8 @@ define([
return vm;
}, {byValue: {}, byString: {}});
this.formatter.format = function (value) {
if (this.enumerations.byValue.hasOwnProperty(value)) {
return this.enumerations.byValue[value];
if (typeof value === "number") {
return this.enumerations.byValue[value] || value;
}
return value;
}.bind(this);

View File

@ -90,7 +90,7 @@ define(['./Type'], function (Type) {
/**
* Retrieve a registered type by its key.
* @method get
* @param {string} typeKey the key for this type
* @param {string} typeKey the key for htis type
* @memberof module:openmct.TypeRegistry#
* @returns {module:openmct.Type} the registered type
*/

View File

@ -1,55 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2017, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define(['./TypeRegistry', './Type'], function (TypeRegistry, Type) {
describe('The Type API', function () {
var typeRegistryInstance;
beforeEach(function () {
typeRegistryInstance = new TypeRegistry ();
typeRegistryInstance.addType('testType', {
name: 'Test Type',
description: 'This is a test type.',
creatable: true
});
});
it('types can be standardized', function () {
typeRegistryInstance.addType('standardizationTestType', {
label: 'Test Type',
description: 'This is a test type.',
creatable: true
});
typeRegistryInstance.standardizeType(typeRegistryInstance.types.standardizationTestType);
expect(typeRegistryInstance.get('standardizationTestType').definition.label).toBeUndefined();
expect(typeRegistryInstance.get('standardizationTestType').definition.name).toBe('Test Type');
});
it('new types are registered successfully and can be retrieved', function () {
expect(typeRegistryInstance.get('testType').definition.name).toBe('Test Type');
});
it('type registry contains new keys', function () {
expect(typeRegistryInstance.listKeys ()).toContain('testType');
});
});
});

View File

@ -38,6 +38,7 @@ define([
'../example/msl/bundle',
'../example/notifications/bundle',
'../example/persistence/bundle',
'../example/plotOptions/bundle',
'../example/policy/bundle',
'../example/profiling/bundle',
'../example/scratchpad/bundle',

View File

@ -166,6 +166,11 @@
ng-show="plotHistory.length"
style="position: absolute; top: 8px; right: 8px;">
<a class="s-button icon-brackets"
ng-click="plot.syncConductor()"
title="Synchronize Time Conductor to plot bounds">
</a>
<a class="s-button icon-arrow-left"
ng-click="plot.back()"
title="Restore previous pan/zoom">

View File

@ -61,7 +61,7 @@ function (
this.alarmSets = [];
this.offset = {};
this.config = $scope.config;
this.listenTo(this.$scope, '$destroy', this.destroy, this);
this.listenTo(this.$scope, '$destoy', this.destroy, this);
this.draw = this.draw.bind(this);
this.scheduleDraw = this.scheduleDraw.bind(this);
this.seriesElements = new WeakMap();
@ -75,6 +75,7 @@ function (
this.$scope.$watch('highlights', this.scheduleDraw);
this.$scope.$watch('rectangles', this.scheduleDraw);
this.config.series.forEach(this.onSeriesAdd, this);
window.chart = this;
}
eventHelpers.extend(MCTChartController.prototype);
@ -197,29 +198,9 @@ function (
this.canvas = canvas;
this.overlay = overlay;
this.drawAPI = DrawLoader.getDrawAPI(canvas, overlay);
if (this.drawAPI) {
this.listenTo(this.drawAPI, 'error', this.fallbackToCanvas, this);
}
return !!this.drawAPI;
};
MCTChartController.prototype.fallbackToCanvas = function () {
this.stopListening(this.drawAPI);
DrawLoader.releaseDrawAPI(this.drawAPI);
// Have to throw away the old canvas elements and replace with new
// canvas elements in order to get new drawing contexts.
var div = document.createElement('div');
div.innerHTML = this.TEMPLATE;
var mainCanvas = div.querySelectorAll("canvas")[1];
var overlayCanvas = div.querySelectorAll("canvas")[0];
this.canvas.parentNode.replaceChild(mainCanvas, this.canvas);
this.canvas = mainCanvas;
this.overlay.parentNode.replaceChild(overlayCanvas, this.overlay);
this.overlay = overlayCanvas;
this.drawAPI = DrawLoader.getFallbackDrawAPI(this.canvas, this.overlay);
this.$scope.$emit('plot:reinitializeCanvas');
};
MCTChartController.prototype.removeChartElement = function (series) {
var elements = this.seriesElements.get(series);
@ -231,10 +212,6 @@ function (
this.pointSets.splice(this.pointSets.indexOf(pointSet), 1);
pointSet.destroy();
}, this);
if (elements.alarmSet) {
elements.alarmSet.destroy();
this.alarmSets.splice(this.alarmSets.indexOf(elements.alarmSet), 1);
}
this.seriesElements.delete(series);
};

View File

@ -43,7 +43,6 @@ define([
restrict: "E",
template: TEMPLATE,
link: function ($scope, $element, attrs, ctrl) {
ctrl.TEMPLATE = TEMPLATE;
var mainCanvas = $element.find("canvas")[1];
var overlayCanvas = $element.find("canvas")[0];

View File

@ -75,32 +75,16 @@ define([
openmct: options.openmct
});
if (this.get('domainObject').type === 'telemetry.plot.overlay') {
this.removeMutationListener = this.openmct.objects.observe(
this.get('domainObject'),
'*',
this.updateDomainObject.bind(this)
);
}
this.removeMutationListener = this.openmct.objects.observe(
this.get('domainObject'),
'*',
this.updateDomainObject.bind(this)
);
this.yAxis.listenToSeriesCollection(this.series);
this.legend.listenToSeriesCollection(this.series);
this.listenTo(this, 'destroy', this.onDestroy, this);
},
/**
* Retrieve the persisted series config for a given identifier.
*/
getPersistedSeriesConfig: function (identifier) {
var domainObject = this.get('domainObject');
if (!domainObject.configuration || !domainObject.configuration.series) {
return;
}
return domainObject.configuration.series.filter(function (seriesConfig) {
return seriesConfig.identifier.key === identifier.key &&
seriesConfig.identifier.namespace === identifier.namespace;
})[0];
},
/**
* Update the domain object with the given value.
*/
@ -115,9 +99,7 @@ define([
this.yAxis.destroy();
this.series.destroy();
this.legend.destroy();
if (this.removeMutationListener) {
this.removeMutationListener();
}
this.removeMutationListener();
},
/**
* Return defaults, which are extracted from the passed in domain

View File

@ -165,13 +165,10 @@ define([
return;
}
var valueMetadata = this.metadata.value(newKey);
var persistedConfig = this.get('persistedConfiguration');
if (!persistedConfig || !persistedConfig.interpolate) {
if (valueMetadata.format === 'enum') {
this.set('interpolate', 'stepAfter');
} else {
this.set('interpolate', 'linear');
}
if (valueMetadata.format === 'enum') {
this.set('interpolate', 'stepAfter');
} else {
this.set('interpolate', 'linear');
}
this.evaluate = function (datum) {
return this.limitEvaluator.evaluate(datum, valueMetadata);
@ -236,6 +233,8 @@ define([
* @returns {Promise}
*/
load: function (options) {
this.resetOnAppend = true;
return this.fetch(options)
.then(function (res) {
this.emit('load');

View File

@ -41,7 +41,6 @@ define([
this.palette = new color.ColorPalette();
this.listenTo(this, 'add', this.onSeriesAdd, this);
this.listenTo(this, 'remove', this.onSeriesRemove, this);
this.listenTo(this.plot, 'change:domainObject', this.trackPersistedConfig, this);
var domainObject = this.plot.get('domainObject');
if (domainObject.telemetry) {
@ -50,14 +49,6 @@ define([
this.watchTelemetryContainer(domainObject);
}
},
trackPersistedConfig: function (domainObject) {
domainObject.configuration.series.forEach(function (seriesConfig) {
var series = this.byIdentifier(seriesConfig.identifier);
if (series) {
series.set('persistedConfiguration', seriesConfig);
}
}, this);
},
watchTelemetryContainer: function (domainObject) {
var composition = this.openmct.composition.get(domainObject);
this.listenTo(composition, 'add', this.addTelemetryObject, this);
@ -84,9 +75,6 @@ define([
seriesConfig = JSON.parse(JSON.stringify(seriesConfig));
}
seriesConfig.persistedConfiguration =
this.plot.getPersistedSeriesConfig(domainObject.identifier);
this.add(new PlotSeries({
model: seriesConfig,
domainObject: domainObject,
@ -137,19 +125,12 @@ define([
},
updateColorPalette: function (newColor, oldColor) {
this.palette.remove(newColor);
var seriesWithColor = this.filter(function (series) {
var seriesWithColor = this.series.filter(function (series) {
return series.get('color') === newColor;
})[0];
if (!seriesWithColor) {
this.palette.return(oldColor);
}
},
byIdentifier: function (identifier) {
return this.filter(function (series) {
var seriesIdentifier = series.get('identifier');
return seriesIdentifier.namespace === identifier.namespace &&
seriesIdentifier.key === identifier.key;
})[0];
}
});

View File

@ -22,13 +22,9 @@
define([
'lodash',
'EventEmitter',
'../lib/eventHelpers'
], function (
_,
EventEmitter,
eventHelpers
) {
/**
@ -51,9 +47,6 @@ define([
}
}
_.extend(Draw2D.prototype, EventEmitter.prototype);
eventHelpers.extend(Draw2D.prototype);
// Convert from logical to physical x coordinates
Draw2D.prototype.x = function (v) {
return ((v - this.origin[0]) / this.dimensions[0]) * this.width;

View File

@ -35,7 +35,7 @@ define(
ALLOCATIONS: []
},
{
MAX_INSTANCES: Number.POSITIVE_INFINITY,
MAX_INSTANCES: Number.MAX_INFINITY,
API: Draw2D,
ALLOCATIONS: []
}
@ -83,24 +83,12 @@ define(
return api;
},
/**
* Returns a fallback draw api.
*/
getFallbackDrawAPI: function (canvas, overlay) {
var api = new CHARTS[1].API(canvas, overlay);
CHARTS[1].ALLOCATIONS.push(api);
return api;
},
releaseDrawAPI: function (api) {
CHARTS.forEach(function (CHART_TYPE) {
if (api instanceof CHART_TYPE.API) {
CHART_TYPE.ALLOCATIONS.splice(CHART_TYPE.ALLOCATIONS.indexOf(api), 1);
}
});
if (api.destroy) {
api.destroy();
}
}
};
}

View File

@ -22,13 +22,9 @@
define([
'lodash',
'EventEmitter',
'../lib/eventHelpers'
], function (
_,
EventEmitter,
eventHelpers
) {
// WebGL shader sources (for drawing plain colors)
@ -73,21 +69,6 @@ define([
throw new Error("WebGL unavailable.");
}
this.initContext();
this.listenTo(this.canvas, "webglcontextlost", this.onContextLost, this);
}
_.extend(DrawWebGL.prototype, EventEmitter.prototype);
eventHelpers.extend(DrawWebGL.prototype);
DrawWebGL.prototype.onContextLost = function (event) {
this.emit('error');
this.isContextLost = true;
this.destroy();
};
DrawWebGL.prototype.initContext = function () {
// Initialize shaders
this.vertexShader = this.gl.createShader(this.gl.VERTEX_SHADER);
this.gl.shaderSource(this.vertexShader, VERTEX_SHADER);
@ -122,12 +103,7 @@ define([
// Enable blending, for smoothness
this.gl.enable(this.gl.BLEND);
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
};
DrawWebGL.prototype.destroy = function () {
this.stopListening();
};
}
// Convert from logical to physical x coordinates
DrawWebGL.prototype.x = function (v) {
@ -141,9 +117,6 @@ define([
};
DrawWebGL.prototype.doDraw = function (drawType, buf, color, points) {
if (this.isContextLost) {
return;
}
this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.buffer);
this.gl.bufferData(this.gl.ARRAY_BUFFER, buf, this.gl.DYNAMIC_DRAW);
this.gl.vertexAttribPointer(this.aVertexPosition, 2, this.gl.FLOAT, false, 0, 0);
@ -152,9 +125,6 @@ define([
};
DrawWebGL.prototype.clear = function () {
if (this.isContextLost) {
return;
}
this.height = this.canvas.height = this.canvas.offsetHeight;
this.width = this.canvas.width = this.canvas.offsetWidth;
this.overlay.height = this.overlay.offsetHeight;
@ -181,9 +151,6 @@ define([
DrawWebGL.prototype.setDimensions = function (dimensions, origin) {
this.dimensions = dimensions;
this.origin = origin;
if (this.isContextLost) {
return;
}
if (dimensions && dimensions.length > 0 &&
origin && origin.length > 0) {
this.gl.uniform2fv(this.uDimensions, dimensions);
@ -202,9 +169,6 @@ define([
* @param {number} points the number of points to draw
*/
DrawWebGL.prototype.drawLine = function (buf, color, points) {
if (this.isContextLost) {
return;
}
this.doDraw(this.gl.LINE_STRIP, buf, color, points);
};
@ -213,9 +177,6 @@ define([
*
*/
DrawWebGL.prototype.drawPoints = function (buf, color, points, pointSize) {
if (this.isContextLost) {
return;
}
this.gl.uniform1f(this.uPointSize, pointSize);
this.doDraw(this.gl.POINTS, buf, color, points);
};
@ -230,9 +191,6 @@ define([
* is in the range of 0.0-1.0
*/
DrawWebGL.prototype.drawSquare = function (min, max, color) {
if (this.isContextLost) {
return;
}
this.doDraw(this.gl.TRIANGLE_FAN, new Float32Array(
min.concat([min[0], max[1]]).concat(max).concat([max[0], min[1]])
), color, 4);

View File

@ -48,6 +48,7 @@ define([
this.configId = $scope.domainObject.getId();
this.setUpScope();
window.config = this;
}
eventHelpers.extend(PlotOptionsController.prototype);

View File

@ -33,12 +33,13 @@ define([
* It supports pan and zoom, implements zoom history, and supports locating
* values near the cursor.
*/
function MCTPlotController($scope, $element, $window) {
function MCTPlotController($scope, $element, $window, openmct) {
this.$scope = $scope;
this.$scope.config = this.config;
this.$scope.plot = this;
this.$element = $element;
this.$window = $window;
this.openmct = openmct;
this.xScale = new LinearScale(this.config.xAxis.get('displayRange'));
this.yScale = new LinearScale(this.config.yAxis.get('displayRange'));
@ -53,25 +54,13 @@ define([
this.listenTo(this.$scope, 'plot:clearHistory', this.clear, this);
this.initialize();
window.control = this;
}
MCTPlotController.$inject = ['$scope', '$element', '$window'];
eventHelpers.extend(MCTPlotController.prototype);
MCTPlotController.prototype.initCanvas = function () {
if (this.$canvas) {
this.stopListening(this.$canvas);
}
this.$canvas = this.$element.find('canvas');
this.listenTo(this.$canvas, 'mousemove', this.trackMousePosition, this);
this.listenTo(this.$canvas, 'mouseleave', this.untrackMousePosition, this);
this.listenTo(this.$canvas, 'mousedown', this.onMouseDown, this);
this.watchForMarquee();
};
MCTPlotController.prototype.initialize = function () {
this.$canvas = this.$element.find('canvas');
@ -95,7 +84,6 @@ define([
this.listenTo(this.$scope, '$destroy', this.destroy, this);
this.listenTo(this.$scope, 'plot:tickWidth', this.onTickWidthChange, this);
this.listenTo(this.$scope, 'plot:highlight:set', this.onPlotHighlightSet, this);
this.listenTo(this.$scope, 'plot:reinitializeCanvas', this.initCanvas, this);
this.listenTo(this.config.xAxis, 'change:displayRange', this.onXAxisChange, this);
this.listenTo(this.config.yAxis, 'change:displayRange', this.onYAxisChange, this);
@ -220,7 +208,6 @@ define([
return;
}
this.marquee.end = this.positionOverPlot;
this.marquee.endPixels = this.positionOverElement;
};
MCTPlotController.prototype.startMarquee = function ($event) {
@ -228,8 +215,6 @@ define([
if (this.positionOverPlot) {
this.freeze();
this.marquee = {
startPixels: this.positionOverElement,
endPixels: this.positionOverElement,
start: this.positionOverPlot,
end: this.positionOverPlot,
color: [1, 1, 1, 0.5]
@ -240,14 +225,8 @@ define([
};
MCTPlotController.prototype.endMarquee = function () {
var startPixels = this.marquee.startPixels;
var endPixels = this.marquee.endPixels;
var marqueeDistance = Math.sqrt(
Math.pow(startPixels.x - endPixels.x, 2) +
Math.pow(startPixels.y - endPixels.y, 2)
);
// Don't zoom if mouse moved less than 7.5 pixels.
if (marqueeDistance > 7.5) {
if (this.marquee.start.x !== this.marquee.end.x &&
this.marquee.start.y !== this.marquee.end.y) {
this.$scope.xAxis.set('displayRange', {
min: Math.min(this.marquee.start.x, this.marquee.end.x),
max: Math.max(this.marquee.start.x, this.marquee.end.x)
@ -257,10 +236,6 @@ define([
max: Math.max(this.marquee.start.y, this.marquee.end.y)
});
this.$scope.$emit('user:viewport:change:end');
} else {
// A history entry is created by startMarquee, need to remove
// if marquee zoom doesn't occur.
this.back();
}
this.$scope.rectangles = [];
this.marquee = undefined;
@ -358,6 +333,13 @@ define([
this.$scope.$emit('user:viewport:change:end');
};
MCTPlotController.prototype.syncConductor = function () {
var xDisplayRange = this.config.xAxis.get('displayRange');
this.openmct.time.stopClock();
this.openmct.time.bounds({start: xDisplayRange.min, end: xDisplayRange.max});
};
MCTPlotController.prototype.destroy = function () {
this.stopListening();
};

View File

@ -33,7 +33,7 @@ define([
return {
restrict: "E",
template: PlotTemplate,
controller: MCTPlotController,
controller: ['$scope', '$element', '$window', 'openmct', MCTPlotController],
controllerAs: 'mctPlotController',
bindToController: {
config: "="

View File

@ -117,6 +117,12 @@ define([
this.$scope = $scope;
this.$element = $element;
if (!window.ticks) {
window.ticks = [];
}
window.ticks.push(this);
this.tickCount = 4;
this.tickUpdate = false;
this.listenTo(this.axis, 'change:displayRange', this.updateTicks, this);

View File

@ -71,6 +71,7 @@ define([
this.config.series.forEach(this.addSeries, this);
this.followTimeConductor();
window.plot = this;
}
eventHelpers.extend(PlotController.prototype);
@ -82,10 +83,6 @@ define([
};
PlotController.prototype.loadSeriesData = function (series) {
if (this.$element[0].offsetWidth === 0) {
this.scheduleLoad(series);
return;
}
this.startLoading();
var options = {
size: this.$element[0].offsetWidth,
@ -96,26 +93,6 @@ define([
.then(this.stopLoading.bind(this));
};
PlotController.prototype.scheduleLoad = function (series) {
if (!this.scheduledLoads) {
this.startLoading();
this.scheduledLoads = [];
this.checkForSize = setInterval(function () {
if (this.$element[0].offsetWidth === 0) {
return;
}
this.stopLoading();
this.scheduledLoads.forEach(this.loadSeriesData, this);
delete this.scheduledLoads;
clearInterval(this.checkForSize);
delete this.checkForSize;
}.bind(this));
}
if (this.scheduledLoads.indexOf(series) === -1) {
this.scheduledLoads.push(series);
}
};
PlotController.prototype.addSeries = function (series) {
this.listenTo(series, 'change:yKey', function () {
this.loadSeriesData(series);
@ -150,10 +127,6 @@ define([
PlotController.prototype.destroy = function () {
configStore.untrack(this.config.id);
this.stopListening();
if (this.checkForSize) {
clearInterval(this.checkForSize);
delete this.checkForSize;
}
};
PlotController.prototype.loadMoreData = function (range, purge) {

View File

@ -31,8 +31,7 @@ define([
'./summaryWidget/plugin',
'./URLIndicatorPlugin/URLIndicatorPlugin',
'./telemetryMean/plugin',
'./plot/plugin',
'./staticRootPlugin/plugin'
'./plot/plugin'
], function (
_,
UTCTimeSystem,
@ -44,8 +43,7 @@ define([
SummaryWidget,
URLIndicatorPlugin,
TelemetryMean,
PlotPlugin,
StaticRootPlugin
PlotPlugin
) {
var bundleMap = {
CouchDB: 'platform/persistence/couch',
@ -68,8 +66,6 @@ define([
plugins.ImportExport = ImportExport;
plugins.StaticRootPlugin = StaticRootPlugin;
/**
* A tabular view showing the latest values of multiple telemetry points at
* once. Formatted so that labels and values are aligned.

View File

@ -1,78 +0,0 @@
define([
'../../api/objects/object-utils'
], function (
objectUtils
) {
/**
* Transforms an import json blob into a object map that can be used to
* provide objects. Rewrites root identifier in import data with provided
* rootIdentifier, and rewrites all child object identifiers so that they
* exist in the same namespace as the rootIdentifier.
*/
function rewriteObjectIdentifiers(importData, rootIdentifier) {
var rootId = importData.rootId;
var objectString = JSON.stringify(importData.openmct);
Object.keys(importData.openmct).forEach(function (originalId, i) {
var newId;
if (originalId === rootId) {
newId = objectUtils.makeKeyString(rootIdentifier);
} else {
newId = objectUtils.makeKeyString({
namespace: rootIdentifier.namespace,
key: i
});
}
while (objectString.indexOf(originalId) !== -1) {
objectString = objectString.replace(
'"' + originalId + '"',
'"' + newId + '"'
);
}
});
return JSON.parse(objectString);
}
/**
* Convets all objects in an object make from old format objects to new
* format objects.
*/
function convertToNewObjects(oldObjectMap) {
return Object.keys(oldObjectMap)
.reduce(function (newObjectMap, key) {
newObjectMap[key] = objectUtils.toNewFormat(oldObjectMap[key], key);
return newObjectMap;
}, {});
}
/* Set the root location correctly for a top-level object */
function setRootLocation(objectMap, rootIdentifier) {
objectMap[objectUtils.makeKeyString(rootIdentifier)].location = 'ROOT';
return objectMap;
}
/**
* Takes importData (as provided by the ImportExport plugin) and exposes
* an object provider to fetch those objects.
*/
function StaticModelProvider(importData, rootIdentifier) {
var oldFormatObjectMap = rewriteObjectIdentifiers(importData, rootIdentifier);
var newFormatObjectMap = convertToNewObjects(oldFormatObjectMap);
this.objectMap = setRootLocation(newFormatObjectMap, rootIdentifier);
}
/**
* Standard "Get".
*/
StaticModelProvider.prototype.get = function (identifier) {
var keyString = objectUtils.makeKeyString(identifier);
if (this.objectMap[keyString]) {
return this.objectMap[keyString];
}
throw new Error(keyString + ' not found in import models.');
};
return StaticModelProvider;
});

View File

@ -1,133 +0,0 @@
define([
'./StaticModelProvider',
'text!./static-provider-test.json'
], function (
StaticModelProvider,
testStaticDataText
) {
describe('StaticModelProvider', function () {
var staticProvider;
beforeEach(function () {
var staticData = JSON.parse(testStaticDataText);
staticProvider = new StaticModelProvider(staticData, {
namespace: 'my-import',
key: 'root'
});
});
describe('rootObject', function () {
var rootModel;
beforeEach(function () {
rootModel = staticProvider.get({
namespace: 'my-import',
key: 'root'
});
});
it('is located at top level', function () {
expect(rootModel.location).toBe('ROOT');
});
it('has new-format identifier', function () {
expect(rootModel.identifier).toEqual({
namespace: 'my-import',
key: 'root'
});
});
it('has new-format composition', function () {
expect(rootModel.composition).toContain({
namespace: 'my-import',
key: '1'
});
expect(rootModel.composition).toContain({
namespace: 'my-import',
key: '2'
});
});
});
describe('childObjects', function () {
var swg;
var layout;
var fixed;
beforeEach(function () {
swg = staticProvider.get({
namespace: 'my-import',
key: '1'
});
layout = staticProvider.get({
namespace: 'my-import',
key: '2'
});
fixed = staticProvider.get({
namespace: 'my-import',
key: '3'
});
});
it('match expected ordering', function () {
// this is a sanity check to make sure the identifiers map in
// the correct order.
expect(swg.type).toBe('generator');
expect(layout.type).toBe('layout');
expect(fixed.type).toBe('telemetry.fixed');
});
it('have new-style identifiers', function () {
expect(swg.identifier).toEqual({
namespace: 'my-import',
key: '1'
});
expect(layout.identifier).toEqual({
namespace: 'my-import',
key: '2'
});
expect(fixed.identifier).toEqual({
namespace: 'my-import',
key: '3'
});
});
it('have new-style composition', function () {
expect(layout.composition).toContain({
namespace: 'my-import',
key: '1'
});
expect(layout.composition).toContain({
namespace: 'my-import',
key: '3'
});
expect(fixed.composition).toContain({
namespace: 'my-import',
key: '1'
});
});
it('rewrites locations', function () {
expect(swg.location).toBe('my-import:root');
expect(layout.location).toBe('my-import:root');
expect(fixed.location).toBe('my-import:2');
});
it('rewrites matched identifiers in objects', function () {
expect(layout.configuration.layout.panels['my-import:1'])
.toBeDefined();
expect(layout.configuration.layout.panels['my-import:3'])
.toBeDefined();
expect(layout.configuration.layout.panels['483c00d4-bb1d-4b42-b29a-c58e06b322a0'])
.not.toBeDefined();
expect(layout.configuration.layout.panels['20273193-f069-49e9-b4f7-b97a87ed755d'])
.not.toBeDefined();
expect(fixed.configuration['fixed-display'].elements[0].id)
.toBe('my-import:1');
});
});
});
});

View File

@ -1,51 +0,0 @@
define([
'./StaticModelProvider'
], function (
StaticModelProvider
) {
/**
* Static Root Plugin: takes an export file and exposes it as a new root
* object.
*/
function StaticRootPlugin(namespace, exportUrl) {
var rootIdentifier = {
namespace: namespace,
key: 'root'
};
var cachedProvider;
var loadProvider = function () {
return fetch(exportUrl)
.then(function (response) {
return response.json();
})
.then(function (importData) {
cachedProvider = new StaticModelProvider(importData, rootIdentifier);
return cachedProvider;
});
};
var getProvider = function () {
if (!cachedProvider) {
cachedProvider = loadProvider();
}
return Promise.resolve(cachedProvider);
};
return function install(openmct) {
openmct.objects.addRoot(rootIdentifier);
openmct.objects.addProvider(namespace, {
get: function (identifier) {
return getProvider().then(function (provider) {
return provider.get(identifier);
});
}
});
};
}
return StaticRootPlugin;
});

View File

@ -1 +0,0 @@
{"openmct":{"a9122832-4b6e-43ea-8219-5359c14c5de8":{"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0","d2ac3ae4-0af2-49fe-81af-adac09936215"],"name":"import-provider-test","type":"folder","notes":"test data for import provider.","modified":1508522673278,"location":"mine","persisted":1508522673278},"483c00d4-bb1d-4b42-b29a-c58e06b322a0":{"telemetry":{"period":10,"amplitude":1,"offset":0,"dataRateInHz":1,"values":[{"key":"utc","name":"Time","format":"utc","hints":{"domain":1,"priority":0},"source":"utc"},{"key":"yesterday","name":"Yesterday","format":"utc","hints":{"domain":2,"priority":1},"source":"yesterday"},{"key":"sin","name":"Sine","hints":{"range":1,"priority":2},"source":"sin"},{"key":"cos","name":"Cosine","hints":{"range":2,"priority":3},"source":"cos"}]},"name":"SWG-10","type":"generator","modified":1508522652874,"location":"a9122832-4b6e-43ea-8219-5359c14c5de8","persisted":1508522652874},"d2ac3ae4-0af2-49fe-81af-adac09936215":{"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0","20273193-f069-49e9-b4f7-b97a87ed755d"],"name":"Layout","type":"layout","configuration":{"layout":{"panels":{"483c00d4-bb1d-4b42-b29a-c58e06b322a0":{"position":[0,0],"dimensions":[17,8]},"20273193-f069-49e9-b4f7-b97a87ed755d":{"position":[0,8],"dimensions":[17,1],"hasFrame":false}}}},"modified":1508522745580,"location":"a9122832-4b6e-43ea-8219-5359c14c5de8","persisted":1508522745580},"20273193-f069-49e9-b4f7-b97a87ed755d":{"layoutGrid":[64,16],"composition":["483c00d4-bb1d-4b42-b29a-c58e06b322a0"],"name":"FP Test","type":"telemetry.fixed","configuration":{"fixed-display":{"elements":[{"type":"fixed.telemetry","x":0,"y":0,"id":"483c00d4-bb1d-4b42-b29a-c58e06b322a0","stroke":"transparent","color":"","titled":true,"width":8,"height":2,"useGrid":true,"size":"24px"}]}},"modified":1508522717619,"location":"d2ac3ae4-0af2-49fe-81af-adac09936215","persisted":1508522717619}},"rootId":"a9122832-4b6e-43ea-8219-5359c14c5de8"}

View File

@ -32,7 +32,7 @@ define(
var parentType = parent.getCapability('type');
var newStyleChild = child.useCapability('adapter');
if (parentType.instanceOf('summary-widget') && !this.openmct.telemetry.isTelemetryObject(newStyleChild)) {
if (parentType.instanceOf('summary-widget') && !this.openmct.telemetry.canProvideTelemetry(newStyleChild)) {
return false;
}

View File

@ -1,14 +1,4 @@
define([
'./SummaryWidgetsCompositionPolicy',
'./src/telemetry/SummaryWidgetMetadataProvider',
'./src/telemetry/SummaryWidgetTelemetryProvider',
'./src/views/SummaryWidgetViewProvider'
], function (
SummaryWidgetsCompositionPolicy,
SummaryWidgetMetadataProvider,
SummaryWidgetTelemetryProvider,
SummaryWidgetViewProvider
) {
define(['./src/SummaryWidget', './SummaryWidgetsCompositionPolicy'], function (SummaryWidget, SummaryWidgetsCompositionPolicy) {
function plugin() {
@ -19,40 +9,8 @@ define([
cssClass: 'icon-summary-widget',
initialize: function (domainObject) {
domainObject.composition = [];
domainObject.configuration = {
ruleOrder: ['default'],
ruleConfigById: {
default: {
name: 'Default',
label: 'Unnamed Rule',
message: '',
id: 'default',
icon: ' ',
style: {
'color': '#ffffff',
'background-color': '#38761d',
'border-color': 'rgba(0,0,0,0)'
},
description: 'Default appearance for the widget',
conditions: [{
object: '',
key: '',
operation: '',
values: []
}],
jsCondition: '',
trigger: 'any',
expanded: 'true'
}
},
testDataConfig: [{
object: '',
key: '',
value: ''
}]
};
domainObject.configuration = {};
domainObject.openNewTab = 'thisTab';
domainObject.telemetry = {};
},
form: [
{
@ -82,14 +40,26 @@ define([
]
};
function initViewProvider(openmct) {
return {
name: 'Widget View',
view: function (domainObject) {
return new SummaryWidget(domainObject, openmct);
},
canView: function (domainObject) {
return (domainObject.type === 'summary-widget');
},
editable: true,
key: 'summaryWidgets'
};
}
return function install(openmct) {
openmct.types.addType('summary-widget', widgetType);
openmct.objectViews.addProvider(initViewProvider(openmct));
openmct.legacyExtension('policies', {category: 'composition',
implementation: SummaryWidgetsCompositionPolicy, depends: ['openmct']
});
openmct.telemetry.addProvider(new SummaryWidgetMetadataProvider(openmct));
openmct.telemetry.addProvider(new SummaryWidgetTelemetryProvider(openmct));
openmct.objectViews.addProvider(new SummaryWidgetViewProvider(openmct));
};
}

View File

@ -1,12 +1,10 @@
define ([
'./ConditionEvaluator',
'../../../api/objects/object-utils',
'EventEmitter',
'zepto',
'lodash'
], function (
ConditionEvaluator,
objectUtils,
EventEmitter,
$,
_
@ -125,23 +123,21 @@ define ([
* has completed and types have been parsed
*/
ConditionManager.prototype.parsePropertyTypes = function (object) {
var objectId = objectUtils.makeKeyString(object.identifier);
var telemetryAPI = this.openmct.telemetry,
key,
type,
self = this;
this.telemetryTypesById[objectId] = {};
Object.values(this.telemetryMetadataById[objectId]).forEach(function (valueMetadata) {
var type;
if (valueMetadata.hints.hasOwnProperty('range')) {
type = 'number';
} else if (valueMetadata.hints.hasOwnProperty('domain')) {
type = 'number';
} else if (valueMetadata.key === 'name') {
type = 'string';
} else {
type = 'string';
}
this.telemetryTypesById[objectId][valueMetadata.key] = type;
this.addGlobalPropertyType(valueMetadata.key, type);
}, this);
self.telemetryTypesById[object.identifier.key] = {};
return telemetryAPI.request(object, {size: 1, strategy: 'latest'}).then(function (telemetry) {
Object.entries(telemetry[telemetry.length - 1]).forEach(function (telem) {
key = telem[0];
type = typeof telem[1];
self.telemetryTypesById[object.identifier.key][key] = type;
self.subscriptionCache[object.identifier.key][key] = telem[1];
self.addGlobalPropertyType(key, type);
});
});
};
/**
@ -151,9 +147,23 @@ define ([
* and property types parsed
*/
ConditionManager.prototype.parseAllPropertyTypes = function () {
Object.values(this.compositionObjs).forEach(this.parsePropertyTypes, this);
this.metadataLoadComplete = true;
this.eventEmitter.emit('metadata');
var self = this,
index = 0,
objs = Object.values(self.compositionObjs),
promise = new Promise(function (resolve, reject) {
if (objs.length === 0) {
resolve();
}
objs.forEach(function (obj) {
self.parsePropertyTypes(obj).then(function () {
if (index === objs.length - 1) {
resolve();
}
index += 1;
});
});
});
return promise;
};
/**
@ -177,17 +187,18 @@ define ([
ConditionManager.prototype.onCompositionAdd = function (obj) {
var compositionKeys,
telemetryAPI = this.openmct.telemetry,
objId = objectUtils.makeKeyString(obj.identifier),
objId = obj.identifier.key,
telemetryMetadata,
self = this;
if (telemetryAPI.isTelemetryObject(obj)) {
if (telemetryAPI.canProvideTelemetry(obj)) {
self.compositionObjs[objId] = obj;
self.telemetryMetadataById[objId] = {};
// FIXME: this should just update based on listener.
compositionKeys = self.domainObject.composition.map(objectUtils.makeKeyString);
if (!compositionKeys.includes(objId)) {
compositionKeys = self.domainObject.composition.map(function (object) {
return object.key;
});
if (!compositionKeys.includes(obj.identifier.key)) {
self.domainObject.composition.push(obj.identifier);
}
@ -201,12 +212,6 @@ define ([
self.subscriptions[objId] = telemetryAPI.subscribe(obj, function (datum) {
self.handleSubscriptionCallback(objId, datum);
}, {});
telemetryAPI.request(obj, {strategy: 'latest', size: 1})
.then(function (results) {
if (results && results.length) {
self.handleSubscriptionCallback(objId, results[results.length - 1]);
}
});
/**
* if this is the initial load, parsing property types will be postponed
@ -229,14 +234,11 @@ define ([
* @private
*/
ConditionManager.prototype.onCompositionRemove = function (identifier) {
var objectId = objectUtils.makeKeyString(identifier);
// FIXME: this should just update by listener.
_.remove(this.domainObject.composition, function (id) {
return id.key === identifier.key &&
id.namespace === identifier.namespace;
return id.key === identifier.key;
});
delete this.compositionObjs[objectId];
this.subscriptions[objectId](); //unsubscribe from telemetry source
delete this.compositionObjs[identifier.key];
this.subscriptions[identifier.key](); //unsubscribe from telemetry source
this.eventEmitter.emit('remove', identifier);
if (_.isEmpty(this.compositionObjs)) {
@ -251,9 +253,13 @@ define ([
* @private
*/
ConditionManager.prototype.onCompositionLoad = function () {
this.loadComplete = true;
this.eventEmitter.emit('load');
this.parseAllPropertyTypes();
var self = this;
self.loadComplete = true;
self.eventEmitter.emit('load');
self.parseAllPropertyTypes().then(function () {
self.metadataLoadComplete = true;
self.eventEmitter.emit('metadata');
});
};
/**

View File

@ -126,13 +126,6 @@ define([
}
};
/**
* Implement "off" to complete event emitter interface.
*/
TestDataItem.prototype.off = function (event, callback, context) {
this.eventEmitter.off(event, callback, context);
};
/**
* Hide the appropriate inputs when this is the only item
*/

View File

@ -131,20 +131,15 @@ define([
*/
TestDataManager.prototype.refreshItems = function () {
var self = this;
if (this.items) {
this.items.forEach(function (item) {
this.stopListening(item);
}, this);
}
self.items = [];
$('.t-test-data-item', this.domElement).remove();
this.config.forEach(function (item, index) {
var newItem = new TestDataItem(item, index, self.manager);
self.listenTo(newItem, 'remove', self.removeItem, self);
self.listenTo(newItem, 'duplicate', self.initItem, self);
self.listenTo(newItem, 'change', self.onItemChange, self);
newItem.on('remove', self.removeItem, self);
newItem.on('duplicate', self.initItem, self);
newItem.on('change', self.onItemChange, self);
self.items.push(newItem);
});
@ -195,10 +190,10 @@ define([
};
TestDataManager.prototype.destroy = function () {
this.stopListening();
this.items.forEach(function (item) {
item.remove();
});
this.stopListening();
};
return TestDataManager;

View File

@ -1,10 +1,4 @@
define([
'./Select',
'../../../../api/objects/object-utils'
], function (
Select,
objectUtils
) {
define(['./Select'], function (Select) {
/**
* Create a {Select} element whose composition is dynamically updated with
@ -43,7 +37,7 @@ define([
* @private
*/
function onCompositionAdd(obj) {
self.select.addOption(objectUtils.makeKeyString(obj.identifier), obj.name);
self.select.addOption(obj.identifier.key, obj.name);
}
/**
@ -81,7 +75,7 @@ define([
*/
ObjectSelect.prototype.generateOptions = function () {
var items = Object.values(this.compositionObjs).map(function (obj) {
return [objectUtils.makeKeyString(obj.identifier), obj.name];
return [obj.identifier.key, obj.name];
});
this.baseOptions.forEach(function (option, index) {
items.splice(index, 0, option);

View File

@ -1,64 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define([
'./SummaryWidgetEvaluator',
'../../../../api/objects/object-utils'
], function (
SummaryWidgetEvaluator,
objectUtils
) {
function EvaluatorPool(openmct) {
this.openmct = openmct;
this.byObjectId = {};
this.byEvaluator = new WeakMap();
}
EvaluatorPool.prototype.get = function (domainObject) {
var objectId = objectUtils.makeKeyString(domainObject.identifier);
var poolEntry = this.byObjectId[objectId];
if (!poolEntry) {
poolEntry = {
leases: 0,
objectId: objectId,
evaluator: new SummaryWidgetEvaluator(domainObject, this.openmct)
};
this.byEvaluator.set(poolEntry.evaluator, poolEntry);
this.byObjectId[objectId] = poolEntry;
}
poolEntry.leases += 1;
return poolEntry.evaluator;
};
EvaluatorPool.prototype.release = function (evaluator) {
var poolEntry = this.byEvaluator.get(evaluator);
poolEntry.leases -= 1;
if (poolEntry.leases === 0) {
evaluator.destroy();
this.byEvaluator.delete(evaluator);
delete this.byObjectId[poolEntry.objectId];
}
};
return EvaluatorPool;
});

View File

@ -1,102 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define([
'./EvaluatorPool',
'./SummaryWidgetEvaluator'
], function (
EvaluatorPool,
SummaryWidgetEvaluator
) {
describe('EvaluatorPool', function () {
var pool;
var openmct;
var objectA;
var objectB;
beforeEach(function () {
openmct = {
composition: jasmine.createSpyObj('compositionAPI', ['get']),
objects: jasmine.createSpyObj('objectAPI', ['observe'])
};
openmct.composition.get.andCallFake(function () {
var compositionCollection = jasmine.createSpyObj(
'compositionCollection',
[
'load',
'on',
'off'
]
);
compositionCollection.load.andReturn(Promise.resolve());
return compositionCollection;
});
openmct.objects.observe.andCallFake(function () {
return function () {};
});
pool = new EvaluatorPool(openmct);
objectA = {
identifier: {
namespace: 'someNamespace',
key: 'someKey'
},
configuration: {
ruleOrder: []
}
};
objectB = {
identifier: {
namespace: 'otherNamespace',
key: 'otherKey'
},
configuration: {
ruleOrder: []
}
};
});
it('returns new evaluators for different objects', function () {
var evaluatorA = pool.get(objectA);
var evaluatorB = pool.get(objectB);
expect(evaluatorA).not.toBe(evaluatorB);
});
it('returns the same evaluator for the same object', function () {
var evaluatorA = pool.get(objectA);
var evaluatorB = pool.get(objectA);
expect(evaluatorA).toBe(evaluatorB);
var evaluatorC = pool.get(JSON.parse(JSON.stringify(objectA)));
expect(evaluatorA).toBe(evaluatorC);
});
it('returns new evaluator when old is released', function () {
var evaluatorA = pool.get(objectA);
var evaluatorB = pool.get(objectA);
expect(evaluatorA).toBe(evaluatorB);
pool.release(evaluatorA);
pool.release(evaluatorB);
var evaluatorC = pool.get(objectA);
expect(evaluatorA).not.toBe(evaluatorC);
});
});
});

View File

@ -1,80 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define([
'./operations'
], function (
OPERATIONS
) {
function SummaryWidgetCondition(definition) {
this.object = definition.object;
this.key = definition.key;
this.values = definition.values;
if (!definition.operation) {
// TODO: better handling for default rule.
this.evaluate = function () {
return true;
};
} else {
this.comparator = OPERATIONS[definition.operation].operation;
}
}
SummaryWidgetCondition.prototype.evaluate = function (telemetryState) {
var stateKeys = Object.keys(telemetryState);
var state;
var result;
var i;
if (this.object === 'any') {
for (i = 0; i < stateKeys.length; i++) {
state = telemetryState[stateKeys[i]];
result = this.evaluateState(state);
if (result) {
return true;
}
}
return false;
} else if (this.object === 'all') {
for (i = 0; i < stateKeys.length; i++) {
state = telemetryState[stateKeys[i]];
result = this.evaluateState(state);
if (!result) {
return false;
}
}
return true;
} else {
return this.evaluateState(telemetryState[this.object]);
}
};
SummaryWidgetCondition.prototype.evaluateState = function (state) {
var testValues = [
state.formats[this.key].parse(state.lastDatum)
].concat(this.values);
return this.comparator(testValues);
};
return SummaryWidgetCondition;
});

View File

@ -1,142 +0,0 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT 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 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.
*****************************************************************************/
define([
'./SummaryWidgetCondition'
], function (
SummaryWidgetCondition
) {
describe('SummaryWidgetCondition', function () {
var condition;
var telemetryState;
beforeEach(function () {
// Format map intentionally uses different keys than those present
// in datum, which serves to verify conditions use format map to get
// data.
var formatMap = {
adjusted: {
parse: function (datum) {
return datum.value + 10;
}
},
raw: {
parse: function (datum) {
return datum.value;
}
}
};
telemetryState = {
objectId: {
formats: formatMap,
lastDatum: {
}
},
otherObjectId: {
formats: formatMap,
lastDatum: {
}
}
};
});
it('can evaluate if a single object matches', function () {
condition = new SummaryWidgetCondition({
object: 'objectId',
key: 'raw',
operation: 'greaterThan',
values: [
10
]
});
telemetryState.objectId.lastDatum.value = 5;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(true);
});
it('can evaluate if a single object matches (alternate keys)', function () {
condition = new SummaryWidgetCondition({
object: 'objectId',
key: 'adjusted',
operation: 'greaterThan',
values: [
10
]
});
telemetryState.objectId.lastDatum.value = -5;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 5;
expect(condition.evaluate(telemetryState)).toBe(true);
});
it('can evaluate "if all objects match"', function () {
condition = new SummaryWidgetCondition({
object: 'all',
key: 'raw',
operation: 'greaterThan',
values: [
10
]
});
telemetryState.objectId.lastDatum.value = 0;
telemetryState.otherObjectId.lastDatum.value = 0;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 0;
telemetryState.otherObjectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 15;
telemetryState.otherObjectId.lastDatum.value = 0;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 15;
telemetryState.otherObjectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(true);
});
it('can evalute "if any object matches"', function () {
condition = new SummaryWidgetCondition({
object: 'any',
key: 'raw',
operation: 'greaterThan',
values: [
10
]
});
telemetryState.objectId.lastDatum.value = 0;
telemetryState.otherObjectId.lastDatum.value = 0;
expect(condition.evaluate(telemetryState)).toBe(false);
telemetryState.objectId.lastDatum.value = 0;
telemetryState.otherObjectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(true);
telemetryState.objectId.lastDatum.value = 15;
telemetryState.otherObjectId.lastDatum.value = 0;
expect(condition.evaluate(telemetryState)).toBe(true);
telemetryState.objectId.lastDatum.value = 15;
telemetryState.otherObjectId.lastDatum.value = 15;
expect(condition.evaluate(telemetryState)).toBe(true);
});
});
});

Some files were not shown because too many files have changed in this diff Show More