Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AS4630-54TE]Revise the platform api return type from int to float #235

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions device/accton/x86_64-accton_as4630_54te-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 @@ -159,12 +159,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 @@ -173,6 +176,9 @@ def get_temperature_high_threshold(self):
A float number, the high threshold temperature of PSU in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
if self.get_status() is not True:
return 0.0

return self._thermal_list[0].get_high_threshold()

def get_voltage_high_threshold(self):
Expand All @@ -182,12 +188,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 Down Expand Up @@ -222,7 +231,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 @@ -235,7 +244,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