From dd19222728577ad7282b6e628cb5b36ee4a72f54 Mon Sep 17 00:00:00 2001 From: atef Date: Tue, 14 Nov 2023 10:48:16 +0100 Subject: [PATCH] small fixes in program Salimax --- csharp/App/SaliMax/src/Program.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/csharp/App/SaliMax/src/Program.cs b/csharp/App/SaliMax/src/Program.cs index 245281a1f..20ff268d9 100644 --- a/csharp/App/SaliMax/src/Program.cs +++ b/csharp/App/SaliMax/src/Program.cs @@ -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,13 +300,16 @@ 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; } catch (Exception ex) @@ -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