Changeset 3592 in Sophya for trunk/AddOn/TAcq/brpaqu.h


Ignore:
Timestamp:
Apr 6, 2009, 11:57:39 PM (16 years ago)
Author:
ansari
Message:

Amelioration programme mfits2pec.cc - Reza 06/04/2009

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/brpaqu.h

    r3538 r3592  
    1212#include "brtypes.h"
    1313
     14
    1415using namespace std;
    1516
     17// On definit une classe TwoByteComplex() pour manipuler une paire de byte
     18// representant partie relle et imaginaire d'un nombre complexe
     19// Remarque Byte = unsigned char
     20// Remarque SByte = char = signed char
     21class TwoByteComplex {
     22 public:
     23  explicit TwoByteComplex() { val_[0] = val_[1] = 0; }
     24  //  explicit TwoByteComplex(TwoByteComplex const & a) { val_[0] = a.val_[0]; val_[1] = 0; }
     25  explicit TwoByteComplex(Byte re, Byte im) { val_[0] = re; val_[1] = im; }
     26  explicit TwoByteComplex(SByte re, SByte im) { val_[0] = re; val_[1] = im; }
     27  explicit TwoByteComplex(int re, int im) { val_[0] = re; val_[1] = im; }
     28  explicit TwoByteComplex(float re, float im) { val_[0] = re; val_[1] = im; }
     29  explicit TwoByteComplex(double re, double im) { val_[0] = re; val_[1] = im; }
     30 
     31  inline Byte& realB() { return  val_[0]; }
     32  inline Byte& imagB() { return  val_[1]; }
     33
     34  inline SByte realSB() { return  ((SByte*)val_)[0]; }
     35  inline SByte imagSB() { return  ((SByte*)val_)[1]; }
     36
     37  inline int realI() { return  ((SByte*)val_)[0]; }
     38  inline int imagI() { return  ((SByte*)val_)[1]; }
     39
     40  inline double realD() { return  ((SByte*)val_)[0]; }
     41  inline double imagD() { return  ((SByte*)val_)[1]; }
     42
     43  Byte val_[2];
     44};
     45
     46// Actuellement apres test Nancay un mot de 4octects est mis avant le header
     47#define OFFSET 0
    1648// Taille entete/trailer en octets
    1749#define BRHDRSIZE 24
    1850// Actuellement le trailer est vire ...
    19 /* #define BRTRLSIZE 16  */
    20 #define BRTRLSIZE 0
     51// Reza, 28 Jan 2009  le trailer fait 16 octets
     52#define BRTRLSIZE 16 
     53/* REZA passe a 16 octets  #define BRTRLSIZE 40 */
     54//Offset Mode Acq
     55#define BRMODACQOFF  20 /*RezaMOD #define BRMODACQOFF  24 */
     56// Offset ChanId
     57#define BRCHANIDOFF 20 /*RezaMOD #define BRCHANIDOFF 24 */
    2158// Offset du time-tag
    22 #define BRTMTAGOFF 8
     59#define BRTMTAGOFF 12 /*RezaMOD #define BRTMTAGOFF 16 */
     60// offset FrameCounter
     61#define BRFRCPTOFF 16 /*RezaMOD#define BRFRCPTOFF 20 */
     62// offset Paquet Id
     63#define BRPKTIDOFF 20  /*RezaMOD #define BRPKTIDOFF 24 */
     64// offset paquet lenght = FrameDataLength
     65#define BRPKTLENOFF 8 /*RezaMOD #define BRPKTLENOFF 12 */
     66// offset position chariot ???
     67//#define BRPCOFF 16
     68
     69enum ChannelID
     70  {
     71    None=0,
     72    Ch1,
     73    Ch2,
     74    Ch1_2,
     75    Ch3,
     76    Ch4,
     77    Ch3_4
     78  };
     79enum ModeAcq
     80  {
     81    RawData=1,
     82    FFT
     83  };
     84
     85// Definition des actions sur la conversion de format (swap...) des donnees arrivant
     86enum BRDataFmtConv {
     87  BR_DoNothing,
     88  BR_Copy,
     89  BR_SwapAll,
     90  BR_SwapHDR,
     91  BR_FFTOneChan,
     92  BR_FFTTwoChan,
     93  BR_Swap32,
     94  BR_FFTOneChan32,
     95  BR_FFTTwoChan32,
     96  BR_FFTOneChanNoSwap,
     97  BR_FFTTwoChanNoSwap
     98};
    2399
    24100// Structure correspondant a HEADER-DATA-TRAILER
    25101class BRPaquet {
    26102 public:
    27   BRPaquet(Byte* src, Byte* dst, int paqsz=4096);
     103  BRPaquet(Byte* src, Byte* dst, int paqsz=4096, BRDataFmtConv fgswap=BR_SwapAll);
     104  BRPaquet(Byte* srcdst, int paqsz=4096);
    28105  //  ~BRPaquet();
    29106
     
    31108  inline int PaquetSize() { return sz_; }
    32109  inline int DataSize() { return sz_-(BRHDRSIZE+BRTRLSIZE); }
    33 
    34110  inline int HeaderSize() { return BRHDRSIZE; }
    35111  inline int TrailerSize() { return BRTRLSIZE; }
    36112
    37113  // Acces differentes zone memoire
    38   inline Byte* Data() { return dst_+BRHDRSIZE; }
    39   inline Byte* Header() { return dst_; }
    40   inline Byte* Trailer() { return (dst_+sz_-BRTRLSIZE); }
     114  inline Byte* Data() { return dst_+BRHDRSIZE+OFFSET; }
     115  inline Byte* Data1() { return dst_+BRHDRSIZE+OFFSET; }
     116  inline Byte* Data2() { return dst_+BRHDRSIZE+(DataSize()/2)+OFFSET; }
     117  inline Byte* Header() { return dst_+OFFSET; }
     118  inline Byte* Trailer() { return (dst_+sz_-BRTRLSIZE+OFFSET); }
    41119 
    42120  // Valeurs differentes zones HDR/TRL
    43   inline UInt64 HDRMarker() {return *((UInt64*)dst_);}
    44   inline UInt64 TRLMarker() {return *((UInt64*)(dst_+sz_-BRTRLSIZE));}
    45   inline UInt64 TimeTag() {return *((UInt64*)(dst_+BRTMTAGOFF));}
     121  inline UInt32 HDRMarker() {return *((UInt32*)(dst_+OFFSET));}
     122  inline UInt32 TRLMarker() {return *((UInt32*)(dst_+(sz_-BRTRLSIZE+OFFSET)));}
     123  inline UInt16 ModeAcq()   {return *((UInt16*)(dst_+(BRMODACQOFF+OFFSET)));}
     124  inline UInt16 ChanId()    {return (( *((UInt16*)(dst_+(BRCHANIDOFF+OFFSET))) & 0x1800)>> 12) ;}
     125  inline UInt16 ChipId()    {return (( *((UInt16*)(dst_+(BRCHANIDOFF+OFFSET))) & 0xC00)>> 10) ;}
     126
     127  inline UInt32 TimeTag1()   {return *((UInt32*)(dst_+(BRTMTAGOFF+OFFSET)));}
     128  inline UInt32 FrameCounter()   {return ((*((UInt32*)(dst_+(BRFRCPTOFF+OFFSET))) &0xFFFF0000) >> 16);}
     129  inline UInt32 TimeTag2() {return (*((UInt32*)(dst_+(BRFRCPTOFF+OFFSET))) &0xFFFF);}
     130
     131  inline UInt32 PaqId()     {return *((UInt32*)(dst_+(BRPKTIDOFF+OFFSET)));}
     132  inline UInt16 PaqLen()    {return *((UInt16*)(dst_+(BRPKTLENOFF+OFFSET)));}
     133
     134
     135  // inline unsigned short PositionChariot() {return *((unsigned short*)(dst_+BRPCOFF+OFFSET));}
    46136
    47137  // pour faire un print de la structure
    48138  void Print(ostream & os, int nelt=8, bool prht=true);
     139  UInt16  ChannelID();
     140  UInt16  ModeAcquisition();
    49141
    50   // protected:
     142  // fonction appelee par le constructeur pour reordonner les donnees FFT
     143  static void ReorderFFTData(Byte* src, Byte* dst, int sz);
     144  static void ReorderFFTData32(Byte* src, Byte* dst, int sz);
     145  static void ReorderFFTDataNoSwap(Byte* src, Byte* dst, int sz);
     146  static const char* FmtConvToString(BRDataFmtConv fgswap);
     147// protected:
    51148  // donnees membres
    52149  int sz_; //taille du paquet
     
    54151};
    55152
     153// --------------------------------------------------------------------------
     154// Classe pour effectuer des verifications d'integrite sur les paquets/frames
     155// --------------------------------------------------------------------------
     156
     157class BRPaqChecker {
     158public:
     159  BRPaqChecker();
     160  ~BRPaqChecker();
     161  // Verifie le paquet, renvoie true si OK
     162  bool Check(BRPaquet& paq);
     163  // Imprime le compte de paquets ...
     164  ostream & Print(ostream& os);
     165
     166  unsigned long long totnframes;    // Nombre totale de frames/paquets traites
     167  unsigned long long  nframeok;     // Nombre totale de frames/paquets avec HDR/TRL OK
     168  unsigned long long lostframes;    // Nombre totale de frames/paquets perdus
     169  unsigned int frclst;         // derniere valeur du frame-counter
     170};
     171
    56172#endif
     173 
     174 
Note: See TracChangeset for help on using the changeset viewer.