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_H 17 #define SENSOR_H 18 19 #include <string> 20 #include <vector> 21 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace Sensors { 26 class Sensor : public Parcelable { 27 public: 28 Sensor(); 29 virtual ~Sensor() = default; 30 uint32_t GetSensorId() const; 31 void SetSensorId(uint32_t sensorId); 32 33 uint32_t GetSensorTypeId() const; 34 void SetSensorTypeId(uint32_t sensorTypeId); 35 36 std::string GetSensorName() const; 37 void SetSensorName(const std::string &sensorName); 38 39 std::string GetVendorName() const; 40 void SetVendorName(const std::string &vendorName); 41 42 std::string GetHardwareVersion() const; 43 void SetHardwareVersion(const std::string &hardwareVersion); 44 45 std::string GetFirmwareVersion() const; 46 void SetFirmwareVersion(const std::string &firmwareVersion); 47 48 float GetMaxRange() const; 49 void SetMaxRange(float maxRange); 50 51 float GetResolution() const; 52 void SetResolution(float resolution); 53 54 float GetPower() const; 55 void SetPower(float power); 56 57 uint32_t GetFlags() const; 58 void SetFlags(uint32_t flags); 59 60 int32_t GetFifoMaxEventCount() const; 61 void SetFifoMaxEventCount(int32_t fifoMaxEventCount); 62 63 int64_t GetMinSamplePeriodNs() const; 64 void SetMinSamplePeriodNs(int64_t minSamplePeriodNs); 65 66 int64_t GetMaxSamplePeriodNs() const; 67 void SetMaxSamplePeriodNs(int64_t maxSamplePeriodNs); 68 69 bool ReadFromParcel(Parcel &parcel); 70 static std::unique_ptr<Sensor> Unmarshalling(Parcel &parcel); 71 virtual bool Marshalling(Parcel &parcel) const override; 72 73 private: 74 uint32_t sensorId_; 75 uint32_t sensorTypeId_; 76 std::string sensorName_; 77 std::string vendorName_; 78 std::string firmwareVersion_; 79 std::string hardwareVersion_; 80 float maxRange_; 81 float resolution_; 82 float power_; 83 uint32_t flags_; 84 int32_t fifoMaxEventCount_; 85 int64_t minSamplePeriodNs_; 86 int64_t maxSamplePeriodNs_; 87 }; 88 } // namespace Sensors 89 } // namespace OHOS 90 #endif // SENSOR_H 91