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