From d92f96f0123ed6ce4ed817f60ed2384818b787e4 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 23 Dec 2022 11:54:13 +0100 Subject: [PATCH] update present count event args, to receive actual present count from mqttclient --- ADIS_Csharp/RobotLib/Status/DevStatus.cs | 10 ++++++++-- ADIS_Csharp/RobotLib/Status/PresentEventArgs.cs | 7 ++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ADIS_Csharp/RobotLib/Status/DevStatus.cs b/ADIS_Csharp/RobotLib/Status/DevStatus.cs index 44ba3a2..1fe793e 100644 --- a/ADIS_Csharp/RobotLib/Status/DevStatus.cs +++ b/ADIS_Csharp/RobotLib/Status/DevStatus.cs @@ -23,8 +23,14 @@ namespace RobotLib.Status { StatusEventArgs eventArgs = new(message); StatusChanged?.Invoke(this, eventArgs); }else if(fromTopic == TOPIC_STATUS_PRESENT) { - PresentEventArgs presentEventArgs = new(true); - PresentChanged?.Invoke(this, presentEventArgs); + Int16 presentCnt = 0; + if (Int16.TryParse(message, out presentCnt)) { + PresentEventArgs presentEventArgs = new(presentCnt); + PresentChanged?.Invoke(this, presentEventArgs); + } else { + log.Error($"Invalid payload received {message}"); + } + } } diff --git a/ADIS_Csharp/RobotLib/Status/PresentEventArgs.cs b/ADIS_Csharp/RobotLib/Status/PresentEventArgs.cs index c10116f..f6a6054 100644 --- a/ADIS_Csharp/RobotLib/Status/PresentEventArgs.cs +++ b/ADIS_Csharp/RobotLib/Status/PresentEventArgs.cs @@ -6,10 +6,11 @@ using System.Threading.Tasks; namespace RobotLib.Status { public class PresentEventArgs { - public bool Present { get; } + public int Present { get; } - public PresentEventArgs(bool present) { - Present = present; + public PresentEventArgs(int presentCount) { + Present = presentCount; + } } }