CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/EventFilter/ShmBuffer/bin/FUShmClient_t.cc

Go to the documentation of this file.
00001 
00002 //
00003 // FUShmClient_t
00004 // -------------
00005 //
00006 //            17/11/2006 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
00008 
00009 
00010 #include "EventFilter/ShmBuffer/interface/FUShmBuffer.h"
00011 #include "EventFilter/ShmBuffer/bin/FUShmClient.h"
00012 
00013 
00014 #include <iostream>
00015 #include <iomanip>
00016 #include <sstream>
00017 #include <unistd.h>
00018 
00019 
00020 using namespace std;
00021 using namespace evf;
00022 
00023 
00024 //______________________________________________________________________________
00025 void print_fed(unsigned int iFed,const vector<unsigned char>& fedData);
00026 
00027 
00028 //______________________________________________________________________________
00029 int main(int argc,char**argv)
00030 {
00031   // set parameters
00032   bool   waitForKey(false);if (argc>1) {stringstream ss;ss<<argv[1];ss>>waitForKey;}
00033   double crashPrb(0.0);    if (argc>2) {stringstream ss;ss<<argv[2];ss>>crashPrb;  }
00034   int    sleepTime(0);     if (argc>3) {stringstream ss;ss<<argv[3];ss>>sleepTime; }
00035 
00036   // get shared memory buffer and instantiate client
00037   FUShmBuffer* buffer=FUShmBuffer::getShmBuffer(); if (0==buffer) return 1;
00038   FUShmClient* client=new FUShmClient(buffer);
00039   client->setCrashPrb(crashPrb);
00040   client->setSleep(sleepTime);
00041   
00042   // the structure to hold the read fed data
00043   vector<vector<unsigned char> > fedData;
00044   
00045   // client loop
00046   while(1) {
00047     
00048     // wait for the user to press a key
00049     if (waitForKey) {
00050       cout<<"press key+<RETURN> to read next: "<<flush; char val; cin>>val;
00051       cout<<endl;
00052     }
00053     
00054     // read next event
00055     unsigned int iCell=client->readNext(fedData);
00056     cout<<"READ at index "<<iCell<<endl;
00057 
00058     // print content
00059     for(unsigned int i=0;i<4 /*fedData.size()*/;i++) print_fed(i,fedData[i]);
00060     cout<<endl;
00061     
00062   }
00063   
00064   return 0;
00065 }
00066 
00067 
00068 //______________________________________________________________________________
00069 void print_fed(unsigned int iFed,const vector<unsigned char>& fedData)
00070 {
00071   cout<<"fed "<<iFed<<": "<<flush;
00072   vector<unsigned char>::const_iterator it;
00073   cout.fill('0');
00074   for (it=fedData.begin();it!=fedData.end();++it)
00075     cout<<setiosflags(ios::right)<<setw(2)<<hex<<(int)(*it)<<dec<<" ";
00076   cout<<endl;
00077 }