CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUShmClient_t.cc
Go to the documentation of this file.
1 //
3 // FUShmClient_t
4 // -------------
5 //
6 // 17/11/2006 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
8 
9 
12 
13 
14 #include <iostream>
15 #include <iomanip>
16 #include <sstream>
17 #include <unistd.h>
18 
19 
20 using namespace std;
21 using namespace evf;
22 
23 
24 //______________________________________________________________________________
25 void print_fed(unsigned int iFed,const vector<unsigned char>& fedData);
26 
27 
28 //______________________________________________________________________________
29 int main(int argc,char**argv)
30 {
31  // set parameters
32  bool waitForKey(false);if (argc>1) {stringstream ss;ss<<argv[1];ss>>waitForKey;}
33  double crashPrb(0.0); if (argc>2) {stringstream ss;ss<<argv[2];ss>>crashPrb; }
34  int sleepTime(0); if (argc>3) {stringstream ss;ss<<argv[3];ss>>sleepTime; }
35 
36  // get shared memory buffer and instantiate client
37  FUShmBuffer* buffer=FUShmBuffer::getShmBuffer(); if (0==buffer) return 1;
38  FUShmClient* client=new FUShmClient(buffer);
39  client->setCrashPrb(crashPrb);
40  client->setSleep(sleepTime);
41 
42  // the structure to hold the read fed data
43  vector<vector<unsigned char> > fedData;
44 
45  // client loop
46  while(1) {
47 
48  // wait for the user to press a key
49  if (waitForKey) {
50  cout<<"press key+<RETURN> to read next: "<<flush; char val; cin>>val;
51  cout<<endl;
52  }
53 
54  // read next event
55  unsigned int iCell=client->readNext(fedData);
56  cout<<"READ at index "<<iCell<<endl;
57 
58  // print content
59  for(unsigned int i=0;i<4 /*fedData.size()*/;i++) print_fed(i,fedData[i]);
60  cout<<endl;
61 
62  }
63 
64  return 0;
65 }
66 
67 
68 //______________________________________________________________________________
69 void print_fed(unsigned int iFed,const vector<unsigned char>& fedData)
70 {
71  cout<<"fed "<<iFed<<": "<<flush;
72  vector<unsigned char>::const_iterator it;
73  cout.fill('0');
74  for (it=fedData.begin();it!=fedData.end();++it)
75  cout<<setiosflags(ios::right)<<setw(2)<<hex<<(int)(*it)<<dec<<" ";
76  cout<<endl;
77 }
int i
Definition: DBlmapReader.cc:9
unsigned int readNext(std::vector< std::vector< unsigned char > > &feds)
Definition: FUShmClient.cc:51
void print_fed(unsigned int iFed, const vector< unsigned char > &fedData)
int main(int argc, char **argv)
void setSleep(int sec)
Definition: FUShmClient.h:30
tuple argc
Definition: dir2webdir.py:41
tuple cout
Definition: gather_cfg.py:121
void setCrashPrb(double prb)
Definition: FUShmClient.h:29