Changeset 3623 in Sophya for trunk/AddOn/TAcq/pciewrap.cc
- Timestamp:
- May 22, 2009, 9:59:38 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AddOn/TAcq/pciewrap.cc
r3538 r3623 1 1 #include "pciewrap.h" 2 #include "brpaqu.h" 3 4 #include "racqumem.h" 2 5 3 6 #include <stdlib.h> 4 7 #include <stdio.h> 5 8 #include <math.h> 6 7 9 #include <iostream> 8 10 9 PCIEWrapper::PCIEWrapper() 11 TestPCIWrapperNODMA::TestPCIWrapperNODMA(UInt32 sz) 12 : PCIEWrapper() , size_(sz) 10 13 { 11 // Faire l'initialisation PCI-Express ici 14 data_ = new Byte[size_]; 15 frame_counter_ = 0; 16 timetag_ = 0; 17 tottransfer_ = 0; 12 18 } 13 19 14 PCIEWrapper::~PCIEWrapper()20 TestPCIWrapperNODMA::~TestPCIWrapperNODMA() 15 21 { 16 // Faire le nettoyage (liberer memoire ...) 22 delete[] data_; 17 23 } 18 24 19 20 // Variables pour tests 21 static uint_4 NBytes = 0; 22 static uint_4 Choix = 0; 23 24 uint_4 PCIEWrapper::NBytesToRead() 25 UInt32 TestPCIWrapperNODMA::TransferSize() 25 26 { 26 // Lire le registre indiquant le nombre de mots prets a etre lus 27 // cad transfere en memoire du PC 28 int choix = rand()%5; 29 if (choix < 2) { 30 Choix = choix; 31 if (choix == 0) NBytes = 4096; 32 else NBytes = 5000; 33 } 34 else { 35 NBytes = 0; 36 Choix = 0; 37 } 38 return NBytes; 27 return size_; 39 28 } 40 29 41 uint_4 PCIEWrapper::Read(uint_1* buff, uint_4 nbytes)30 UInt64 TestPCIWrapperNODMA::TotTransferBytes() 42 31 { 43 if (NBytes == 0) throw PCIEWException("PCIEWrapper::Read()/Error NBytes==0"); 44 if (nbytes > NBytes) nbytes = NBytes; 45 double dx = (rand()%8+1)*0.05; 46 for(int k=0; k<nbytes; k++) buff[k] = (uint_1)((1.+sin(dx*k))*100.); 47 if ((Choix == 1) && (nbytes>2000)) 48 for(int k=1600; k<1900; k++) buff[k] = (uint_1)(128); 49 return nbytes; 32 return tottransfer_; 50 33 } 34 35 Byte* TestPCIWrapperNODMA::DoTransferData(int numbuff) 36 { 37 frame_counter_ ++; 38 timetag_ = frame_counter_ * size_ / 2; 39 BRPaquet paq(data_, size_); 40 paq.SetHDRMarker64(pchk_.HDRTag()); 41 paq.SetTRLMarker64(pchk_.TRLTag()); 42 paq.SetFrameCounter(frame_counter_); 43 paq.SetTimeTag(timetag_); 44 paq.SetPaqLen((UInt16)((size_ - BRHDRSIZE - BRTRLSIZE)/4)); 45 Byte* bp = paq.Data1(); 46 for(UInt32 kk=0; kk<paq.DataSize(); kk++) 47 bp[kk] = (Byte)(sin(0.0345*kk)*78.+127.5); 48 tottransfer_ += size_; 49 return data_; 50 } 51 52 void TestPCIWrapperNODMA::PrintStatus(ostream& os) 53 { 54 os << "TestPCIWrapperNODMA::Status, FrameCounter=" << frame_counter_ 55 << " TimeTag=" << timetag_ << endl; 56 }
Note:
See TracChangeset
for help on using the changeset viewer.