| [3537] | 1 | // Utilisation de SOPHYA pour faciliter les tests ...
 | 
|---|
 | 2 | #include "sopnamsp.h"
 | 
|---|
 | 3 | #include "machdefs.h"
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | // include standard c/c++
 | 
|---|
 | 6 | #include <math.h>
 | 
|---|
 | 7 | #include <stdio.h>
 | 
|---|
 | 8 | 
 | 
|---|
 | 9 | #include <iostream>
 | 
|---|
 | 10 | #include <typeinfo>
 | 
|---|
 | 11 | #include <string>
 | 
|---|
 | 12 | 
 | 
|---|
 | 13 | 
 | 
|---|
 | 14 | #include "pexceptions.h"  // les exceptions SOPHYA
 | 
|---|
 | 15 | // include sophya mesure ressource CPU/memoire ...
 | 
|---|
 | 16 | #include "resusage.h"
 | 
|---|
 | 17 | #include "ctimer.h"
 | 
|---|
 | 18 | #include "timing.h"
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | // #include "array.h"
 | 
|---|
 | 21 | 
 | 
|---|
 | 22 | #include "pciewrap.h"
 | 
|---|
 | 23 | int main(int narg, char* arg[])
 | 
|---|
 | 24 | {
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 |   if (narg < 2) {
 | 
|---|
 | 27 |     cout << "tpciew.cc/Usage: tpciew nread [prtlev=0] " << endl;
 | 
|---|
 | 28 |     cout << "     nread<=0 --> PCIEWException " << endl;
 | 
|---|
 | 29 |     return 1;
 | 
|---|
 | 30 |   }
 | 
|---|
 | 31 | 
 | 
|---|
 | 32 |   int NRead = atoi(arg[1]);
 | 
|---|
 | 33 |   int PrtLev = 0;
 | 
|---|
 | 34 |   if (narg > 2) PrtLev = atoi(arg[2]);
 | 
|---|
 | 35 |   // Sophya modules initialization
 | 
|---|
 | 36 |   //   TArrayInitiator  _inia;
 | 
|---|
 | 37 |   //------- AU LIEU DE ------>  SophyaInit();  
 | 
|---|
 | 38 | 
 | 
|---|
 | 39 |   InitTim();   // Initializing the CPU timer
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 |   cout << " ---------- tpciew.cc Start --- NRead= " << NRead << " PrtLev=" << PrtLev << endl;
 | 
|---|
 | 42 |   int rc = 0;
 | 
|---|
 | 43 |   try {
 | 
|---|
 | 44 | #define SZ  4096  
 | 
|---|
 | 45 |     uint_1 data[SZ];
 | 
|---|
 | 46 |     PCIEWrapper pciw;
 | 
|---|
 | 47 |     if (NRead <= 0) {
 | 
|---|
 | 48 |       uint_4 nbytes = 1;
 | 
|---|
 | 49 |       while(nbytes > 0)  nbytes = pciw.NBytesToRead();
 | 
|---|
 | 50 |       pciw.Read(data, SZ);
 | 
|---|
 | 51 |     }
 | 
|---|
 | 52 |     else {
 | 
|---|
 | 53 |       for(int k=0; k<NRead; k++) {
 | 
|---|
 | 54 |         uint_4 nbytes = 0;
 | 
|---|
 | 55 |         while(nbytes <= 0) {
 | 
|---|
 | 56 |           usleep(1000);
 | 
|---|
 | 57 |           nbytes = pciw.NBytesToRead();
 | 
|---|
 | 58 |         }
 | 
|---|
 | 59 |         uint_4 nbok = pciw.Read(data, SZ);
 | 
|---|
 | 60 |         cout << "---[" << k << "] pciw.Read(data, SZ=" << SZ << ") --> NBytesOk=" << nbok << endl;
 | 
|---|
 | 61 |         if (PrtLev > 0) {
 | 
|---|
 | 62 |           cout << "data[] : ";
 | 
|---|
 | 63 |           for(int j=0; j<PrtLev*5; j++) cout << " , " << (uint_4)data[j];
 | 
|---|
 | 64 |           cout << endl;
 | 
|---|
 | 65 |         }
 | 
|---|
 | 66 |       }
 | 
|---|
 | 67 |     }
 | 
|---|
 | 68 |   }
 | 
|---|
 | 69 |   catch (PCIEWException& exc) {
 | 
|---|
 | 70 |     cerr << " tpciew.cc catched PCIEWException " << exc.Msg() << endl;
 | 
|---|
 | 71 |     rc = 77;
 | 
|---|
 | 72 |   }  
 | 
|---|
 | 73 |   catch (PThrowable& exc) {
 | 
|---|
 | 74 |     cerr << " tpciew.cc catched Exception " << exc.Msg() << endl;
 | 
|---|
 | 75 |     rc = 76;
 | 
|---|
 | 76 |   }  
 | 
|---|
 | 77 |   catch (std::exception& sex) {
 | 
|---|
 | 78 |     cerr << "\n tpciew.cc std::exception :" 
 | 
|---|
 | 79 |          << (string)typeid(sex).name() << "\n msg= " 
 | 
|---|
 | 80 |          << sex.what() << endl;
 | 
|---|
 | 81 |     rc = 78;
 | 
|---|
 | 82 |   }
 | 
|---|
 | 83 |   catch (...) {
 | 
|---|
 | 84 |     cerr << " tpciew.cc catched unknown (...) exception  " << endl; 
 | 
|---|
 | 85 |     rc = 79; 
 | 
|---|
 | 86 |   } 
 | 
|---|
 | 87 | 
 | 
|---|
 | 88 |   cout << ">>>> tpciew.cc ------- FIN ----------- RC=" << rc << endl;
 | 
|---|
 | 89 |   PrtTim("FIN tpciew.cc");
 | 
|---|
 | 90 |   return rc;
 | 
|---|
 | 91 | 
 | 
|---|
 | 92 | }
 | 
|---|