From 254604491aa829300c793de49d371bd710a82017 Mon Sep 17 00:00:00 2001
From: Markus Quaritsch <markus.quaritsch@tugraz.at>
Date: Mon, 24 Aug 2020 15:50:15 +0200
Subject: [PATCH] correct reading/writing battery capacity: use ampere-hour.

---
 VECTO/GUI/BatteryForm.Designer.vb                       | 4 ++--
 VECTO/GUI/BatteryForm.vb                                | 2 +-
 VECTO/Input Files/Battery.vb                            | 2 +-
 VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/VECTO/GUI/BatteryForm.Designer.vb b/VECTO/GUI/BatteryForm.Designer.vb
index 4a1407df72..20061845e6 100644
--- a/VECTO/GUI/BatteryForm.Designer.vb
+++ b/VECTO/GUI/BatteryForm.Designer.vb
@@ -105,9 +105,9 @@ Partial Class BatteryForm
         Me.lblCapacityUnit.AutoSize = true
         Me.lblCapacityUnit.Location = New System.Drawing.Point(153, 7)
         Me.lblCapacityUnit.Name = "lblCapacityUnit"
-        Me.lblCapacityUnit.Size = New System.Drawing.Size(25, 13)
+        Me.lblCapacityUnit.Size = New System.Drawing.Size(26, 13)
         Me.lblCapacityUnit.TabIndex = 24
-        Me.lblCapacityUnit.Text = "[As]"
+        Me.lblCapacityUnit.Text = "[Ah]"
         '
         'lblCapacity
         '
diff --git a/VECTO/GUI/BatteryForm.vb b/VECTO/GUI/BatteryForm.vb
index e1f2c39b2f..b7902b750e 100644
--- a/VECTO/GUI/BatteryForm.vb
+++ b/VECTO/GUI/BatteryForm.vb
@@ -174,7 +174,7 @@ Public Class BatteryForm
 
         Dim basePath As String = Path.GetDirectoryName(file)
         tbMakeModel.Text = battery.Model
-        tbCapacity.Text = battery.Capacity.ToGUIFormat()
+        tbCapacity.Text = battery.Capacity.AsAmpHour.ToGUIFormat()
 
         tbCFactor.Text = battery.MaxCurrentFactor.ToGUIFormat()
         tbSoCMin.Text = (battery.MinSOC * 100).ToGUIFormat()
diff --git a/VECTO/Input Files/Battery.vb b/VECTO/Input Files/Battery.vb
index e587205213..2e72a647b5 100644
--- a/VECTO/Input Files/Battery.vb	
+++ b/VECTO/Input Files/Battery.vb	
@@ -213,7 +213,7 @@ Public Class Battery
 
     Public ReadOnly Property Capacity As AmpereSecond Implements IBatteryPackDeclarationInputData.Capacity
         Get
-            Return BatCapacity.SI(Of AmpereSecond)
+            Return BatCapacity.SI(Unit.SI.Ampere.Hour).Cast(Of AmpereSecond)
         End Get
     End Property
 
diff --git a/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs b/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs
index 373b7924b9..71d19e9d9d 100644
--- a/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs
+++ b/VectoCore/VectoCore/OutputData/FileIO/JSONFileWriter.cs
@@ -94,7 +94,7 @@ public class JSONFileWriter : IOutputFileWriter
 		body.Add("SavedInDeclMode", declMode);
 
 		body.Add("Model", battery.Model);
-		body.Add("Capacity", battery.Capacity.Value());
+		body.Add("Capacity", battery.Capacity.AsAmpHour);
 		body.Add("SOC_min", battery.MinSOC * 100.0);
 		body.Add("SOC_max",battery.MaxSOC * 100.0);
 		body.Add("MaxCurrentFactor", battery.MaxCurrentFactor);
-- 
GitLab