Add ControlPvPower function.
This commit is contained in:
parent
85b248dc6f
commit
91da191874
|
@ -1,3 +1,6 @@
|
|||
#undef Amax
|
||||
#undef GridLimit
|
||||
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
using Flurl.Http;
|
||||
|
@ -21,6 +24,8 @@ using InnovEnergy.Lib.Units;
|
|||
using InnovEnergy.Lib.Utils;
|
||||
using InnovEnergy.App.SaliMax.AggregationService;
|
||||
using InnovEnergy.App.SaliMax.DataTypes;
|
||||
using static InnovEnergy.App.SaliMax.AggregationService.Aggregator;
|
||||
using static InnovEnergy.App.SaliMax.MiddlewareClasses.MiddlewareAgent;
|
||||
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig;
|
||||
using DeviceState = InnovEnergy.App.SaliMax.Devices.DeviceState;
|
||||
|
||||
|
@ -80,9 +85,16 @@ internal static class Program
|
|||
public static async Task Main(String[] args)
|
||||
{
|
||||
//Do not await
|
||||
Aggregator.HourlyDataAggregationManager().ContinueWith(t => t.Exception.WriteLine(), TaskContinuationOptions.OnlyOnFaulted).SupressAwaitWarning();
|
||||
Aggregator.DailyDataAggregationManager().ContinueWith(t => t.Exception.WriteLine(), TaskContinuationOptions.OnlyOnFaulted).SupressAwaitWarning();
|
||||
MiddlewareAgent.InitializeCommunicationToMiddleware();
|
||||
HourlyDataAggregationManager()
|
||||
.ContinueWith(t=>t.Exception.WriteLine(), TaskContinuationOptions.OnlyOnFaulted)
|
||||
.SupressAwaitWarning();
|
||||
|
||||
DailyDataAggregationManager()
|
||||
.ContinueWith(t=>t.Exception.WriteLine(), TaskContinuationOptions.OnlyOnFaulted)
|
||||
.SupressAwaitWarning();
|
||||
|
||||
InitializeCommunicationToMiddleware();
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
|
@ -142,8 +154,8 @@ internal static class Program
|
|||
? new DcPowerDevice { Power = 0 }
|
||||
: Topology.CalculateDcLoad(acDc, pvOnDc, dcDc);
|
||||
|
||||
var acDcToDcLink = devices.LoadOnDc.DeviceState == DeviceState.Disabled
|
||||
? Topology.CalculateAcDcToDcLink(pvOnDc, dcDc, acDc)
|
||||
var acDcToDcLink = devices.LoadOnDc.DeviceState == DeviceState.Disabled ?
|
||||
Topology.CalculateAcDcToDcLink(pvOnDc, dcDc, acDc)
|
||||
: new DcPowerDevice{ Power = acDc.Dc.Power};
|
||||
|
||||
return new StatusRecord
|
||||
|
@ -235,7 +247,7 @@ internal static class Program
|
|||
// ReSharper disable once FunctionNeverReturns
|
||||
}
|
||||
|
||||
public static void SendSalimaxStateAlarm(StatusMessage currentSalimaxState, StatusRecord record)
|
||||
private static void SendSalimaxStateAlarm(StatusMessage currentSalimaxState, StatusRecord record)
|
||||
{
|
||||
var s3Bucket = Config.Load().S3?.Bucket;
|
||||
|
||||
|
@ -268,7 +280,7 @@ internal static class Program
|
|||
}
|
||||
|
||||
//If there is an available message from the RabbitMQ Broker, apply the configuration file
|
||||
Configuration? config = MiddlewareAgent.SetConfigurationFile();
|
||||
Configuration? config = SetConfigurationFile();
|
||||
if (config != null)
|
||||
{
|
||||
record.ApplyConfigFile(config);
|
||||
|
@ -324,18 +336,19 @@ internal static class Program
|
|||
|
||||
foreach (var battery in record.Battery.Devices)
|
||||
{
|
||||
i++;
|
||||
foreach (var alarm in battery.Alarms)
|
||||
{
|
||||
alarmList.Add(new AlarmOrWarning
|
||||
{
|
||||
Date = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
Time = DateTime.Now.ToString("HH:mm:ss"),
|
||||
CreatedBy = "Battery" + i,
|
||||
CreatedBy = "Battery node" + record.Config.Devices.BatteryNodes[i],
|
||||
Description = alarm
|
||||
});
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
foreach (var warning in record.AcDc.Warnings)
|
||||
|
@ -441,6 +454,23 @@ internal static class Program
|
|||
r.AcDc.ResetAlarms();
|
||||
}
|
||||
|
||||
// This is will be used for
|
||||
private static void ControlPvPower(this StatusRecord r, Int16 exportLimit = 100)
|
||||
{
|
||||
var inverters = r.AcDc.Devices;
|
||||
var dcDevices = r.DcDc.Devices;
|
||||
var configFile = r.Config;
|
||||
|
||||
var devicesConfig = configFile.GridTie;
|
||||
|
||||
inverters.ForEach(d => d.Control.Dc.MaxVoltage = devicesConfig.AcDc.MaxDcLinkVoltage);
|
||||
inverters.ForEach(d => d.Control.Dc.MinVoltage = devicesConfig.AcDc.MinDcLinkVoltage);
|
||||
inverters.ForEach(d => d.Control.Dc.ReferenceVoltage = devicesConfig.AcDc.ReferenceDcLinkVoltage);
|
||||
|
||||
dcDevices.ForEach(d => d.Control.DroopControl.UpperVoltage = devicesConfig.DcDc.UpperDcLinkVoltage);
|
||||
dcDevices.ForEach(d => d.Control.DroopControl.LowerVoltage = devicesConfig.DcDc.LowerDcLinkVoltage);
|
||||
dcDevices.ForEach(d => d.Control.DroopControl.ReferenceVoltage = devicesConfig.DcDc.ReferenceDcLinkVoltage);
|
||||
}
|
||||
|
||||
// why this is not in Controller?
|
||||
private static void DistributePower(StatusRecord record, EssControl essControl)
|
||||
|
@ -484,6 +514,7 @@ internal static class Program
|
|||
|
||||
private static void ApplyDcDcDefaultSettings(this SystemControlRegisters? sc)
|
||||
{
|
||||
|
||||
if (sc is null)
|
||||
return;
|
||||
|
||||
|
@ -498,6 +529,7 @@ internal static class Program
|
|||
sc.UseSlaveIdForAddressing = true;
|
||||
sc.SlaveErrorHandling = SlaveErrorHandling.Relaxed;
|
||||
sc.SubSlaveErrorHandling = SubSlaveErrorHandling.Off;
|
||||
|
||||
sc.ResetAlarmsAndWarnings = true;
|
||||
}
|
||||
|
||||
|
@ -531,4 +563,5 @@ internal static class Program
|
|||
status.Config.GridSetPoint = config.GridSetPoint * 1000; // converted from kW to W
|
||||
status.Config.ForceCalibrationCharge = config.ForceCalibrationCharge;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue