CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUShmServer_t.cc
Go to the documentation of this file.
1 //
3 // FUShmServer_t
4 // -------------
5 //
6 // 17/11/2006 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
8 
9 
12 
13 #include <iostream>
14 #include <cstdlib> // rand()
15 #include <sstream>
16 
17 
18 using namespace std;
19 using namespace evf;
20 
21 
22 //______________________________________________________________________________
23 int main(int argc,char**argv)
24 {
25  bool segmentationMode=false;
26  unsigned int nCells =32;
27  unsigned int nFed = 4;
28  unsigned int bytesPerFed =10;
29  unsigned int cellBufferSize =nFed*bytesPerFed;
30 
31  if (argc>1) { stringstream ss; ss<<argv[1]; ss>>segmentationMode; }
32 
33  cout<<" FUShmServer_t:"
34  <<" segmentationMode="<<segmentationMode
35  <<" nCells="<<nCells
36  <<" nFed="<<nFed
37  <<" bytesPerFed="<<bytesPerFed
38  <<" cellBufferSize="<<cellBufferSize<<endl<<endl;
39 
40  FUShmBuffer* buffer=FUShmBuffer::createShmBuffer(segmentationMode,
41  nCells,0,0,
42  cellBufferSize,0,0);
43  if (0==buffer) return 1;
44  FUShmServer* server=new FUShmServer(buffer);
45 
46 
47  // the fake data written to shared memory
48  unsigned char* data =new unsigned char[cellBufferSize];
49  unsigned int* fedSize =new unsigned int[nFed];
50  for (unsigned int i=0;i<nFed;i++) fedSize[i]=bytesPerFed;
51 
52 
53  // server loop
54  while(1) {
55 
56  // generate data
57  for (unsigned int i=0;i<cellBufferSize;i++) {
58  unsigned int rnd=rand();
59  double tmp=rnd/(double)RAND_MAX*255;
60  rnd=(unsigned int)tmp;
61  data[i]=(unsigned char)rnd;
62  }
63 
64  unsigned int iCell=server->writeNext(data,nFed,fedSize);
65  cout<<"WROTE at index "<<iCell<<endl;
66  }
67 
68  return 0;
69 }
int i
Definition: DBlmapReader.cc:9
int main(int argc, char **argv)
tuple argc
Definition: dir2webdir.py:41
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int writeNext(unsigned char *data, unsigned int nFed, unsigned int *fedSize)
Definition: FUShmServer.cc:44
Signal rand(Signal arg)
Definition: vlib.cc:442
tuple cout
Definition: gather_cfg.py:121