Update Middelware classes for growatt
This commit is contained in:
parent
84b8446ec3
commit
b1b307a12f
|
|
@ -68,7 +68,7 @@ public static class MiddlewareAgent
|
||||||
if (config != null)
|
if (config != null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Received a configuration message: GridSetPoint is " + config.GridSetPoint +
|
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
|
// Send the reply to the sender's endpoint
|
||||||
_udpListener.Send(replyData, replyData.Length, serverEndpoint);
|
_udpListener.Send(replyData, replyData.Length, serverEndpoint);
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ namespace InnovEnergy.App.GrowattCommunication.MiddlewareClasses;
|
||||||
|
|
||||||
public static class RabbitMqManager
|
public static class RabbitMqManager
|
||||||
{
|
{
|
||||||
public static ConnectionFactory? Factory ;
|
private static ConnectionFactory? _factory ;
|
||||||
public static IConnection ? Connection;
|
private static IConnection ? _connection;
|
||||||
public static IModel? Channel;
|
private static IModel? _channel;
|
||||||
|
|
||||||
public static Boolean SubscribeToQueue(StatusMessage currentSalimaxState, String? s3Bucket,String VpnServerIp)
|
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 { HostName = VpnServerIp };
|
||||||
|
|
||||||
Factory = new ConnectionFactory
|
_factory = new ConnectionFactory
|
||||||
{
|
{
|
||||||
HostName = VpnServerIp,
|
HostName = VpnServerIp,
|
||||||
Port = 5672,
|
Port = 5672,
|
||||||
|
|
@ -27,9 +27,9 @@ public static class RabbitMqManager
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Connection = Factory.CreateConnection();
|
_connection = _factory.CreateConnection();
|
||||||
Channel = Connection.CreateModel();
|
_channel = _connection.CreateModel();
|
||||||
Channel.QueueDeclare(queue: "statusQueue", durable: true, exclusive: false, autoDelete: false, arguments: null);
|
_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");
|
Console.WriteLine("The controller sends its status to the middleware for the first time");
|
||||||
if (s3Bucket != null) InformMiddleware(currentSalimaxState);
|
if (s3Bucket != null) InformMiddleware(currentSalimaxState);
|
||||||
|
|
@ -49,7 +49,7 @@ public static class RabbitMqManager
|
||||||
var message = JsonSerializer.Serialize(status);
|
var message = JsonSerializer.Serialize(status);
|
||||||
var body = Encoding.UTF8.GetBytes(message);
|
var body = Encoding.UTF8.GetBytes(message);
|
||||||
|
|
||||||
Channel.BasicPublish(exchange: string.Empty,
|
_channel.BasicPublish(exchange: string.Empty,
|
||||||
routingKey: "statusQueue",
|
routingKey: "statusQueue",
|
||||||
basicProperties: null,
|
basicProperties: null,
|
||||||
body: body);
|
body: body);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue