add battery node in the salimax alarm and warning

This commit is contained in:
atef 2024-03-15 11:36:19 +01:00
parent 3ab2570084
commit 183f8cfc2a
1 changed files with 72 additions and 64 deletions

View File

@ -334,7 +334,77 @@ internal static class Program
var alarmList = new List<AlarmOrWarning>(); var alarmList = new List<AlarmOrWarning>();
var warningList = new List<AlarmOrWarning>(); var warningList = new List<AlarmOrWarning>();
var bAlarmList = new List<String>();
var bWarningList = new List<String>();
if (record.Battery != null)
{
var i = 0;
foreach (var battery in record.Battery.Devices)
{
var devicesBatteryNode = record.Config.Devices.BatteryNodes[i];
if (battery.LimpBitMap == 0)
{
// "All String are Active".WriteLine();
}
else if (IsPowerOfTwo(battery.LimpBitMap))
{
"1 String is disabled".WriteLine();
warningList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + devicesBatteryNode,
Description = "1 String is disabled"
});
bWarningList.Add("/"+i+1 + "/1 String is disabled"); // battery id instead ( i +1 ) of node id: requested from the frontend
}
else
{
"2 or more string are disabled".WriteLine();
alarmList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + devicesBatteryNode,
Description = "2 or more string are disabled"
});
bAlarmList.Add(i +";2 or more string are disabled");
}
foreach (var warning in record.Battery.Warnings)
{
warningList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + devicesBatteryNode,
Description = warning
});
bWarningList.Add(i +";" + warning);
}
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 node" + devicesBatteryNode,
Description = alarm
});
bWarningList.Add(i +";" + alarm);
}
i++;
}
}
if (alarmCondition is not null) if (alarmCondition is not null)
{ {
alarmCondition.LogInfo(); alarmCondition.LogInfo();
@ -369,68 +439,6 @@ internal static class Program
Description = alarm.ToString() Description = alarm.ToString()
}); });
} }
if (record.Battery != null)
{
var i = 0;
foreach (var battery in record.Battery.Devices)
{
if (battery.LimpBitMap == 0)
{
// "All String are Active".WriteLine();
}
else if (IsPowerOfTwo(battery.LimpBitMap))
{
"1 String is disabled".WriteLine();
warningList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + record.Config.Devices.BatteryNodes[i],
Description = "1 String is disabled"
});
}
else
{
"2 or more string are disabled".WriteLine();
alarmList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + record.Config.Devices.BatteryNodes[i],
Description = "2 or more string are disabled"
});
}
foreach (var warning in record.Battery.Warnings)
{
warningList.Add(new AlarmOrWarning
{
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Time = DateTime.Now.ToString("HH:mm:ss"),
CreatedBy = "Battery node" + record.Config.Devices.BatteryNodes[i],
Description = warning
});
}
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 node" + record.Config.Devices.BatteryNodes[i],
Description = alarm
});
}
i++;
}
}
foreach (var warning in record.AcDc.Warnings) foreach (var warning in record.AcDc.Warnings)
{ {
@ -464,8 +472,8 @@ internal static class Program
int.TryParse(s3Bucket?.Split("-")[0], out var installationId); int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
record.Log.SalimaxAlarms = alarmList; //record.Log.SalimaxAlarms = bAlarmList;
record.Log.SalimaxWarnings = warningList; //record.Log.SalimaxWarnings = bWarningList;
var returnedStatus = new StatusMessage var returnedStatus = new StatusMessage
{ {