Update InformMiddleware function
This commit is contained in:
parent
e143a4be6e
commit
9840e0c9f8
|
@ -261,6 +261,7 @@ internal static class Program
|
|||
private static void SendSalimaxStateAlarm(StatusMessage currentSalimaxState)
|
||||
{
|
||||
var s3Bucket = Config.Load().S3?.Bucket;
|
||||
|
||||
_heartBitInterval++;
|
||||
|
||||
//When the controller boots, it tries to subscribe to the queue
|
||||
|
@ -279,7 +280,7 @@ internal static class Program
|
|||
{
|
||||
_prevSalimaxState = currentSalimaxState.Status;
|
||||
if (s3Bucket != null)
|
||||
InformMiddleware(s3Bucket, currentSalimaxState);
|
||||
InformMiddleware(currentSalimaxState);
|
||||
}
|
||||
else if (_subscribedToQueue && _heartBitInterval>=15)
|
||||
{
|
||||
|
@ -288,7 +289,7 @@ internal static class Program
|
|||
currentSalimaxState.Type = MessageType.Heartbit;
|
||||
|
||||
if (s3Bucket != null)
|
||||
InformMiddleware(s3Bucket, currentSalimaxState);
|
||||
InformMiddleware(currentSalimaxState);
|
||||
}
|
||||
|
||||
//If there is an available message from the RabbitMQ Broker, subscribe to the queue
|
||||
|
@ -324,7 +325,7 @@ internal static class Program
|
|||
|
||||
Console.WriteLine("The controller sends its status to the middleware for the first time");
|
||||
|
||||
if (s3Bucket != null) InformMiddleware(s3Bucket, currentSalimaxState);
|
||||
if (s3Bucket != null) InformMiddleware(currentSalimaxState);
|
||||
|
||||
_subscribedToQueue = true;
|
||||
}
|
||||
|
@ -356,11 +357,8 @@ internal static class Program
|
|||
return IPAddress.None;
|
||||
}
|
||||
|
||||
private static void InformMiddleware(String? bucket, StatusMessage status)
|
||||
private static void InformMiddleware(StatusMessage status)
|
||||
{
|
||||
//dddddddddff
|
||||
int.TryParse(bucket[0].ToString(), out var installationId);
|
||||
|
||||
var message = JsonSerializer.Serialize(status);
|
||||
var body = Encoding.UTF8.GetBytes(message);
|
||||
|
||||
|
@ -480,13 +478,13 @@ internal static class Program
|
|||
? SalimaxAlarmState.Red
|
||||
: salimaxAlarmsState; // this will be replaced by LedState
|
||||
|
||||
int.TryParse(s3Bucket[0].ToString(), out var installationId);
|
||||
int.TryParse(s3Bucket?.Split("-")[0], out var installationId);
|
||||
|
||||
var returnedStatus = new StatusMessage
|
||||
{
|
||||
InstallationId = installationId,
|
||||
Status = salimaxAlarmsState,
|
||||
Type= MessageType.AlarmOrWarning,
|
||||
Type = MessageType.AlarmOrWarning,
|
||||
Alarms = alarmList,
|
||||
Warnings = warningList
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue