Merge pull request #1196 from hudsonfoo/open1185

[Timeline] Add battery starting state-of-charge
This commit is contained in:
Victor Woeltjen 2016-10-04 18:06:50 -07:00 committed by GitHub
commit c9c8998fa2
3 changed files with 16 additions and 2 deletions

View File

@ -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": {

View File

@ -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)
);
}

View File

@ -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 }