ns-3 PLC model
|
00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2012 University of British Columbia, Vancouver 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Alexander Schloegl <alexander.schloegl@gmx.de> 00019 */ 00020 00021 #ifndef PLC_VALUE_H_ 00022 #define PLC_VALUE_H_ 00023 00024 #include <iostream> 00025 #include <vector> 00026 00027 #include <ns3/ptr.h> 00028 #include <ns3/simple-ref-count.h> 00029 #include <ns3/spectrum-model.h> 00030 #include <ns3/spectrum-value.h> 00031 00032 #include "plc-defs.h" 00033 #include "plc-time.h" 00034 00035 namespace ns3 { 00036 00037 Ptr<PLC_ValueBase> Add(Ptr<PLC_ValueBase> op1, Ptr<PLC_ValueBase> op2); 00038 Ptr<PLC_ValueBase> Subtract(Ptr<PLC_ValueBase> op1, Ptr<PLC_ValueBase> op2); 00039 Ptr<PLC_ValueBase> Divide(Ptr<PLC_ValueBase> op1, Ptr<PLC_ValueBase> op2); 00040 Ptr<PLC_ValueBase> Multiply(Ptr<PLC_ValueBase> op1, Ptr<PLC_ValueBase> op2); 00041 00053 class PLC_ValueBase : public SimpleRefCount<PLC_ValueBase> 00054 { 00055 public: 00056 00057 enum PLC_ValueType { 00058 CONSTANT, 00059 FREQ_SELECTIVE, 00060 TIMEVARIANT_CONSTANT, 00061 TIMEVARIANT_FREQ_SELECTIVE 00062 }; 00063 00064 PLC_ValueBase() {} 00065 PLC_ValueBase(Ptr<const SpectrumModel> sm, PLC_ValueType type); 00066 ~PLC_ValueBase(void); 00067 00068 PLC_ValueType GetValueType(void) const { return m_value_type; } 00069 Ptr<const SpectrumModel> GetSpectrumModel(void) const { return m_spectrum_model; } 00070 size_t GetNumBands(void) const { return m_spectrum_model->GetNumBands(); } 00071 00072 void Lock(void) const { m_mutex.Lock(); } 00073 void Unlock(void) const { m_mutex.Unlock(); } 00074 00075 bool IsTimeVariant(void) const; 00076 00077 friend std::ostream& operator<<(std::ostream& stream, PLC_ValueBase& value); 00078 00079 Ptr<PLC_ValueBase> Copy(void); 00080 00081 protected: 00082 // pure virtual dummy function to keep pybindgen happy 00083 virtual void pureVirtualDummy(void) = 0; 00084 00085 mutable PLC_Mutex m_mutex; 00086 Ptr<const SpectrumModel> m_spectrum_model; 00087 PLC_ValueType m_value_type; 00088 }; 00089 00093 class PLC_ConstValue : public PLC_ValueBase 00094 { 00095 00096 public: 00097 00098 PLC_ConstValue(); 00099 PLC_ConstValue(Ptr<const SpectrumModel> sm, double real); 00100 PLC_ConstValue(Ptr<const SpectrumModel> sm, PLC_Value value = PLC_Value(0, 0)); 00101 PLC_ConstValue(const PLC_ConstValue& value); 00102 00103 PLC_Value GetValue(void) const; 00104 00105 PLC_ConstValue& operator=(const PLC_ConstValue& value); 00106 00107 PLC_ConstValue& operator+=(double value); 00108 PLC_ConstValue& operator+=(const PLC_Value& value); 00109 PLC_ConstValue& operator+=(const PLC_ConstValue& value); 00110 00111 PLC_ConstValue& operator-=(double value); 00112 PLC_ConstValue& operator-=(const PLC_Value& value); 00113 PLC_ConstValue& operator-=(const PLC_ConstValue& value); 00114 00115 PLC_ConstValue& operator*=(double value); 00116 PLC_ConstValue& operator*=(const PLC_Value& value); 00117 PLC_ConstValue& operator*=(const PLC_ConstValue& value); 00118 00119 PLC_ConstValue& operator/=(double value); 00120 PLC_ConstValue& operator/=(const PLC_Value& value); 00121 PLC_ConstValue& operator/=(const PLC_ConstValue& value); 00122 00123 friend PLC_ConstValue operator+(const PLC_ConstValue& value); 00124 friend PLC_ConstValue operator-(const PLC_ConstValue& value); 00125 00126 friend PLC_ConstValue operator+(const PLC_ConstValue& lhs, double rhs); 00127 friend PLC_ConstValue operator+(double lhs, const PLC_ConstValue& rhs); 00128 friend PLC_ConstValue operator+(const PLC_ConstValue& lhs, const PLC_Value& rhs); 00129 friend PLC_ConstValue operator+(const PLC_Value& lhs, const PLC_ConstValue& rhs); 00130 friend PLC_ConstValue operator+(const PLC_ConstValue& lhs, const PLC_ConstValue& rhs); 00131 00132 friend PLC_ConstValue operator-(const PLC_ConstValue& lhs, double rhs); 00133 friend PLC_ConstValue operator-(double lhs, const PLC_ConstValue& rhs); 00134 friend PLC_ConstValue operator-(const PLC_ConstValue& lhs, const PLC_Value& rhs); 00135 friend PLC_ConstValue operator-(const PLC_Value& lhs, const PLC_ConstValue& rhs); 00136 friend PLC_ConstValue operator-(const PLC_ConstValue& lhs, const PLC_ConstValue& rhs); 00137 00138 friend PLC_ConstValue operator*(const PLC_ConstValue& lhs, double rhs); 00139 friend PLC_ConstValue operator*(double lhs, const PLC_ConstValue& rhs); 00140 friend PLC_ConstValue operator*(const PLC_ConstValue& lhs, const PLC_Value& rhs); 00141 friend PLC_ConstValue operator*(const PLC_Value& lhs, const PLC_ConstValue& rhs); 00142 friend PLC_ConstValue operator*(const PLC_ConstValue& lhs, const PLC_ConstValue& rhs); 00143 00144 friend PLC_ConstValue operator/(const PLC_ConstValue& lhs, double rhs); 00145 friend PLC_ConstValue operator/(double lhs, const PLC_ConstValue& rhs); 00146 friend PLC_ConstValue operator/(const PLC_ConstValue& lhs, const PLC_Value& rhs); 00147 friend PLC_ConstValue operator/(const PLC_Value& lhs, const PLC_ConstValue& rhs); 00148 friend PLC_ConstValue operator/(const PLC_ConstValue& lhs, const PLC_ConstValue& rhs); 00149 00150 friend std::ostream& operator<<(std::ostream& stream, PLC_ConstValue& value); 00151 00152 protected: 00153 // virtual dummy function to keep pybindgen happy 00154 virtual void pureVirtualDummy(void) {} 00155 00156 private: 00157 00158 PLC_Value m_value; 00159 }; 00160 00164 class PLC_FreqSelectiveValue : public PLC_ValueBase 00165 { 00166 public: 00167 00168 PLC_FreqSelectiveValue() {} 00169 PLC_FreqSelectiveValue(Ptr<const SpectrumModel> sm, PLC_Value value = PLC_Value(0, 0)); 00170 PLC_FreqSelectiveValue(Ptr<const SpectrumModel> sm, const PLC_ValueSpectrum& values); 00171 PLC_FreqSelectiveValue(Ptr<const SpectrumModel> sm, double R, double Q, double f_0); 00172 PLC_FreqSelectiveValue(const PLC_ConstValue& value); 00173 PLC_FreqSelectiveValue(const PLC_FreqSelectiveValue& value); 00174 00175 PLC_ValueSpectrum GetValues(void) const { return m_values; } 00176 PLC_ValueSpectrum *GetValuesRef(void) { return &m_values; } 00177 00178 PLC_FreqSelectiveValue& operator=(const PLC_ConstValue& value); 00179 PLC_FreqSelectiveValue& operator=(const PLC_FreqSelectiveValue& value); 00180 00181 PLC_Value operator[](size_t i) const; 00182 PLC_Value& operator[](size_t i); 00183 00184 PLC_FreqSelectiveValue& operator+=(double value); 00185 PLC_FreqSelectiveValue& operator+=(const PLC_Value& value); 00186 PLC_FreqSelectiveValue& operator+=(const PLC_ConstValue& value); 00187 PLC_FreqSelectiveValue& operator+=(const PLC_FreqSelectiveValue& value); 00188 00189 PLC_FreqSelectiveValue& operator-=(double value); 00190 PLC_FreqSelectiveValue& operator-=(const PLC_Value& value); 00191 PLC_FreqSelectiveValue& operator-=(const PLC_ConstValue& value); 00192 PLC_FreqSelectiveValue& operator-=(const PLC_FreqSelectiveValue& value); 00193 00194 PLC_FreqSelectiveValue& operator*=(double value); 00195 PLC_FreqSelectiveValue& operator*=(const PLC_Value& value); 00196 PLC_FreqSelectiveValue& operator*=(const PLC_ConstValue& value); 00197 PLC_FreqSelectiveValue& operator*=(const PLC_FreqSelectiveValue& value); 00198 00199 PLC_FreqSelectiveValue& operator/=(double value); 00200 PLC_FreqSelectiveValue& operator/=(const PLC_Value& value); 00201 PLC_FreqSelectiveValue& operator/=(const PLC_ConstValue& value); 00202 PLC_FreqSelectiveValue& operator/=(const PLC_FreqSelectiveValue& value); 00203 00204 friend PLC_FreqSelectiveValue operator+(const PLC_FreqSelectiveValue& value); 00205 friend PLC_FreqSelectiveValue operator-(const PLC_FreqSelectiveValue& value); 00206 00207 friend PLC_FreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, double rhs); 00208 friend PLC_FreqSelectiveValue operator+(double lhs, const PLC_FreqSelectiveValue& rhs); 00209 friend PLC_FreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_Value& rhs); 00210 friend PLC_FreqSelectiveValue operator+(const PLC_Value& lhs, const PLC_FreqSelectiveValue& rhs); 00211 friend PLC_FreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00212 friend PLC_FreqSelectiveValue operator+(const PLC_ConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00213 friend PLC_FreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00214 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00215 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00216 00217 friend PLC_FreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, double rhs); 00218 friend PLC_FreqSelectiveValue operator-(double lhs, const PLC_FreqSelectiveValue& rhs); 00219 friend PLC_FreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_Value& rhs); 00220 friend PLC_FreqSelectiveValue operator-(const PLC_Value& lhs, const PLC_FreqSelectiveValue& rhs); 00221 friend PLC_FreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00222 friend PLC_FreqSelectiveValue operator-(const PLC_ConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00223 friend PLC_FreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00224 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00225 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00226 00227 friend PLC_FreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, double rhs); 00228 friend PLC_FreqSelectiveValue operator*(double lhs, const PLC_FreqSelectiveValue& rhs); 00229 friend PLC_FreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_Value& rhs); 00230 friend PLC_FreqSelectiveValue operator*(const PLC_Value& lhs, const PLC_FreqSelectiveValue& rhs); 00231 friend PLC_FreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00232 friend PLC_FreqSelectiveValue operator*(const PLC_ConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00233 friend PLC_FreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00234 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00235 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00236 00237 friend PLC_FreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, double rhs); 00238 friend PLC_FreqSelectiveValue operator/(double lhs, const PLC_FreqSelectiveValue& rhs); 00239 friend PLC_FreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_Value& rhs); 00240 friend PLC_FreqSelectiveValue operator/(const PLC_Value& lhs, const PLC_FreqSelectiveValue& rhs); 00241 friend PLC_FreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00242 friend PLC_FreqSelectiveValue operator/(const PLC_ConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00243 friend PLC_FreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00244 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00245 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00246 00247 friend std::ostream& operator<<(std::ostream& stream, PLC_FreqSelectiveValue& value); 00248 00249 protected: 00250 // virtual dummy function to keep pybindgen happy 00251 virtual void pureVirtualDummy(void) {} 00252 00253 private: 00254 00255 PLC_ValueSpectrum m_values; 00256 }; 00257 00261 class PLC_TimeVariantConstValue : public PLC_ValueBase 00262 { 00263 public: 00264 00265 PLC_TimeVariantConstValue() {} 00266 PLC_TimeVariantConstValue(Ptr<const SpectrumModel> sm, PLC_Value value = PLC_Value(0, 0), size_t timeslots = PLC_Time::GetNumTimeslots()); 00267 PLC_TimeVariantConstValue(Ptr<const SpectrumModel> sm, const PLC_TimeVariantValue& values); 00268 PLC_TimeVariantConstValue(const PLC_ConstValue& value, size_t timeslots = PLC_Time::GetNumTimeslots()); 00269 PLC_TimeVariantConstValue(const PLC_TimeVariantConstValue& value); 00270 00271 PLC_TimeVariantValue GetValues(void) const { return m_values; } 00272 size_t GetNumTimeSlots(void) const { return m_values.size(); } 00273 00274 PLC_TimeVariantConstValue& operator=(const PLC_ConstValue& value); 00275 PLC_TimeVariantConstValue& operator=(const PLC_TimeVariantConstValue& value); 00276 00277 PLC_Value operator[](size_t i) const; 00278 00279 PLC_TimeVariantConstValue& operator+=(double value); 00280 PLC_TimeVariantConstValue& operator+=(const PLC_Value& value); 00281 PLC_TimeVariantConstValue& operator+=(const PLC_ConstValue& value); 00282 PLC_TimeVariantConstValue& operator+=(const PLC_TimeVariantConstValue& value); 00283 00284 PLC_TimeVariantConstValue& operator-=(double value); 00285 PLC_TimeVariantConstValue& operator-=(const PLC_Value& value); 00286 PLC_TimeVariantConstValue& operator-=(const PLC_ConstValue& value); 00287 PLC_TimeVariantConstValue& operator-=(const PLC_TimeVariantConstValue& value); 00288 00289 PLC_TimeVariantConstValue& operator*=(double value); 00290 PLC_TimeVariantConstValue& operator*=(const PLC_Value& value); 00291 PLC_TimeVariantConstValue& operator*=(const PLC_ConstValue& value); 00292 PLC_TimeVariantConstValue& operator*=(const PLC_TimeVariantConstValue& value); 00293 00294 PLC_TimeVariantConstValue& operator/=(double value); 00295 PLC_TimeVariantConstValue& operator/=(const PLC_Value& value); 00296 PLC_TimeVariantConstValue& operator/=(const PLC_ConstValue& value); 00297 PLC_TimeVariantConstValue& operator/=(const PLC_TimeVariantConstValue& value); 00298 00299 friend PLC_TimeVariantConstValue operator+(const PLC_TimeVariantConstValue& value); 00300 friend PLC_TimeVariantConstValue operator-(const PLC_TimeVariantConstValue& value); 00301 00302 friend PLC_TimeVariantConstValue operator+(const PLC_TimeVariantConstValue& lhs, double rhs); 00303 friend PLC_TimeVariantConstValue operator+(double lhs, const PLC_TimeVariantConstValue& rhs); 00304 friend PLC_TimeVariantConstValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_Value& rhs); 00305 friend PLC_TimeVariantConstValue operator+(const PLC_Value& lhs, const PLC_TimeVariantConstValue& rhs); 00306 friend PLC_TimeVariantConstValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_ConstValue& rhs); 00307 friend PLC_TimeVariantConstValue operator+(const PLC_ConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00308 friend PLC_TimeVariantConstValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00309 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00310 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00311 00312 friend PLC_TimeVariantConstValue operator-(const PLC_TimeVariantConstValue& lhs, double rhs); 00313 friend PLC_TimeVariantConstValue operator-(double lhs, const PLC_TimeVariantConstValue& rhs); 00314 friend PLC_TimeVariantConstValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_Value& rhs); 00315 friend PLC_TimeVariantConstValue operator-(const PLC_Value& lhs, const PLC_TimeVariantConstValue& rhs); 00316 friend PLC_TimeVariantConstValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_ConstValue& rhs); 00317 friend PLC_TimeVariantConstValue operator-(const PLC_ConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00318 friend PLC_TimeVariantConstValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00319 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00320 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00321 00322 friend PLC_TimeVariantConstValue operator*(const PLC_TimeVariantConstValue& lhs, double rhs); 00323 friend PLC_TimeVariantConstValue operator*(double lhs, const PLC_TimeVariantConstValue& rhs); 00324 friend PLC_TimeVariantConstValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_Value& rhs); 00325 friend PLC_TimeVariantConstValue operator*(const PLC_Value& lhs, const PLC_TimeVariantConstValue& rhs); 00326 friend PLC_TimeVariantConstValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_ConstValue& rhs); 00327 friend PLC_TimeVariantConstValue operator*(const PLC_ConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00328 friend PLC_TimeVariantConstValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00329 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00330 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00331 00332 friend PLC_TimeVariantConstValue operator/(const PLC_TimeVariantConstValue& lhs, double rhs); 00333 friend PLC_TimeVariantConstValue operator/(double lhs, const PLC_TimeVariantConstValue& rhs); 00334 friend PLC_TimeVariantConstValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_Value& rhs); 00335 friend PLC_TimeVariantConstValue operator/(const PLC_Value& lhs, const PLC_TimeVariantConstValue& rhs); 00336 friend PLC_TimeVariantConstValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_ConstValue& rhs); 00337 friend PLC_TimeVariantConstValue operator/(const PLC_ConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00338 friend PLC_TimeVariantConstValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantConstValue& rhs); 00339 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00340 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00341 00342 00343 friend std::ostream& operator<<(std::ostream& stream, PLC_TimeVariantConstValue& value); 00344 00345 protected: 00346 // virtual dummy function to keep pybindgen happy 00347 virtual void pureVirtualDummy(void) {} 00348 00349 private: 00350 00351 PLC_TimeVariantValue m_values; 00352 }; 00353 00357 class PLC_TimeVariantFreqSelectiveValue : public PLC_ValueBase 00358 { 00359 public: 00360 struct PLC_TimeVariantParamSet 00361 { 00362 double R_offset; 00363 double Q_offset; 00364 double f_0_offset; 00365 double R_amplitude; 00366 double Q_amplitude; 00367 double f0_amplitude; 00368 double phi; 00369 }; 00370 00371 PLC_TimeVariantFreqSelectiveValue() {} 00372 PLC_TimeVariantFreqSelectiveValue(Ptr<const SpectrumModel> sm, size_t timeslots = PLC_Time::GetNumTimeslots(), PLC_Value value = PLC_Value(0, 0)); 00373 PLC_TimeVariantFreqSelectiveValue(Ptr<const SpectrumModel> sm, const PLC_TimeVariantValue& values); 00374 PLC_TimeVariantFreqSelectiveValue(Ptr<const SpectrumModel> sm, const PLC_TimeVariantValueSpectrum& values); 00375 PLC_TimeVariantFreqSelectiveValue(const PLC_ConstValue& value, size_t timeslots = PLC_Time::GetNumTimeslots()); 00376 PLC_TimeVariantFreqSelectiveValue(const PLC_FreqSelectiveValue& value, size_t timeslots = PLC_Time::GetNumTimeslots()); 00377 PLC_TimeVariantFreqSelectiveValue(const PLC_TimeVariantConstValue& value); 00378 PLC_TimeVariantFreqSelectiveValue(const PLC_TimeVariantFreqSelectiveValue& value); 00379 PLC_TimeVariantFreqSelectiveValue(PLC_FreqSelectiveValue& offset, PLC_FreqSelectiveValue& amplitude, double phi, size_t timeslots = PLC_Time::GetNumTimeslots()); 00380 PLC_TimeVariantFreqSelectiveValue(Ptr<const SpectrumModel> sm, struct PLC_TimeVariantParamSet& paramSet, size_t timeslots = PLC_Time::GetNumTimeslots()); 00381 00382 PLC_TimeVariantValueSpectrum GetValues(void) const { return m_values; } 00383 PLC_TimeVariantValueSpectrum *GetValuesRef(void) { return &m_values; } 00384 00385 size_t GetNumTimeSlots(void) const { return m_values.size(); } 00386 00387 PLC_ValueSpectrum operator[](size_t i) const; 00388 PLC_ValueSpectrum& operator[](size_t i); 00389 00390 PLC_TimeVariantFreqSelectiveValue& operator+=(double value); 00391 PLC_TimeVariantFreqSelectiveValue& operator+=(const PLC_Value& value); 00392 PLC_TimeVariantFreqSelectiveValue& operator+=(const PLC_ConstValue& value); 00393 PLC_TimeVariantFreqSelectiveValue& operator+=(const PLC_FreqSelectiveValue& value); 00394 PLC_TimeVariantFreqSelectiveValue& operator+=(const PLC_TimeVariantConstValue& value); 00395 PLC_TimeVariantFreqSelectiveValue& operator+=(const PLC_TimeVariantFreqSelectiveValue& value); 00396 00397 PLC_TimeVariantFreqSelectiveValue& operator-=(double value); 00398 PLC_TimeVariantFreqSelectiveValue& operator-=(const PLC_Value& value); 00399 PLC_TimeVariantFreqSelectiveValue& operator-=(const PLC_ConstValue& value); 00400 PLC_TimeVariantFreqSelectiveValue& operator-=(const PLC_FreqSelectiveValue& value); 00401 PLC_TimeVariantFreqSelectiveValue& operator-=(const PLC_TimeVariantConstValue& value); 00402 PLC_TimeVariantFreqSelectiveValue& operator-=(const PLC_TimeVariantFreqSelectiveValue& value); 00403 00404 PLC_TimeVariantFreqSelectiveValue& operator*=(double value); 00405 PLC_TimeVariantFreqSelectiveValue& operator*=(const PLC_Value& value); 00406 PLC_TimeVariantFreqSelectiveValue& operator*=(const PLC_ConstValue& value); 00407 PLC_TimeVariantFreqSelectiveValue& operator*=(const PLC_FreqSelectiveValue& value); 00408 PLC_TimeVariantFreqSelectiveValue& operator*=(const PLC_TimeVariantConstValue& value); 00409 PLC_TimeVariantFreqSelectiveValue& operator*=(const PLC_TimeVariantFreqSelectiveValue& value); 00410 00411 PLC_TimeVariantFreqSelectiveValue& operator/=(double value); 00412 PLC_TimeVariantFreqSelectiveValue& operator/=(const PLC_Value& value); 00413 PLC_TimeVariantFreqSelectiveValue& operator/=(const PLC_ConstValue& value); 00414 PLC_TimeVariantFreqSelectiveValue& operator/=(const PLC_FreqSelectiveValue& value); 00415 PLC_TimeVariantFreqSelectiveValue& operator/=(const PLC_TimeVariantConstValue& value); 00416 PLC_TimeVariantFreqSelectiveValue& operator/=(const PLC_TimeVariantFreqSelectiveValue& value); 00417 00418 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& value); 00419 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& value); 00420 00421 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, double rhs); 00422 friend PLC_TimeVariantFreqSelectiveValue operator+(double lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00423 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_Value& rhs); 00424 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_Value& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00425 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00426 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_ConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00427 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00428 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00429 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00430 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00431 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00432 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00433 friend PLC_TimeVariantFreqSelectiveValue operator+(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00434 00435 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, double rhs); 00436 friend PLC_TimeVariantFreqSelectiveValue operator-(double lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00437 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_Value& rhs); 00438 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_Value& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00439 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00440 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_ConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00441 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00442 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00443 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00444 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00445 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00446 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00447 friend PLC_TimeVariantFreqSelectiveValue operator-(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00448 00449 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, double rhs); 00450 friend PLC_TimeVariantFreqSelectiveValue operator*(double lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00451 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_Value& rhs); 00452 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_Value& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00453 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00454 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_ConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00455 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00456 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00457 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00458 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00459 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00460 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00461 friend PLC_TimeVariantFreqSelectiveValue operator*(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00462 00463 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, double rhs); 00464 friend PLC_TimeVariantFreqSelectiveValue operator/(double lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00465 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_Value& rhs); 00466 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_Value& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00467 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_ConstValue& rhs); 00468 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_ConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00469 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_FreqSelectiveValue& rhs); 00470 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00471 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00472 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00473 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantFreqSelectiveValue& lhs, const PLC_TimeVariantFreqSelectiveValue& rhs); 00474 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_TimeVariantConstValue& lhs, const PLC_FreqSelectiveValue& rhs); 00475 friend PLC_TimeVariantFreqSelectiveValue operator/(const PLC_FreqSelectiveValue& lhs, const PLC_TimeVariantConstValue& rhs); 00476 00477 friend std::ostream& operator<<(std::ostream& stream, PLC_TimeVariantFreqSelectiveValue& value); 00478 00479 protected: 00480 // virtual dummy function to keep pybindgen happy 00481 virtual void pureVirtualDummy(void) {} 00482 00483 private: 00484 00485 PLC_TimeVariantValueSpectrum m_values; 00486 }; 00487 00488 double abs(const PLC_ConstValue& value); 00489 PLC_FreqSelectiveRealValue abs(const PLC_FreqSelectiveValue& value); 00490 PLC_TimeVariantRealValue abs(const PLC_TimeVariantConstValue& value); 00491 PLC_TimeVariantFreqSelectiveRealValue abs(const PLC_TimeVariantFreqSelectiveValue& value); 00492 00493 double arg(const PLC_ConstValue& value); 00494 PLC_FreqSelectiveRealValue arg(const PLC_FreqSelectiveValue& value); 00495 PLC_TimeVariantRealValue arg(const PLC_TimeVariantConstValue& value); 00496 PLC_TimeVariantFreqSelectiveRealValue arg(const PLC_TimeVariantFreqSelectiveValue& value); 00497 00498 double real(const PLC_ConstValue& value); 00499 PLC_FreqSelectiveRealValue real(const PLC_FreqSelectiveValue& value); 00500 PLC_TimeVariantRealValue real(const PLC_TimeVariantConstValue& value); 00501 PLC_TimeVariantFreqSelectiveRealValue real(const PLC_TimeVariantFreqSelectiveValue& value); 00502 00503 double imag(const PLC_ConstValue& value); 00504 PLC_FreqSelectiveRealValue imag(const PLC_FreqSelectiveValue& value); 00505 PLC_TimeVariantRealValue imag(const PLC_TimeVariantConstValue& value); 00506 PLC_TimeVariantFreqSelectiveRealValue imag(const PLC_TimeVariantFreqSelectiveValue& value); 00507 00508 double absSqr(const PLC_ConstValue& value); 00509 PLC_FreqSelectiveRealValue absSqr(const PLC_FreqSelectiveValue& value); 00510 PLC_TimeVariantRealValue absSqr(const PLC_TimeVariantConstValue& value); 00511 PLC_TimeVariantFreqSelectiveRealValue absSqr(const PLC_TimeVariantFreqSelectiveValue& value); 00512 00513 PLC_ConstValue sinh(const PLC_ConstValue& value); 00514 PLC_FreqSelectiveValue sinh(const PLC_FreqSelectiveValue& value); 00515 PLC_TimeVariantConstValue sinh(const PLC_TimeVariantConstValue& value); 00516 PLC_TimeVariantFreqSelectiveValue sinh(const PLC_TimeVariantFreqSelectiveValue& value); 00517 00518 PLC_ConstValue cosh(const PLC_ConstValue& value); 00519 PLC_FreqSelectiveValue cosh(const PLC_FreqSelectiveValue& value); 00520 PLC_TimeVariantConstValue cosh(const PLC_TimeVariantConstValue& value); 00521 PLC_TimeVariantFreqSelectiveValue cosh(const PLC_TimeVariantFreqSelectiveValue& value); 00522 00523 PLC_ConstValue exp(const PLC_ConstValue& value); 00524 PLC_FreqSelectiveValue exp(const PLC_FreqSelectiveValue& value); 00525 PLC_TimeVariantConstValue exp(const PLC_TimeVariantConstValue& value); 00526 PLC_TimeVariantFreqSelectiveValue exp(const PLC_TimeVariantFreqSelectiveValue& value); 00527 00528 PLC_ConstValue log10(const PLC_ConstValue& value); 00529 PLC_FreqSelectiveValue log10(const PLC_FreqSelectiveValue& value); 00530 PLC_TimeVariantConstValue log10(const PLC_TimeVariantConstValue& value); 00531 PLC_TimeVariantFreqSelectiveValue log10(const PLC_TimeVariantFreqSelectiveValue& value); 00532 00533 PLC_ConstValue tan(const PLC_ConstValue& value); 00534 PLC_FreqSelectiveValue tan(const PLC_FreqSelectiveValue& value); 00535 PLC_TimeVariantConstValue tan(const PLC_TimeVariantConstValue& value); 00536 PLC_TimeVariantFreqSelectiveValue tan(const PLC_TimeVariantFreqSelectiveValue& value); 00537 00538 PLC_ConstValue tanh(const PLC_ConstValue& value); 00539 PLC_FreqSelectiveValue tanh(const PLC_FreqSelectiveValue& value); 00540 PLC_TimeVariantConstValue tanh(const PLC_TimeVariantConstValue& value); 00541 PLC_TimeVariantFreqSelectiveValue tanh(const PLC_TimeVariantFreqSelectiveValue& value); 00542 00543 double max(SpectrumValue& value); 00544 double min(SpectrumValue& value); 00545 00546 // power (integral of power spectral density) 00547 double Pwr(SpectrumValue& value); 00548 00549 // Watts to dBm 00550 double W2dBm(double watt); 00551 00552 double max(PLC_FreqSelectiveRealValue& value); 00553 double min(PLC_FreqSelectiveRealValue& value); 00554 00555 void AddInverseValue(PLC_ValueBase *res, PLC_ValueBase *imp); 00556 00557 template<typename ImpedanceReturnType> 00558 Ptr<ImpedanceReturnType> CalcEquivalentImpedance(Ptr<const SpectrumModel> sm, std::vector<PLC_Impedance *> parallel_impedances) 00559 { 00560 ImpedanceReturnType inv_ret(sm); 00561 00562 std::vector<PLC_Impedance *>::iterator p_it; 00563 for (p_it = parallel_impedances.begin(); p_it != parallel_impedances.end(); p_it++) { 00564 (*p_it)->Lock(); 00565 AddInverseValue(&inv_ret, *p_it); 00566 (*p_it)->Unlock(); 00567 } 00568 00569 return Create<ImpedanceReturnType>(1 / inv_ret); 00570 } 00571 00572 } 00573 00574 #endif /* PLC_VALUE_H_ */