From 80f91863199c568cf1aefddf79cb0a534a904e00 Mon Sep 17 00:00:00 2001 From: atef Date: Fri, 19 Jan 2024 12:32:43 +0100 Subject: [PATCH] Add the daily production data in AMPT --- csharp/Lib/Devices/AMPT/AmptDevices.cs | 18 ++++++++++++++---- csharp/Lib/Devices/AMPT/AmptStatus.cs | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/csharp/Lib/Devices/AMPT/AmptDevices.cs b/csharp/Lib/Devices/AMPT/AmptDevices.cs index 04f6183f3..8ba1248ca 100644 --- a/csharp/Lib/Devices/AMPT/AmptDevices.cs +++ b/csharp/Lib/Devices/AMPT/AmptDevices.cs @@ -47,6 +47,11 @@ public class AmptDevices // CommunicationUnit knows how many StringOptimizers are connected var nStringOptimizers = cuStatus.NumberOfStringOptimizers; + //Factor + var nEnergyFactor = cuStatus.EnergyScaleFactor; + var nCurrentFactor = cuStatus.CurrentScaleFactor; + var nVoltageFactor = cuStatus.VoltageScaleFactor; + // hardcoded: every SO has 2 strings (produced like this by AMPT) var nStrings = nStringOptimizers * 2; @@ -62,12 +67,16 @@ public class AmptDevices // TODO: alarm when we see substantially different voltages - var busVoltage = nStringOptimizers == 0 ? 0 : soStati.Average(r => r.Voltage); - var busCurrent = nStringOptimizers == 0 ? 0 : soStati.Sum (r => r.Current); + var busVoltage = nStringOptimizers == 0 ? 0 : soStati.Average(r => r.Voltage); + var busCurrent = nStringOptimizers == 0 ? 0 : soStati.Sum (r => r.Current); + var dailyOutputEnergy = nStringOptimizers == 0 ? 0 : soStati.Sum (r => r.ProductionToday); + + dailyOutputEnergy.WriteLine(" Daily Production "); + var dc = new DcBus { Voltage = busVoltage, - Current = busCurrent, + Current = busCurrent }; // flatten the 2 strings of each SO into one array @@ -76,7 +85,8 @@ public class AmptDevices return new AmptStatus { Dc = dc, - Strings = strings + Strings = strings, + DcWh = dailyOutputEnergy }; } diff --git a/csharp/Lib/Devices/AMPT/AmptStatus.cs b/csharp/Lib/Devices/AMPT/AmptStatus.cs index 49f118011..bbaa5fd05 100644 --- a/csharp/Lib/Devices/AMPT/AmptStatus.cs +++ b/csharp/Lib/Devices/AMPT/AmptStatus.cs @@ -5,7 +5,8 @@ namespace InnovEnergy.Lib.Devices.AMPT; public class AmptStatus : IMppt { - public required DcBus Dc { get; init; } - public required IReadOnlyList Strings { get; init; } + public required DcBus Dc { get; init; } + public required IReadOnlyList Strings { get; init; } + public required Double DcWh { get; init; } //Daily integrated string output energy in Wh }