Esempio n. 1
0
    def execute(self, thermal_info_dict):
        """
        Publish thermal information to platform
        :param thermal_info_dict: A dictionary stores all thermal information.
        :return:
        """
        from .thermal_infos import ChassisInfo
        from .thermal_infos import ThermalInfo
        if ChassisInfo.INFO_NAME in thermal_info_dict:
            # chassis_info_obj = thermal_info_dict[ChassisInfo.INFO_NAME]
            # chassis = chassis_info_obj.get_chassis()
            pass
        else:
            return

        if ThermalInfo.INFO_NAME in thermal_info_dict:
            thermal_info_obj = thermal_info_dict[ThermalInfo.INFO_NAME]

            for slot, lc_info in thermal_info_obj.lc_thermal_dict.items():
                update_hwslot_temp = platform_ndk_pb2.UpdateTempInfoPb(
                    slot_num=slot, current_temp=int(lc_info['curr_temp']), min_temp=int(lc_info['min_temp']),
                    max_temp=int(lc_info['max_temp']), margin=int(lc_info['margin_temp']))
                channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_THERMAL_SERVICE)
                if not channel or not stub:
                    continue
                ret, response = nokia_common.try_grpc(stub.UpdateThermalHwSlot,
                                                      platform_ndk_pb2.ReqTempParamsPb(hwslot_temp=update_hwslot_temp))
                nokia_common.channel_shutdown(channel)
Esempio n. 2
0
def show_temp(stub):
    response = stub.ShowThermalInfo(platform_ndk_pb2.ReqTempParamsPb())

    if format_type == 'json-format':
        json_response = MessageToJson(response)
        print(json_response)
        return

    field = []
    field.append('Name    ')
    field.append('Local   ')
    field.append('Remote   ')
    field.append('Description        ')

    i = 0
    item_list = []
    while i < len(response.temp_show.temp_device):
        temp_device = response.temp_show.temp_device[i]
        item = []
        item.append(temp_device.sensor_name)
        item.append(str(temp_device.local))
        item.append(str(temp_device.remote))
        item.append(temp_device.device_desc)
        item_list.append(item)
        i += 1

    print('TEMPERATURE DEVICES TABLE')
    print_table(field, item_list)

    field = []
    field.append('Hw Slot')
    field.append('Current Temp')
    field.append('Min Temp')
    field.append('Max Temp')
    field.append('Margin')

    i = 0
    item_list = []
    while i < len(response.temp_show.temp_summary):
        temp_summary = response.temp_show.temp_summary[i]
        item = []
        item.append(str(temp_summary.slot_num))
        item.append(str(temp_summary.current_temp))
        item.append(str(temp_summary.min_temp))
        item.append(str(temp_summary.max_temp))
        item.append(str(temp_summary.margin))
        item_list.append(item)
        i += 1

    print('TEMPERATURE SUMMARY TABLE')
    print_table(field, item_list)

    return
Esempio n. 3
0
    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        channel, stub = nokia_common.channel_setup(
            nokia_common.NOKIA_GRPC_THERMAL_SERVICE)
        if not channel or not stub:
            return self.thermal_temperature
        ret, response = nokia_common.try_grpc(
            stub.GetThermalCurrTemp,
            platform_ndk_pb2.ReqTempParamsPb(idx=self.map_index))
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return self.thermal_temperature

        self.thermal_temperature = float(response.curr_temp)

        return float("{:.3f}".format(self.thermal_temperature))
Esempio n. 4
0
    def get_low_threshold(self):
        """
        Retrieves the low threshold temperature of thermal

        Returns:
            A float number, the low threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        channel, stub = nokia_common.channel_setup(
            nokia_common.NOKIA_GRPC_THERMAL_SERVICE)
        if not channel or not stub:
            return self.thermal_low_threshold
        ret, response = nokia_common.try_grpc(
            stub.GetThermalLowThreshold,
            platform_ndk_pb2.ReqTempParamsPb(idx=self.map_index))
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return self.thermal_low_threshold

        self.thermal_low_threshold = float(response.low_threshold)
        return float("{:.3f}".format(self.thermal_low_threshold))
Esempio n. 5
0
    def get_thermal_list(self):
        channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_THERMAL_SERVICE)
        if not channel or not stub:
            return
        ret, response = nokia_common.try_grpc(stub.GetThermalDevicesInfo,
                                              platform_ndk_pb2.ReqTempParamsPb())
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return

        all_temp_devices = response.temp_devices
        self.num_thermals = len(all_temp_devices.temp_device)
        i = 0

        # Empty previous list
        if len(self._thermal_list) != self.num_thermals:
            del self._thermal_list[:]

            for i in range(self.num_thermals):
                temp_device_ = all_temp_devices.temp_device[i]
                thermal = Thermal(i, temp_device_.device_idx, temp_device_.sensor_name, self.thermal_stub)
                self._thermal_list.append(thermal)
Esempio n. 6
0
def set_temp_offset(stub, offset):
    stub.SetThermalOffset(platform_ndk_pb2.ReqTempParamsPb(temp_offset=offset))