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