sensor-mon: Handle propertiesChanged

Fill in the propertiesChanged handler to check if any event logs need to
be created.

When a sensor is added to D-Bus after this application starts, the code
sees it via the propertiesChanged signal.  It knows its new because
there is no previous value saved, so it knows to only care about an
alarm value of true by making up a previous value of false.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I66571b6acaba180ab210cd41701014942d2dc050
diff --git a/sensor-monitor/threshold_alarm_logger.cpp b/sensor-monitor/threshold_alarm_logger.cpp
index 137e7dc..08a3a2c 100644
--- a/sensor-monitor/threshold_alarm_logger.cpp
+++ b/sensor-monitor/threshold_alarm_logger.cpp
@@ -119,7 +119,42 @@
 
 void ThresholdAlarmLogger::propertiesChanged(sdbusplus::message::message& msg)
 {
-    // TODO
+    std::map<std::string, std::variant<bool>> properties;
+    std::string sensorPath = msg.get_path();
+    std::string interface;
+
+    msg.read(interface, properties);
+
+    auto alarmProperties = thresholdData.find(interface);
+    if (alarmProperties == thresholdData.end())
+    {
+        return;
+    }
+
+    for (const auto& [propertyName, propertyValue] : properties)
+    {
+        if (alarmProperties->second.find(propertyName) !=
+            alarmProperties->second.end())
+        {
+            // If this is the first time we've seen this alarm, then
+            // assume it was off before so it doesn't create an event
+            // log for a value of false.
+
+            InterfaceKey key{sensorPath, interface};
+            if (alarms.find(key) == alarms.end())
+            {
+                alarms[key][propertyName] = false;
+            }
+
+            // Check if the value changed from what was there before.
+            auto alarmValue = std::get<bool>(propertyValue);
+            if (alarmValue != alarms[key][propertyName])
+            {
+                alarms[key][propertyName] = alarmValue;
+                createEventLog(sensorPath, interface, propertyName, alarmValue);
+            }
+        }
+    }
 }
 
 void ThresholdAlarmLogger::checkThresholds(const std::string& interface,