New AMPT paths are created in salimax
This commit is contained in:
parent
eeb949bdfa
commit
7510ee0ce2
|
|
@ -25,7 +25,7 @@ public record StatusRecord
|
||||||
public required DcPowerDevice? AcDcToDcLink { get; init; }
|
public required DcPowerDevice? AcDcToDcLink { get; init; }
|
||||||
public required DcPowerDevice? LoadOnDc { get; init; }
|
public required DcPowerDevice? LoadOnDc { get; init; }
|
||||||
public required IRelaysRecord? Relays { get; init; }
|
public required IRelaysRecord? Relays { get; init; }
|
||||||
public required AmptStatus? PvOnDc { get; init; }
|
public required IReadOnlyList<AmptStatus?> PvOnDc { get; init; }
|
||||||
public required Config Config { get; set; }
|
public required Config Config { get; set; }
|
||||||
public required SystemLog Log { get; init; } // TODO: init only
|
public required SystemLog Log { get; init; } // TODO: init only
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#undef Amax
|
#define Amax
|
||||||
#undef GridLimit
|
#undef GridLimit
|
||||||
|
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
|
@ -47,6 +47,7 @@ internal static class Program
|
||||||
private static readonly Channel GridMeterChannel;
|
private static readonly Channel GridMeterChannel;
|
||||||
private static readonly Channel IslandBusLoadChannel;
|
private static readonly Channel IslandBusLoadChannel;
|
||||||
private static readonly Channel PvOnDc;
|
private static readonly Channel PvOnDc;
|
||||||
|
private static readonly Channel SecondPvOnDc;
|
||||||
private static readonly Channel PvOnAcGrid;
|
private static readonly Channel PvOnAcGrid;
|
||||||
private static readonly Channel PvOnAcIsland;
|
private static readonly Channel PvOnAcIsland;
|
||||||
private static readonly Channel RelaysChannel;
|
private static readonly Channel RelaysChannel;
|
||||||
|
|
@ -77,6 +78,7 @@ internal static class Program
|
||||||
GridMeterChannel = CreateChannel(d.GridMeterIp);
|
GridMeterChannel = CreateChannel(d.GridMeterIp);
|
||||||
IslandBusLoadChannel = CreateChannel(d.IslandBusLoadMeterIp);
|
IslandBusLoadChannel = CreateChannel(d.IslandBusLoadMeterIp);
|
||||||
PvOnDc = CreateChannel(d.PvOnDc);
|
PvOnDc = CreateChannel(d.PvOnDc);
|
||||||
|
SecondPvOnDc = CreateChannel(d.SecondPvOnDc);
|
||||||
PvOnAcGrid = CreateChannel(d.PvOnAcGrid);
|
PvOnAcGrid = CreateChannel(d.PvOnAcGrid);
|
||||||
PvOnAcIsland = CreateChannel(d.PvOnAcIsland);
|
PvOnAcIsland = CreateChannel(d.PvOnAcIsland);
|
||||||
RelaysChannel = CreateChannel(d.RelaysIp);
|
RelaysChannel = CreateChannel(d.RelaysIp);
|
||||||
|
|
@ -133,6 +135,7 @@ internal static class Program
|
||||||
var gridMeterDevice = new EmuMeterDevice(GridMeterChannel);
|
var gridMeterDevice = new EmuMeterDevice(GridMeterChannel);
|
||||||
var acIslandLoadMeter = new EmuMeterDevice(IslandBusLoadChannel);
|
var acIslandLoadMeter = new EmuMeterDevice(IslandBusLoadChannel);
|
||||||
var pvOnDcDevice = new AmptDevices(PvOnDc);
|
var pvOnDcDevice = new AmptDevices(PvOnDc);
|
||||||
|
var secondPvOnDcDevice = new AmptDevices(SecondPvOnDc);
|
||||||
var pvOnAcGridDevice = new AmptDevices(PvOnAcGrid);
|
var pvOnAcGridDevice = new AmptDevices(PvOnAcGrid);
|
||||||
var pvOnAcIslandDevice = new AmptDevices(PvOnAcIsland);
|
var pvOnAcIslandDevice = new AmptDevices(PvOnAcIsland);
|
||||||
var saliMaxTsRelaysDevice = new RelaysDeviceAdam6060(RelaysTsChannel);
|
var saliMaxTsRelaysDevice = new RelaysDeviceAdam6060(RelaysTsChannel);
|
||||||
|
|
@ -155,12 +158,15 @@ internal static class Program
|
||||||
var tsRelays = saliMaxTsRelaysDevice.Read();
|
var tsRelays = saliMaxTsRelaysDevice.Read();
|
||||||
var loadOnAcIsland = acIslandLoadMeter.Read();
|
var loadOnAcIsland = acIslandLoadMeter.Read();
|
||||||
var gridMeter = gridMeterDevice.Read();
|
var gridMeter = gridMeterDevice.Read();
|
||||||
var pvOnDc = pvOnDcDevice.Read();
|
var firstPvOnDc = pvOnDcDevice.Read();
|
||||||
|
var secondPvOnDc = secondPvOnDcDevice.Read();
|
||||||
var battery = batteryDevices.Read();
|
var battery = batteryDevices.Read();
|
||||||
|
|
||||||
var pvOnAcGrid = pvOnAcGridDevice.Read();
|
var pvOnAcGrid = pvOnAcGridDevice.Read();
|
||||||
var pvOnAcIsland = pvOnAcIslandDevice.Read();
|
var pvOnAcIsland = pvOnAcIslandDevice.Read();
|
||||||
|
|
||||||
|
IReadOnlyList<AmptStatus?> pvOnDc = new List<AmptStatus?> { firstPvOnDc, secondPvOnDc };
|
||||||
|
|
||||||
var gridBusToIslandBus = Topology.CalculateGridBusToIslandBusPower(pvOnAcIsland, loadOnAcIsland, acDc);
|
var gridBusToIslandBus = Topology.CalculateGridBusToIslandBusPower(pvOnAcIsland, loadOnAcIsland, acDc);
|
||||||
|
|
||||||
var gridBusLoad = devices.LoadOnAcGrid.DeviceState == DeviceState.Disabled
|
var gridBusLoad = devices.LoadOnAcGrid.DeviceState == DeviceState.Disabled
|
||||||
|
|
@ -290,7 +296,8 @@ internal static class Program
|
||||||
|
|
||||||
WriteControl(record);
|
WriteControl(record);
|
||||||
|
|
||||||
$"{DateTime.Now.Round(UpdateInterval).ToUnixTime()} : {record.StateMachine.State}: {record.StateMachine.Message}".WriteLine();
|
$"{record.StateMachine.State}: {record.StateMachine.Message}".WriteLine();
|
||||||
|
$"{DateTime.Now.Round(UpdateInterval).ToUnixTime()} : {DateTime.Now.Round(UpdateInterval):dd/MM/yyyy HH:mm:ss}".WriteLine();
|
||||||
|
|
||||||
record.CreateTopologyTextBlock().WriteLine();
|
record.CreateTopologyTextBlock().WriteLine();
|
||||||
|
|
||||||
|
|
@ -856,7 +863,6 @@ internal static class Program
|
||||||
|
|
||||||
|
|
||||||
Dictionary<string, object> jsonData = new Dictionary<string, object>();
|
Dictionary<string, object> jsonData = new Dictionary<string, object>();
|
||||||
//Console.WriteLine(csv);
|
|
||||||
|
|
||||||
foreach (var line in csv.Split('\n'))
|
foreach (var line in csv.Split('\n'))
|
||||||
{
|
{
|
||||||
|
|
@ -878,7 +884,6 @@ internal static class Program
|
||||||
string jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None);
|
string jsonOutput = JsonConvert.SerializeObject(jsonData, Formatting.None);
|
||||||
jsonOutput.LogInfo();
|
jsonOutput.LogInfo();
|
||||||
|
|
||||||
|
|
||||||
await RestApiSavingFile(csv);
|
await RestApiSavingFile(csv);
|
||||||
|
|
||||||
var s3Config = status.Config.S3;
|
var s3Config = status.Config.S3;
|
||||||
|
|
@ -909,7 +914,7 @@ internal static class Program
|
||||||
var compressedBytes = CompresseBytes(csvToSend);
|
var compressedBytes = CompresseBytes(csvToSend);
|
||||||
|
|
||||||
// Encode the compressed byte array as a Base64 string
|
// Encode the compressed byte array as a Base64 string
|
||||||
string base64String = Convert.ToBase64String(compressedBytes);
|
var base64String = Convert.ToBase64String(compressedBytes);
|
||||||
|
|
||||||
// Create StringContent from Base64 string
|
// Create StringContent from Base64 string
|
||||||
var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64");
|
var stringContent = new StringContent(base64String, Encoding.UTF8, "application/base64");
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
|
||||||
IslandBusLoadMeterIp = new() { Host = "localhost", Port = 5004, DeviceState = DeviceState.Measured},
|
IslandBusLoadMeterIp = new() { Host = "localhost", Port = 5004, DeviceState = DeviceState.Measured},
|
||||||
TruConvertAcIp = new() { Host = "localhost", Port = 5001, DeviceState = DeviceState.Measured},
|
TruConvertAcIp = new() { Host = "localhost", Port = 5001, DeviceState = DeviceState.Measured},
|
||||||
PvOnDc = new() { Host = "localhost", Port = 5005, DeviceState = DeviceState.Measured},
|
PvOnDc = new() { Host = "localhost", Port = 5005, DeviceState = DeviceState.Measured},
|
||||||
|
SecondPvOnDc = new() { Host = "localhost", Port = 5006, DeviceState = DeviceState.Measured},
|
||||||
LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured},
|
LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured},
|
||||||
TruConvertDcIp = new() { Host = "localhost", Port = 5002, DeviceState = DeviceState.Measured},
|
TruConvertDcIp = new() { Host = "localhost", Port = 5002, DeviceState = DeviceState.Measured},
|
||||||
BatteryIp = new() { Host = "localhost", Port = 5007, DeviceState = DeviceState.Measured},
|
BatteryIp = new() { Host = "localhost", Port = 5007, DeviceState = DeviceState.Measured},
|
||||||
|
|
@ -214,6 +215,7 @@ public class Config //TODO: let IE choose from config files (Json) and connect t
|
||||||
IslandBusLoadMeterIp = new() { Host = "10.0.4.2", Port = 502, DeviceState = DeviceState.Measured},
|
IslandBusLoadMeterIp = new() { Host = "10.0.4.2", Port = 502, DeviceState = DeviceState.Measured},
|
||||||
TruConvertAcIp = new() { Host = "10.0.2.1", Port = 502, DeviceState = DeviceState.Measured},
|
TruConvertAcIp = new() { Host = "10.0.2.1", Port = 502, DeviceState = DeviceState.Measured},
|
||||||
PvOnDc = new() { Host = "10.0.5.1", Port = 502, DeviceState = DeviceState.Measured},
|
PvOnDc = new() { Host = "10.0.5.1", Port = 502, DeviceState = DeviceState.Measured},
|
||||||
|
SecondPvOnDc = new() { Host = "10.0.5.2", Port = 502, DeviceState = DeviceState.Measured},
|
||||||
LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured},
|
LoadOnDc = new() { Host = "false" , Port = 0 , DeviceState = DeviceState.Measured},
|
||||||
TruConvertDcIp = new() { Host = "10.0.3.1", Port = 502, DeviceState = DeviceState.Measured},
|
TruConvertDcIp = new() { Host = "10.0.3.1", Port = 502, DeviceState = DeviceState.Measured},
|
||||||
BatteryIp = new() { Host = "localhost", Port = 6855, DeviceState = DeviceState.Measured },
|
BatteryIp = new() { Host = "localhost", Port = 6855, DeviceState = DeviceState.Measured },
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public class DeviceConfig
|
||||||
public required SalimaxDevice IslandBusLoadMeterIp { get; init; }
|
public required SalimaxDevice IslandBusLoadMeterIp { get; init; }
|
||||||
public required SalimaxDevice TruConvertAcIp { get; init; }
|
public required SalimaxDevice TruConvertAcIp { get; init; }
|
||||||
public required SalimaxDevice PvOnDc { get; init; }
|
public required SalimaxDevice PvOnDc { get; init; }
|
||||||
|
public required SalimaxDevice SecondPvOnDc { get; init; }
|
||||||
public required SalimaxDevice LoadOnDc { get; init; }
|
public required SalimaxDevice LoadOnDc { get; init; }
|
||||||
public required SalimaxDevice TruConvertDcIp { get; init; }
|
public required SalimaxDevice TruConvertDcIp { get; init; }
|
||||||
public required SalimaxDevice BatteryIp { get; init; }
|
public required SalimaxDevice BatteryIp { get; init; }
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public static class Topology
|
||||||
var f = status.LoadOnAcIsland?.Ac.Power.Active;
|
var f = status.LoadOnAcIsland?.Ac.Power.Active;
|
||||||
var g = status.AcDc.Dc.Power.Value;
|
var g = status.AcDc.Dc.Power.Value;
|
||||||
var h = status.AcDcToDcLink?.Power.Value;
|
var h = status.AcDcToDcLink?.Power.Value;
|
||||||
var i = status.PvOnDc?.Dc.Power.Value;
|
var i = status.PvOnDc?.Sum(p => p?.Dc.Power.Value);
|
||||||
var k = status.DcDc.Dc.Link.Power.Value;
|
var k = status.DcDc.Dc.Link.Power.Value;
|
||||||
var l = status.Battery is not null ? status.Battery.Dc.Power.Value : 0;
|
var l = status.Battery is not null ? status.Battery.Dc.Power.Value : 0;
|
||||||
var j = status.LoadOnDc?.Power.Value;
|
var j = status.LoadOnDc?.Power.Value;
|
||||||
|
|
@ -331,10 +331,8 @@ public static class Topology
|
||||||
/////////////////// top ///////////////////
|
/////////////////// top ///////////////////
|
||||||
|
|
||||||
var mppt = status.PvOnDc;
|
var mppt = status.PvOnDc;
|
||||||
|
var totalStrings = mppt.Sum(p => p?.Strings.Count ?? 0); // or we can use mppt.Sum(p => p.NbrOfStrings)
|
||||||
var nStrings = mppt is not null
|
var nStrings = "x" + totalStrings;
|
||||||
? "x" + mppt.Strings.Count
|
|
||||||
: "?";
|
|
||||||
|
|
||||||
var pvBox = TextBlock.FromString($"PV {nStrings}").Box();
|
var pvBox = TextBlock.FromString($"PV {nStrings}").Box();
|
||||||
var pvToBus = Flow.Vertical(i);
|
var pvToBus = Flow.Vertical(i);
|
||||||
|
|
@ -486,15 +484,15 @@ public static class Topology
|
||||||
}
|
}
|
||||||
|
|
||||||
//We are fake using the ampt instead of PvOnAc, We dont have a Pv on Ac at the moment and we don't have it classes :TODO
|
//We are fake using the ampt instead of PvOnAc, We dont have a Pv on Ac at the moment and we don't have it classes :TODO
|
||||||
public static DcPowerDevice? CalculateAcDcToDcLink(AmptStatus? pvOnDc, DcDcDevicesRecord? dcDc, AcDcDevicesRecord acDc)
|
public static DcPowerDevice? CalculateAcDcToDcLink(IReadOnlyList<AmptStatus?> pvOnDc, DcDcDevicesRecord? dcDc, AcDcDevicesRecord acDc)
|
||||||
{
|
{
|
||||||
var i = pvOnDc?.Dc.Power;
|
var i = pvOnDc?.Sum(p => p?.Dc.Power ?? 0);
|
||||||
var k = dcDc?.Dc.Link.Power; // We don't check on the DcDc because this device is mandatory
|
var k = dcDc?.Dc.Link.Power; // We don't check on the DcDc because this device is mandatory
|
||||||
var g = acDc?.Dc.Power;
|
var g = acDc?.Dc.Power;
|
||||||
|
|
||||||
if (i is null || k is null )
|
if (i is null || k is null )
|
||||||
{
|
{
|
||||||
return new DcPowerDevice { Power = g };
|
return new DcPowerDevice { Power = g ?? 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
var h = -(i - k); // [eq4]
|
var h = -(i - k); // [eq4]
|
||||||
|
|
@ -517,10 +515,10 @@ public static class Topology
|
||||||
return new AcPowerDevice { Power = d };
|
return new AcPowerDevice { Power = d };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DcPowerDevice? CalculateDcLoad(AcDcDevicesRecord? acDc, AmptStatus? pvOnDc, DcDcDevicesRecord? dcDc)
|
public static DcPowerDevice? CalculateDcLoad(AcDcDevicesRecord? acDc, IReadOnlyList<AmptStatus?> pvOnDc, DcDcDevicesRecord? dcDc)
|
||||||
{
|
{
|
||||||
var h = acDc?.Dc.Power; // We don't check on the AcDc because this device is mandatory
|
var h = acDc?.Dc.Power; // We don't check on the AcDc because this device is mandatory
|
||||||
var i = pvOnDc is not null? pvOnDc?.Dc.Power: 0;
|
var i = pvOnDc?.Sum(p => p?.Dc.Power ?? 0);
|
||||||
var k = dcDc?.Dc.Link.Power; // We don't check on the DcDc because this device is mandatory
|
var k = dcDc?.Dc.Link.Power; // We don't check on the DcDc because this device is mandatory
|
||||||
|
|
||||||
if (h is null || i is null || k is null)
|
if (h is null || i is null || k is null)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue