Skip to content

Commit c9c8998

Browse files
authored
Merge pull request #1196 from hudsonfoo/open1185
[Timeline] Add battery starting state-of-charge
2 parents 5b0fa90 + e077f9e commit c9c8998

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

platform/features/timeline/bundle.js

+10
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ define([
182182
"capacity"
183183
],
184184
"pattern": "^-?\\d+(\\.\\d*)?$"
185+
},
186+
{
187+
"name": "Battery starting SOC (%)",
188+
"control": "textfield",
189+
"required": false,
190+
"conversion": "number",
191+
"property": [
192+
"startingSOC"
193+
],
194+
"pattern": "^([0-9](\\.\\d*)?|[1-9][0-9](\\.\\d*)?|100)%?$"
185195
}
186196
],
187197
"model": {

platform/features/timeline/src/capabilities/GraphCapability.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ define(
3737
// Build graphs for this group of utilizations
3838
function buildGraphs(utilizations) {
3939
var utilizationMap = {},
40-
result = {};
40+
result = {},
41+
startingSOC;
4142

4243
// Bucket utilizations by type
4344
utilizations.forEach(function (u) {
@@ -55,12 +56,14 @@ define(
5556
if (domainObject.getModel().type === 'timeline' &&
5657
result.power &&
5758
domainObject.getModel().capacity > 0) {
59+
startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ?
60+
100 : parseFloat(domainObject.getModel().startingSOC);
5861

5962
result.battery = new CumulativeGraph(
6063
result.power,
6164
0,
6265
domainObject.getModel().capacity, // Watts
63-
domainObject.getModel().capacity,
66+
(startingSOC / 100) * domainObject.getModel().capacity,
6467
1 / 3600000 // millis-to-hour (since units are watt-hours)
6568
);
6669
}

platform/features/timeline/test/capabilities/GraphCapabilitySpec.js

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ define(
101101
it("provides a battery graph for timelines with capacity", function () {
102102
var mockCallback = jasmine.createSpy('callback');
103103
testModel.capacity = 1000;
104+
testModel.startingSOC = 100;
104105
testModel.type = "timeline";
105106
mockDomainObject.useCapability.andReturn(asPromise([
106107
{ key: "power", start: 0, end: 15 }

0 commit comments

Comments
 (0)