00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _DIFFDEMODULATOR_H
00029 #define _DIFFDEMODULATOR_H
00030
00031 #include "demodulator.h"
00032
00033 namespace simthlib
00034 {
00035
00036
00037
00040 class DiffDemodulator : public Demodulator
00041 {
00042 friend class AdachiDemodulator;
00043
00044 public:
00045
00048 DiffDemodulator(int deviceID, simth::DeviceSystemIntf* system,
00049 const simth::PropertyList& pl,
00050 simth::SequenceType outType )
00051 : Demodulator(deviceID, system, pl, outType) { };
00052
00053 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlvSeq *correspondingLlrValues,
00054 double noise = 0, const simth::ModSeq* trans = NULL) = 0;
00055
00056 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlrSeq *correspondingLlrValues,
00057
00058 double noise = 0, const simth::ModSeq* trans = NULL) = 0;
00059
00064 virtual void adachiDemodulate(const simth::ModSeq &receivedSym,
00065 simth::LlvSeq *correspondingLlvValues1, simth::LlvSeq *correspondingLlvValues2,
00066 double noise = 0, const simth::ModSeq* trans = NULL) = 0;
00067
00074 virtual int ConcatData(int data1, int data2) const = 0;
00075
00076 virtual int getInputLength(int outputLength) const;
00077
00078 };
00079
00090 class DiffDemodulatorMapping : public DiffDemodulator
00091 {
00092 MappingScheme* usedMapping;
00093
00094 public:
00095
00099 DiffDemodulatorMapping(int deviceID, simth::DeviceSystemIntf* system,
00100 const simth::PropertyList& pl,
00101 std::auto_ptr<MappingScheme> mapp, simth::SequenceType outType );
00102
00103 ~DiffDemodulatorMapping();
00104
00105 int getSymbolIndex(int dataValue) const
00106 {return usedMapping->getSymbolIndex(dataValue);}
00107
00108 int getDataValue(int symbolIndex) const
00109 {return usedMapping->getDataValue(symbolIndex);}
00110
00111
00112
00113
00114
00115
00116 virtual int ConcatData(int data1, int data2) const;
00117
00118 virtual void print(std::ostream &os) const;
00119 };
00120
00129 class DiffDemodulatorMetric : public DiffDemodulatorMapping
00130 {
00131 friend class AdachiDemodulator;
00132
00133
00134
00135 simth::ModSeq::storage_type diffDecodedSymbols;
00136
00137
00138 protected:
00145 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv,
00146 Complex h2, Complex h1, double noise) const = 0;
00147
00153 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv) const = 0;
00154
00155 public:
00156
00157
00158 DiffDemodulatorMetric(int deviceID, simth::DeviceSystemIntf* system,
00159 const simth::PropertyList& pl,
00160 std::auto_ptr<MappingScheme> mapp, simth::SequenceType outType );
00161
00165 virtual ~DiffDemodulatorMetric() = 0;
00166
00167
00168 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlvSeq *correspondingLlrValues,
00169 double noise = 0, const simth::ModSeq* trans = NULL);
00170
00171 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlrSeq *correspondingLlrValues,
00172 double noise = 0, const simth::ModSeq* trans = NULL);
00173
00178 virtual void adachiDemodulate(const simth::ModSeq &receivedSym,
00179 simth::LlvSeq *correspondingLlvValues1, simth::LlvSeq *correspondingLlvValues2,
00180 double noise = 0, const simth::ModSeq* trans = NULL);
00181
00182 };
00183
00184
00185
00186 inline DiffDemodulatorMetric::~DiffDemodulatorMetric()
00187 {}
00188
00189
00190
00191
00192 class DiffSubSeqDemodulatorMetric : public DiffDemodulatorMetric
00193 {
00194
00195 int subSeqLen;
00196
00197 protected:
00198
00199 public:
00200
00204 DiffSubSeqDemodulatorMetric(int deviceID, simth::DeviceSystemIntf* system,
00205 const simth::PropertyList& pl,
00206 std::auto_ptr<MappingScheme> mapp, int subSeqLength, simth::SequenceType outType)
00207 : DiffDemodulatorMetric(deviceID, system, pl, mapp, outType), subSeqLen(subSeqLength) {};
00208
00212 virtual ~DiffSubSeqDemodulatorMetric() = 0;
00213
00214 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlvSeq *correspondingLlvValues,
00215 double noise = 0, const simth::ModSeq* trans = NULL);
00216
00217 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlrSeq *correspondingLlrValues,
00218 double noise = 0, const simth::ModSeq* trans = NULL);
00219
00220
00221 virtual void adachiDemodulate(const simth::ModSeq &receivedSym,
00222 simth::LlvSeq *correspondingLlvValues1, simth::LlvSeq *correspondingLlvValues2,
00223 double noise = 0, const simth::ModSeq* trans = NULL);
00224
00225 virtual void print(std::ostream &os) const;
00226 };
00227
00228 inline DiffSubSeqDemodulatorMetric::~DiffSubSeqDemodulatorMetric()
00229 {}
00230
00231
00235 class DpskDemodulator : public DiffSubSeqDemodulatorMetric
00236 {
00237
00238 private:
00239
00240 PskConstellationDiagram* usedConstellationDiagram;
00241
00242 bool onlyPhaseEqualisation_;
00243
00244 protected:
00245
00246
00247
00248 public:
00249
00250 virtual Complex getComplSymbol(int symbolIndex) const
00251 {return usedConstellationDiagram->getComplSymbol(symbolIndex);}
00252
00253 double getPhase(int symbIndex) const
00254 {return usedConstellationDiagram->getPhase(symbIndex);}
00255
00256 double getAmplitude(int symbIndex) const
00257 {return usedConstellationDiagram->getAmplitude(symbIndex);}
00258
00259 public:
00260
00261 DpskDemodulator(int deviceID, simth::DeviceSystemIntf* system,
00262 const simth::PropertyList& pl,
00263 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType);
00264 ~DpskDemodulator();
00265
00266
00267 bool onlyPhaseEqualisation() const {return onlyPhaseEqualisation_;}
00268 void setOnlyPhaseEqualisationOn() {onlyPhaseEqualisation_=true;}
00269
00270 virtual int getBitsPerSymbol() const
00271 {return usedConstellationDiagram->getBitsPerSymbol();}
00272
00273 virtual int getNumStates() const
00274 {return usedConstellationDiagram->getNumStates();}
00275
00276 virtual void print(std::ostream &os) const;
00277 };
00278
00279
00280 inline DpskDemodulator::~DpskDemodulator()
00281 {
00282 if(usedConstellationDiagram != NULL) {
00283 delete usedConstellationDiagram;
00284 }
00285 }
00286
00287
00294 class DpskDemodulatorQC : public DpskDemodulator
00295 {
00296
00297
00298 private:
00299
00300 mutable std::vector<Complex> correctedConstellation1;
00301 mutable std::vector<Complex> correctedConstellation2;
00302
00303
00304 virtual void MetricQC(Complex sym, Complex prev_sym, simth::Llv* llv,
00305 Complex sc2, Complex sc1, double noise) const;
00306 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv,
00307 Complex h2, Complex h1, double noise) const;
00308 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00309 public:
00310 DpskDemodulatorQC(int deviceID, simth::DeviceSystemIntf* system,
00311 const simth::PropertyList& pl);
00312
00316 DpskDemodulatorQC(int deviceID, simth::DeviceSystemIntf* system,
00317 const simth::PropertyList& pl,
00318 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType);
00319
00320 ~DpskDemodulatorQC();
00321
00322 virtual void print(std::ostream &os) const;
00323 };
00324
00325
00326
00332 class DpskDemodulatorDD : public DpskDemodulator
00333 {
00334
00335 protected:
00336
00337
00338 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const = 0;
00339 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv,
00340 Complex h2, Complex h1, double noise) const;
00341 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00342 public:
00343 DpskDemodulatorDD(int deviceID, simth::DeviceSystemIntf* system,
00344 const simth::PropertyList& pl,
00345 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType)
00346 : DpskDemodulator(deviceID, system, pl, bitsPerState, SubSeqLen, mapMode, outType){};
00347
00348 ~DpskDemodulatorDD();
00349 virtual void print(std::ostream &os) const;
00350 };
00351
00352
00353
00354
00355
00359 class DpskDemDD_STD : public DpskDemodulatorDD
00360 {
00361
00362 protected:
00363
00364 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00365 public:
00366 DpskDemDD_STD(int deviceID, simth::DeviceSystemIntf* system,
00367 const simth::PropertyList& pl)
00368 : DpskDemodulatorDD(
00369 deviceID, system, pl,
00370 pl.getProperty<int>("bits_per_symbol"),
00371 pl.getProperty<int>("sub_seq_length"),
00372 string2map_type(pl.getProperty<std::string>("mapping")),
00373 simth::string2SequenceType(pl.getProperty<std::string>("output_type")))
00374 { };
00375
00379 DpskDemDD_STD(int deviceID, simth::DeviceSystemIntf* system,
00380 const simth::PropertyList& pl,
00381 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType)
00382 : DpskDemodulatorDD(deviceID, system, pl, bitsPerState, SubSeqLen, mapMode, outType){};
00383
00384 ~DpskDemDD_STD();
00385 virtual void print(std::ostream &os) const;
00386 };
00387
00388
00389 inline DpskDemDD_STD::~DpskDemDD_STD()
00390 {}
00391
00392
00397 class DpskDemDD_AWGN : public DpskDemodulatorDD
00398 {
00399
00400 protected:
00401
00402 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00403 public:
00404 DpskDemDD_AWGN(int deviceID, simth::DeviceSystemIntf* system,
00405 const simth::PropertyList& pl)
00406 : DpskDemodulatorDD(
00407 deviceID, system, pl,
00408 pl.getProperty<int>("bits_per_symbol"),
00409 pl.getProperty<int>("sub_seq_length"),
00410 string2map_type(pl.getProperty<std::string>("mapping")),
00411 simth::string2SequenceType(pl.getProperty<std::string>("output_type")))
00412 { };
00413
00416 DpskDemDD_AWGN(int deviceID, simth::DeviceSystemIntf* system,
00417 const simth::PropertyList& pl,
00418 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType)
00419 : DpskDemodulatorDD(deviceID, system, pl, bitsPerState, SubSeqLen, mapMode, outType){};
00420
00421 ~DpskDemDD_AWGN();
00422 virtual void print(std::ostream &os) const;
00423 };
00424
00425
00426 inline DpskDemDD_AWGN::~DpskDemDD_AWGN()
00427 {}
00428
00429
00430
00439 class DpskDemDD_MIN : public DpskDemodulatorDD
00440 {
00441
00442 protected:
00443
00444 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00445 public:
00446 DpskDemDD_MIN(int deviceID, simth::DeviceSystemIntf* system,
00447 const simth::PropertyList& pl)
00448 : DpskDemodulatorDD(
00449 deviceID, system, pl,
00450 pl.getProperty<int>("bits_per_symbol"),
00451 pl.getProperty<int>("sub_seq_length"),
00452 string2map_type(pl.getProperty<std::string>("mapping")),
00453 simth::string2SequenceType(pl.getProperty<std::string>("output_type")))
00454 { };
00455
00458 DpskDemDD_MIN(int deviceID, simth::DeviceSystemIntf* system,
00459 const simth::PropertyList& pl,
00460 int bitsPerState, int SubSeqLen, map_type mapMode, simth::SequenceType outType)
00461 : DpskDemodulatorDD(deviceID, system, pl, bitsPerState, SubSeqLen, mapMode, outType){};
00462
00463 ~DpskDemDD_MIN(){};
00464 virtual void print(std::ostream &os) const;
00465 };
00466
00471 class DpskDemDD_KARSTEN : public DpskDemodulatorDD
00472 {
00473
00474 protected:
00475
00476
00477 virtual void MetricDD(Complex sym, Complex prev_sym,
00478 simth::Llv* llv) const;
00479 public:
00480 DpskDemDD_KARSTEN(int deviceID, simth::DeviceSystemIntf* system,
00481 const simth::PropertyList& pl)
00482 : DpskDemodulatorDD(
00483 deviceID, system, pl,
00484 pl.getProperty<int>("bits_per_symbol"),
00485 pl.getProperty<int>("sub_seq_length"),
00486 string2map_type(pl.getProperty<std::string>("mapping")),
00487 simth::string2SequenceType(pl.getProperty<std::string>("output_type")))
00488 { };
00489
00492 DpskDemDD_KARSTEN(int deviceID, simth::DeviceSystemIntf* system,
00493 const simth::PropertyList& pl,
00494 int bitsPerState,
00495 int SubSeqLen,
00496 map_type mapMode, simth::SequenceType outType)
00497 : DpskDemodulatorDD(deviceID, system, pl, bitsPerState, SubSeqLen,
00498 mapMode, outType)
00499 {};
00500 ~DpskDemDD_KARSTEN() {};
00501 virtual void print(std::ostream &os) const;
00502 };
00503
00504
00505
00506
00507
00512 class DaskDemodulator : public DiffSubSeqDemodulatorMetric
00513 {
00514 private:
00515
00516 ApskConstellationDiagram* usedConstellationDiagram;
00517
00518
00519 protected:
00520
00521 simth::checkedVector<double> logAmplQuotients;
00522
00523 public:
00524
00525 virtual Complex getComplSymbol(int symbolIndex) const
00526 {return usedConstellationDiagram->getComplSymbol(symbolIndex);}
00527
00528 double getPhase(int symbIndex) const
00529 {return usedConstellationDiagram->getPhase(symbIndex);}
00530
00531 double getAmplitude(int symbIndex) const
00532 {return usedConstellationDiagram->getAmplitude(symbIndex);}
00533
00534
00535 int getNumAmplitudes() const
00536 {return 1<<(usedConstellationDiagram->bitsPerAmpl());}
00537
00538 int getNumPhases() const
00539 {return 1;}
00540
00544 int getNumAmplitudeBits() const
00545 {return usedConstellationDiagram->bitsPerAmpl();}
00546
00550 int getNumPhaseBits() const
00551 {return 0;}
00552
00553
00554 public:
00557 DaskDemodulator(int deviceID, simth::DeviceSystemIntf* system,
00558 const simth::PropertyList& pl,
00559 int bitsPerState, double amplFactor, double amplAddend,
00560 int SubSeqLen, map_type mapMode, simth::SequenceType outType);
00561
00562 ~DaskDemodulator();
00563
00564 virtual int getBitsPerSymbol() const
00565 {return usedConstellationDiagram->getBitsPerSymbol();}
00566
00567 virtual int getNumStates() const
00568 {return usedConstellationDiagram->getNumStates();}
00569
00570
00571 virtual void print(std::ostream &os) const;
00572
00573 };
00574
00575
00576
00584 class DaskDemodulatorQC : public DaskDemodulator
00585 {
00586 private:
00587 mutable std::vector<Complex> correctedConstellation1;
00588 mutable std::vector<Complex> correctedConstellation2;
00589
00590 protected:
00591
00592 virtual void MetricQC(Complex sym, Complex prev_sym, simth::Llv* llv,
00593 Complex sc2, Complex sc1, double noise) const;
00594
00595 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv,
00596 Complex h2, Complex h1, double noise) const;
00597 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00598 public:
00599
00600 DaskDemodulatorQC(int deviceID, simth::DeviceSystemIntf* system,
00601 const simth::PropertyList& pl,
00602 int bitsPerState, double amplFactor, double amplAddend,
00603 int SubSeqLen, map_type mapMode, simth::SequenceType outType);
00604
00605 ~DaskDemodulatorQC(){};
00606
00607 virtual void print(std::ostream &os) const;
00608
00609 };
00610
00611
00617 class DaskDemodulatorDD : public DaskDemodulator
00618 {
00619 private:
00620
00621
00622 protected:
00623
00624 simth::checkedVector<double> logAmplQuotients;
00625
00626
00627
00628 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const = 0;
00629
00630 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv,
00631 Complex h2, Complex h1, double noise) const;
00632 virtual void MakeMetric(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00633 public:
00634
00635 DaskDemodulatorDD(int deviceID, simth::DeviceSystemIntf* system,
00636 const simth::PropertyList& pl,
00637 int bitsPerState, double amplFactor,
00638 int SubSeqLen, map_type mapMode, simth::SequenceType outType);
00639
00640 ~DaskDemodulatorDD(){};
00641
00642 virtual void print(std::ostream &os) const;
00643
00644 };
00645
00646
00650 class DaskDemDD_STD : public DaskDemodulatorDD
00651 {
00652
00653 protected:
00654
00655
00656 virtual void MetricDD(Complex sym, Complex prev_sym, simth::Llv* llv) const;
00657 public:
00658
00665 DaskDemDD_STD(int deviceID, simth::DeviceSystemIntf* system,
00666 const simth::PropertyList& pl,
00667 int bitsPerState, double amplFactor,
00668 int subSeqLen, map_type mapMode, simth::SequenceType outType);
00669
00670 virtual void print(std::ostream &os) const;
00671 };
00672
00673
00674
00675
00676
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00758 class Da_PskDemodulator : public DiffDemodulator
00759 {
00760 DaskDemodulator* amplDemod;
00761 DpskDemodulator* phaseDemod;
00762
00763 mutable simth::LlrSeq::storage_type cacheAmplLlr;
00764 mutable simth::LlrSeq::storage_type cachePhaseLlr;
00765
00766 mutable simth::LlrSeq::storage_type cacheAmplLlv;
00767 mutable simth::LlrSeq::storage_type cachePhaseLlv;
00768
00769
00770 mutable simth::LlrSeq::storage_type cacheAmplLlv2;
00771 mutable simth::LlrSeq::storage_type cachePhaseLlv2;
00772
00773 const int bitsPerSymbol_;
00774 const int numStates_;
00775
00776 virtual Complex getComplSymbol(int symbolIndex) const;
00777
00781 int getNumAmplitudeBits() const
00782 {return amplDemod->getBitsPerSymbol();}
00783
00787 int getNumPhaseBits() const
00788 {return phaseDemod->getBitsPerSymbol();}
00789
00790 void invariante();
00791
00792 public:
00793
00796 Da_PskDemodulator(int deviceID,simth::DeviceSystemIntf* system, const simth::PropertyList& pl);
00797
00798
00799
00800 Da_PskDemodulator(int deviceID,
00801 simth::DeviceSystemIntf* system,
00802 const simth::PropertyList& pl,
00803 int bitsPerAmpl,int bitsPerPhase, int subSeqLength,
00804 detect_type detectType, map_type mapping,simth::SequenceType outType);
00805
00808 Da_PskDemodulator(int deviceID, simth::DeviceSystemIntf* system,
00809 const simth::PropertyList& pl,
00810 DaskDemodulator* amplDemod_, DpskDemodulator* phaseDemod_, simth::SequenceType outType);
00811
00812
00813 ~Da_PskDemodulator();
00814
00815 void updateInputLengths( );
00816
00817 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlrSeq *correspondingLlrValues,
00818 double noise = 0, const simth::ModSeq* trans = NULL);
00819 virtual void demodulate(const simth::ModSeq &receivedSym, simth::LlvSeq *correspondingLlvValues,
00820 double noise = 0, const simth::ModSeq* trans = NULL);
00821
00822 virtual void adachiDemodulate(const simth::ModSeq &receivedSym,
00823 simth::LlvSeq *correspondingLlvValues1, simth::LlvSeq *correspondingLlvValues2,
00824 double noise = 0, const simth::ModSeq* trans = NULL);
00825
00826
00827
00828
00829
00830
00831
00832 virtual int ConcatData(int data1, int data2) const;
00833
00834
00835 virtual int getBitsPerSymbol() const;
00836
00837 virtual int getNumStates() const;
00838
00839 virtual void print(std::ostream &os) const;
00840
00841 };
00842
00843 inline void Da_PskDemodulator::invariante()
00844 {
00845 if(DEBUG) {
00846 if( (1<<getBitsPerSymbol()) != amplDemod->getNumStates() * phaseDemod->getNumStates() ) {
00847 throw std::logic_error("Da_PskDemodulator::DapskDemodulator(...) : error 1");
00848 }
00849 if(getNumStates() != amplDemod->getNumStates() * phaseDemod->getNumStates()) {
00850 throw std::logic_error("Da_PskDemodulator::DapskDemodulator(...) : error 2");
00851 }
00852 }
00853 }
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036 typedef Da_PskDemodulator DapskDemodulator;
01037
01038
01039
01040 }
01041
01042
01043 #endif // _DIFFDEMODULATOR_H