1 /* 2 * Copyright (c) 2022-2023 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 DEVICESTATUS_DATA_DEFINE_H 17 #define DEVICESTATUS_DATA_DEFINE_H 18 19 #include <functional> 20 21 #include "cJSON.h" 22 #include "sensor_agent.h" 23 24 #include "devicestatus_data_utils.h" 25 26 namespace OHOS { 27 namespace Msdp { 28 constexpr double PI = 3.141592653589793; 29 constexpr double RESULTANT_ACC_LOW_THRHD = 9; 30 constexpr double RESULTANT_ACC_UP_THRHD = 10.5; 31 constexpr double RELATIVE_ACC_MIN_THRHD = 7.5; 32 constexpr double RELATIVE_ACC_MAX_THRHD = 13; 33 constexpr double ACC_VALID_THRHD = 160.0; 34 constexpr double ANGLE_180_DEGREE = 180.0; 35 constexpr double ANGLE_HOR_UP_THRHD = 180.1; 36 constexpr double ANGLE_HOR_LOW_THRHD = 160.0; 37 constexpr double ANGLE_VER_UP_THRHD = 110.0; 38 constexpr double ANGLE_VER_LOW_THRHD = 80.0; 39 40 constexpr int32_t VALID_TIME_THRESHOLD = 500; 41 constexpr int32_t ACC_SAMPLE_PERIOD = 100; 42 constexpr int32_t COUNTER_THRESHOLD = VALID_TIME_THRESHOLD / ACC_SAMPLE_PERIOD; 43 44 using SensorCallback = std::function<void(int32_t, AccelData*)>; 45 46 struct JsonParser { 47 JsonParser() = default; ~JsonParserJsonParser48 ~JsonParser() 49 { 50 if (json_ != nullptr) { 51 cJSON_Delete(json_); 52 json_ = nullptr; 53 } 54 } 55 operator cJSON *() 56 { 57 return json_; 58 } 59 cJSON *json_ = nullptr; 60 }; 61 } // namespace Msdp 62 } // namespace OHOS 63 #endif // DEVICESTATUS_DATA_DEFINE_H 64