From e0fca894d30279a487d375a312dd956c195b046a Mon Sep 17 00:00:00 2001
From: wangjue <jue.wang2@luxshare-ict.com>
Date: Wed, 8 Jan 2025 20:23:11 +0800
Subject: [PATCH] Get the highest temperature of TS0, TS1, SPD_Temp

Signed-off-by: wangjue <jue.wang2@luxshare-ict.com>
---
 src/DIMMTempSensor.cpp | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/DIMMTempSensor.cpp b/src/DIMMTempSensor.cpp
index 852810b..0fe9b83 100644
--- a/src/DIMMTempSensor.cpp
+++ b/src/DIMMTempSensor.cpp
@@ -43,6 +43,9 @@ extern "C"
 #include <linux/i2c-dev.h>
 }
 
+using PropertyMapType =
+    boost::container::flat_map<std::string, BasicVariantType>;
+
 constexpr const bool debug = false;
 constexpr auto dimmSensorInterface = "xyz.openbmc_project.Sensor.dimmLED";
 constexpr auto dimmSensorPath = "/xyz/openbmc_project/sensors/temperature/";
@@ -261,7 +264,7 @@ void DIMMTempSensor::getDIMMRegsTemp(const std::string& sensorName)
 
     std::weak_ptr<DIMMTempSensor> weakRef = weak_from_this();
     dbusConnection->async_method_call(
-        [weakRef, sensorName](const boost::system::error_code ec, const std::variant<double> value) {
+        [weakRef, sensorName](const boost::system::error_code ec, PropertyMapType& propMap) {
             if (ec)
             {
               std::cerr << "Error getting DIMM sensor " << sensorName << " Temp" << "\n";
@@ -272,16 +275,23 @@ void DIMMTempSensor::getDIMMRegsTemp(const std::string& sensorName)
             {
                 return;
             }
-            double v = std::get<double>(value);
+
+            auto ts0_temp = std::get_if<double>(&propMap["TS0"]);
+            auto ts1_temp = std::get_if<double>(&propMap["TS1"]);
+            auto spd_temp = std::get_if<double>(&propMap["SPD_TS"]);
+
+            double v = std::max(std::max(*ts0_temp, *ts1_temp), *spd_temp);
+
             if constexpr (debug)
             {
-                std::cerr << "Dimm Temp raw reading " << v << "\n";
+                std::cout << "ts0_temp: " << *ts0_temp << " ts1_temp: " << *ts1_temp << " spd_temp: " << *spd_temp << std::endl;
+                std::cerr << "Dimm Temp max_value: " << v << std::endl;
             }
             v += self->calibOffset;
             self->updateValue(v);
 
         },
-        dimmSpdReaderService, path, dbusProperties, "Get", tempInterface, "TS0");
+        dimmSpdReaderService, path, dbusProperties, "GetAll", tempInterface);
 
     return;
 }
-- 
2.34.1

