[Timeline] Fix logic error

Issue #1185. Also removed direct modification of domain object.
This commit is contained in:
David Hudson
2016-09-30 21:34:03 +02:00
parent e9f4db7719
commit e077f9ee18

View File

@@ -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,14 +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) {
domainObject.getModel().startingSOC = startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ?
parseFloat(domainObject.getModel().startingSOC) || 100; 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().startingSOC / 100) * 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)
); );
} }