Skip to content

Commit

Permalink
[AS4630-54NPE]Revise the platform api return type from int to float
Browse files Browse the repository at this point in the history
  • Loading branch information
ecsonic committed Oct 4, 2024
1 parent 23a6fd8 commit d3175dd
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions device/accton/x86_64-accton_as4630_54npe-r0/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def get_voltage(self):
e.g. 12.1
"""
if self.get_status() is not True:
return 0
return 0.0

vout_path = "{}{}".format(self.hwmon_path, 'psu_v_out')
vout_val = self._api_helper.read_txt_file(vout_path)
if vout_val is not None:
return float(vout_val) / 1000
else:
return 0
return 0.0

def get_current(self):
"""
Expand All @@ -90,14 +90,14 @@ def get_current(self):
A float number, the electric current in amperes, e.g 15.4
"""
if self.get_status() is not True:
return 0
return 0.0

iout_path = "{}{}".format(self.hwmon_path, 'psu_i_out')
val = self._api_helper.read_txt_file(iout_path)
if val is not None:
return float(val) / 1000
else:
return 0
return 0.0

def get_power(self):
"""
Expand All @@ -106,14 +106,14 @@ def get_power(self):
A float number, the power in watts, e.g. 302.6
"""
if self.get_status() is not True:
return 0
return 0.0

pout_path = "{}{}".format(self.hwmon_path, 'psu_p_out')
val = self._api_helper.read_txt_file(pout_path)
if val is not None:
return float(val) / 1000
else:
return 0
return 0.0

def get_powergood_status(self):
"""
Expand Down Expand Up @@ -158,12 +158,15 @@ def get_temperature(self):
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
if self.get_status() is not True:
return 0.0

temp_path = "{}{}".format(self.hwmon_path, 'psu_temp1_input')
val = self._api_helper.read_txt_file(temp_path)
if val is not None:
return float(val) / 1000
else:
return 0
return 0.0

def get_temperature_high_threshold(self):
"""
Expand All @@ -181,12 +184,15 @@ def get_voltage_high_threshold(self):
A float number, the high threshold output voltage in volts,
e.g. 12.1
"""
if self.get_status() is not True:
return 0.0

vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_max')
vout_val = self._api_helper.read_txt_file(vout_path)
if vout_val is not None:
return float(vout_val) / 1000
else:
return 0
return 0.0

def get_voltage_low_threshold(self):
"""
Expand All @@ -195,12 +201,15 @@ def get_voltage_low_threshold(self):
A float number, the low threshold output voltage in volts,
e.g. 12.1
"""
if self.get_status() is not True:
return 0.0

vout_path = "{}{}".format(self.hwmon_path, 'psu_mfr_vout_min')
vout_val = self._api_helper.read_txt_file(vout_path)
if vout_val is not None:
return float(vout_val) / 1000
else:
return 0
return 0.0

def get_name(self):
"""
Expand All @@ -221,7 +230,7 @@ def get_presence(self):
if val is not None:
return int(val, 10) == 1
else:
return 0
return False

def get_status(self):
"""
Expand All @@ -234,7 +243,7 @@ def get_status(self):
if val is not None:
return int(val, 10) == 1
else:
return 0
return False

def get_model(self):
"""
Expand Down

0 comments on commit d3175dd

Please sign in to comment.