diff --git a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py index 222d9d26d044..51a2457a48af 100644 --- a/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py +++ b/platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/thermal.py @@ -68,10 +68,12 @@ def _value_get(d: dict, key_prefix, key_suffix=''): # Thermal -> ThermalBase -> DeviceBase class Thermal(ThermalBase): - def __init__(self, chip, label): + def __init__(self, chip, label, index = 0): self.__chip = chip self.__label = label self.__name = f"{chip}:{label}".lower().replace(' ', '-') + self.__collect_temp = [] + self.__index = index def __get(self, attr_prefix, attr_suffix): sensor_data = _sensors_get().get(self.__chip, {}).get(self.__label, {}) @@ -80,7 +82,10 @@ def __get(self, attr_prefix, attr_suffix): # ThermalBase interface methods: def get_temperature(self) -> float: - return float(self.__get('temp', 'input')) + temp = self.__get('temp', 'input') + self.__collect_temp.append(float(temp)) + self.__collect_temp.sort() + return float(temp) def get_high_threshold(self) -> float: return float(self.__get('temp', 'max')) @@ -107,11 +112,38 @@ def get_status(self): def is_replaceable(self): return False + def get_low_threshold(self) -> float: + return float(self.__get('temp', 'min')) + + def get_serial(self): + return 'N/A' + + def get_minimum_recorded(self) -> float: + temp = self.__collect_temp[0] if len(self.__collect_temp) > 0 else 0.1 + temp = temp if temp > 0.0 else 0.1 + return float(temp) + + def get_maximum_recorded(self) -> float: + temp = self.__collect_temp[-1] if len(self.__collect_temp) > 0 else 100.0 + temp = temp if temp <= 100.0 else 100.0 + return float(temp) + + def get_position_in_parent(self): + return self.__index + + def set_high_threshold(self, temperature): + return False + + def set_low_threshold(self, temperature): + return False + def thermal_list_get(): l = [] + index = 0 for chip, chip_data in _sensors_get().items(): for sensor, sensor_data in chip_data.items(): # add only temperature sensors if _value_get(sensor_data, "temp") is not None: - l.append(Thermal(chip, sensor)) + l.append(Thermal(chip, sensor, index)) + index += 1 return l