Index: /trunk/AddOn/TAcq/baoradex.cc
===================================================================
--- /trunk/AddOn/TAcq/baoradex.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/baoradex.cc	(revision 3538)
@@ -0,0 +1,146 @@
+#include "sopnamsp.h"
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <math.h>
+
+#include <typeinfo>
+
+#include <vector>
+#include <string>
+
+#include "tvector.h"
+#include "piacmd.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+
+
+//  Module pour lire les fichiers generes par Monique pour Acq-BAORadio
+
+//  Declaration de la fonction d'activation et de desactivation du module
+extern "C" {
+void BAORadio_init();
+void BAORadio_end();
+}
+
+
+//  Une classe commande-executor, permettant d'enregistrer de 
+//  nouvelles commandes a piapp
+class BAORadioExecutor : public CmdExecutor {
+public:
+                BAORadioExecutor();
+  virtual       ~BAORadioExecutor();
+  // Execute s'occupe de l'execution effective des commandes
+  virtual int   Execute(string& keyw, vector<string>& args, string& toks);
+};
+
+/* --Methode-- */
+BAORadioExecutor::BAORadioExecutor()
+{
+
+PIACmd * mpiac;
+NamedObjMgr omg;
+mpiac = omg.GetImgApp()->CmdInterpreter();
+
+// On enregistre deux nouvelles commandes 
+string hgrp = "BAORadioCmd";
+// commande excmd1
+string kw = "brrdfile";
+string usage = "brrdfile: Lecture fichier AcqBAORadio \n" ;
+usage += "Usage: brrdfile size fileName [objName] \n";
+usage += " Defaut objName= data";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+
+}
+
+/* --Methode-- */
+BAORadioExecutor::~BAORadioExecutor()
+{
+
+}
+
+
+static inline void bswap4(void* p)
+{
+  uint_4 tmp = *(uint_4*)p;
+  *(uint_4*)p = ((tmp >> 24) & 0x000000FF) | 
+                ((tmp >> 8)  & 0x0000FF00) |
+                ((tmp & 0x0000FF00) << 8)  |
+                ((tmp & 0x000000FF) << 24);
+}
+
+
+
+/* --Methode-- */
+int BAORadioExecutor::Execute(string& kw, vector<string>& tokens, string&)
+{
+
+NamedObjMgr omg;
+if (kw == "brrdfile") {
+  if (tokens.size() < 2) {
+    cout << "Usage: brrdfile size fileName [objName]" << endl;
+    return(0);
+    }
+  sa_size_t sz = atoi(tokens[0].c_str()); 
+  string filename = tokens[1];
+  string objname = "data";
+  if (tokens.size() > 2) objname = tokens[2];
+
+  cout << " brrdfile : reading from file " << filename 
+       << " Size=" << sz << endl;
+  TVector<int_2> data(sz);
+  TVector<r_8> ddata(sz);
+  FILE *fip = NULL;
+  fip = fopen(filename.c_str(),"rb");
+  if (fip == NULL) {
+    cout << " brrdfile : ERROR opening file" << endl;
+    return 1;
+  }
+  uint_1* buff = new uint_1[sz/4+1];
+  fread(buff, 1, (size_t)(sz), fip);
+  uint_4* first = (uint_4*)(buff);
+  uint_4* second = (uint_4*)(buff+4);
+  cout << " brrdfile, first uint_4= " << hex << (*first) 
+       << " second= " << (*second) << dec << endl;
+  //  uint_1* buff = (uint_1 *)buff4;
+  //  for(sa_size_t ka=0; ka<sz/4; ka++) bswap4(buff4+ka);
+  for(sa_size_t ka=0; ka<sz; ka+=4) {
+    if (ka>=sz-3)  break;
+    for(sa_size_t kb=0; kb<4; kb++) 
+      data(ka+kb) = (int_2)buff[ka+3-kb];
+  }
+//  for(sa_size_t k=0; k<sz; k++) data(k) = (int_2)buff[k];
+  fclose(fip);
+  delete[] buff;
+  omg.AddObj(data, objname);
+  ddata = data;
+  objname += "_f";
+  omg.AddObj(ddata, objname);
+  }
+/*
+else if (kw == "excmd2") {
+  }
+*/
+return(0);
+
+}
+
+static BAORadioExecutor * baoradioex = NULL;
+/* Nouvelle-Fonction */
+void BAORadio_init()
+{
+// Fonction d'initialisation du module
+// Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
+if (baoradioex) delete baoradioex;
+baoradioex = new BAORadioExecutor;
+}
+
+/* Nouvelle-Fonction */
+void BAORadio_end()
+{
+// Desactivation du module
+if (baoradioex) delete baoradioex;
+baoradioex = NULL;
+}
+
Index: /trunk/AddOn/TAcq/baoradex.pic
===================================================================
--- /trunk/AddOn/TAcq/baoradex.pic	(revision 3538)
+++ /trunk/AddOn/TAcq/baoradex.pic	(revision 3538)
@@ -0,0 +1,10 @@
+#  Exemple de macro de commandes pour charger un module
+# Mode trace
+traceon
+loadmodule baoradex.so BAORadio
+
+
+alias brd brrdfile 
+
+brd 16384 ../Raid/Test2/Test20.dat
+disp data
Index: /trunk/AddOn/TAcq/brpaqu.cc
===================================================================
--- /trunk/AddOn/TAcq/brpaqu.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/brpaqu.cc	(revision 3538)
@@ -0,0 +1,65 @@
+#include "brpaqu.h"
+
+
+static inline void bswap4(void* p)
+{
+  UInt32 tmp = *(UInt32*)p;
+  *(UInt32*)p = ((tmp >> 24) & 0x000000FF) |
+                ((tmp >> 8)  & 0x0000FF00) |
+                ((tmp & 0x0000FF00) << 8)  |
+                ((tmp & 0x000000FF) << 24);
+}
+
+BRPaquet::BRPaquet(Byte* src, Byte* dst, int paqsz)
+{
+  dst_ = dst;
+  sz_ = paqsz;
+  if ((src==NULL)||(dst==NULL))  return;
+  // On copie l'entete sans swapper 
+  for(int k=0; k<BRHDRSIZE; k++)  dst_[k] = src[k];
+  // On copie la zone donnees en faisant un byte-swap correspondant a 4 octets 
+   for(int ka=BRHDRSIZE; ka<sz_-BRTRLSIZE; ka+=4) {
+    for(int kb=0; kb<4; kb++)
+      dst_[ka+kb] = src[ka+3-kb];
+  }
+  // On copie le trailer sans swapper 
+  for(int k=sz_-1; k>=sz_-BRTRLSIZE; k--)  dst_[k] = src[k];
+
+}
+
+
+void BRPaquet::Print(ostream & os, int nelt, bool prht)
+{
+  os << "BRPaquet::Print() PaqSz=" << PaquetSize() << " DataSize=" << DataSize() 
+     << " dst_pointer=(hex)" << hex << (unsigned long)dst_ << dec << endl;
+  if (TrailerSize() > 0) 
+    os << " ...HDRMarker(hex)=" << hex <<  HDRMarker() << " TRLMarker=" << TRLMarker() << dec << endl;
+  else 
+    os << " ...HDRMarker(hex)=" << hex <<  HDRMarker() << " NO TRLMarker=" << dec << endl;
+  UInt32 tt1, tt2; 
+//  tt2 = (TimeTag()&0xFFFFFFFF00000000) >> 32; 
+  tt2=0; 
+  tt1 = TimeTag()&0x00000000FFFFFFFF;
+  os << " ...TimeTag (hex)=" << hex << TimeTag() << " TT1= " << tt1 << " TT2=" << tt2 << dec << endl;
+  if (nelt > DataSize()/2) nelt = DataSize()/2;
+  os << " ...Data[1.." << nelt << "]= ";
+  for(int k=0; k<nelt; k++) os << (int)(*(Data()+k)) << " , ";
+  os << endl;
+  os << " ...Data[" << DataSize()-nelt << ".." << DataSize()-1 << "]= ";
+  for(int k=DataSize()-nelt; k<DataSize(); k++) os << (int)(*(Data()+k)) << " , ";
+  os << endl;
+  if (prht) {   // Impression header / trailer
+    UInt32* hdr = (UInt32*)Header();
+    os << " ...Header (hex):" << hex ;
+    for(int k=0; k<HeaderSize()/sizeof(UInt32); k++) 
+      os << hdr[k] << " , " ;
+    os << dec << endl;
+    if (TrailerSize() > 0) {
+      UInt32* trl = (UInt32*)Trailer();
+      os << " ...Trailer (hex):" << hex ;
+      for(int k=0; k<TrailerSize()/sizeof(UInt32); k++) 
+        os << trl[k] << " , " ;
+      os << dec << endl;
+    }
+  }
+}
Index: /trunk/AddOn/TAcq/brpaqu.h
===================================================================
--- /trunk/AddOn/TAcq/brpaqu.h	(revision 3538)
+++ /trunk/AddOn/TAcq/brpaqu.h	(revision 3538)
@@ -0,0 +1,56 @@
+#ifndef  BRPAQU_H_SEEN
+#define  BRPAQU_H_SEEN
+
+/* ----------------------------------------
+     Projet BAORadio --- LAL 
+     Juin 2008 , M.Taurigna , R. Ansari 
+-------------------------------------------  */
+
+#include <stdio.h>
+#include <iostream>
+#include <string>
+#include "brtypes.h"
+
+using namespace std;
+
+// Taille entete/trailer en octets 
+#define BRHDRSIZE 24
+// Actuellement le trailer est vire ...
+/* #define BRTRLSIZE 16  */
+#define BRTRLSIZE 0
+// Offset du time-tag
+#define BRTMTAGOFF 8
+
+// Structure correspondant a HEADER-DATA-TRAILER
+class BRPaquet {
+ public:
+  BRPaquet(Byte* src, Byte* dst, int paqsz=4096);
+  //  ~BRPaquet();
+
+  // Acces diverses tailles 
+  inline int PaquetSize() { return sz_; }
+  inline int DataSize() { return sz_-(BRHDRSIZE+BRTRLSIZE); }
+
+  inline int HeaderSize() { return BRHDRSIZE; }
+  inline int TrailerSize() { return BRTRLSIZE; }
+
+  // Acces differentes zone memoire
+  inline Byte* Data() { return dst_+BRHDRSIZE; }
+  inline Byte* Header() { return dst_; }
+  inline Byte* Trailer() { return (dst_+sz_-BRTRLSIZE); }
+  
+  // Valeurs differentes zones HDR/TRL
+  inline UInt64 HDRMarker() {return *((UInt64*)dst_);}
+  inline UInt64 TRLMarker() {return *((UInt64*)(dst_+sz_-BRTRLSIZE));}
+  inline UInt64 TimeTag() {return *((UInt64*)(dst_+BRTMTAGOFF));}
+
+  // pour faire un print de la structure
+  void Print(ostream & os, int nelt=8, bool prht=true);
+
+  // protected:
+  // donnees membres
+  int sz_; //taille du paquet 
+  Byte* dst_;  
+};
+
+#endif
Index: /trunk/AddOn/TAcq/brtypes.h
===================================================================
--- /trunk/AddOn/TAcq/brtypes.h	(revision 3538)
+++ /trunk/AddOn/TAcq/brtypes.h	(revision 3538)
@@ -0,0 +1,15 @@
+#ifndef  BRTYPES_H_SEEN
+#define  BRTYPES_H_SEEN
+
+typedef unsigned char Byte;
+typedef char SByte;
+typedef unsigned short int UInt16;
+typedef short int Int16;
+typedef int Int32;
+typedef unsigned int UInt32;
+typedef unsigned int UINT32;
+typedef long long int Int64;
+typedef unsigned long long int UInt64;
+typedef float Float32;
+
+#endif
Index: /trunk/AddOn/TAcq/dispspectre.pic
===================================================================
--- /trunk/AddOn/TAcq/dispspectre.pic	(revision 3538)
+++ /trunk/AddOn/TAcq/dispspectre.pic	(revision 3538)
@@ -0,0 +1,68 @@
+setaxesatt 'font=helvetica,bold,14 fixedfontsize minorticks'
+
+set CDIR './'
+
+defscript ds 
+  min = 1
+  max = 10
+  if ( $# > 1 ) then 
+    min = $1 
+    max = $2
+  endif
+  echo "IMin = $min IMax= $max"
+  for i ${min}:$max
+    del spectre
+    openppf $CDIR/spectre$i.ppf
+    rename spectre$i spectre
+    plot2d spectre 1200.+n*500./4072. val n>2 'notit'
+#    plot2d spectre n val n>2
+    settitle "Spectre $i" 'freq MHz' 'font=helvetica,bolditalic,16'
+    
+    sleep 1
+  end
+endscript
+
+defscript dsv 
+  min = 1
+  max = 10
+  if ( $# > 1 ) then 
+    min = $1 
+    max = $2
+  endif
+  echo $min $max
+  for i ${min}:$max
+    mv spectre /autoc/spectre
+    openppf $CDIR/spectre$i.ppf
+    rename spectre$i spectre
+    disp spectre 'notit'
+    settitle "Spectre $i" ' ' 'font=helvetica,bolditalic,16'
+    sleep 1
+  end
+endscript
+
+defscript dsh 
+  min = 1
+  max = 10
+  if ( $# > 1 ) then 
+    min = $1 
+    max = $2
+  endif
+  echo "IMin = $min IMax= $max"
+  newh1d hspec 1199.5 1449.5 2036
+  zone 1 2
+  for i ${min}:$max
+    del spectre
+    openppf $CDIR/spectre$i.ppf
+    rename spectre$i spectre
+    projh1d hspec spectre 1200.+n*500./4072. val n>0&&n<2037 'nodisp'
+#    disp hspec
+#    disp spectre
+#    settitle "Spectre $i" 'freq MHz' 'font=helvetica,bolditalic,16'    
+#    sleep 1
+  end
+zone 1
+disp hspec
+endscript
+
+
+
Index: /trunk/AddOn/TAcq/history.pic
===================================================================
--- /trunk/AddOn/TAcq/history.pic	(revision 3538)
+++ /trunk/AddOn/TAcq/history.pic	(revision 3538)
@@ -0,0 +1,17 @@
+openppf ExA/spectre0.ppf
+disp spectre0
+openppf ExA/spectre1.ppf
+disp spectre1
+openppf ExA/spectre2.ppf
+disp spectre2
+delobjs *
+readfits ExA/signal0.ppf
+readfits ExA/signal0.fits
+disp signal0
+objaoper 
+help objaoper 
+objaoper signal0 row 0 l0
+disp l0
+objaoper signal0 row 1 l1
+disp l1
+objaoper signal0 row 20 l20
Index: /trunk/AddOn/TAcq/makefile
===================================================================
--- /trunk/AddOn/TAcq/makefile	(revision 3538)
+++ /trunk/AddOn/TAcq/makefile	(revision 3538)
@@ -0,0 +1,80 @@
+include $(SOPHYABASE)/include/sophyamake.inc
+
+all : traidio  tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec 
+
+clean :
+	rm *.o traidio tmtfft tstminifits tpciew tbrpaq tmtacq tstrdfits mfits2spec *.ppf *.fits
+
+########################################################
+
+##   --------------
+tmtacq : tmtacq.o  racqumem.o racqurw.o racquproc.o brpaqu.o pciewrap.o minifits.o
+	$(CXXLINK) -o tmtacq tmtacq.o  racqumem.o racqurw.o racquproc.o brpaqu.o pciewrap.o minifits.o $(SOPHYAALLSLBLIST)
+
+tmtacq.o : tmtacq.cc racquproc.h racqurw.h racqumem.h
+	$(CXXCOMPILE) -c -o tmtacq.o tmtacq.cc 
+
+racqumem.o : racqumem.cc racqumem.h
+	$(CXXCOMPILE) -c -o racqumem.o racqumem.cc 
+
+racqurw.o : racqurw.cc racqurw.h racqumem.h
+	$(CXXCOMPILE) -c -o racqurw.o racqurw.cc 
+
+racquproc.o : racquproc.cc racquproc.h racqurw.h racqumem.h
+	$(CXXCOMPILE) -c -o racquproc.o racquproc.cc 
+
+##   --------------
+tbrpaq : tbrpaq.o brpaqu.o racqumem.o racqurw.o racquproc.o  
+	$(CXXLINK) -o tbrpaq tbrpaq.o brpaqu.o  $(SOPHYAALLSLBLIST)
+
+tbrpaq.o : tbrpaq.cc brpaqu.h
+	$(CXXCOMPILE) -c -o tbrpaq.o tbrpaq.cc 
+
+brpaqu.o : brpaqu.cc brpaqu.h
+	$(CXXCOMPILE) -c -o brpaqu.o brpaqu.cc 
+
+##   --------------
+tpciew : tpciew.o pciewrap.o
+	$(CXXLINK) -o tpciew  tpciew.o pciewrap.o $(SOPHYAEXTSLBLIST)
+
+tpciew.o : tpciew.cc pciewrap.h
+	$(CXXCOMPILE) -o tpciew.o tpciew.cc
+
+pciewrap.o : pciewrap.cc pciewrap.h
+	$(CXXCOMPILE) -o pciewrap.o pciewrap.cc
+
+##   --------------
+mfits2spec : mfits2spec.o minifits.o
+	$(CXXLINK) -o mfits2spec mfits2spec.o minifits.o  $(SOPHYAEXTSLBLIST)
+
+mfits2spec.o : mfits2spec.cc minifits.h
+	$(CXXCOMPILE) -o mfits2spec.o mfits2spec.cc
+
+tstrdfits : tstrdfits.o minifits.o
+	$(CXXLINK) -o tstrdfits tstrdfits.o minifits.o  $(SOPHYAEXTSLBLIST)
+
+tstrdfits.o : tstrdfits.cc minifits.h
+	$(CXXCOMPILE) -o tstrdfits.o tstrdfits.cc
+
+tstminifits : tstminifits.o minifits.o
+	$(CXXLINK) -o tstminifits tstminifits.o minifits.o  $(SOPHYAEXTSLBLIST)
+
+tstminifits.o : tstminifits.cc minifits.h
+	$(CXXCOMPILE) -o tstminifits.o tstminifits.cc
+
+minifits.o : minifits.cc minifits.h
+	$(CXXCOMPILE) -o minifits.o minifits.cc
+
+##   --------------
+traidio : traidio.o 
+	$(CXXLINK) -o traidio traidio.o $(SOPHYAEXTSLBLIST)
+
+traidio.o : traidio.cc
+	$(CXXCOMPILE) -o traidio.o traidio.cc
+
+tmtfft : tmtfft.o 
+	$(CXXLINK) -o tmtfft tmtfft.o $(SOPHYAEXTSLBLIST)
+
+tmtfft.o : tmtfft.cc
+	$(CXXCOMPILE) -o tmtfft.o tmtfft.cc
+
Index: /trunk/AddOn/TAcq/makemff
===================================================================
--- /trunk/AddOn/TAcq/makemff	(revision 3538)
+++ /trunk/AddOn/TAcq/makemff	(revision 3538)
@@ -0,0 +1,17 @@
+all : tstrdfits
+
+clean :
+	rm *.o  tstrdfits 
+
+########################################################
+
+##   --------------
+tstrdfits : tstrdfits.o minifits.o
+	g++ -o tstrdfits tstrdfits.o minifits.o  -lstdc++ -lm 
+
+tstrdfits.o : tstrdfits.cc minifits.h
+	g++ -c -o tstrdfits.o tstrdfits.cc
+
+minifits.o : minifits.cc minifits.h
+	g++ -c -o minifits.o minifits.cc
+
Index: /trunk/AddOn/TAcq/makepaq
===================================================================
--- /trunk/AddOn/TAcq/makepaq	(revision 3538)
+++ /trunk/AddOn/TAcq/makepaq	(revision 3538)
@@ -0,0 +1,17 @@
+# Definition flag compilation et librariries SOPHYA
+include $(SOPHYABASE)/include/sophyamake.inc
+
+all : tbrpaq
+
+clean : 
+	rm tbrpaq tbrpaq.o brpaqu.o
+
+tbrpaq : tbrpaq.o brpaqu.o
+	$(CXXLINK) -o tbrpaq tbrpaq.o brpaqu.o  $(SOPHYAALLSLBLIST)
+
+tbrpaq.o : tbrpaq.cc brpaqu.h
+	$(CXXCOMPILE) -c -o tbrpaq.o tbrpaq.cc 
+
+brpaqu.o : brpaqu.cc brpaqu.h
+	$(CXXCOMPILE) -c -o brpaqu.o brpaqu.cc 
+
Index: /trunk/AddOn/TAcq/makeradex
===================================================================
--- /trunk/AddOn/TAcq/makeradex	(revision 3538)
+++ /trunk/AddOn/TAcq/makeradex	(revision 3538)
@@ -0,0 +1,15 @@
+#   ---- Makefile for SOPHYA/DemoPIApp module ----
+#  User functions and loadable modules 
+include $(SOPHYABASE)/include/sophyamake.inc
+
+all : baoradex.so 
+
+clean : 
+	rm  baoradex.o baoradex.so
+
+
+baoradex.so: baoradex.o
+	$(CXXDLL) -o  baoradex.so  baoradex.o $(SOPHYAALLSLBLIST)
+baoradex.o : baoradex.cc
+	$(CXXCOMPILE) -c -o baoradex.o baoradex.cc
+
Index: /trunk/AddOn/TAcq/mfits2spec.cc
===================================================================
--- /trunk/AddOn/TAcq/mfits2spec.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/mfits2spec.cc	(revision 3538)
@@ -0,0 +1,110 @@
+// Utilisation de SOPHYA pour faciliter les tests ...
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+// include standard c/c++
+#include <math.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <string>
+
+#include "pexceptions.h"
+#include "tvector.h"
+#include "fioarr.h"
+#include "tarrinit.h" 
+#include "timestamp.h"
+#include "fftpserver.h"
+#include "fftwserver.h"
+
+#include "FFTW/fftw3.h"
+
+// include sophya mesure ressource CPU/memoire ...
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+
+// include mini-fits lib 
+#include "minifits.h"
+
+
+inline r_4 Zmod2(complex<r_4> z) 
+{ return (z.real()*z.real()+z.imag()*z.imag()); }
+
+int main(int narg, char* arg[])
+{
+  if (narg < 2) {
+    cout << " Usage: mfits2spec file1.fits [file2.fits ...] " << endl;
+    return 1;
+  }
+  cout << " ---------- mfits2spec.cc Start ------------- " << endl;
+
+  TArrayInitiator  _inia;
+
+  int rc = 0;
+  try {
+  	ResourceUsage resu;
+  	TVector<float> spectre;
+  	sa_size_t nzm = 0;   // Nb de spectres moyennes
+    for(int ifile=1; ifile<narg; ifile++) {
+      string ffname = arg[ifile];
+// -------------- Lecture de bytes      
+      cout << ifile <<"-Ouverture/lecture fichier " << ffname << endl;
+      MiniFITSFile mff(ffname, MF_Read);
+      cout << "... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1() 
+	   << " NAxis2=" << mff.NAxis2() << endl;
+      if (mff.DataType() != MF_Byte) {
+        cout << " PB : DataType!=MF_Byte --> skipping " << endl;
+      }
+      size_t sx = mff.NAxis1(); 
+      size_t sy = mff.NAxis2();
+
+      Byte* data = new Byte[sx];
+      TVector<r_4> vx(sx);
+      TVector< complex<r_4> > cfour;
+      FFTPackServer ffts;
+      
+      for(int j=0; j<sy; j++) {
+	    mff.ReadB(data, sx, j*sx);
+        // On convertit en float 
+        for(sa_size_t ix=0; ix<vx.Size(); ix++)  vx(ix) = (r_4)(data[ix]);
+        // On fait le FFT
+        ffts.FFTForward(vx, cfour);
+        if (!spectre.IsAllocated())  spectre.SetSize(cfour.Size());
+        
+        // On cumule les modules carres
+        for(sa_size_t jf=1; jf<spectre.Size(); jf++) 
+          spectre(jf) += Zmod2(cfour(jf)); 
+        nzm++;
+
+//	cout << " j=" << j << " data[0...3]=" << (int)data[0] << " , " 
+//	     << (int)data[1] << " , " <<  (int)data[2] << endl;
+      }
+      cout << "---- FIN lecture " << ffname << endl;      
+    }   
+    cout << "---- Ecriture spectre moyenne ds mspectre.ppf " << endl;      
+    spectre /= (r_4)(nzm);
+    POutPersist po("mspectre.ppf");
+    po << spectre;
+    cout << resu ; 
+  }
+  catch (MiniFITSException& exc) {
+    cerr << " mfits2spec.cc catched MiniFITSException " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n mfits2spec.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " mfits2spec.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> mfits2spec.cc ------- FIN ----------- RC=" << rc << endl;
+  return rc;
+
+}
Index: /trunk/AddOn/TAcq/minifits.cc
===================================================================
--- /trunk/AddOn/TAcq/minifits.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/minifits.cc	(revision 3538)
@@ -0,0 +1,184 @@
+#include "minifits.h"
+
+// #include <iostream>
+
+#define MFITSHLEN 2880
+
+MiniFITSFile::MiniFITSFile()
+{
+  Init();
+}
+
+MiniFITSFile::MiniFITSFile(string const & nom, MiniFITS_Mode rwm)
+{
+  Init();
+  Open(nom, rwm);
+}
+
+MiniFITSFile::MiniFITSFile(const char* nom, MiniFITS_Mode rwm)
+{
+  Init();
+  Open(nom, rwm);
+}
+
+
+MiniFITSFile::~MiniFITSFile()
+{
+  Close();
+  delete[] header;
+}
+
+void MiniFITSFile::Init()
+{
+  fip = NULL;
+  rwmode = MF_Read;
+  dtype = MF_Byte;
+  nax1 = 1;
+  nax2 = 1; 
+  totwsz = 0;
+  header = new char[MFITSHLEN];
+
+}
+
+void MiniFITSFile::Open(const char* nom, MiniFITS_Mode rwm)
+{
+  if (fip != NULL) throw MiniFITSException("MiniFITSFile::Open() - fip != NULL");
+  if (rwm == MF_Write) {
+    FillHeader();
+    fip = fopen(nom, "w");
+    if (fip == NULL) 
+      throw MiniFITSException("MiniFITSFile::Open()/ failed fopen() for write");
+    fwrite(header, 1, MFITSHLEN, fip);
+    rwmode = MF_Write;
+  }
+  else {
+    fip = fopen(nom, "r");
+    if (fip == NULL) 
+      throw MiniFITSException("MiniFITSFile::Open()/ failed fopen() for read");
+    fread(header, 1, MFITSHLEN, fip);
+    DecodeHeader();
+    rwmode = MF_Read;
+  }
+  return;
+}
+
+void MiniFITSFile::Close()
+{
+  if (fip) { 
+  	if (rwmode == MF_Write)  {  
+  	  // on remplit avec des zeros pour avoir une longueur multiple de 2880	
+  	  size_t padsz = MFITSHLEN-(totwsz%MFITSHLEN);
+  	  for(size_t k=0; k<padsz; k++) header[k]=0;
+  	  fwrite(header, 1, padsz, fip);
+  	  // On reecrit l'entete 
+  	  FillHeader();
+  	  fseek(fip, 0, SEEK_SET);
+  	  fwrite(header, 1, MFITSHLEN, fip);
+  	}	
+  	fclose(fip);
+  }
+  fip = NULL;
+  return;
+}
+
+void MiniFITSFile::setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2)
+{
+  // Interdit si fichier ouvert en lecture ...
+  if ((fip!=NULL)&&(rwmode == MF_Read))  
+     throw MiniFITSException("MiniFITSFile::setDTypeNaxis()/Error ReadOnly file");
+
+  dtype = dt;
+  nax1 = na1; 
+  nax2 = na2;
+}
+
+string MiniFITSFile::DataTypeToString()
+{
+  if (dtype == MF_Byte) return "MF_Byte";
+  else if (dtype == MF_Int16) return "MF_Int16";
+  else if (dtype == MF_Float32) return "MF_Float32";
+  else return "Unknown??";
+}
+
+int MiniFITSFile::Write(void* data, size_t sz)
+{
+  fwrite(data, 1, sz, fip);
+  totwsz += sz;
+  return 0;
+}
+
+int MiniFITSFile::Read(void* data, size_t sz, size_t offset)
+{
+  fseek(fip, offset+MFITSHLEN, SEEK_SET);
+  fread(data, 1, sz, fip);
+  return 0;
+}
+
+void MiniFITSFile::FillHeader()
+{
+  for(int i=0; i<MFITSHLEN; i++)  header[i]=' ';
+  strcpy(header, "SIMPLE  =                    T / file does conform to FITS standard");
+  header[strlen(header)] = ' ';
+  int bpix = 8;
+  if (dtype == MF_Byte) bpix = 8;
+  else if (dtype == MF_Int16) bpix = 16;
+  else if (dtype == MF_Float32) bpix = -32;
+  char * buff = header+80;
+  sprintf(buff, "BITPIX  = %20d /   number of bits per data pixel", bpix);
+  buff[strlen(buff)] = ' ';
+  buff = header+160;
+  strcpy(buff, "NAXIS   =                    2 / number of data axes");
+  buff[strlen(buff)] = ' ';
+  buff = header+240;
+  sprintf(buff, "NAXIS1  = %20ld /   number of bits per data pixel", (long)nax1);
+  buff[strlen(buff)] = ' ';
+  buff = header+320;
+  sprintf(buff, "NAXIS2  = %20ld /   number of bits per data pixel", (long)nax2);
+  buff[strlen(buff)] = ' ';
+  buff = header+400;
+  strcpy(buff,"COMMENT  BAO-Radio / MiniFITSFile ");
+  buff[strlen(buff)] = ' ';
+  buff = header+480;
+  strcpy(buff,"END");
+  buff[strlen(buff)] = ' ';
+
+  return;
+}
+
+
+void MiniFITSFile::DecodeHeader()
+{
+  // AMELIORER le decodage de l'entete, remplissage dtype, nax1, nax2
+  char * buff = header;
+  if (strncmp(buff, "SIMPLE  =", 9) != 0) 
+     throw MiniFITSException("MiniFITSFile::DecodeHeader()/Error - NO SIMPLE keyword");
+  bool fgokt=false;
+  bool fgok1=false;
+  bool fgok2=false;
+  for(int kh=80; kh<2800; kh+=80) {
+  	buff = header+kh;
+  	if (strncmp(buff, "NAXIS1  =", 9) == 0)  {
+  	  nax1 = atol(buff+10);
+  	  fgok1 = true;
+//  	  cout << " FOUND : NAXIS1= " << nax1 << endl;
+  	} 
+  	else if (strncmp(buff, "NAXIS2  =", 9) == 0)  {
+  	  nax2 = atol(buff+10);
+  	  fgok2 = true;
+//  	  cout << " FOUND : NAXIS2= " << nax2 << endl;  	  
+  	} 
+  	else if (strncmp(buff, "BITPIX  =", 9) == 0)  {
+  	  int bpix = atoi(buff+10);
+  	  fgokt = true;
+  	  if (bpix == 8)  dtype = MF_Byte;
+  	  else if (bpix == 16)  dtype = MF_Int16;
+  	  else if (bpix == -32)  dtype = MF_Float32;
+  	  else fgokt = false;
+//  	  cout << " FOUND : bpix= " << bpix << endl;  	  	  
+  	} 
+  }
+  if (!(fgok1&&fgok2&&fgokt))  
+     throw MiniFITSException("MiniFITSFile::DecodeHeader()/Error- Missing/wrong NAXIS1/2,BITPIX");
+  return;
+}
+
Index: /trunk/AddOn/TAcq/minifits.h
===================================================================
--- /trunk/AddOn/TAcq/minifits.h	(revision 3538)
+++ /trunk/AddOn/TAcq/minifits.h	(revision 3538)
@@ -0,0 +1,83 @@
+#ifndef  MINIFITS_H_SEEN
+#define  MINIFITS_H_SEEN
+
+#include <stdio.h>
+#include <string>
+
+#include "brtypes.h"
+
+/* 
+   Classe d'I/O simplifie FITS pour ACQ BAO-radio  
+   R. Ansari, C. Magneville -      Fev 2008
+*/
+
+using namespace std;
+
+class MiniFITSException {
+  public:
+  explicit MiniFITSException(const char * m) { msg = m; }
+  explicit MiniFITSException(const string& m) { msg = m; }
+  virtual string const& Msg() const  {return msg;}
+ private:
+  string msg;
+};
+
+
+enum MiniFITS_DT { MF_Byte, MF_Int16, MF_Float32 };
+enum MiniFITS_Mode { MF_Read, MF_Write };
+
+class MiniFITSFile {
+ public:
+  MiniFITSFile();
+  MiniFITSFile(string const & nom, MiniFITS_Mode rwm);
+  MiniFITSFile(const char* nom, MiniFITS_Mode rwm);
+
+  ~MiniFITSFile();
+
+  void Open(const char* nom, MiniFITS_Mode rwm);
+  inline void Open(string const & nom, MiniFITS_Mode rwm)
+    { return Open(nom.c_str(), rwm); }
+
+  void Close();
+
+  inline MiniFITS_DT DataType() { return dtype; }
+  string DataTypeToString();  
+
+  size_t NAxis1() { return nax1; }
+  size_t NAxis2() { return nax2; }
+
+  void setDTypeNaxis(MiniFITS_DT dt, size_t na1, size_t na2);
+
+  // Lecture avec indication de la taille (nb d'elements) et offset 
+  int Read(void* data, size_t sz, size_t offset=0);
+  inline int ReadB(Byte* data, size_t nel, size_t offsel=0)
+    { return ( Read((void *)data, nel, offsel) ); }
+  inline int ReadI(Int16* data, size_t nel, size_t offsel=0)
+    { return ( Read((void *)data, nel*sizeof(Int16), offsel*sizeof(Int16)) ); }
+  inline int ReadF(Float32* data, size_t nel, size_t offsel=0)
+    { return ( Read((void *)data, nel*sizeof(Float32), offsel*sizeof(Float32)) ); }
+
+  // Ecriture en mode append (fin de fichier) 
+  int Write(void* data, size_t sz);
+  inline int WriteB(Byte* data, size_t nel) 
+    { return ( Write((void *)data, nel) ); }
+  inline int WriteI(Int16* data, size_t nel) 
+    { return ( Write((void *)data, nel*sizeof(Int16)) ); }
+  inline int WriteF(Float32* data, size_t nel) 
+    { return ( Write((void *)data, nel*sizeof(Float32)) ); }
+
+  //  string getKey(string& key);
+ protected:
+  void FillHeader();
+  void DecodeHeader();
+  void Init();
+  
+  FILE* fip;
+  MiniFITS_Mode rwmode;
+  MiniFITS_DT dtype;
+  size_t nax1, nax2;
+  size_t totwsz;  // total bytes ecrits
+  char* header; //  entete FITS
+};
+
+#endif
Index: /trunk/AddOn/TAcq/pciewrap.cc
===================================================================
--- /trunk/AddOn/TAcq/pciewrap.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/pciewrap.cc	(revision 3538)
@@ -0,0 +1,50 @@
+#include "pciewrap.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include <iostream>
+
+PCIEWrapper::PCIEWrapper()
+{
+// Faire l'initialisation PCI-Express ici
+}
+
+PCIEWrapper::~PCIEWrapper()
+{
+// Faire le nettoyage (liberer memoire ...)
+}
+
+
+// Variables pour tests 
+static uint_4 NBytes = 0;
+static uint_4 Choix = 0;
+
+uint_4  PCIEWrapper::NBytesToRead()
+{
+// Lire le registre indiquant le nombre de mots prets a etre lus
+// cad transfere en memoire du PC
+int choix = rand()%5;
+if (choix < 2) {
+  Choix = choix;
+  if (choix == 0)  NBytes = 4096;
+  else NBytes = 5000;
+}
+else {
+  NBytes = 0;
+  Choix = 0;
+}
+return NBytes;  
+}
+
+uint_4  PCIEWrapper::Read(uint_1* buff, uint_4 nbytes)
+{
+  if (NBytes == 0)  throw PCIEWException("PCIEWrapper::Read()/Error NBytes==0");
+  if (nbytes > NBytes)  nbytes = NBytes;
+  double dx = (rand()%8+1)*0.05;
+  for(int k=0; k<nbytes; k++)  buff[k] = (uint_1)((1.+sin(dx*k))*100.);
+  if ((Choix == 1) && (nbytes>2000)) 
+    for(int k=1600; k<1900; k++) buff[k] = (uint_1)(128);
+  return nbytes;
+}
Index: /trunk/AddOn/TAcq/pciewrap.h
===================================================================
--- /trunk/AddOn/TAcq/pciewrap.h	(revision 3538)
+++ /trunk/AddOn/TAcq/pciewrap.h	(revision 3538)
@@ -0,0 +1,41 @@
+#ifndef  PCIEWRAP_H_SEEN
+#define  PCIEWRAP_H_SEEN
+
+#include "machdefs.h"
+#include <string>
+
+/* 
+   Classe interface aux fonctions d'I/O PCIExpress 
+   pour la carte de reception optique BAORadio
+   R. Ansari                        Juin 2008
+*/
+
+using namespace std;
+
+class PCIEWException {
+  public:
+  explicit PCIEWException(const char * m) { msg = m; }
+  explicit PCIEWException(const string& m) { msg = m; }
+  virtual string const& Msg() const  {return msg;}
+  virtual const char* what() {return msg.c_str(); }
+ private:
+  string msg;
+};
+
+
+class PCIEWrapper {
+public:
+// Constructeur - fait l'initialisation
+          PCIEWrapper(); 
+// destructeur - libere la memoire allouee
+  virtual ~PCIEWrapper();
+
+// Retourne le nombre d'octets a lire 
+  uint_4  NBytesToRead();
+
+// Lecture du buffer de la carte 
+  uint_4  Read(uint_1* buff, uint_4 nbytes);
+};
+
+
+#endif
Index: /trunk/AddOn/TAcq/racqumem.cc
===================================================================
--- /trunk/AddOn/TAcq/racqumem.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/racqumem.cc	(revision 3538)
@@ -0,0 +1,127 @@
+#include "racqumem.h"
+
+//----------------------------------------------------------------
+// ---- classes de gestion memoire pour acquisition BAORadio -----
+// LAL -      R. Ansari - Juin/Juillet 2008 
+//----------------------------------------------------------------
+
+
+RAcqMemZoneMgr::RAcqMemZoneMgr(uint_4 nz, uint_4 np, uint_4 psz)
+  :  mex(true), nzones(nz), npaq(np), paqsz(psz), stop_(false)
+{
+  St_MemZ st;
+  st.act = (uint_4)MemZA_None;
+  st.stat = (uint_8)MemZS_Free;
+  for(int k=0; k<3; k++) st.nbact[k] = 0;
+  uint_8 mzsz = npaq*paqsz;
+
+  for(int k=0; k<NbZones(); k++) {
+  	memzones.push_back(new Byte[mzsz] );
+  	states.push_back(st);
+  }	
+}
+
+RAcqMemZoneMgr::~RAcqMemZoneMgr()
+{
+  for(uint_4 k=0; k<NbZones(); k++) delete[] memzones[k]; 
+}
+
+int RAcqMemZoneMgr::FindMemZoneId(MemZaction act)
+{
+  int rid = -1;
+  if (stop_) return rid;
+  if ((act != MemZA_Fill) && (act != MemZA_Save) && (act != MemZA_Proc)) return rid;
+  mex.lock();
+  while ((rid < 0)&&(!stop_)) {
+    switch (act) {
+  	  case MemZA_Fill:
+  	    for(int k=0; k<NbZones(); k++) {
+  	      if ((states[k].act == MemZA_None) && 
+  	          ((states[k].stat == MemZS_Free)||(states[k].stat & MemZS_Saved)) ) 
+  	            rid = k; break; 
+  	    }
+  	    if (rid >= 0) { states[rid].act = MemZA_Fill; states[rid].stat = MemZS_Free; }
+  	  break;
+  	  case MemZA_Save:
+  	    for(int k=0; k<NbZones(); k++) {
+  	      if ((states[k].act == MemZA_None) && (states[k].stat & MemZS_Filled) && 
+  	          !(states[k].stat & MemZS_Saved) )  rid = k; break; 
+  	    }
+  	    if (rid >= 0) states[rid].act = MemZA_Save; 
+  	  break;
+  	  case MemZA_Proc:
+  	    for(int k=0; k<NbZones(); k++) {
+  	      if ((states[k].act == MemZA_None) && (states[k].stat & MemZS_Filled) && 
+  	          !(states[k].stat & MemZS_Proc) )  rid = k; break; 
+  	    }
+  	    if (rid >= 0) states[rid].act = MemZA_Proc;   	      	  
+  	  break;
+    }
+    if (rid < 0) mex.wait();
+  }
+  mex.unlock();
+  return rid;
+}
+
+int RAcqMemZoneMgr::FreeMemZone(int id, MemZStatus st)
+{
+  if ((id < 0) || (id >= states.size()))  return 1;
+  int rc = 0;
+  mex.lock();
+  switch (st) {
+  	case MemZS_Free :
+  	  states[id].stat = MemZS_Free; 
+  	  states[id].act = MemZA_None;
+  	break;
+  	case MemZS_Filled :
+  	  if (states[id].act != MemZA_Fill)  rc = 2;
+  	  else states[id].nbact[0]++;
+  	  states[id].stat |= MemZS_Filled; 
+  	  states[id].act = MemZA_None;
+  	break;
+  	case MemZS_Saved :
+  	  if (states[id].act != MemZA_Save)  rc = 4;
+  	  else states[id].nbact[1]++;  	  
+  	  states[id].stat |= MemZS_Saved; 
+  	  states[id].act = MemZA_None;
+  	break;
+  	case MemZS_Proc :
+  	  if (states[id].act != MemZA_Proc)  rc = 8;
+  	  else states[id].nbact[2]++;  	  
+  	  states[id].stat |= MemZS_Proc; 
+  	  states[id].act = MemZA_None;
+  	break;
+  	default :
+  	  rc = 16;
+  	  states[id].stat = MemZS_Free; 
+  	  states[id].act = MemZA_None;
+  	break;
+  }
+  mex.unlock();
+  mex.broadcast();
+  return rc;
+}
+
+/*  MIS en inline 
+Byte* RAcqMemZoneMgr::GetMemZone(int id)
+{
+  if ((id < 0) || (id >= memzones.size()))  return NULL;
+  return memzones[id];
+}
+*/
+ostream& RAcqMemZoneMgr::Print(ostream& os)
+{
+  os << "RAcqMemZoneMgr::Print() NbZones=" << NbZones() << " PaqSize()=" << PaqSize()
+     << " NbPaquets()=" << NbPaquets() << " ZoneSize()=" << ZoneSize() << endl;
+  for(int k=0; k<states.size(); k++) 
+    os << " [" << k << "] Act=" << states[k].act << " Stat=" << states[k].stat 
+       << " NbAct[0..2]=" << states[k].nbact[0] << "," << states[k].nbact[1]
+       << "," << states[k].nbact[2] << endl; 	
+  return os;   
+}
+
+void RAcqMemZoneMgr::Stop()
+{
+  stop_ = true;
+  mex.broadcast();
+}
Index: /trunk/AddOn/TAcq/racqumem.h
===================================================================
--- /trunk/AddOn/TAcq/racqumem.h	(revision 3538)
+++ /trunk/AddOn/TAcq/racqumem.h	(revision 3538)
@@ -0,0 +1,76 @@
+#ifndef  RACQUMEM_H_SEEN
+#define  RACQUMEM_H_SEEN
+
+//----------------------------------------------------------------
+// ---- classes de gestion memoire pour acquisition BAORadio -----
+// LAL -      R. Ansari - Juin/Juillet 2008 
+//----------------------------------------------------------------
+
+
+#include "machdefs.h"
+#include <string>
+#include <vector>
+#include <iostream>
+#include "sopnamsp.h"
+#include "zthread.h"
+
+#include "brtypes.h"
+
+using namespace std;
+
+// Structure de gestion utilisee par la classe RAcqMemMgr
+typedef struct {
+  uint_4 act;
+  uint_4 stat;
+  uint_4 nbact[3]; 
+//  int tid;
+} St_MemZ;
+
+enum MemZStatus { MemZS_Free=0, MemZS_Filled=1, MemZS_Saved=2, MemZS_Proc=4 };
+enum MemZaction { MemZA_None=0, MemZA_Fill=1, MemZA_Save=2, MemZA_Proc=4};
+
+// -------------------------------------------------------------------
+// Structure de gestion de zones memoire partagee (des vecteurs) entre
+// threads - qui doivent operer successivement sur les vecteurs
+// -------------------------------------------------------------------
+class RAcqMemZoneMgr {
+public:
+// Constructeur, nz=Nb de zones, np=Nb de paquets/zone , psz=taille de paquet
+  RAcqMemZoneMgr(uint_4 nz, uint_4 np=1000, uint_4 psz=4096);
+  ~RAcqMemZoneMgr();
+  
+  // Retourne le nombre de zones memoire
+  inline uint_4 NbZones() { return nzones; }
+  // Retourne la taille de paquet
+  inline uint_4 PaqSize() { return paqsz; }
+  // Retourne le nb de paquets dans une zone
+  inline uint_4 NbPaquets() { return npaq; }
+  // Retourne la taille totale d'une zone 
+  inline uint_4 ZoneSize() { return npaq*paqsz; }
+  
+  // Retourne un MemZone disponible pour une action specifique
+  int FindMemZoneId(MemZaction act);
+  // Libere une zone memoire en marquant son etat
+  int FreeMemZone(int id, MemZStatus st);
+  // Retourne le pointeur de la zone numero k
+  inline Byte* GetMemZone(int id)  {
+    if ((id < 0) || (id >= memzones.size()))  return NULL;
+    return memzones[id];  
+    }
+  
+  ostream& Print(ostream& os);
+  void Stop(); 
+        
+protected:
+  // ... variables membres
+  ZMutex mex;   
+  uint_4 nzones, npaq, paqsz;
+  vector< Byte* > memzones;
+  vector< St_MemZ > states; 
+  bool stop_;
+};
+
+
+
+
+#endif
Index: /trunk/AddOn/TAcq/racquproc.cc
===================================================================
--- /trunk/AddOn/TAcq/racquproc.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/racquproc.cc	(revision 3538)
@@ -0,0 +1,115 @@
+#include "racquproc.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <fstream>
+
+#include "pexceptions.h"
+#include "tvector.h"
+#include "fioarr.h"
+#include "timestamp.h"
+#include "fftpserver.h"
+#include "fftwserver.h"
+
+#include "FFTW/fftw3.h"
+
+
+#include "pciewrap.h"
+#include "brpaqu.h"
+#include "minifits.h"
+
+
+//-------------------------------------------------------
+// Classe thread de traitement 
+//-------------------------------------------------------
+
+DataProc::DataProc(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 nmax)
+  :  memgr(mem) 
+{
+  nmax_ = nmax;	
+  nmean_ = nmean;
+  stop_ = false;	
+  path_ = path;	
+}
+
+inline r_4 Zmod2(complex<r_4> z) 
+{ return (z.real()*z.real()+z.imag()*z.imag()); }
+
+void DataProc::run()
+{
+  	
+  setRC(1);	
+  try {
+    TimeStamp ts; 
+    cout << " DataProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_ << endl;	
+    char fname[512];
+    sprintf(fname,"%s/proc.log",path_.c_str());
+    ofstream filog(fname);
+    filog << " DataProc::run() - starting log file " << ts << endl;		       
+
+// Initialisation pour clcul FFT 
+    TVector< complex<r_4> > cfour;  // composant TF
+    uint_4 paqsz = memgr.PaqSize();
+    BRPaquet pq(NULL, NULL, paqsz); 
+    TVector<r_4> vx(pq.DataSize());
+    vx = (r_4)(0.);
+    FFTPackServer ffts;
+    ffts.FFTForward(vx, cfour);
+    TVector<r_4> spectre;
+    spectre.ReSize(cfour.Size());
+    
+    fftwf_plan plan = fftwf_plan_dft_r2c_1d(pq.DataSize(), vx.Data(), 
+	  			       (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); 
+
+    uint_4 ifile = 0;  			        
+    for (uint_4 kmz=0; kmz<nmax_; kmz++) {
+      int mid = memgr.FindMemZoneId(MemZA_Proc);
+      Byte* buff = memgr.GetMemZone(mid);
+      if (buff == NULL) {
+  	cout << " DataProc::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
+  	setRC(2);	
+  	return;	
+      }
+      BRPaquet paq0(NULL, buff, paqsz); 
+      uint_4 nzm = 0;
+      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
+  	BRPaquet paq(NULL, buff+i*paqsz, paqsz); 
+  	Byte min = 255;
+  	Byte max = 0;
+  	    
+  	for(sa_size_t j=0; j<vx.Size(); j++) 
+  	  vx(j) = (r_4)(*(paq.Data()+j));
+  	fftwf_execute(plan); 
+        //    ffts_.FFTForward(vx, cfour_);
+        for(sa_size_t j=0; j<spectre.Size(); j++) 
+          spectre(j) += Zmod2(cfour(j)); 
+        nzm++;
+      }
+      if (nzm >= nmean_) {
+        spectre /= (r_4)(nzm);
+    	sprintf(fname,"%s/spectre%d.ppf",path_.c_str(),(int)ifile);
+        POutPersist po(fname);
+        po << spectre; 
+        spectre = (r_4)(0.);
+        nzm = 0;  ifile++; 
+        ts.SetNow();
+        filog << ts << " :  proc file  " << fname << endl;		       
+        cout << " DataProc::run() " << ts << " : created file  " << fname << endl;
+      }
+      
+      memgr.FreeMemZone(mid, MemZS_Proc);
+    }
+  }
+  catch (PException& exc) {
+    cout << " DataProc::run()/catched PException " << exc.Msg() << endl;
+    setRC(3);	
+    return; 
+  }
+  catch(...) {
+    cout << " DataProc::run()/catched unknown ... exception " << endl;
+    setRC(4);	
+    return; 
+  }
+  setRC(0);
+  return;
+}   
Index: /trunk/AddOn/TAcq/racquproc.h
===================================================================
--- /trunk/AddOn/TAcq/racquproc.h	(revision 3538)
+++ /trunk/AddOn/TAcq/racquproc.h	(revision 3538)
@@ -0,0 +1,39 @@
+#ifndef  RACQUPROC_H_SEEN
+#define  RACQUPROC_H_SEEN
+
+//----------------------------------------------------------------
+// ---- classe de thread de traitememt  acquisition BAORadio -----
+// LAL -      R. Ansari - Juin/Juillet 2008 
+//----------------------------------------------------------------
+
+
+#include "racqumem.h"
+#include <string>
+#include <vector>
+#include <iostream>
+#include "sopnamsp.h"
+#include "zthread.h"
+
+#include "brtypes.h"
+
+using namespace std;
+
+
+//-------------------------------------------------------
+// Classe thread de traitement 
+//-------------------------------------------------------
+class DataProc : public ZThread {
+public:	
+  DataProc(RAcqMemZoneMgr& mem, string& path, uint_4 nmean=1, uint_4 nmax=100);
+  virtual void run(); 
+  inline void STOP() { stop_ = true; }	
+protected:
+  RAcqMemZoneMgr& memgr;
+  bool stop_;  
+  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
+  uint_4 nmean_;  // Nombre de blocs pour le calcul des moyennes 
+  string path_;  
+};
+
+
+#endif
Index: /trunk/AddOn/TAcq/racqurw.cc
===================================================================
--- /trunk/AddOn/TAcq/racqurw.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/racqurw.cc	(revision 3538)
@@ -0,0 +1,118 @@
+//----------------------------------------------------------------
+// ---- classes de threads pour lecture (transfert DMA) 
+//      et ecriture disque pour acquisition   BAORadio       -----
+// LAL -      R. Ansari - Juin/Juillet 2008 
+//----------------------------------------------------------------
+
+#include "racqurw.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <fstream>
+
+#include "pexceptions.h"
+#include "timestamp.h"
+
+
+#include "pciewrap.h"
+#include "brpaqu.h"
+#include "minifits.h"
+
+
+//-------------------------------------------------------
+// Classe thread de lecture PCI-Express
+//-------------------------------------------------------
+
+PCIEReader::PCIEReader(RAcqMemZoneMgr& mem, uint_4 nmax)
+  :  memgr(mem)
+{
+  nmax_ = nmax;		
+  stop_ = false;	
+}
+
+void PCIEReader::run()
+{
+  cout << " PCIEReader::run() - Starting , NMaxMemZones=" << nmax_ << endl;	
+  setRC(1);	
+  PCIEWrapper pciw;	
+  uint_4 paqsz = memgr.PaqSize();
+  for (uint_4 kmz=0; kmz<nmax_; kmz++) {
+    int mid = memgr.FindMemZoneId(MemZA_Fill);
+    Byte* buff = memgr.GetMemZone(mid);
+    if (buff == NULL) {
+      cout << " PCIEReader::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
+      setRC(2);	  	  
+      return;	
+    }
+    for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
+      while(pciw.NBytesToRead() < 1)  usleep(5);
+      pciw.Read(buff+i*paqsz,paqsz); 	
+    }
+    memgr.FreeMemZone(mid, MemZS_Filled);
+  }	
+  setRC(0);
+  return;
+}
+
+
+
+//-------------------------------------------------------
+// Classe thread de sauvegarde sur fichiers
+//-------------------------------------------------------
+
+DataSaver::DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nmax)
+  :  memgr(mem) 
+{
+  nmax_ = nmax;	
+  stop_ = false;	
+  path_ = path;	
+}
+
+void DataSaver::run()
+{
+  setRC(1);	
+  try {
+    TimeStamp ts; 
+    cout << " DataSaver::run() - Starting " << ts << " NMaxMemZones=" << nmax_ << endl;	
+    char fname[512];
+    sprintf(fname,"%s/saver.log",path_.c_str());
+    ofstream filog(fname);
+    filog << " DataProc::run() - starting log file " << ts << endl;		       
+
+    uint_4 paqsz = memgr.PaqSize();
+    for (uint_4 kmz=0; kmz<nmax_; kmz++) {
+      int mid = memgr.FindMemZoneId(MemZA_Save);
+      Byte* buff = memgr.GetMemZone(mid);
+      if (buff == NULL) {
+  	cout << " DataSaver::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
+  	setRC(2);	
+  	return;	
+      }
+      sprintf(fname,"%s/signal%d.fits",path_.c_str(),(int)kmz);
+      MiniFITSFile mff(fname,MF_Write);
+      BRPaquet paq0(NULL, buff, paqsz); 
+      mff.setDTypeNaxis(MF_Byte, paq0.DataSize(), memgr.NbPaquets());
+      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
+  	BRPaquet paq(NULL, buff+i*paqsz, paqsz); 
+  	mff.WriteB(paq.Data(), paq.DataSize());
+      }
+      filog << ts << " : created data file  " << fname << endl;		       
+      cout << " DataSaver::run() " << ts << " : created data file  " << fname << endl;
+      memgr.FreeMemZone(mid, MemZS_Saved);
+    }
+  }
+  catch (MiniFITSException& exc) {
+    cout << " DataSaver::run()/catched MiniFITSException " << exc.Msg() << endl;
+    setRC(3);	
+    return; 
+  }
+  catch(...) {
+    cout << " DataSaver::run()/catched unknown ... exception " << endl;
+    setRC(4);	
+    return; 
+  }
+  setRC(0);
+  return;
+}   
+
+
Index: /trunk/AddOn/TAcq/racqurw.h
===================================================================
--- /trunk/AddOn/TAcq/racqurw.h	(revision 3538)
+++ /trunk/AddOn/TAcq/racqurw.h	(revision 3538)
@@ -0,0 +1,55 @@
+#ifndef  RACQURW_H_SEEN
+#define  RACQURW_H_SEEN
+
+//----------------------------------------------------------------
+// ---- classes de threads pour lecture (transfert DMA) 
+//      et ecriture disque pour acquisition   BAORadio       -----
+// LAL -      R. Ansari - Juin/Juillet 2008 
+//----------------------------------------------------------------
+
+#include "racqumem.h"
+#include <string>
+#include <vector>
+#include <iostream>
+#include "sopnamsp.h"
+#include "zthread.h"
+
+#include "brtypes.h"
+
+using namespace std;
+
+
+
+//-------------------------------------------------------
+// Classe thread de lecture PCI-Express
+//-------------------------------------------------------
+
+class PCIEReader : public ZThread {
+public:
+  PCIEReader(RAcqMemZoneMgr& mem, uint_4 nmax=100);	
+  virtual void run(); 
+  inline void STOP() { stop_ = true; }	
+protected:
+  RAcqMemZoneMgr& memgr;
+  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
+  bool stop_;  
+};
+
+//-------------------------------------------------------
+// Classe thread de sauvegarde sur fichiers
+//-------------------------------------------------------
+
+class DataSaver : public ZThread {
+public:	
+  DataSaver(RAcqMemZoneMgr& mem, string& path, uint_4 nmax=100);
+  virtual void run(); 
+  inline void STOP() { stop_ = true; }	
+protected:
+  RAcqMemZoneMgr& memgr;
+  uint_4 nmax_;  // Nombre maxi de blocs MemZone traites
+  bool stop_;  
+  string path_;  
+};
+
+
+#endif
Index: /trunk/AddOn/TAcq/tbrpaq.cc
===================================================================
--- /trunk/AddOn/TAcq/tbrpaq.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tbrpaq.cc	(revision 3538)
@@ -0,0 +1,92 @@
+// Utilisation de SOPHYA pour faciliter les tests ...
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+// include standard c/c++
+#include <math.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <string>
+
+#include "pexceptions.h"  // les exceptions SOPHYA
+
+// Include sophya des tableaux
+#include "tvector.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
+#include "fioarr.h"  // Pour IO PPF TArray
+#include "sopemtx.h"
+#include "matharr.h"
+#include "tarrinit.h" // Pour l'utilisation des classes TArray, TMatrix , TVecto
+// include sophya mesure ressource CPU/memoire ...
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+// ---- ENTETE classe BRPaquet 
+#include "brpaqu.h"
+
+int main(int narg, char* arg[])
+{
+	/*
+  cout << " sizeof(UInt32)= " << sizeof(UInt32) << endl;
+    cout << " sizeof(UInt64)= " << sizeof(UInt64) << endl;
+ UInt64 i1,i2,i3; 
+ i1 = 0xFF000000; 
+ i2 = i1*256; 
+ i3 = 20000000000L;
+ cout << " i1= " << i1 << " i2 = " << i2 << " 0x" << hex << i2 
+      << dec << " i3=" << i3 << " 0x"<< hex << i3 << dec << endl;
+      */
+      
+  if (narg < 3) {
+    cout << "tbrpaq.cc/Erreur arg: tbrpaq paqsz filename [neltsprint=8] [OutPPFFileName]" << endl;
+    return 1;
+  }
+
+  // Sophya modules initialization
+  TArrayInitiator  _inia;
+  //------- AU LIEU DE ------>  SophyaInit();
+
+  InitTim();   // Initializing the CPU timer
+
+  int paqsz = atoi(arg[1]);
+  string filename = arg[2];
+  int nelt = 8;
+  if (narg>3) nelt = atoi(arg[3]);
+
+  cout << " tbrpaq : reading from file " << filename
+       << " PaqSize=" << paqsz << endl;
+  FILE* fip = NULL;
+  fip = fopen(filename.c_str(),"rb");
+  if (fip == NULL) {
+    cout << " tbrpaq : ERROR opening file" << endl;
+    return 2;
+  }
+  Byte * src = new Byte[paqsz];
+  Byte * dst = new Byte[paqsz];
+
+  fread(src, 1, (size_t)(paqsz), fip);
+  fclose(fip);
+
+  cout << " tbrpaq : Creating BRPaquet(src,dst,paqsz) ... " << endl;
+
+  BRPaquet paq(src, dst, paqsz);
+  cout << " tbrpaq : Appel paq.Print(cout) ... " << endl;
+  paq.Print(cout, nelt, true);
+
+  if (narg>4) {
+    string outppf = arg[4];
+    cout << " tbrpaq: Creating OutPPF file from data to file" << outppf << endl;
+    TVector<int_2> vd(paq.DataSize());
+    for(int k=0; k<paq.DataSize(); k++)  vd(k) = (int_2)(*(paq.Data()+k));
+    POutPersist po(outppf);
+    po << vd; 
+  }
+  // Cleanup
+  delete[] src;
+  delete[] dst;
+
+  PrtTim("FIN tbrpaq.cc");
+  cout << " ---------- FIN tbrpaq -----------" << endl;
+  return 0;
+}
Index: /trunk/AddOn/TAcq/tmtacq.cc
===================================================================
--- /trunk/AddOn/TAcq/tmtacq.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tmtacq.cc	(revision 3538)
@@ -0,0 +1,82 @@
+#include <iostream>
+
+#include "racqumem.h"
+#include "racqurw.h"
+#include "racquproc.h"
+
+#include "pciewrap.h"
+#include "brpaqu.h"
+#include "minifits.h"
+
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+#include "tarrinit.h"
+#include "fiosinit.h"
+
+using namespace std;
+using namespace SOPHYA;
+
+//--------------------------------------------------------
+// Programme test acquisition BAORadio multi-thread
+//  LAL -   R. Ansari Juillet -  2008
+//--------------------------------------------------------
+
+int main(int narg, char* arg[])
+{
+ 
+  int rc = 0;
+  InitTim();
+ 
+  // Initialisation 
+  TArrayInitiator _arri;
+  FitsIOServerInitiator _fiosi;
+  
+  Timer tm("tmtacq");
+  string dir = "ExA";
+  cout << "tmtacq[1] - starting acq program " << endl;
+  
+  try {
+    RAcqMemZoneMgr mmgr(3,100,4096);
+    PCIEReader pcir(mmgr, 10);
+    DataSaver ds(mmgr, dir, 10);
+    DataProc pr(mmgr, dir, 1, 10);
+    tm.Split("Threads created");  
+    cout << "tmtacq[2] - starting 3 threads pcir, ds, pr ... " << endl;
+    pcir.start();
+    ds.start();
+    pr.start();
+    cout << "tmtacq[3] - waiting for threads to finish ... " << endl;
+    sleep(1);
+    pcir.join();
+    ds.join();
+    sleep(1);
+    mmgr.Stop();
+    pr.join();
+    cout << "tmtacq[4] - threads finished " << endl;
+    tm.Split("Threads Finished");  
+    mmgr.Print(cout);
+    rc = 0;
+  }
+  catch (MiniFITSException& exc) {
+    cerr << " tmtacq.cc catched MiniFITSException " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (PThrowable& exc) {
+    cerr << " tmtacq.cc catched Exception " << exc.Msg() << endl;
+    rc = 76;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n tmtacq.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+  	cerr << " tmtacq.cc : Catched ... exception " << endl;
+  	rc = 79;
+  }
+  cout << "tmtacq[9] - stopping acq program " << endl;
+  return rc;
+}
Index: /trunk/AddOn/TAcq/tmtfft.cc
===================================================================
--- /trunk/AddOn/TAcq/tmtfft.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tmtfft.cc	(revision 3538)
@@ -0,0 +1,179 @@
+//--------------------------------------------------------------------------------
+// Programme d'exemple multi-threads de FFT par paquet
+//  Test BAO-Radio/Acq
+//   R. Ansari - C. Magneville  ,   Decembre 2007
+// Exemples de commandes pour test (dans l'ordre ci-dessous :
+// csh> tmtfft OCG 1000000 XXX
+// csh> tmtfft STG 1000000 1024
+// csh> tmtfft RDG 1000000 rg1.ppf
+// csh> tmtfft MTG 3000000 4 
+//--------------------------------------------------------------------------------
+
+#include "sopnamsp.h"
+#include "zthread.h"
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string>
+#include <iostream>
+
+#include "tvector.h"
+#include "fioarr.h"
+#include "matharr.h"
+#include "tarrinit.h"
+
+#include "stsrand.h"
+#include "fftpserver.h"
+#include "fftwserver.h"
+
+#include "FFTW/fftw3.h"
+
+
+//---------------------------------------------------------------------------------
+// Definition d'une classe heritant de ZThread, pour remplir un vecteur avec 
+// des aleatoires
+class MTDoFFT : public ZThread {
+public:
+  MTDoFFT(TVector<r_4>& v, sa_size_t nfft=10, sa_size_t paqsz=4096);
+  virtual void run(); 
+  inline TVector<r_4>& getSpectre() { return spectre_; }
+protected:
+  string nom_;
+  TVector<r_4> vv_;
+  sa_size_t nbfft_;  // Nb de FFT a faire
+  sa_size_t paqsz_;  // taille des paquets pour FFT
+  TVector<r_4> spectre_;   // spectre moyenne 
+  TVector< complex<r_4> > cfour_;  // composant TF
+  FFTPackServer ffts_;   // serveur FFT
+};
+
+static int mtrandId = 0;  // Pour donner un identificateur a chaque thread
+
+MTDoFFT::MTDoFFT(TVector<r_4>& v, sa_size_t nfft, sa_size_t paqsz)
+  : vv_(v,true),    // Partage de reference du vecteur 
+    nbfft_(nfft), paqsz_(paqsz), ffts_(true) // preserve input=true
+{
+  char buff[32];
+  sprintf(buff, "MTDoFFT-Id=%d", mtrandId);
+  mtrandId++;
+  nom_ = buff;
+  // Initialisation taille vecteurs 
+  TVector<r_4> vx(paqsz);
+  vx = RegularSequence();
+  ffts_.FFTForward(vx, cfour_);
+  spectre_.ReSize(cfour_.Size());
+  cout << " Thread MTDoFFT(" << nom_ << " ) Created ... " << endl;
+}
+
+inline r_4 Zmod2(complex<r_4> z) 
+{ return (z.real()*z.real()+z.imag()*z.imag()); }
+
+// Le travail fait dans chaque thread (appele par start())
+void MTDoFFT::run()
+{
+  Timer tm(nom_.c_str());
+  cout << "MTDoFFT::run() - Nom= " << nom_ << " vv.Size()= " << vv_.Size() 
+       << " PaqSz=" << paqsz_ << " NbFFT= " << nbfft_ << endl;
+  RandomGenerator rgen;
+  TVector<r_4> vx(paqsz_);
+  fftwf_plan plan = fftwf_plan_dft_r2c_1d(paqsz_, vx.Data(), 
+				       (fftwf_complex *)cfour_.Data(), FFTW_ESTIMATE);  
+
+  sa_size_t prm = nbfft_/10;
+  for(sa_size_t i=0; i<nbfft_; i++) {
+    sa_size_t first = rgen.Flat01()*(vv_.Size()-paqsz_-10);
+    sa_size_t last = first+paqsz_-1;
+    TVector<r_4> vx = vv_(Range(first,last));
+    fftwf_execute(plan); 
+
+    //    ffts_.FFTForward(vx, cfour_);
+//    for(sa_size_t j=0; j<spectre_.Size(); j++) 
+//      spectre_(j) += Zmod2(cfour_(j)); 
+    if (i%prm == 0)  
+      cout << "MTDoFFT::run() - Nom= " << nom_ << " Done i= " << i << endl;
+  }
+}
+// ----- Fin de la definition de la classe MTDoFFT ----
+//---------------------------------------------------------------------------------
+
+//----------------- Les fonction de test -----------------
+
+//------- f3_tmtfft()
+int f3_tmtfft(sa_size_t VSZ, int NTH, sa_size_t nfft=10, sa_size_t paqsz=4096) 
+{
+  cout << "[1] f3_tmtfft/starting, VSZ= " << VSZ << " NTH= " << NTH << endl;
+  cout << "  ... NbFFT=" << nfft << " PaqSz=" << paqsz << endl;
+  ResourceUsage res(ResourceUsage::RU_All);
+  Timer tm("f3_tmtfft");
+  vector<MTDoFFT *> vth;
+  RandomGenerator rg;
+  TVector<r_4> DATA(VSZ);
+  for(sa_size_t i=0; i<VSZ; i++) 
+    DATA(i) = sin(i*M_PI*0.08654)+2*cos(i*M_PI*0.27591)+rg.Flatpm1();
+  tm.Split("DATA-OK");
+  cout << "[2] f3_tmtfft/creating threads " << endl;
+  for(int kt=0; kt<NTH; kt++) {
+    vth.push_back(new MTDoFFT(DATA, nfft, paqsz) );
+  }
+  tm.Split("Thread-Created");
+  cout << "[3] f3_tmtfft/starting threads " << endl;
+  for(int kt=0; kt<NTH; kt++)  vth[kt]->start();
+  
+  cout << "[4] f3_tmtfft/waiting for all  threads to finish " << endl;
+  sleep(1);
+  for(int kt=0; kt<NTH; kt++)  vth[kt]->join();
+  tm.Split("Threads-Finished");
+
+  cout << "[5] f3_tmtfft/saving spectra to file mtspectra.ppf " << endl;
+  POutPersist po("mtspectra.ppf");
+  for(int kt=0; kt<NTH; kt++)  
+    po << vth[kt]->getSpectre();
+  
+  cout << "[6] f3_tmtfft/deleting thread objects " << endl;
+  for(int kt=0; kt<NTH; kt++)  delete vth[kt];
+  
+  cout << res;
+  return 0;
+}
+//----------------- FIN des fonctions de test -----------------
+
+//-------------------------------------------------------------
+//---------------------- MAIN MAIN MAIN -----------------------
+//-------------------------------------------------------------
+
+int main(int narg, char *arg[])
+
+{
+  InitTim();
+  SophyaInit();
+
+  int rc = 0;
+  if (narg < 4) {
+    cout << " tmtfft/Error args - Usage: tmtfft VSZ NTH NbFFT [PaqSz=4096]" << endl;
+    return 1;
+  }
+  sa_size_t VSZ = atoi(arg[1]);
+  int NTH = atoi(arg[2]);
+  sa_size_t nfft = atoi(arg[3]);
+  sa_size_t paqsz = 4096;
+  if (narg > 4) paqsz = atoi(arg[3]);
+  try {
+    f3_tmtfft(VSZ, NTH, nfft, paqsz); 
+  }
+  catch (PThrowable exc) {
+    cerr << "tmtfft: catched Exception " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (...) {
+    cerr << " catched unknown (...) exception (tmtfft.cc) " << endl; 
+    rc = 78; 
+  } 
+  cout << "----------- tmtfft/END ------- " << endl;
+  PrtTim("---END tmtfft---");
+  return(rc);
+  
+}
Index: /trunk/AddOn/TAcq/tpciew.cc
===================================================================
--- /trunk/AddOn/TAcq/tpciew.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tpciew.cc	(revision 3538)
@@ -0,0 +1,92 @@
+// Utilisation de SOPHYA pour faciliter les tests ...
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+// include standard c/c++
+#include <math.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <typeinfo>
+#include <string>
+
+
+#include "pexceptions.h"  // les exceptions SOPHYA
+// include sophya mesure ressource CPU/memoire ...
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+// #include "array.h"
+
+#include "pciewrap.h"
+int main(int narg, char* arg[])
+{
+
+  if (narg < 2) {
+    cout << "tpciew.cc/Usage: tpciew nread [prtlev=0] " << endl;
+    cout << "     nread<=0 --> PCIEWException " << endl;
+    return 1;
+  }
+
+  int NRead = atoi(arg[1]);
+  int PrtLev = 0;
+  if (narg > 2) PrtLev = atoi(arg[2]);
+  // Sophya modules initialization
+  //   TArrayInitiator  _inia;
+  //------- AU LIEU DE ------>  SophyaInit();  
+
+  InitTim();   // Initializing the CPU timer
+
+  cout << " ---------- tpciew.cc Start --- NRead= " << NRead << " PrtLev=" << PrtLev << endl;
+  int rc = 0;
+  try {
+#define SZ  4096  
+    uint_1 data[SZ];
+    PCIEWrapper pciw;
+    if (NRead <= 0) {
+      uint_4 nbytes = 1;
+      while(nbytes > 0)  nbytes = pciw.NBytesToRead();
+      pciw.Read(data, SZ);
+    }
+    else {
+      for(int k=0; k<NRead; k++) {
+        uint_4 nbytes = 0;
+        while(nbytes <= 0) {
+          usleep(1000);
+          nbytes = pciw.NBytesToRead();
+        }
+        uint_4 nbok = pciw.Read(data, SZ);
+        cout << "---[" << k << "] pciw.Read(data, SZ=" << SZ << ") --> NBytesOk=" << nbok << endl;
+        if (PrtLev > 0) {
+          cout << "data[] : ";
+          for(int j=0; j<PrtLev*5; j++) cout << " , " << (uint_4)data[j];
+          cout << endl;
+        }
+      }
+    }
+  }
+  catch (PCIEWException& exc) {
+    cerr << " tpciew.cc catched PCIEWException " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (PThrowable& exc) {
+    cerr << " tpciew.cc catched Exception " << exc.Msg() << endl;
+    rc = 76;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n tpciew.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " tpciew.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> tpciew.cc ------- FIN ----------- RC=" << rc << endl;
+  PrtTim("FIN tpciew.cc");
+  return rc;
+
+}
Index: /trunk/AddOn/TAcq/traidf.cc
===================================================================
--- /trunk/AddOn/TAcq/traidf.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/traidf.cc	(revision 3538)
@@ -0,0 +1,18 @@
+int SZ = 25000;
+int N = 10;
+
+{
+  Timer tm("traid.cc");
+  TArray<int_4> ia(SZ,0,0);
+  ia = RegularSequence();
+  tm.Split("ia-OK");
+  char flnm[128];
+  for(int i=0; i<N; i++) {
+    sprintf(flnm, "!traid%d.fits",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    FitsOutFile fo(ss);
+    fo << ia;
+    tm.Split("Write-Done");
+  }
+}
Index: /trunk/AddOn/TAcq/traidio.cc
===================================================================
--- /trunk/AddOn/TAcq/traidio.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/traidio.cc	(revision 3538)
@@ -0,0 +1,176 @@
+#include "sopnamsp.h"
+#include "machdefs.h"
+#include <math.h>
+#include <iostream>
+#include <stdio.h>
+#include <typeinfo>
+
+// Pour 
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "pexceptions.h"  // les exceptions SOPHYA
+
+#include "tvector.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
+#include "fioarr.h"  // Pour IO PPF TArray
+#include "sopemtx.h"
+#include "matharr.h"  
+
+#include "fitsfile.h"     // Pour IO FITS TArray
+#include "fitsarrhand.h"     // Pour IO FITS TArray
+
+
+// Pour l'initialisation des modules  TArray , FitsIOServer 
+#include "tarrinit.h"   
+#include "fiosinit.h"     
+
+
+#include "timing.h"
+#include "ctimer.h"
+
+//-----------------------------------------------------------
+
+static long SIZE = 25000;
+static int NFILE = 10;
+
+void tio_raw();
+void tio_fraw();
+void tio_ppf();
+void tio_fits();
+
+/* --------------------------------------------------------
+  Programme de comparaison IO disk - manip BAO-Radio
+  --------------------------------------------------------- */
+   
+int main(int narg, char* arg[])
+{
+  // Sophya modules initialization
+  TArrayInitiator  _inia;
+  FitsIOServerInitiator  _inif;
+  //------- AU LIEU DE ------>  SophyaInit();  
+
+  InitTim();   // Initializing the CPU timer
+
+  if (narg < 2) {
+    cout << "  Usage: traidio SEL [Size [NFile]] \n" 
+	 << "    SEL = raw OU fraw OU ppf  OU fits \n"  
+	 << "    Size : taille tableau (int_4) \n"
+	 << "    NFile : Nb de fichiers \n" << endl;
+    return 1;
+  }
+  string sel = arg[1];
+  if (narg > 2)  SIZE = atol(arg[2]);
+  if (narg > 3)  NFILE = atoi(arg[3]);
+  cout << " ====== traidio : SEL=" << sel << " Size=" << SIZE << " NFile= " << NFILE << endl;
+  int rc = 0;
+  try {
+    if (sel == "raw") tio_raw();
+    else if (sel == "fraw") tio_fraw();
+    else if (sel == "ppf") tio_ppf();
+    else if (sel == "fits") tio_fits();
+    else { rc = 2; cout << " traidio/erreur : SEL non valide" << endl;}
+  }
+  catch (PThrowable& exc) {
+    cerr << " traidio.cc catched Exception " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n traidio.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " traidio.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> traidio.cc ------- FIN ----------- RC=" << rc << endl;
+  PrtTim("FIN traidio.cc");
+  return rc;
+}
+
+
+
+
+void tio_raw()
+{
+  Timer tm("traidio/tio_raw");
+  TArray<int_4> ia(SIZE,0,0);
+  ia = RegularSequence();
+  tm.Split("tio_raw/ia-OK");
+  char flnm[128];
+  for(int i=0; i<NFILE; i++) {
+    sprintf(flnm, "traid%d.raw",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    int fid = -1;
+    fid = open(flnm,O_CREAT|O_WRONLY,S_IRUSR|S_IWUSR);
+    if (fid < 0) {
+      cout << i << " ERROR !!!! creating file " << flnm << endl;
+      continue;
+    }
+    write(fid, ia.Data(), SIZE*sizeof(int_4));
+    close(fid);
+    tm.Split("tio_raw/Write-Done");
+  }
+}
+
+void tio_fraw()
+{
+  Timer tm("traidio/tio_fraw");
+  TArray<int_4> ia(SIZE,0,0);
+  ia = RegularSequence();
+  tm.Split("tio_fraw/ia-OK");
+  char flnm[128];
+  for(int i=0; i<NFILE; i++) {
+    sprintf(flnm, "traid%d.fraw",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    FILE* fip = NULL;
+    fip = fopen(flnm,"w");
+    if (fip == NULL) {
+      cout << i << " ERROR !!!! creating file " << flnm << endl;
+      continue;
+    }
+    fwrite(ia.Data(), SIZE, sizeof(int_4), fip);
+    fclose(fip);
+    tm.Split("tio_fraw/Write-Done");
+  }
+}
+
+void tio_ppf()
+{
+  Timer tm("traidio/tio_ppf");
+  TArray<int_4> ia(SIZE,0,0);
+  ia = RegularSequence();
+  tm.Split("tio_ppf/ia-OK");
+  char flnm[128];
+  for(int i=0; i<NFILE; i++) {
+    sprintf(flnm, "traid%d.ppf",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    POutPersist po(ss);
+    po << ia;
+    tm.Split("tio_ppf/Write-Done");
+  }
+}
+
+void tio_fits()
+{
+  Timer tm("traidio/tio_fits");
+  TArray<int_4> ia(SIZE,0,0);
+  ia = RegularSequence();
+  tm.Split("tio_fits/ia-OK");
+  char flnm[128];
+  for(int i=0; i<NFILE; i++) {
+    sprintf(flnm, "!traid%d.fits",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    FitsOutFile fo(ss);
+    fo << ia;
+    tm.Split("tio_fits/Write-Done");
+  }
+}
Index: /trunk/AddOn/TAcq/traidp.cc
===================================================================
--- /trunk/AddOn/TAcq/traidp.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/traidp.cc	(revision 3538)
@@ -0,0 +1,18 @@
+int SZ = 25000;
+int N = 10;
+
+{
+  Timer tm("traid.cc");
+  TArray<int_4> ia(SZ,0,0);
+  ia = RegularSequence();
+  tm.Split("ia-OK");
+  char flnm[128];
+  for(int i=0; i<N; i++) {
+    sprintf(flnm, "traid%d.ppf",i);
+    string ss = flnm;
+    cout << i << "-----> Creating file " << flnm << endl;
+    POutPersist po(ss);
+    po << ia;
+    tm.Split("Write-Done");
+  }
+}
Index: /trunk/AddOn/TAcq/tstminifits.cc
===================================================================
--- /trunk/AddOn/TAcq/tstminifits.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tstminifits.cc	(revision 3538)
@@ -0,0 +1,118 @@
+// Utilisation de SOPHYA pour faciliter les tests ...
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+// include standard c/c++
+#include <math.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <typeinfo>
+#include <string>
+
+
+#include "pexceptions.h"  // les exceptions SOPHYA
+
+// Include sophya des tableaux 
+#include "tvector.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
+#include "fioarr.h"  // Pour IO PPF TArray
+#include "sopemtx.h"
+#include "matharr.h"  
+#include "tarrinit.h" // Pour l'utilisation des classes TArray, TMatrix , TVector
+
+// include sophya mesure ressource CPU/memoire ...
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+
+// include mini-fits lib 
+#include "minifits.h"
+
+int main(int narg, char* arg[])
+{
+  // Sophya modules initialization
+  TArrayInitiator  _inia;
+  //------- AU LIEU DE ------>  SophyaInit();  
+
+  InitTim();   // Initializing the CPU timer
+
+  cout << " ---------- tstminifits.cc Start ------------- " << endl;
+  int rc = 0;
+  try {
+  	{
+    cout << "1/ Creation tableau " << endl;
+    size_t sx = 300;
+    size_t sy = 200; 
+    TArray<int_2> ta(sx, sy);
+    ta = RegularSequence(0.,0.5);
+    ta.Show();
+    cout << "2/ ecriture tableau ds tmf.ppf " << endl;
+    POutPersist po("tmf.ppf");
+    po << ta;
+    cout << "3/ ecriture tableau ds tmf.fits " << endl;
+    MiniFITSFile mff;
+    mff.setDTypeNaxis(MF_Int16, sx, sy);
+    mff.Open("tmf.fits", MF_Write);
+    mff.WriteI(ta.Data(), sx*sy);
+    cout << "3.b/ FIN ecriture tableau ds tmf.fits " << endl;   
+  	}
+//  --------------  Ecriture de bytes par morceaux 
+    {
+    cout << "4/ Creation tableau uint_1" << endl;
+    size_t sx = 178; 
+    size_t sy = 14;
+    uint_1* data = new uint_1[sx];
+    MiniFITSFile mff("tmfb.fits", MF_Write);
+
+    for(int k=0; k<sy; k++) {
+      for(int j=0; j<sx; j++) data[j] = (k%8)*3+j;
+      mff.WriteB(data, sx);
+    }
+    mff.setDTypeNaxis(MF_Byte, sx, sy);
+    delete [] data;
+    cout << "5/ FIN ecriture tableau ds tmfb.fits " << endl;   
+    }
+// -------------- Lecture de bytes      
+    {
+    cout << "6/ Ouverture/lecture tmfb.fits" << endl;
+    MiniFITSFile mff("tmfb.fits", MF_Read);
+    cout << "6.b/ Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1() 
+    << " NAxis2=" << mff.NAxis2() << endl;
+    size_t sx = mff.NAxis1(); 
+    size_t sy = mff.NAxis2();
+    uint_1* data = new uint_1[sx*sy];
+    mff.ReadB(data, sx*sy);
+    cout << "7/ FIN lecture depuis tmfb.fits " << endl;   
+    TArray<int_2> ta(sx, sy);
+    for(int k=0; k<sy; k++) 
+      for(int j=0; j<sx; j++) ta(j, k) = (int_2)data[j+k*sx];
+    POutPersist po("tmfb.ppf");
+    po << ta;
+    cout << "8/ FIN ecriture tableau ds tmfb.ppf " << endl; 
+    delete[] data;
+    }
+  }
+  catch (MiniFITSException& exc) {
+    cerr << " tstminifits.cc catched MiniFITSException " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (PThrowable& exc) {
+    cerr << " tstminifits.cc catched Exception " << exc.Msg() << endl;
+    rc = 76;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n tstminifits.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " tstminifits.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> tstminifits.cc ------- FIN ----------- RC=" << rc << endl;
+  PrtTim("FIN tstminifits.cc");
+  return rc;
+
+}
Index: /trunk/AddOn/TAcq/tstrdfits.cc
===================================================================
--- /trunk/AddOn/TAcq/tstrdfits.cc	(revision 3538)
+++ /trunk/AddOn/TAcq/tstrdfits.cc	(revision 3538)
@@ -0,0 +1,61 @@
+
+// include standard c/c++
+#include <math.h>
+#include <stdio.h>
+
+#include <iostream>
+#include <string>
+
+
+// include mini-fits lib 
+#include "minifits.h"
+
+int main(int narg, char* arg[])
+{
+  if (narg < 2) {
+    cout << " Usage: tstrdfits file1.fits [file2.fits ...] " << endl;
+    return 1;
+  }
+  cout << " ---------- tstrdfits.cc Start ------------- " << endl;
+  int rc = 0;
+  try {
+    for(int ifile=1; ifile<narg; ifile++) {
+      string ffname = arg[ifile];
+// -------------- Lecture de bytes      
+      cout << ifile <<"-Ouverture/lecture fichier " << ffname << endl;
+      MiniFITSFile mff(ffname, MF_Read);
+      cout << "... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1() 
+	   << " NAxis2=" << mff.NAxis2() << endl;
+      if (mff.DataType() != MF_Byte) {
+        cout << " PB : DataType!=MF_Byte --> skipping " << endl;
+      }
+      size_t sx = mff.NAxis1(); 
+      size_t sy = mff.NAxis2();
+      Byte* data = new Byte[sx];
+      for(int j=0; j<sy; j++) {
+	mff.ReadB(data, sx, j*sx);
+	cout << " j=" << j << " data[0...3]=" << (int)data[0] << " , " 
+	     << (int)data[1] << " , " <<  (int)data[2] << endl;
+      }
+      cout << "---- FIN lecture " << ffname << endl;
+    }   
+  }
+  catch (MiniFITSException& exc) {
+    cerr << " tstrdfits.cc catched MiniFITSException " << exc.Msg() << endl;
+    rc = 77;
+  }  
+  catch (std::exception& sex) {
+    cerr << "\n tstrdfits.cc std::exception :" 
+         << (string)typeid(sex).name() << "\n msg= " 
+         << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " tstrdfits.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> tstrdfits.cc ------- FIN ----------- RC=" << rc << endl;
+  return rc;
+
+}
