mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
Merge pull request #1196 from hudsonfoo/open1185
[Timeline] Add battery starting state-of-charge
This commit is contained in:
commit
c9c8998fa2
@ -182,6 +182,16 @@ define([
|
||||
"capacity"
|
||||
],
|
||||
"pattern": "^-?\\d+(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Battery starting SOC (%)",
|
||||
"control": "textfield",
|
||||
"required": false,
|
||||
"conversion": "number",
|
||||
"property": [
|
||||
"startingSOC"
|
||||
],
|
||||
"pattern": "^([0-9](\\.\\d*)?|[1-9][0-9](\\.\\d*)?|100)%?$"
|
||||
}
|
||||
],
|
||||
"model": {
|
||||
|
@ -37,7 +37,8 @@ define(
|
||||
// Build graphs for this group of utilizations
|
||||
function buildGraphs(utilizations) {
|
||||
var utilizationMap = {},
|
||||
result = {};
|
||||
result = {},
|
||||
startingSOC;
|
||||
|
||||
// Bucket utilizations by type
|
||||
utilizations.forEach(function (u) {
|
||||
@ -55,12 +56,14 @@ define(
|
||||
if (domainObject.getModel().type === 'timeline' &&
|
||||
result.power &&
|
||||
domainObject.getModel().capacity > 0) {
|
||||
startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ?
|
||||
100 : parseFloat(domainObject.getModel().startingSOC);
|
||||
|
||||
result.battery = new CumulativeGraph(
|
||||
result.power,
|
||||
0,
|
||||
domainObject.getModel().capacity, // Watts
|
||||
domainObject.getModel().capacity,
|
||||
(startingSOC / 100) * domainObject.getModel().capacity,
|
||||
1 / 3600000 // millis-to-hour (since units are watt-hours)
|
||||
);
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ define(
|
||||
it("provides a battery graph for timelines with capacity", function () {
|
||||
var mockCallback = jasmine.createSpy('callback');
|
||||
testModel.capacity = 1000;
|
||||
testModel.startingSOC = 100;
|
||||
testModel.type = "timeline";
|
||||
mockDomainObject.useCapability.andReturn(asPromise([
|
||||
{ key: "power", start: 0, end: 15 }
|
||||
|
Loading…
Reference in New Issue
Block a user