• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef SENSOR_DUMP_H
17 #define SENSOR_DUMP_H
18 
19 #include "client_info.h"
20 #include "sensor.h"
21 #include "sensor_agent_type.h"
22 
23 namespace OHOS {
24 namespace Sensors {
25 class SensorDump : public Singleton<SensorDump> {
26 public:
27     SensorDump() = default;
28     virtual ~SensorDump() = default;
29     void ParseCommand(int32_t fd, const std::vector<std::string> &args, const std::vector<Sensor> &sensors,
30         ClientInfo &clientInfo);
31     void DumpHelp(int32_t fd);
32     bool DumpSensorList(int32_t fd, const std::vector<Sensor> &sensors);
33     bool DumpSensorChannel(int32_t fd, ClientInfo &clientInfo);
34     bool DumpOpeningSensor(int32_t fd, const std::vector<Sensor> &sensors, ClientInfo &clientInfo);
35     bool DumpSensorData(int32_t fd, ClientInfo &clientInfo);
36 
37 private:
38     DISALLOW_COPY_AND_MOVE(SensorDump);
39     void DumpCurrentTime(int32_t fd);
40     int32_t GetDataDimension(int32_t sensorType);
41     std::string GetDataBySensorId(int32_t sensorType, SensorData &sensorData);
42     static std::unordered_map<int32_t, std::string> sensorMap_;
43     void RunSensorDump(int32_t fd, int32_t optionIndex, const std::vector<std::string> &args, char **argv);
44     std::vector<Sensor> sensors_;
45     ClientInfo &clientInfo_ = ClientInfo::GetInstance();
46 };
47 } // namespace Sensors
48 } // namespace OHOS
49 #endif // SENSOR_DUMP_H
50