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