From b1b307a12fab37f6efa5ef88bc969e2838ffa33c Mon Sep 17 00:00:00 2001 From: atef Date: Mon, 20 Oct 2025 14:57:04 +0200 Subject: [PATCH] Update Middelware classes for growatt --- .../MiddlewareClasses/MiddlewareAgent.cs | 2 +- .../MiddlewareClasses/RabbitMQManager.cs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/csharp/App/GrowattCommunication/MiddlewareClasses/MiddlewareAgent.cs b/csharp/App/GrowattCommunication/MiddlewareClasses/MiddlewareAgent.cs index 92dcd0e58..e7d47b40f 100644 --- a/csharp/App/GrowattCommunication/MiddlewareClasses/MiddlewareAgent.cs +++ b/csharp/App/GrowattCommunication/MiddlewareClasses/MiddlewareAgent.cs @@ -68,7 +68,7 @@ public static class MiddlewareAgent if (config != null) { Console.WriteLine($"Received a configuration message: GridSetPoint is " + config.GridSetPoint + - ", MinimumSoC is " + config.MinimumSoC, " and operating priorty is " +config.OperatingPriority ); + ", MinimumSoC is " + config.MinimumSoC + " and operating priorty is " +config.OperatingPriority + "Number of batteries is " + config.BatteriesCount ); // Send the reply to the sender's endpoint _udpListener.Send(replyData, replyData.Length, serverEndpoint); diff --git a/csharp/App/GrowattCommunication/MiddlewareClasses/RabbitMQManager.cs b/csharp/App/GrowattCommunication/MiddlewareClasses/RabbitMQManager.cs index 93e770434..2207ba0af 100644 --- a/csharp/App/GrowattCommunication/MiddlewareClasses/RabbitMQManager.cs +++ b/csharp/App/GrowattCommunication/MiddlewareClasses/RabbitMQManager.cs @@ -7,9 +7,9 @@ namespace InnovEnergy.App.GrowattCommunication.MiddlewareClasses; public static class RabbitMqManager { - public static ConnectionFactory? Factory ; - public static IConnection ? Connection; - public static IModel? Channel; + private static ConnectionFactory? _factory ; + private static IConnection ? _connection; + private static IModel? _channel; public static Boolean SubscribeToQueue(StatusMessage currentSalimaxState, String? s3Bucket,String VpnServerIp) { @@ -17,7 +17,7 @@ public static class RabbitMqManager { //_factory = new ConnectionFactory { HostName = VpnServerIp }; - Factory = new ConnectionFactory + _factory = new ConnectionFactory { HostName = VpnServerIp, Port = 5672, @@ -27,9 +27,9 @@ public static class RabbitMqManager }; - Connection = Factory.CreateConnection(); - Channel = Connection.CreateModel(); - Channel.QueueDeclare(queue: "statusQueue", durable: true, exclusive: false, autoDelete: false, arguments: null); + _connection = _factory.CreateConnection(); + _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(currentSalimaxState); @@ -49,7 +49,7 @@ public static class RabbitMqManager var message = JsonSerializer.Serialize(status); var body = Encoding.UTF8.GetBytes(message); - Channel.BasicPublish(exchange: string.Empty, + _channel.BasicPublish(exchange: string.Empty, routingKey: "statusQueue", basicProperties: null, body: body);