1 /* 2 * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. 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 HTRACE_XPOWER_PARSER_H 16 #define HTRACE_XPOWER_PARSER_H 17 18 #include <cstdint> 19 #include <unordered_set> 20 #include "common_types.h" 21 #include "event_parser_base.h" 22 #include "htrace_plugin_time_parser.h" 23 #include "trace_data_cache.h" 24 #include "trace_streamer_filters.h" 25 namespace SysTuning { 26 namespace TraceStreamer { 27 using namespace SysTuning::base; 28 class PbreaderXpowerParser : public EventParserBase, public HtracePluginTimeParser { 29 public: 30 PbreaderXpowerParser(TraceDataCache *dataCache, const TraceStreamerFilters *ctx); 31 ~PbreaderXpowerParser(); 32 void Parse(PbreaderDataSegment &seg, uint64_t, BuiltinClocks clock); 33 34 private: 35 void ProcessRealBattery(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 36 void ProcessThermalReport(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 37 void ProcessAppStatistic(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 38 void ProcessAppStatisticCommon(const ProtoReader::BytesView &bytesView, 39 uint64_t timestamp, 40 const std::string &name); 41 void ProcessAppDetail(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 42 void ProcessAppDetailCpu(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 43 void ProcessAppDetailGpu(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 44 void ProcessAppDetailWifi(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 45 void ProcessAppDetailDisplay(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 46 void ProcessComponentTop(const ProtoReader::BytesView &bytesView, uint64_t timestamp); 47 void ProcessComponentTopComm(const DataIndex type, const ProtoReader::BytesView &bytesView, uint64_t timestamp); 48 void ProcessComponentTopDisplay(const DataIndex type, const ProtoReader::BytesView &bytesView, uint64_t timestamp); 49 void ProcessComponentTopCamera(const DataIndex type, const ProtoReader::BytesView &bytesView, uint64_t timestamp); 50 void ProcessComponentTopCpu(const DataIndex type, const ProtoReader::BytesView &bytesView, uint64_t timestamp); 51 52 std::unordered_set<uint64_t> timeSet_; 53 54 // RealBattery 55 const DataIndex rBaCapDataIndex_ = traceDataCache_->GetDataIndex("Battery.Capacity"); 56 const DataIndex rBaChaDataIndex_ = traceDataCache_->GetDataIndex("Battery.Charge"); 57 const DataIndex rBaGasDataIndex_ = traceDataCache_->GetDataIndex("Battery.GasGauge"); 58 const DataIndex rBaLevDataIndex_ = traceDataCache_->GetDataIndex("Battery.Level"); 59 const DataIndex rBaScrDataIndex_ = traceDataCache_->GetDataIndex("Battery.Screen"); 60 const DataIndex rBaRealCurDataIndex_ = traceDataCache_->GetDataIndex("Battery.RealCurrent"); 61 // ThermalReport 62 const DataIndex tReSheDataIndex_ = traceDataCache_->GetDataIndex("ThermalReport.ShellTemp"); 63 const DataIndex tReTheDataIndex_ = traceDataCache_->GetDataIndex("ThermalReport.ThermalLevel"); 64 // AppStatistic, ComponentTop 65 const std::string appStatisticStr_ = "AppStatistic"; 66 const std::string audioStr_ = "audio"; 67 const std::string bluetoothStr_ = "bluetooth"; 68 const std::string cameraStr_ = "camera"; 69 const std::string cpuStr_ = "cpu"; 70 const std::string displayStr_ = "display"; 71 const std::string flashlightStr_ = "flashlight"; 72 const std::string gpuStr_ = "gpu"; 73 const std::string locationStr_ = "location"; 74 const std::string wifiscanStr_ = "wifiscan"; 75 const std::string wifiStr_ = "wifi"; 76 const std::string modemStr_ = "modem"; 77 const std::string energyStr_ = "energy"; 78 const std::string timeStr_ = "time"; 79 80 // AppDetail 81 const std::string appDetailStr_ = "AppDetail"; 82 const std::string loadStr_ = "load"; 83 const std::string idleTimeStr_ = "idle_time"; 84 const std::string runTimeStr_ = "run_time"; 85 const std::string txPacketsStr_ = "tx_packets"; 86 const std::string rxPacketsStr_ = "rx_packets"; 87 const std::string txBytesStr_ = "tx_bytes"; 88 const std::string rxBytesStr_ = "rx_bytes"; 89 const std::string count1hzStr_ = "count_1hz"; 90 const std::string count5hzStr_ = "count_5hz"; 91 const std::string count10hzStr_ = "count_10hz"; 92 const std::string count15hzStr_ = "count_15hz"; 93 const std::string count24hzStr_ = "count_24hz"; 94 const std::string count30hzStr_ = "count_30hz"; 95 const std::string count45hzStr_ = "count_45hz"; 96 const std::string count60hzStr_ = "count_60hz"; 97 const std::string count90hzStr_ = "count_90hz"; 98 const std::string count120hzStr_ = "count_120hz"; 99 const std::string count180hzStr_ = "count_180hz"; 100 }; 101 } // namespace TraceStreamer 102 } // namespace SysTuning 103 104 #endif // HTRACE_XPOWER_PARSER_H 105