• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 SATELLITE_STATUS_H
17 #define SATELLITE_STATUS_H
18 
19 #include <mutex>
20 #include <parcel.h>
21 #include <vector>
22 
23 namespace OHOS {
24 namespace Location {
25 class SatelliteStatus : public Parcelable {
26 public:
27     SatelliteStatus();
28     explicit SatelliteStatus(SatelliteStatus &satelliteStatus);
29     ~SatelliteStatus() override = default;
30 
GetSatellitesNumber()31     inline int GetSatellitesNumber() const
32     {
33         return satellitesNumber_;
34     }
35 
SetSatellitesNumber(int num)36     inline void SetSatellitesNumber(int num)
37     {
38         satellitesNumber_ = num;
39     }
40 
GetSatelliteIds()41     inline std::vector<int> GetSatelliteIds() const
42     {
43         return satelliteIds_;
44     }
45 
SetSatelliteIds(std::vector<int> ids)46     inline void SetSatelliteIds(std::vector<int> ids)
47     {
48         std::unique_lock<std::mutex> lock(mutex_);
49         for (std::vector<int>::iterator it = ids.begin(); it != ids.end(); ++it) {
50             satelliteIds_.push_back(*it);
51         }
52     }
53 
SetSatelliteId(int id)54     inline void SetSatelliteId(int id)
55     {
56         std::unique_lock<std::mutex> lock(mutex_);
57         satelliteIds_.push_back(id);
58     }
59 
GetCarrierToNoiseDensitys()60     inline std::vector<double> GetCarrierToNoiseDensitys() const
61     {
62         return carrierToNoiseDensitys_;
63     }
64 
SetCarrierToNoiseDensitys(std::vector<double> cn0)65     inline void SetCarrierToNoiseDensitys(std::vector<double> cn0)
66     {
67         std::unique_lock<std::mutex> lock(mutex_);
68         for (std::vector<double>::iterator it = cn0.begin(); it != cn0.end(); ++it) {
69             carrierToNoiseDensitys_.push_back(*it);
70         }
71     }
72 
SetCarrierToNoiseDensity(double cn0)73     inline void SetCarrierToNoiseDensity(double cn0)
74     {
75         std::unique_lock<std::mutex> lock(mutex_);
76         carrierToNoiseDensitys_.push_back(cn0);
77     }
78 
GetAltitudes()79     inline std::vector<double> GetAltitudes() const
80     {
81         return altitudes_;
82     }
83 
SetAltitudes(std::vector<double> altitudes)84     inline void SetAltitudes(std::vector<double> altitudes)
85     {
86         std::unique_lock<std::mutex> lock(mutex_);
87         for (std::vector<double>::iterator it = altitudes.begin(); it != altitudes.end(); ++it) {
88             altitudes_.push_back(*it);
89         }
90     }
91 
SetAltitude(double altitude)92     inline void SetAltitude(double altitude)
93     {
94         std::unique_lock<std::mutex> lock(mutex_);
95         altitudes_.push_back(altitude);
96     }
97 
GetAzimuths()98     inline std::vector<double> GetAzimuths() const
99     {
100         return azimuths_;
101     }
102 
SetAzimuths(std::vector<double> azimuths)103     inline void SetAzimuths(std::vector<double> azimuths)
104     {
105         std::unique_lock<std::mutex> lock(mutex_);
106         for (std::vector<double>::iterator it = azimuths.begin(); it != azimuths.end(); ++it) {
107             azimuths_.push_back(*it);
108         }
109     }
110 
SetAzimuth(double azimuth)111     inline void SetAzimuth(double azimuth)
112     {
113         std::unique_lock<std::mutex> lock(mutex_);
114         azimuths_.push_back(azimuth);
115     }
116 
GetCarrierFrequencies()117     inline std::vector<double> GetCarrierFrequencies() const
118     {
119         return carrierFrequencies_;
120     }
121 
SetCarrierFrequencies(std::vector<double> cfs)122     inline void SetCarrierFrequencies(std::vector<double> cfs)
123     {
124         std::unique_lock<std::mutex> lock(mutex_);
125         for (std::vector<double>::iterator it = cfs.begin(); it != cfs.end(); ++it) {
126             carrierFrequencies_.push_back(*it);
127         }
128     }
129 
SetCarrierFrequencie(double cf)130     inline void SetCarrierFrequencie(double cf)
131     {
132         std::unique_lock<std::mutex> lock(mutex_);
133         carrierFrequencies_.push_back(cf);
134     }
135 
136     void ReadFromParcel(Parcel& parcel);
137     bool Marshalling(Parcel& parcel) const override;
138     static std::unique_ptr<SatelliteStatus> Unmarshalling(Parcel& parcel);
139 private:
140     int satellitesNumber_;
141     std::vector<int> satelliteIds_;
142     std::vector<double> carrierToNoiseDensitys_;
143     std::vector<double> altitudes_;
144     std::vector<double> azimuths_;
145     std::vector<double> carrierFrequencies_;
146     std::mutex mutex_;
147 };
148 } // namespace Location
149 } // namespace OHOS
150 #endif // SATELLITE_STATUS_H
151