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 XPOWER_DECODER_H
16 #define XPOWER_DECODER_H
17 
18 #include "cJSON.h"
19 #include "xpower_plugin_result.pb.h"
20 
21 class XpowerDecoder {
22 public:
23     XpowerDecoder();
24     ~XpowerDecoder();
25     std::string DecodeXpowerMessage(OptimizeReport& dataProto);
26 
27 private:
28     // 应用各器件的调优信息
29     cJSON* CreateAppDetail(const AppDetail& appDetail);
30     cJSON* CreateAppDetailGpu(const AppDetailGPU& appDeGpu);
31     cJSON* CreateAppDetailCpu(const AppDetailCPU& appDeCpu);
32     cJSON* CreateAppDetailWifi(const AppDetailWifi& appWifi);
33     cJSON* CreateAppDetailDisplay(const AppDetailDisplay& appDisplay);
34     // 应用的各器件信息的统计
35     cJSON* CreateAppStatistic(const AppStatistic& appStatistic);
36     cJSON* CreatAppStatisticCommon(const AppStatisticCommon& appCom);
37     // 电源信息统计
38     cJSON* CreateRealBattery(const RealBattery& realBattery);
39     // 整机各器件的top应用信息
40     cJSON* CreateComponentTop(const ComponentTop& componentTop);
41     cJSON* CreateComponentTopCommon(const ComponentTopCommon& topCommon);
42     cJSON* CreateComponentTopCamera(const ComponentTopCamera& topCamera);
43     cJSON* CreateComponentTopCpu(const ComponentTopCpu& topCpu);
44     cJSON* CreateComponentTopDisplay(const ComponentTopDisplay& topDisplay);
45     // 异常事件上报
46     cJSON* CreateAbnormalEventInfo(const AbnormalEventInfo& eventInfo);
47     cJSON* CreateAbnormalEvents(const AbnormalEvents& abnormEvent);
48 };
49 
50 #endif // XPOWER_DECODER_H
51