small fixes in program Salimax

This commit is contained in:
atef 2023-11-14 10:48:16 +01:00
parent 89492a76e2
commit dd19222728
1 changed files with 12 additions and 7 deletions

View File

@ -51,8 +51,8 @@ internal static class Program
private const String VpnServerIp = "194.182.190.208";
private static IPAddress? _controllerIpAddress;
private static UdpClient _udpListener;
private static IPAddress? _controllerIpAddress;
private static UdpClient _udpListener = null!;
private static ConnectionFactory? _factory ;
private static IConnection ? _connection;
private static IModel? _channel;
@ -219,8 +219,8 @@ internal static class Program
Watchdog.NotifyAlive();
var record = ReadStatus();
var currentSalimaxState = GetSalimaxStateAlarm(record);
var currentSalimaxState = GetSalimaxStateAlarm(record);
SendSalimaxStateAlarm(currentSalimaxState);
@ -300,11 +300,14 @@ internal static class Program
{
try
{
_factory = new ConnectionFactory { HostName = VpnServerIp };
_factory = new ConnectionFactory { HostName = VpnServerIp };
_connection = _factory.CreateConnection();
_channel = _connection.CreateModel();
_channel.QueueDeclare(queue: "statusQueue", durable: false, exclusive: false, autoDelete: false, arguments: null);
_channel = _connection.CreateModel();
_channel.QueueDeclare(queue: "statusQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);
Console.WriteLine("The controller sends its status to the middleware for the first time");
if (s3Bucket != null) InformMiddleware(s3Bucket, (Int32)currentSalimaxState);
_subscribedToQueue = true;
@ -375,12 +378,14 @@ internal static class Program
var salimaxAlarmsState = (record.Battery is not null && record.Battery.Warnings.Any())
| record.AcDc.Warnings.Any()
| record.AcDc.SystemControl.Warnings.Any()
| record.DcDc.Warnings.Any()
? SalimaxAlarmState.Orange
: SalimaxAlarmState.Green; // this will be replaced by LedState
salimaxAlarmsState = (record.Battery is not null && record.Battery.Alarms.Any())
| record.AcDc.Alarms.Any()
| record.AcDc.SystemControl.Alarms.Any()
| record.DcDc.Alarms.Any()
| alarmCondition is not null
? SalimaxAlarmState.Red