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 STATIONARY_DATA_H 17 #define STATIONARY_DATA_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace Msdp { 23 namespace DeviceStatus { 24 constexpr double MOVEMENT_THRESHOLD { 0.001 }; 25 enum Type { 26 TYPE_INVALID = -1, 27 TYPE_ABSOLUTE_STILL, 28 TYPE_HORIZONTAL_POSITION, 29 TYPE_VERTICAL_POSITION, 30 TYPE_STILL, 31 TYPE_RELATIVE_STILL, 32 TYPE_CAR_BLUETOOTH, 33 TYPE_LID_OPEN, 34 TYPE_MAX 35 }; 36 37 enum TypeValue : bool { 38 INVALID = false, 39 VALID = true 40 }; 41 42 enum OnChangedValue { 43 VALUE_INVALID = -1, 44 VALUE_ENTER = 1, 45 VALUE_EXIT = 2 46 }; 47 48 enum ActivityEvent { 49 EVENT_INVALID = 0, 50 ENTER = 1, 51 EXIT = 2, 52 ENTER_EXIT = 3 53 }; 54 55 enum ReportLatencyNs { 56 Latency_INVALID = -1, 57 SHORT = 1, 58 MIDDLE = 2, 59 LONG = 3 60 }; 61 enum Status { 62 STATUS_INVALID = -1, 63 STATUS_CANCEL, 64 STATUS_START, 65 STATUS_PROCESS, 66 STATUS_FINISH 67 }; 68 69 enum Action { 70 ACTION_INVALID = -1, 71 ACTION_ENLARGE, 72 ACTION_REDUCE, 73 ACTION_UP, 74 ACTION_LEFT, 75 ACTION_DOWN, 76 ACTION_RIGHT 77 }; 78 79 struct Data { 80 Type type { TYPE_INVALID }; 81 OnChangedValue value { VALUE_INVALID }; 82 Status status { STATUS_INVALID }; 83 Action action { ACTION_INVALID }; 84 double movement { 0.0 }; 85 86 bool operator !=(const Data& r) const 87 { 88 if (type == r.type && value == r.value && 89 status - r.status && action == r.action && (movement - r.movement) < MOVEMENT_THRESHOLD) { 90 return false; 91 } 92 return true; 93 } 94 }; 95 96 typedef struct DeviceStatusJsonData { 97 int32_t type { -1 }; 98 std::string json; 99 }DeviceStatusJsonD; 100 101 static DeviceStatusJsonD DeviceStatusJson[] = { 102 {Type::TYPE_ABSOLUTE_STILL, "absoluteStill"}, 103 {Type::TYPE_HORIZONTAL_POSITION, "horizontalPosition"}, 104 {Type::TYPE_VERTICAL_POSITION, "verticalPosition"}, 105 {Type::TYPE_STILL, "still"}, 106 {Type::TYPE_RELATIVE_STILL, "relativeStill"}, 107 {Type::TYPE_CAR_BLUETOOTH, "carBluetooth"}, 108 {Type::TYPE_LID_OPEN, "LID_OPEN"}, 109 {Type::TYPE_MAX, "MAX"} 110 }; 111 } // namespace DeviceStatus 112 } // namespace Msdp 113 } // namespace OHOS 114 #endif // STATIONARY_DATA_H 115