mirror of
https://github.com/nasa/openmct.git
synced 2024-12-24 15:26:39 +00:00
[Time Conductor] Use formatService from telemetryFormatter
This commit is contained in:
parent
82b321b3f9
commit
3fe386fcd6
@ -37,7 +37,8 @@
|
|||||||
"services": [
|
"services": [
|
||||||
{
|
{
|
||||||
"key": "telemetryFormatter",
|
"key": "telemetryFormatter",
|
||||||
"implementation": "TelemetryFormatter.js"
|
"implementation": "TelemetryFormatter.js",
|
||||||
|
"depends": [ "formatService" ]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "telemetrySubscriber",
|
"key": "telemetrySubscriber",
|
||||||
@ -63,4 +64,4 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,14 +22,13 @@
|
|||||||
/*global define,moment*/
|
/*global define,moment*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['moment'],
|
[],
|
||||||
function (moment) {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Date format to use for domain values; in particular,
|
// Date format to use for domain values; in particular,
|
||||||
// use day-of-year instead of month/day
|
// use day-of-year instead of month/day
|
||||||
var DATE_FORMAT = "YYYY-DDD HH:mm:ss",
|
var VALUE_FORMAT_DIGITS = 3;
|
||||||
VALUE_FORMAT_DIGITS = 3;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The TelemetryFormatter is responsible for formatting (as text
|
* The TelemetryFormatter is responsible for formatting (as text
|
||||||
@ -38,21 +37,23 @@ define(
|
|||||||
* @memberof platform/telemetry
|
* @memberof platform/telemetry
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function TelemetryFormatter() {
|
function TelemetryFormatter(formatService) {
|
||||||
|
this.formatService = formatService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a domain value.
|
* Format a domain value.
|
||||||
* @param {number} v the domain value; a timestamp
|
* @param {number} v the domain value; usually, a timestamp
|
||||||
* in milliseconds since start of 1970
|
* in milliseconds since start of 1970
|
||||||
* @param {string} [key] the key which identifies the
|
* @param {string} [key] a key which identifies the format
|
||||||
* domain; if unspecified or unknown, this will
|
* to use
|
||||||
* be treated as a standard timestamp.
|
|
||||||
* @returns {string} a textual representation of the
|
* @returns {string} a textual representation of the
|
||||||
* data and time, suitable for display.
|
* data and time, suitable for display.
|
||||||
*/
|
*/
|
||||||
TelemetryFormatter.prototype.formatDomainValue = function (v, key) {
|
TelemetryFormatter.prototype.formatDomainValue = function (v, key) {
|
||||||
return isNaN(v) ? "" : moment.utc(v).format(DATE_FORMAT);
|
var formatter = this.formatService.getFormat(key) ||
|
||||||
|
this.formatService.getFormat('utc');
|
||||||
|
return isNaN(v) ? "" : formatter.format(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user