Skip to content

Commit

Permalink
Update OpenHWMon status, show "Disconnected" only when both CPU and G…
Browse files Browse the repository at this point in the history
…PU temperatures are zero
  • Loading branch information
akej74 committed Sep 29, 2016
1 parent bec943a commit 416d884
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 1 addition & 10 deletions grid-control/gridcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ def setup_ui_logic(self):
self.thread.update_signal.connect(self.update_fan_speed)

# Connect CPU and GPU temperature signals (from polling thread) to function for updating HWMon status
self.thread.cpu_temp_signal.connect(self.set_hwmon_status)
self.thread.gpu_temp_signal.connect(self.set_hwmon_status)
self.thread.hwmon_status_signal.connect(self.ui.labelHWMonStatus.setText)

# Connect exception signal to show exception message from running thread
# This is needed as it's not possible to show a message box widget from the QThread directly
Expand Down Expand Up @@ -552,14 +551,6 @@ def restart(self):
self.thread.update_sensors(self.get_cpu_sensor_ids(), self.get_gpu_sensor_ids())
self.init_communication()

def set_hwmon_status(self, temperature):
"""Update OpenHardwareMonitor status based on current CPU and GPU temperatures."""

if temperature == 0:
self.ui.labelHWMonStatus.setText('<b><font color="red">Disconnected</font></b>')
else:
self.ui.labelHWMonStatus.setText('<b><font color="green">Connected</font></b>')

def thread_exception_handling(self, msg):
"""Display an error message with details about the exception and reset the "serial port value" to <Select port>.
Called when an exception occurs in the polling thread."""
Expand Down
16 changes: 14 additions & 2 deletions grid-control/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class PollingThread(QtCore.QThread):
cpu_temp_signal = QtCore.pyqtSignal(int)
gpu_temp_signal = QtCore.pyqtSignal(int)

hwmon_status_signal = QtCore.pyqtSignal(str)

# Signal to indicate fan speed should be updated
update_signal = QtCore.pyqtSignal()

Expand Down Expand Up @@ -210,8 +212,18 @@ def run(self):
temperature_sensors = openhwmon.get_temperature_sensors(hwmon_thread_wmi)

# Emit signals with current CPU and GPU temperatures
self.cpu_temp_signal.emit(self.calculate_temp(temperature_sensors, "cpu"))
self.gpu_temp_signal.emit(self.calculate_temp(temperature_sensors, "gpu"))
current_cpu_temp = self.calculate_temp(temperature_sensors, "cpu")
current_gpu_temp = self.calculate_temp(temperature_sensors, "gpu")

# Emit temperature signals
self.cpu_temp_signal.emit(current_cpu_temp)
self.gpu_temp_signal.emit(current_gpu_temp)

# If both CPU and GPU temp are 0, set OpenHardwareMonitor status to "Disconnected"
if current_cpu_temp == current_gpu_temp == 0:
self.hwmon_status_signal.emit('<b><font color="red">Disconnected</font></b>')
else:
self.hwmon_status_signal.emit('<b><font color="green">Connected</font></b>')

# Read rpm for all fans
fans_rpm = grid.read_fan_rpm(self.ser, self.lock)
Expand Down

0 comments on commit 416d884

Please sign in to comment.