From 943e2ebe14fc076904ca2eb2832c08f8197efc1e Mon Sep 17 00:00:00 2001 From: David Hudson Date: Tue, 20 Sep 2016 17:40:08 +0900 Subject: [PATCH] [Timeline] Convert SOC to use percentages Also includes updated validation params which allow for floats to a maximum of 100 as well as a percentage sign which is later removed. --- platform/features/timeline/bundle.js | 4 ++-- .../features/timeline/src/capabilities/GraphCapability.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/platform/features/timeline/bundle.js b/platform/features/timeline/bundle.js index 145a496f08..42b3c948f9 100644 --- a/platform/features/timeline/bundle.js +++ b/platform/features/timeline/bundle.js @@ -184,14 +184,14 @@ define([ "pattern": "^-?\\d+(\\.\\d*)?$" }, { - "name": "Battery Starting SOC", + "name": "Battery starting SOC (%)", "control": "textfield", "required": false, "conversion": "number", "property": [ "startingSOC" ], - "pattern": "^-?\\d+(\\.\\d*)?$" + "pattern": "^([0-9](\\.\\d*)?|[1-9][0-9](\\.\\d*)?|100)%?$" } ], "model": { diff --git a/platform/features/timeline/src/capabilities/GraphCapability.js b/platform/features/timeline/src/capabilities/GraphCapability.js index c4e5166f0e..86095b13ab 100644 --- a/platform/features/timeline/src/capabilities/GraphCapability.js +++ b/platform/features/timeline/src/capabilities/GraphCapability.js @@ -55,12 +55,14 @@ define( if (domainObject.getModel().type === 'timeline' && result.power && domainObject.getModel().capacity > 0) { + domainObject.getModel().startingSOC = + parseFloat(domainObject.getModel().startingSOC) || 100; result.battery = new CumulativeGraph( result.power, 0, domainObject.getModel().capacity, // Watts - domainObject.getModel().startingSOC, + (domainObject.getModel().startingSOC/100)*domainObject.getModel().capacity, 1 / 3600000 // millis-to-hour (since units are watt-hours) ); }