1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef TEMPERATURE_H 16 #define TEMPERATURE_H 17 18 #include <string> 19 #include <vector> 20 #include <sstream> 21 #include <map> 22 #include <cstdlib> 23 #include "gp_utils.h" 24 25 namespace OHOS { 26 namespace SmartPerf { 27 class Temperature { 28 public: 29 static constexpr const char *thermal_path[] = { 30 "/sys/devices/virtual/thermal", 31 "/sys/class/thermal" 32 }; 33 34 const std::map<std::string, std::string> collect_nodes = { 35 { "soc_thermal", "soc_thermal" }, { "system_h", "system_h" }, { "soc-thermal", "soc-thermal" }, 36 { "gpu-thermal", "gpu-thermal" }, { "shell_frame", "shell_frame" }, { "shell_front", "shell_front" }, 37 { "shell_back", "shell_back" } 38 }; 39 static Temperature *getInstance(); 40 std::map<std::string, float> getThermalMap(); 41 42 static pthread_mutex_t mutex; 43 44 private: 45 Temperature(); ~Temperature()46 ~Temperature() {} 47 48 static Temperature *instance; 49 std::string thermal_base_path; 50 std::map<std::string, std::string> thermal_node_path_map; 51 void initThermalNode(); 52 }; 53 } 54 } 55 #endif