1 /*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2024. 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
16 #include "xpower_app_detaile_display_table.h"
17
18 namespace SysTuning {
19 namespace TraceStreamer {
20 enum class Index : int32_t {
21 ID = 0,
22 START_TIME,
23 COUNT_1_HZ,
24 COUNT_5_HZ,
25 COUNT_10_HZ,
26 COUNT_15_HZ,
27 COUNT_24_HZ,
28 COUNT_30_HZ,
29 COUNT_45_HZ,
30 COUNT_60_HZ,
31 COUNT_90_HZ,
32 COUNT_120_HZ,
33 COUNT_180_HZ
34 };
XpowerAppDetaileDisplayTable(const TraceDataCache * dataCache)35 XpowerAppDetaileDisplayTable::XpowerAppDetaileDisplayTable(const TraceDataCache *dataCache) : TableBase(dataCache)
36 {
37 tableColumn_.push_back(TableBase::ColumnInfo("id", "INTEGER"));
38 tableColumn_.push_back(TableBase::ColumnInfo("start_time", "INTEGER"));
39 tableColumn_.push_back(TableBase::ColumnInfo("count_1hz", "INTEGER"));
40 tableColumn_.push_back(TableBase::ColumnInfo("count_5hz", "INTEGER"));
41 tableColumn_.push_back(TableBase::ColumnInfo("count_10hz", "INTEGER"));
42 tableColumn_.push_back(TableBase::ColumnInfo("count_15hz", "INTEGER"));
43 tableColumn_.push_back(TableBase::ColumnInfo("count_24hz", "INTEGER"));
44 tableColumn_.push_back(TableBase::ColumnInfo("count_30hz", "INTEGER"));
45 tableColumn_.push_back(TableBase::ColumnInfo("count_45hz", "INTEGER"));
46 tableColumn_.push_back(TableBase::ColumnInfo("count_60hz", "INTEGER"));
47 tableColumn_.push_back(TableBase::ColumnInfo("count_90hz", "INTEGER"));
48 tableColumn_.push_back(TableBase::ColumnInfo("count_120hz", "INTEGER"));
49 tableColumn_.push_back(TableBase::ColumnInfo("count_180hz", "INTEGER"));
50 tablePriKey_.push_back("id");
51 }
52
~XpowerAppDetaileDisplayTable()53 XpowerAppDetaileDisplayTable::~XpowerAppDetaileDisplayTable() {}
54
CreateCursor()55 std::unique_ptr<TableBase::Cursor> XpowerAppDetaileDisplayTable::CreateCursor()
56 {
57 return std::make_unique<Cursor>(dataCache_, this);
58 }
59
Cursor(const TraceDataCache * dataCache,TableBase * table)60 XpowerAppDetaileDisplayTable::Cursor::Cursor(const TraceDataCache *dataCache, TableBase *table)
61 : TableBase::Cursor(dataCache,
62 table,
63 static_cast<uint32_t>(dataCache->GetConstXPowerAppDetailDisplayInfo().Size())),
64 xPowerAppDetailDisplayObj_(dataCache->GetConstXPowerAppDetailDisplayInfo())
65 {
66 }
67
~Cursor()68 XpowerAppDetaileDisplayTable::Cursor::~Cursor() {}
Column(int32_t column) const69 int32_t XpowerAppDetaileDisplayTable::Cursor::Column(int32_t column) const
70 {
71 switch (static_cast<Index>(column)) {
72 case Index::ID:
73 sqlite3_result_int64(context_, xPowerAppDetailDisplayObj_.IdsData()[CurrentRow()]);
74 break;
75 case Index::START_TIME:
76 sqlite3_result_int64(context_, xPowerAppDetailDisplayObj_.TimeStampData()[CurrentRow()]);
77 break;
78 case Index::COUNT_1_HZ:
79 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count1HertzsData()[CurrentRow()], INVALID_INT64);
80 break;
81 case Index::COUNT_5_HZ:
82 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count5HertzsData()[CurrentRow()], INVALID_INT64);
83 break;
84 case Index::COUNT_10_HZ:
85 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count10HertzsData()[CurrentRow()], INVALID_INT64);
86 break;
87 case Index::COUNT_15_HZ:
88 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count15HertzsData()[CurrentRow()], INVALID_INT64);
89 break;
90 case Index::COUNT_24_HZ:
91 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count24HertzsData()[CurrentRow()], INVALID_INT64);
92 break;
93 case Index::COUNT_30_HZ:
94 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count30HertzsData()[CurrentRow()], INVALID_INT64);
95 break;
96 case Index::COUNT_45_HZ:
97 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count45HertzsData()[CurrentRow()], INVALID_INT64);
98 break;
99 case Index::COUNT_60_HZ:
100 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count60HertzsData()[CurrentRow()], INVALID_INT64);
101 break;
102 case Index::COUNT_90_HZ:
103 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count90HertzsData()[CurrentRow()], INVALID_INT64);
104 break;
105 case Index::COUNT_120_HZ:
106 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count120HertzsData()[CurrentRow()], INVALID_INT64);
107 break;
108 case Index::COUNT_180_HZ:
109 SetTypeColumnInt64(xPowerAppDetailDisplayObj_.Count180HertzsData()[CurrentRow()], INVALID_INT64);
110 break;
111 default:
112 TS_LOGF("Unregistered column : %d", column);
113 }
114 return SQLITE_OK;
115 }
116 } // namespace TraceStreamer
117 } // namespace SysTuning
118