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
values.
* `parse`: A `function` that takes a `string` representation of a telemetry
value, and returns the value in its native type. It accepts one argument:
* `text`: A `string` representation of a telemetry value.
value, and returns the value in its native type. **Note** parse might receive an already-parsed value. This function should be idempotent.
* `validate`: A `function` that takes a `string` representation of a telemetry
value, and returns a `boolean` value indicating whether the provided string
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
A single telemetry point is considered a Datum, and is represented by a standard

View File

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

View File

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

View File

@ -22,14 +22,10 @@
define([
"./UTCTimeSystem",
"./LocalClock",
"./UTCTimeFormat",
"./DurationFormat"
"./LocalClock"
], function (
UTCTimeSystem,
LocalClock,
UTCTimeFormat,
DurationFormat
LocalClock
) {
/**
* Install a time system that supports UTC times. It also installs a local
@ -40,13 +36,6 @@ define([
var timeSystem = new UTCTimeSystem();
openmct.time.addTimeSystem(timeSystem);
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"
});
};
};
});