# SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: LicenseRef-NvidiaProprietary # # NVIDIA CORPORATION, its affiliates and licensors retain all intellectual # property and proprietary rights in and to this material, related # documentation and any modifications thereto. Any use, reproduction, # disclosure or distribution of this material and related documentation # without an express license agreement from NVIDIA CORPORATION or # its affiliates is strictly prohibited. from tkinter import StringVar from tkinter.ttk import Label, LabelFrame from ...utils.common import PAttrs, PNames, err_symbol, tsensor_off_ret from ...utils.layoutmanager import fill_parent, grid_span, padding from ...utils.subjectobserver import Observer class ThermalFrame(LabelFrame, Observer): def __init__(self, master=None, **kwargs): super().__init__(master, text="Thermal", **kwargs) self.create_widgets() self.manage_layout() fill_parent(self) def create_widgets(self): # warn user that current temperature is too close to sw shutdown limit self.WARN_RANGE_IN_C = 2.5 self.sensor_names = PNames.THERMAL_SENSOR_NAMES self.sensor_nums = len(self.sensor_names) self.sensor_l = [None] * self.sensor_nums self.sw_throttling_l = [None] * self.sensor_nums self.sw_shutdown_l = [None] * self.sensor_nums self.curr_temp_l = [None] * self.sensor_nums self.sw_throttling_v = [None] * self.sensor_nums self.sw_shutdown_v = [None] * self.sensor_nums self.curr_temp_v = [None] * self.sensor_nums self.name_hl = Label(self, text="Name") self.sw_throttling_hl = Label(self, text="SW Throttling Limit") self.sw_shutdown_hl = Label(self, text="SW Shutdown Limit") self.curr_temp_hl = Label(self, text="Current Temp") for i in range(self.sensor_nums): self.sw_throttling_v[i] = StringVar() self.sw_shutdown_v[i] = StringVar() self.curr_temp_v[i] = StringVar() self.sensor_l[i] = Label(self, text=self.sensor_names[i]) self.sw_throttling_l[i] = Label( self, textvariable=self.sw_throttling_v[i]) self.sw_shutdown_l[i] = Label(self, textvariable=self.sw_shutdown_v[i]) self.curr_temp_l[i] = Label(self, textvariable=self.curr_temp_v[i]) def manage_layout(self): self.name_hl.grid(row=0, column=0, **grid_span, **padding) self.sw_throttling_hl.grid(row=0, column=1, **grid_span, **padding) self.sw_shutdown_hl.grid(row=0, column=2, **grid_span, **padding) self.curr_temp_hl.grid(row=0, column=3, **grid_span, **padding) for i in range(self.sensor_nums): self.sensor_l[i].grid(row=1 + i, column=0, **grid_span, **padding) self.sw_throttling_l[i].grid(row=1 + i, column=1, **grid_span, **padding) self.sw_shutdown_l[i].grid(row=1 + i, column=2, **grid_span, **padding) self.curr_temp_l[i].grid(row=1 + i, column=3, **grid_span, **padding) def update_data(self, data): for i in range(self.sensor_nums): sensor_name = self.sensor_names[i] curr_temp = data[(sensor_name, PAttrs.CURR_TEMP)] s_th_temp = data[(sensor_name, PAttrs.SW_THROTTLING_TEMP)] s_sd_temp = data[(sensor_name, PAttrs.SW_SHUTDOWN_TEMP)] postfix = "" if curr_temp not in (err_symbol, tsensor_off_ret): postfix = " C" # Only check thermal zones that have software throttling limit if err_symbol not in (curr_temp, s_th_temp): if curr_temp >= s_th_temp: postfix = " C (Software throttling!)" # Only check thermal zones that have software shutdown limit if err_symbol not in (curr_temp, s_sd_temp): if curr_temp >= s_sd_temp - self.WARN_RANGE_IN_C: postfix = " C (Close to software shutdown limit!)" if curr_temp > s_sd_temp: postfix = " C (Software shutdown!)" # Display "offline" instead of err_symbol if the power domain of the # sensor is off if tsensor_off_ret == curr_temp: curr_temp = "offline" self.curr_temp_v[i].set(f"{curr_temp}{postfix}") postfix = " C" if s_th_temp != err_symbol else "" self.sw_throttling_v[i].set(f"{s_th_temp}{postfix}") postfix = " C" if s_sd_temp != err_symbol else "" self.sw_shutdown_v[i].set(f"{s_sd_temp}{postfix}")