Create an apply Default settings for dc

This commit is contained in:
atef 2023-06-22 10:00:44 +02:00
parent 8455bb64e3
commit f1c03ad333
1 changed files with 20 additions and 26 deletions

View File

@ -322,7 +322,7 @@ internal static class Program
});
}
private static void ApplyDefaultSettings(this SystemControlRegisters? sc)
private static void ApplyDefaultSettingsAc(this SystemControlRegisters? sc)
{
if (sc is null)
return;
@ -333,7 +333,7 @@ internal static class Program
#if DEBUG
sc.CommunicationTimeout = TimeSpan.FromMinutes(2);
#else
sc.CommunicationTimeout = TimeSpan.FromSeconds(10);
sc.CommunicationTimeout = TimeSpan.FromSeconds(20);
#endif
sc.PowerSetPointActivation = PowerSetPointActivation.Immediate;
@ -343,37 +343,31 @@ internal static class Program
sc.ResetAlarmsAndWarnings = true;
}
private static DcDcDevicesRecord ResetAlarms(this DcDcDevicesRecord dcDcStatus)
private static void ApplyDefaultSettingsDc(this SystemControlRegisters? sc)
{
var sc = dcDcStatus.SystemControl;
if (sc is null)
return;
if (sc is not null)
sc.ResetAlarmsAndWarnings = sc.Alarms.Any();
sc.SystemConfig = DcDcOnly;
foreach (var d in dcDcStatus.Devices)
d.Control.ResetAlarmsAndWarnings = d.Status.Alarms.Any() || d.Status.Warnings.Any();
#if DEBUG
sc.CommunicationTimeout = TimeSpan.FromMinutes(2);
#else
sc.CommunicationTimeout = TimeSpan.FromSeconds(20);
#endif
return dcDcStatus;
}
private static AcDcDevicesRecord ResetAlarms(this AcDcDevicesRecord acDcRecord)
{
var sc = acDcRecord.SystemControl;
if (sc is not null)
sc.ResetAlarmsAndWarnings = sc.Alarms.Any() || sc.Warnings.Any();
foreach (var d in acDcRecord.Devices)
d.Control.ResetAlarmsAndWarnings = d.Status.Alarms.Any() || d.Status.Warnings.Any();
return acDcRecord;
sc.PowerSetPointActivation = PowerSetPointActivation.Immediate;
sc.UseSlaveIdForAddressing = true;
sc.SlaveErrorHandling = SlaveErrorHandling.Relaxed;
sc.SubSlaveErrorHandling = SubSlaveErrorHandling.Off;
sc.ResetAlarmsAndWarnings = true;
}
private static async Task UploadCsv(StatusRecord status, UnixTime timeStamp)
{
timeStamp.WriteLine();
var csv = status.ToCsv().WriteLine();
var csv = status.ToCsv();//.WriteLine();
var s3Path = timeStamp + ".csv";
var request = S3Config.CreatePutRequest(s3Path);
var response = await request.PutAsync(new StringContent(csv));