Merge pull request #1196 from hudsonfoo/open1185
[Timeline] Add battery starting state-of-charge
This commit is contained in:
@@ -182,6 +182,16 @@ define([
|
|||||||
"capacity"
|
"capacity"
|
||||||
],
|
],
|
||||||
"pattern": "^-?\\d+(\\.\\d*)?$"
|
"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": {
|
"model": {
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ define(
|
|||||||
// Build graphs for this group of utilizations
|
// Build graphs for this group of utilizations
|
||||||
function buildGraphs(utilizations) {
|
function buildGraphs(utilizations) {
|
||||||
var utilizationMap = {},
|
var utilizationMap = {},
|
||||||
result = {};
|
result = {},
|
||||||
|
startingSOC;
|
||||||
|
|
||||||
// Bucket utilizations by type
|
// Bucket utilizations by type
|
||||||
utilizations.forEach(function (u) {
|
utilizations.forEach(function (u) {
|
||||||
@@ -55,12 +56,14 @@ define(
|
|||||||
if (domainObject.getModel().type === 'timeline' &&
|
if (domainObject.getModel().type === 'timeline' &&
|
||||||
result.power &&
|
result.power &&
|
||||||
domainObject.getModel().capacity > 0) {
|
domainObject.getModel().capacity > 0) {
|
||||||
|
startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ?
|
||||||
|
100 : parseFloat(domainObject.getModel().startingSOC);
|
||||||
|
|
||||||
result.battery = new CumulativeGraph(
|
result.battery = new CumulativeGraph(
|
||||||
result.power,
|
result.power,
|
||||||
0,
|
0,
|
||||||
domainObject.getModel().capacity, // Watts
|
domainObject.getModel().capacity, // Watts
|
||||||
domainObject.getModel().capacity,
|
(startingSOC / 100) * domainObject.getModel().capacity,
|
||||||
1 / 3600000 // millis-to-hour (since units are watt-hours)
|
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 () {
|
it("provides a battery graph for timelines with capacity", function () {
|
||||||
var mockCallback = jasmine.createSpy('callback');
|
var mockCallback = jasmine.createSpy('callback');
|
||||||
testModel.capacity = 1000;
|
testModel.capacity = 1000;
|
||||||
|
testModel.startingSOC = 100;
|
||||||
testModel.type = "timeline";
|
testModel.type = "timeline";
|
||||||
mockDomainObject.useCapability.andReturn(asPromise([
|
mockDomainObject.useCapability.andReturn(asPromise([
|
||||||
{ key: "power", start: 0, end: 15 }
|
{ key: "power", start: 0, end: 15 }
|
||||||
|
|||||||
Reference in New Issue
Block a user