[1442] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 |
|
---|
| 3 | #ifndef SIMTOIPR_H
|
---|
| 4 | #define SIMTOIPR_H
|
---|
| 5 |
|
---|
| 6 | #include "toiprocessor.h"
|
---|
[1454] | 7 | #include "tvector.h"
|
---|
[1442] | 8 |
|
---|
| 9 | // --------- Un deglitcheur simple
|
---|
| 10 | // Dans chaque fenetre de largeur de wsz
|
---|
| 11 | // if (val > Mean(Window)+ns*Sigma(Window)) val = Mean(Window)
|
---|
| 12 | // Si Pas plus de maxnpt points remplissants cette condition
|
---|
| 13 |
|
---|
| 14 | class SimpleDeglitcher : public TOIProcessor {
|
---|
| 15 | public:
|
---|
| 16 | SimpleDeglitcher(int wsz=64, double ns=3, int maxnpt=5);
|
---|
| 17 | virtual ~SimpleDeglitcher();
|
---|
| 18 |
|
---|
[1454] | 19 | inline void SetRange(double min, double max)
|
---|
| 20 | { range_min = min; range_max = max; }
|
---|
| 21 | inline void GetRange(double& min, double& max) const
|
---|
| 22 | { min = range_min; max = range_max; }
|
---|
| 23 |
|
---|
[1442] | 24 | virtual void init();
|
---|
| 25 | virtual void run();
|
---|
| 26 |
|
---|
| 27 | inline int WSize() const { return wsize; }
|
---|
| 28 | inline double NbSigmas() const { return nsig; }
|
---|
| 29 | inline int MaxPoints() const { return maxpoints; }
|
---|
| 30 |
|
---|
[1454] | 31 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 32 | inline int_8 GlitchCount() const { return glcount; }
|
---|
| 33 | inline int_8 GlitchSampleCount() const { return glnscount; }
|
---|
| 34 | inline int_8 OutOfRangeSampleCount() const { return out_range_nscount; }
|
---|
[1442] | 35 |
|
---|
[1443] | 36 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 37 |
|
---|
[1442] | 38 | protected:
|
---|
[1454] | 39 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 40 | int_8 glnscount; // Nombre total de glitch
|
---|
| 41 | int_8 glcount; // Nombre de glitch detecte
|
---|
| 42 | int_8 out_range_nscount; // Nombre de sample Out Of Range
|
---|
[1443] | 43 | bool deglitchdone; // Deglitch effectue
|
---|
[1442] | 44 |
|
---|
| 45 | int wsize; // Taille de fenetre de travail
|
---|
| 46 | double nsig; // Seuil en nb de sigmas
|
---|
| 47 | int maxpoints; // Nb maxi de points > ns sigmas
|
---|
[1454] | 48 | double range_min, range_max; // Range acceptable pour in
|
---|
[1442] | 49 | };
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | // Un filtre simple, dans le domaine temporel
|
---|
| 53 | // remplace val -> Somme(val(i)*coeff(i)) ds Fenetre
|
---|
| 54 |
|
---|
| 55 | class SimpleFilter : public TOIProcessor {
|
---|
| 56 | public:
|
---|
| 57 | enum FilterKind {
|
---|
| 58 | UserFilter=0, // User defined filter function
|
---|
| 59 | MeanFilter=1, // Replace sample by the window mean value (lowpass)
|
---|
| 60 | SumFilter=2, // Replace sample by the window sum (lowpass)
|
---|
| 61 | GaussFilter=3, // Apply a gaussian to the window samples
|
---|
| 62 | DiffFilter=4, // value -= MeanValue
|
---|
| 63 | };
|
---|
| 64 |
|
---|
[1454] | 65 | static string FilterKind2String(FilterKind fk);
|
---|
[1442] | 66 | SimpleFilter(int wsz=128,
|
---|
[1454] | 67 | FilterKind fk=SimpleFilter::MeanFilter,
|
---|
| 68 | double a=1., double s=1.);
|
---|
| 69 | SimpleFilter(Vector const & vc);
|
---|
[1442] | 70 | ~SimpleFilter();
|
---|
| 71 |
|
---|
| 72 | inline FilterKind Type() { return fkind; }
|
---|
| 73 |
|
---|
| 74 | inline int WSize() const { return wsize; }
|
---|
[1454] | 75 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 76 | Vector FilterCoefficients() const;
|
---|
[1442] | 77 |
|
---|
[1443] | 78 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 79 |
|
---|
[1442] | 80 | virtual void init();
|
---|
| 81 | virtual void run();
|
---|
| 82 |
|
---|
| 83 | protected:
|
---|
| 84 | FilterKind fkind;
|
---|
[1454] | 85 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
[1442] | 86 | int wsize; // Taille de fenetre de travail
|
---|
| 87 | double* coef; // Coefficients du filtre
|
---|
| 88 |
|
---|
| 89 | };
|
---|
| 90 |
|
---|
[1454] | 91 | // Classe SimpleAdder
|
---|
| 92 | // Calcule la sortie = Somme_Entree [ coeff[num] * entree[num] ]
|
---|
| 93 |
|
---|
| 94 | class SimpleAdder : public TOIProcessor {
|
---|
| 95 | public:
|
---|
| 96 | SimpleAdder(int nbinput);
|
---|
| 97 | ~SimpleAdder();
|
---|
| 98 |
|
---|
| 99 | void SetGain(int num, double g);
|
---|
| 100 | double Gain(int num);
|
---|
| 101 |
|
---|
| 102 | inline int NbInput() const { return nb_input; }
|
---|
| 103 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 104 |
|
---|
| 105 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 106 |
|
---|
| 107 | virtual void init();
|
---|
| 108 | virtual void run();
|
---|
| 109 |
|
---|
| 110 | protected:
|
---|
| 111 | int nb_input;
|
---|
| 112 | Vector gains;
|
---|
| 113 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 114 | };
|
---|
| 115 |
|
---|
| 116 |
|
---|
[1467] | 117 | // Classe SimpleFanOut
|
---|
| 118 | // Transforme recopie chaque entree sur M lignes de sortie
|
---|
| 119 |
|
---|
| 120 | class SimpleFanOut : public TOIProcessor {
|
---|
| 121 | public:
|
---|
| 122 | SimpleFanOut(int nbinput, int mfanout);
|
---|
| 123 | ~SimpleFanOut();
|
---|
| 124 |
|
---|
| 125 | inline int NbInput() const { return nb_input; }
|
---|
| 126 | inline int MFanOut() const { return m_fanout; }
|
---|
| 127 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
| 128 |
|
---|
| 129 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
| 130 |
|
---|
| 131 | virtual void init();
|
---|
| 132 | virtual void run();
|
---|
| 133 |
|
---|
| 134 | protected:
|
---|
| 135 | int nb_input;
|
---|
| 136 | int m_fanout;
|
---|
| 137 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
| 138 | };
|
---|
| 139 |
|
---|
[1442] | 140 | #endif
|
---|