Skip to content

Commit

Permalink
The API spec need return a float instead of an integer.
Browse files Browse the repository at this point in the history
  • Loading branch information
roger530-ho committed May 28, 2024
1 parent 6d45104 commit 42359e1
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,15 @@ def get_high_threshold(self):
A float number, the high threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.is_psu:
return 80.0
value = self.conf.get_high_threshold()
if value != self.conf.NOT_AVAILABLE:
return float(value)

default_value = self.default_threshold[self.get_name()][self.conf.HIGH_THRESHOLD_FIELD]
if default_value != self.conf.NOT_AVAILABLE:
return float(default_value)

temp_file = "temp{}_max".format(self.ss_index)
return self.__get_temp(temp_file)
raise NotImplementedError

def set_high_threshold(self, temperature):
"""
Expand All @@ -297,9 +301,15 @@ def set_high_threshold(self, temperature):
Returns:
A boolean, True if threshold is set successfully, False if not
"""
temp_file = "temp{}_max".format(self.ss_index)
temperature = temperature *1000
self.__set_threshold(temp_file, temperature)
try:
value = float(temperature)
except:
return False

try:
self.conf.set_high_threshold(str(value))
except:
return False

return True

Expand Down

0 comments on commit 42359e1

Please sign in to comment.