1 /* 2 * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., 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 "client_info.h" 24 #include "medical_sensor.h" 25 #include "nocopyable.h" 26 #include "medical_native_type.h" 27 28 namespace OHOS { 29 namespace Sensors { 30 class MedicalSensorDump : public Singleton<MedicalSensorDump> { 31 public: 32 MedicalSensorDump() = default; 33 virtual ~MedicalSensorDump() = default; 34 void DumpHelp(int32_t fd); 35 bool DumpSensorHelp(int32_t fd, const std::vector<std::u16string> &args); 36 bool DumpSensorList(int32_t fd, const std::vector<MedicalSensor> &sensors, const std::vector<std::u16string> &args); 37 bool DumpSensorChannel(int32_t fd, ClientInfo &clientInfo, const std::vector<std::u16string> &args); 38 bool DumpOpeningSensor(int32_t fd, const std::vector<MedicalSensor> &sensors, ClientInfo &clientInfo, 39 const std::vector<std::u16string> &args); 40 bool DumpSensorData(int32_t fd, ClientInfo &clientInfo, const std::vector<std::u16string> &args); 41 int32_t Dump(int32_t fd, const std::vector<std::u16string> &args, 42 std::vector<MedicalSensor> &sensors, ClientInfo &clientInfo); 43 44 private: 45 DISALLOW_COPY_AND_MOVE(MedicalSensorDump); 46 void DumpCurrentTime(int32_t fd); 47 int32_t DataSizeBySensorId(uint32_t sensorId); 48 std::string GetDataBySensorId(uint32_t sensorId, struct SensorEvent &sensorData); 49 static std::unordered_map<uint32_t, std::string> sensorMap_; 50 }; 51 } // namespace Sensors 52 } // namespace OHOS 53 #endif // SENSOR_DUMP_H 54