Merge pull request #1576 from nasa/separate-formats-from-timesystem

Separate formats from timesystem
This commit is contained in:
Victor Woeltjen 2017-05-15 12:06:05 -07:00 committed by GitHub
commit c2cd0db9a3
6 changed files with 26 additions and 26 deletions

11
API.md
View File

@ -435,8 +435,7 @@ They have a simple structure:
* `count`: An __optional__ argument specifying the number of displayed * `count`: An __optional__ argument specifying the number of displayed
values. values.
* `parse`: A `function` that takes a `string` representation of a telemetry * `parse`: A `function` that takes a `string` representation of a telemetry
value, and returns the value in its native type. It accepts one argument: value, and returns the value in its native type. **Note** parse might receive an already-parsed value. This function should be idempotent.
* `text`: A `string` representation of a telemetry value.
* `validate`: A `function` that takes a `string` representation of a telemetry * `validate`: A `function` that takes a `string` representation of a telemetry
value, and returns a `boolean` value indicating whether the provided string value, and returns a `boolean` value indicating whether the provided string
can be parsed. can be parsed.
@ -460,14 +459,6 @@ openmct.telemetry.addFormat({
}); });
``` ```
##### Examples of Formats in Use
* The [NumberFormat](https://github.com/nasa/openmct/blob/time-api-redo/platform/features/conductor/core/src/ui/NumberFormat.js)
provides an example of a simple format available by default in OpenMCT.
* The [UTCTimeFormat](https://github.com/nasa/openmct/blob/master/src/plugins/utcTimeSystem/UTCTimeFormat.js)
is a more complex implementation of a format that uses the optional context
arguments in `format` to provide scale-appropriate values.
#### Telemetry Data #### Telemetry Data
A single telemetry point is considered a Datum, and is represented by a standard A single telemetry point is considered a Datum, and is represented by a standard

View File

@ -22,15 +22,19 @@
define([ define([
"./src/FormatProvider", "./src/FormatProvider",
"./src/UTCTimeFormat",
"./src/DurationFormat",
'legacyRegistry' 'legacyRegistry'
], function ( ], function (
FormatProvider, FormatProvider,
UTCTimeFormat,
DurationFormat,
legacyRegistry legacyRegistry
) { ) {
legacyRegistry.register("platform/commonUI/formats", { legacyRegistry.register("platform/commonUI/formats", {
"name": "Time services bundle", "name": "Format Registry",
"description": "Defines interfaces and provides default implementations for handling different time systems.", "description": "Provides a registry for formats, which allow parsing and formatting of values.",
"extensions": { "extensions": {
"components": [ "components": [
{ {
@ -42,6 +46,22 @@ define([
] ]
} }
], ],
"formats": [
{
"key": "utc",
"implementation": UTCTimeFormat
},
{
"key": "duration",
"implementation": DurationFormat
}
],
"constants": [
{
"key": "DEFAULT_TIME_FORMAT",
"value": "utc"
}
],
"licenses": [ "licenses": [
{ {
"name": "d3", "name": "d3",

View File

@ -21,7 +21,7 @@
*****************************************************************************/ *****************************************************************************/
define([ define([
"./UTCTimeFormat", "../src/UTCTimeFormat",
"moment" "moment"
], function ( ], function (
UTCTimeFormat, UTCTimeFormat,

View File

@ -22,14 +22,10 @@
define([ define([
"./UTCTimeSystem", "./UTCTimeSystem",
"./LocalClock", "./LocalClock"
"./UTCTimeFormat",
"./DurationFormat"
], function ( ], function (
UTCTimeSystem, UTCTimeSystem,
LocalClock, LocalClock
UTCTimeFormat,
DurationFormat
) { ) {
/** /**
* Install a time system that supports UTC times. It also installs a local * Install a time system that supports UTC times. It also installs a local
@ -40,13 +36,6 @@ define([
var timeSystem = new UTCTimeSystem(); var timeSystem = new UTCTimeSystem();
openmct.time.addTimeSystem(timeSystem); openmct.time.addTimeSystem(timeSystem);
openmct.time.addClock(new LocalClock(100)); openmct.time.addClock(new LocalClock(100));
openmct.telemetry.addFormat(new UTCTimeFormat());
openmct.telemetry.addFormat(new DurationFormat());
openmct.legacyExtension("constants", {
"key": "DEFAULT_TIME_FORMAT",
"value": "utc"
});
}; };
}; };
}); });