IPC.cxx
Go to the documentation of this file.
3 #include <sys/time.h>
4 #include <sys/resource.h>
5 #ifdef DARWINBUILD
6  #include <unistd.h>
7 #endif
8 #include <iostream>
9 #include <cstdlib>
10 #include <cstring>
11 #include "TObject.h"
12 #include "TH1F.h"
13 #include "TH2F.h"
14 using namespace om;
15 
16 //
17 // Number of microseconds to wait between request attempts and the
18 // number of requests to make. Units are microseconds
19 //
20 static const unsigned int kSecond = 1000000;
21 static const unsigned int kSleep = kSecond/1000;
22 static const unsigned int kWait = 5*kSecond;
23 
24 //......................................................................
25 
26 IPC::IPC(int mode, const char* shm_key) : fMode(mode)
27 {
28  int shmflg = 0666;
29  if (fMode == kIPC_SERVER) shmflg |= IPC_CREAT;
30 
31  memset(fShmHdl, 0, kHdlSz);
32  strncpy(fShmHdl, shm_key, kHdlSz-1);
33  fKey = (key_t*)fShmHdl;
34 
35  //
36  // Try to open the SHM area. Try repeatedly eventually timing out.
37  //
38  unsigned int i, imax = 30*(kSecond/kSleep);
39  for (i=0; i<imax; ++i) {
40  fShmId = shmget(*fKey, sizeof(om::IPCBlock), shmflg);
41  if (fShmId>0) break;
42  if (i%100==0) {
43  std::cerr << __FILE__ << ":" << __LINE__
44  << " Looking for shared memory segment..." << std::endl;
45  }
46  usleep(kSleep);
47  }
48  if (fShmId<0) {
49  std::cerr << __FILE__ << ":" << __LINE__ << " shmget failed" << std::endl;
50  exit(1);
51  }
52 
53  fShm = shmat(fShmId, NULL, 0);
54  if (fShm==(char*)-1) {
55  std::cerr << __FILE__ << ":" << __LINE__ << " shmat failed" << std::endl;
56  exit(1);
57  }
58 
60 
61  if (fMode == kIPC_SERVER) {
62  //
63  // Zero the data blocks and set the headers and footers to their
64  // standard values
65  //
66  memset(fIPC, 0, sizeof(om::IPCBlock));
67 
70 
73 
76 
79 
82 
85  }
86 
87  if (fMode == kIPC_CLIENT) {
88  ++fIPC->fNclient;
89  }
90 }
91 
92 //......................................................................
93 
95 {
96  if (fMode == kIPC_CLIENT) {
97  --fIPC->fNclient;
98  shmdt(fShm);
99  }
100  if (fMode == kIPC_SERVER) {
101  shmdt(fShm);
102  shmid_ds buf;
103  shmctl(fShmId, IPC_RMID, &buf);
104  }
105 }
106 
107 //......................................................................
108 
109 TH1F* IPC::RequestTH1F(const char* n)
110 {
111  if (fMode==kIPC_SERVER) {
112  std::cerr << __FILE__ << ":" << __LINE__
113  << " Server used as client." << std::endl;
114  abort();
115  }
116 
117  //
118  // Wait for any locks to clear then set our own client lock
119  //
120  unsigned int i;
121  for (i=0; i<kWait; ++i) {
122  if ( (fIPC->fHistogram.fClientLock ==0) &&
123  (fIPC->fHistogram.fServerLock ==0) &&
124  (fIPC->fHistogram.fRequestPending==0)) break;
125  usleep(kSleep);
126  }
127  if (i==kWait) {
128  std::cerr << __FILE__ << ":" << __LINE__
129  << " Time out waiting for client lock, server lock, "
130  << "and pending requests. " << std::endl;
131  return 0;
132  }
133 
135 
136  //
137  // Submit a request to the server and wait for a response
138  //
139  this->Request(n, "TH1F");
140  for (i=0; i<kWait; ++i) {
141  if (fIPC->fHistogram.fRequestPending==0) break;
142  usleep(kSleep);
143  }
144  if (i==kWait) {
145  std::cerr << __FILE__ << ":" << __LINE__
146  << " Time out waiting for request to be satisfied."
147  << std::endl;
149  return 0;
150  }
151 
152  //
153  // With the request satisfied by the server, make a TH1F for
154  // return. Now that we are done with the data in the shared memory
155  // segment, release the lock we have on it.
156  //
157  TH1F* h = this->UnpackTH1F();
159 
160  return h;
161 }
162 
163 //......................................................................
164 
165 TH2F* IPC::RequestTH2F(const char* n)
166 {
167  if (fMode==kIPC_SERVER) {
168  std::cerr << __FILE__ << ":" << __LINE__
169  << " Server used as client." << std::endl;
170  abort();
171  }
172 
173  //
174  // Wait for any locks to clear then set our own client lock
175  //
176  unsigned int i;
177  for (i=0; i<kWait; ++i) {
178  if ( (fIPC->fHistogram.fClientLock ==0) &&
179  (fIPC->fHistogram.fServerLock ==0) &&
180  (fIPC->fHistogram.fRequestPending==0)) break;
181  usleep(kSleep);
182  }
183  if (i==kWait) {
184  std::cerr << __FILE__ << ":" << __LINE__
185  << " Time out waiting for client lock, server lock, "
186  << "and pending requests. "
187  << std::endl;
188  return 0;
189  }
190 
192 
193  //
194  // Submit a request to the server and wait for a response
195  //
196  this->Request(n, "TH2F");
197  for (i=0; i<kWait; ++i) {
198  if (fIPC->fHistogram.fRequestPending==0) break;
199  usleep(kSleep);
200  }
201  if (i==kWait) {
202  std::cerr << __FILE__ << ":" << __LINE__
203  << " Time out waiting for request to be satisfied."
204  << std::endl;
206  return 0;
207  }
208 
209  //
210  // With the request satisfied by the server, make a TH1F for
211  // return. Now that we are done with the data in the shared memory
212  // segment, release the lock we have on it.
213  //
214  TH2F* h = this->UnpackTH2F();
216 
217  return h;
218 }
219 
220 //......................................................................
221 
222 ///
223 /// Client call to request the histogram list
224 ///
225 int IPC::RequestHistoList(std::list<std::string>& hlist)
226 {
227  if (fMode==kIPC_SERVER) {
228  std::cerr << __FILE__ << ":" << __LINE__
229  << " Server used as client." << std::endl;
230  abort();
231  }
232 
233  //
234  // Wait for any locks to clear then set our own client lock
235  //
236  unsigned int i;
237  for (i=0; i<kWait; ++i) {
238  if ( (fIPC->fHistoList.fClientLock ==0) &&
239  (fIPC->fHistoList.fServerLock ==0) &&
240  (fIPC->fHistoList.fRequestPending==0)) break;
241  usleep(kSleep);
242  }
243  if (i==kWait) {
244  std::cerr << __FILE__ << ":" << __LINE__
245  << " Time out waiting for client lock, server "
246  << "lock, and pending requests."
247  << std::endl;
248  return 0;
249  }
250 
254 
255  for (i=0; i<kWait; ++i) {
256  if (fIPC->fHistoList.fRequestPending==0) break;
257  usleep(kSleep);
258  }
259  if (i==kWait) {
260  std::cerr << __FILE__ << ":" << __LINE__
261  << " Time out waiting for request to be satisfied."
262  << std::endl;
264  return 0;
265  }
266 
267  //
268  // With the request satisfied by the server, fill the list
269  //
271  for (i=0; i<fIPC->fHistoList.fN; ++i) {
272  hlist.push_back(fIPC->fHistoList.fName[i]);
273  }
275 
276  return 1;
277 }
278 
279 //......................................................................
280 
281 ///
282 /// Client call to request the current watchlist
283 ///
284 int IPC::RequestCurrentWatchList(std::vector<int>& db,
285  std::vector<int>& dcm,
286  std::vector<int>& feb,
287  std::vector<int>& pix)
288 {
289  if (fMode==kIPC_SERVER) {
290  std::cerr << __FILE__ << ":" << __LINE__
291  << " Server used as client." << std::endl;
292  abort();
293  }
294 
295  //
296  // Wait for any locks to clear then set our own client lock
297  //
298  unsigned int i;
299  for (i=0; i<kWait; ++i) {
300  if ( (fIPC->fWatchList.fClientLock ==0) &&
301  (fIPC->fWatchList.fServerLock ==0) &&
302  (fIPC->fWatchList.fRequestPending==0)) break;
303  usleep(kSleep);
304  }
305  if (i==kWait) {
306  std::cerr << __FILE__ << ":" << __LINE__
307  << " Time out waiting for client lock, server "
308  << "lock, and pending requests."
309  << std::endl;
310  return 0;
311  }
312 
316 
317  for (i=0; i<kWait; ++i) {
318  if (fIPC->fWatchList.fRequestPending==0) break;
319  usleep(kSleep);
320  }
321  if (i==kWait) {
322  std::cerr << __FILE__ << ":" << __LINE__
323  << " Time out waiting for request to be satisfied."
324  << std::endl;
326  return 0;
327  }
328 
329  //
330  // With the request satisfied by the server, fill the list
331  //
333  for(i=0; i<fIPC->fWatchList.fN; ++i) {
334  db .push_back(fIPC->fWatchList.fDB [i]);
335  dcm.push_back(fIPC->fWatchList.fDCM[i]);
336  feb.push_back(fIPC->fWatchList.fFEB[i]);
337  pix.push_back(fIPC->fWatchList.fPIX[i]);
338  }
340 
341  return 1;
342 }
343 
344 //......................................................................
345 
346 int IPC::RequestAddToWatchList(int db, int dcm, int feb, int pix)
347 {
348  // only the clients can request changes to the watchlist
349  if (fMode==kIPC_SERVER) {
350  std::cerr << __FILE__ << ":" << __LINE__
351  << " Server used as client." << std::endl;
352  abort();
353  }
354 
355  //
356  // Wait for any locks to clear then set our own client lock
357  //
358  unsigned int i;
359  for (i=0; i<kWait; ++i) {
360  if ( (fIPC->fChangeWatchList.fClientLock == 0) &&
362  (fIPC->fChangeWatchList.fRequestPending == 0) ) break;
363  usleep(kSleep);
364  }
365  if (i==kWait) {
366  std::cerr << __FILE__ << ":" << __LINE__
367  << " Time out waiting for client lock, server "
368  << "lock, and pending requests."
369  << std::endl;
370  return 0;
371  }
372 
378  fIPC->fChangeWatchList.fPIX = pix;
379 
380  //
381  // Submit a request to the server and wait for a response
382  //
384  for (i=0; i<kWait; ++i) {
385  if (fIPC->fChangeWatchList.fRequestPending==0) break;
386  usleep(kSleep);
387  }
388  if (i==kWait) {
389  std::cerr << __FILE__ << ":" << __LINE__
390  << " Time out waiting for request to be satisfied."
391  << std::endl;
393  return 0;
394  }
395 
397  return 1;
398 }
399 
400 //......................................................................
401 
402 int IPC::RequestRemoveFromWatchList(int db, int dcm, int feb, int pix)
403 {
404  // only the clients can request changes to the watchlist
405  if (fMode==kIPC_SERVER) {
406  std::cerr << __FILE__ << ":" << __LINE__
407  << " Server used as client." << std::endl;
408  abort();
409  }
410 
411  //
412  // Wait for any locks to clear then set our own client lock
413  //
414  unsigned int i;
415  for (i=0; i<kWait; ++i) {
416  if ( (fIPC->fChangeWatchList.fClientLock == 0) &&
418  (fIPC->fChangeWatchList.fRequestPending == 0) ) break;
419  usleep(kSleep);
420  }
421  if (i==kWait) {
422  std::cerr << __FILE__ << ":" << __LINE__
423  << " Time out waiting for client lock, server "
424  << "lock, and pending requests."
425  << std::endl;
426  return 0;
427  }
428 
434  fIPC->fChangeWatchList.fPIX = pix;
435 
436  //
437  // Submit a request to the server and wait for a response
438  //
440  for (i=0; i<kWait; ++i) {
441  if (fIPC->fChangeWatchList.fRequestPending==0) break;
442  usleep(kSleep);
443  }
444  if (i==kWait) {
445  std::cerr << __FILE__ << ":" << __LINE__
446  << " Time out waiting for request to be satisfied."
447  << std::endl;
449  return 0;
450  }
451 
453  return 1;
454 }
455 
456 //......................................................................
457 
459 {
460  static const std::string s("TH1F");
461  if (s != fIPC->fHistogram.fType) return 0;
462  if (fIPC->fHistogram.fHistoOK==0) return 0;
463 
464  TH1F* h = new TH1F(fIPC->fHistogram.fName,
468  fIPC->fHistogram.fX2);
469 
470  for (int i=0; i<h->fN; ++i) {
471  h->SetBinContent(i, fIPC->fHistogram.fData[i]);
472  }
473 
474  return h;
475 }
476 
477 //......................................................................
478 
480 {
481  static const std::string s("TH2F");
482  if (s != fIPC->fHistogram.fType) { return 0; }
483  if (fIPC->fHistogram.fHistoOK==0) { return 0; }
484 
485  TH2F* h = new TH2F(fIPC->fHistogram.fName,
492  fIPC->fHistogram.fY2);
493  for (int i=0; i<h->fN; ++i) {
494  h->SetBinContent(i, fIPC->fHistogram.fData[i]);
495  }
496 
497  return h;
498 }
499 
500 //......................................................................
501 
502 ///
503 /// Submit a request to the server. It is assumed that the caller has
504 /// already checked that the server and client locks are clear
505 ///
506 int IPC::Request(const char* n, const char* t)
507 {
509  strcpy(fIPC->fHistogram.fName, n);
510  strcpy(fIPC->fHistogram.fType, t);
511  return 1;
512 }
513 
514 //......................................................................
515 
517 {
518  int ok1 = this->HandleHistogramRequests();
519  int ok2 = this->HandleHistoListRequests();
520  int ok3 = this->HandleChangeWatchList();
521  int ok4 = this->HandleCurrentWatchListRequests();
522  if (ok1==1 && ok2==1 && ok3==1 && ok4==1) return 1;
523  return 0;
524 }
525 
526 //......................................................................
527 
528 void IPC::PostResources(unsigned int run,
529  unsigned int subrun,
530  unsigned int event)
531 {
534  fIPC->fProcessResources.fEvent = event;
535 
536  struct rusage r;
537  getrusage(RUSAGE_SELF, &r);
538 
539  fIPC->fProcessResources.fPID = getpid();
540  fIPC->fProcessResources.fSTIME = r.ru_stime.tv_sec;
541  fIPC->fProcessResources.fUTIME = r.ru_utime.tv_sec;
543  fIPC->fProcessResources.fRSIZE = r.ru_maxrss;
545 
546 }
547 
548 //......................................................................
549 
551 {
552  if (fMode == kIPC_CLIENT) {
553  std::cerr << __FILE__ << ":" << __LINE__
554  << " Client used as server." << std::endl;
555  abort();
556  }
557 
558  //
559  // Only proceed if there is a request pending
560  //
561  if (fIPC->fHistogram.fRequestPending==0) return 0;
562 
564  static const std::string TH1Fs("TH1F");
565  if (TH1Fs==fIPC->fHistogram.fType) {
566  TH1F* h1 = this->FindTH1F(fIPC->fHistogram.fName);
567 
568  this->Publish1DHistogram(h1);
569 
572 
573  if (h1) return 1;
574  }
575 
576  static const std::string TH2Fs("TH2F");
577  if (TH2Fs==fIPC->fHistogram.fType) {
578  TH2F* h2 = this->FindTH2F(fIPC->fHistogram.fName);
579 
580  this->Publish2DHistogram(h2);
581 
584 
585  if (h2) return 1;
586  }
587 
588  // If we reach here, we have not sucessfully exited by any of the
589  // above pathways, so return 0.
590  return 0;
591 
592 }
593 
594 //......................................................................
595 
597 {
598  if (fMode == kIPC_CLIENT) {
599  std::cerr << __FILE__ << ":" << __LINE__
600  << " Client used as server." << std::endl;
601  abort();
602  }
603 
604  //
605  // Only proceed if there is a request pending
606  //
607  if (fIPC->fHistoList.fRequestPending==0) return 0;
608 
610 
611  std::list<std::string> hlist;
612  this->HistoList(hlist);
613  std::list<std::string>::iterator itr(hlist.begin());
614  std::list<std::string>::iterator itrEnd(hlist.end());
615  unsigned int n=0;
616  for (; itr!=itrEnd; ++itr) {
617  strcpy(fIPC->fHistoList.fName[n], itr->c_str());
618  ++n;
619  }
620  if (n>=NMAX_HISTOS) {
621  std::cerr << __FILE__ << " : " << __LINE__
622  << " Request for " << n << " histograms with limit of " << NMAX_HISTOS
623  << ". Time to update IPC.h and recompile."
624  << std::endl;
625  abort();
626  }
627  fIPC->fHistoList.fN = n;
628 
631 
632  return 1;
633 }
634 
635 //......................................................................
636 
638 {
639  // only the server can actually change the watchlist
640  if (fMode == kIPC_CLIENT) {
641  std::cerr << __FILE__ << ":" << __LINE__
642  << " Client used as server." << std::endl;
643  abort();
644  }
645 
646  //
647  // Only proceed if there is a request pending
648  //
649  if (fIPC->fChangeWatchList.fRequestPending==0) return 0;
650 
652 
658  }
664  }
665 
668  return 1;
669 }
670 
671 //......................................................................
672 
674 {
675  if (fMode == kIPC_CLIENT) {
676  std::cerr << __FILE__ << ":" << __LINE__
677  << " Client used as server." << std::endl;
678  abort();
679  }
680 
681  //
682  // Only proceed if there is a request pending
683  //
684  if (fIPC->fWatchList.fRequestPending==0) return 0;
685 
687 
688  std::vector<int> DB;
689  std::vector<int> DCM;
690  std::vector<int> FEB;
691  std::vector<int> PIX;
692 
693  this->CurrentWatchList(DB, DCM, FEB, PIX);
694 
695  for(unsigned int j = 0; j < DB.size(); ++j) {
696  fIPC->fWatchList.fDB [j] = DB [j];
697  fIPC->fWatchList.fDCM[j] = DCM[j];
698  fIPC->fWatchList.fFEB[j] = FEB[j];
699  fIPC->fWatchList.fPIX[j] = PIX[j];
700  }
701 
702  fIPC->fWatchList.fN = DB.size();
703 
706 
707  return 1;
708 }
709 
710 //......................................................................
711 
712 int IPC::Publish1DHistogram(const TH1F* h)
713 {
714  fIPC->fHistogram.fHistoOK = 0;
715  if (h==0) return 0;
716 
717  //
718  // Check the histogram name size is within limits
719  //
720  if (strlen(h->GetName()) >HISTO_NAME_SZ ) {
721  std::cerr << __FILE__ << ":" << __LINE__
722  << " Histogram name size " << strlen(h->GetName())
723  << " exceeds maximum " << HISTO_NAME_SZ << std::endl;
724  abort();
725  }
726 
727  //
728  // Test that the title will be within limits and construct it from
729  // the global title and the axis labels
730  //
731  unsigned int tsz =
732  4 + // 3 semi colons and \0
733  strlen(h->GetTitle()) + // global title
734  strlen(h->GetXaxis()->GetTitle()) + // x-axis title
735  strlen(h->GetYaxis()->GetTitle()) + // y-axis title
736  strlen(h->GetZaxis()->GetTitle()); // z-axis title
737  if (tsz>HISTO_NAME_SZ ) {
738  std::cerr << __FILE__ << ":" << __LINE__
739  << " Histogram title size " << strlen(h->GetTitle())
740  << " exceeds maximum " << HISTO_NAME_SZ << std::endl;
741  abort();
742  }
743  char title[HISTO_NAME_SZ];
744  sprintf(title,
745  "%s;%s;%s",
746  h->GetTitle(),
747  h->GetXaxis()->GetTitle(),
748  h->GetYaxis()->GetTitle());
749 
750  //
751  // Check that the number of bins will not exceed limits
752  //
753  if (h->fN>HISTO_NBINS_SZ) {
754  std::cerr << __FILE__ << ":" << __LINE__
755  << " Histogram #bins " << h->fN
756  << " exceeds maximum " << HISTO_NBINS_SZ << std::endl;
757  abort();
758  }
759 
760  strcpy(fIPC->fHistogram.fType, "TH1F");
761  strcpy(fIPC->fHistogram.fName, h->GetName());
762  strcpy(fIPC->fHistogram.fTitle, title);
763  fIPC->fHistogram.fN1 = h->GetNbinsX();
764  fIPC->fHistogram.fX1 = h->GetXaxis()->GetXmin();
765  fIPC->fHistogram.fX2 = h->GetXaxis()->GetXmax();
766  fIPC->fHistogram.fN2 = 0;
767  fIPC->fHistogram.fY1 = 0;
768  fIPC->fHistogram.fY2 = 0;
769  memcpy(fIPC->fHistogram.fData, h->fArray, h->fN*sizeof(float));
770  fIPC->fHistogram.fHistoOK = 1;
771 
772  return 1;
773 }
774 
775 //......................................................................
776 
777 int IPC::Publish2DHistogram(const TH2F* h)
778 {
779  fIPC->fHistogram.fHistoOK = 0;
780  if (h==0) return 0;
781 
782  //
783  // Check the histogram name size is within limits
784  //
785  if (strlen(h->GetName())>=HISTO_NAME_SZ ) {
786  std::cerr << __FILE__ << ":" << __LINE__
787  << " Histogram name size " << strlen(h->GetName())
788  << " exceeds maximum " << HISTO_NAME_SZ << std::endl;
789  abort();
790  }
791 
792  //
793  // Test that the title will be within limits and construct it from
794  // the global title and the axis labels
795  //
796  unsigned int tsz =
797  4 + // 3 semi colons and \0
798  strlen(h->GetTitle()) + // global title
799  strlen(h->GetXaxis()->GetTitle()) + // x-axis title
800  strlen(h->GetYaxis()->GetTitle()) + // y-axis title
801  strlen(h->GetZaxis()->GetTitle()); // z-axis title
802  if (tsz>=HISTO_NAME_SZ ) {
803  std::cerr << __FILE__ << ":" << __LINE__
804  << " Histogram title size " << strlen(h->GetTitle())
805  << " exceeds maximum " << HISTO_NAME_SZ << std::endl;
806  abort();
807  }
808  char title[HISTO_NAME_SZ];
809  sprintf(title,
810  "%s;%s;%s;%s",
811  h->GetTitle(),
812  h->GetXaxis()->GetTitle(),
813  h->GetYaxis()->GetTitle(),
814  h->GetZaxis()->GetTitle());
815 
816  //
817  // Check that the number of bins will not exceed limits
818  //
819  if (h->fN>HISTO_NBINS_SZ) {
820  std::cerr << __FILE__ << ":" << __LINE__
821  << " Histogram #bins " << h->fN
822  << " exceeds maximum " << HISTO_NBINS_SZ << std::endl;
823  abort();
824  }
825 
826  strcpy(fIPC->fHistogram.fType, "TH2F");
827  strcpy(fIPC->fHistogram.fName, h->GetName());
828  strcpy(fIPC->fHistogram.fTitle, title);
829  fIPC->fHistogram.fN1 = h->GetNbinsX();
830  fIPC->fHistogram.fX1 = h->GetXaxis()->GetXmin();
831  fIPC->fHistogram.fX2 = h->GetXaxis()->GetXmax();
832  fIPC->fHistogram.fN2 = h->GetNbinsY();
833  fIPC->fHistogram.fY1 = h->GetYaxis()->GetXmin();
834  fIPC->fHistogram.fY2 = h->GetYaxis()->GetXmax();
835  memcpy(fIPC->fHistogram.fData, h->fArray, h->fN*sizeof(float));
836  fIPC->fHistogram.fHistoOK = 1;
837 
838  return 1;
839 }
840 
841 //......................................................................
842 
844 {
848 
852  fIPC->fHistogram.fHistoOK = 0;
853 
857 
861 }
862 
863 ////////////////////////////////////////////////////////////////////////
unsigned int fSubrun
Subrun number of last update.
Definition: IPCBlock.h:39
static const unsigned int kSecond
Definition: IPC.cxx:20
static const unsigned int NMAX_HISTOS
Definition: IPCBlock.h:25
long fSTIME
System time.
Definition: IPCBlock.h:42
unsigned int fFooter
Definition: IPCBlock.h:136
unsigned int fFooter
Definition: IPCBlock.h:61
virtual void HistoList(std::list< std::string > &hlist)
Definition: IPC.h:96
std::vector< int > fDCM
int RequestAddToWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.cxx:346
int fMode
Client or server?
Definition: IPC.h:146
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
char fClientLock
Definition: IPCBlock.h:71
time_t fCLOCK
Time of update.
Definition: IPCBlock.h:46
int HandleHistoListRequests()
Definition: IPC.cxx:596
virtual TH2F * FindTH2F(const char *nm)
Definition: IPC.h:89
void PostResources(unsigned int run, unsigned int subrun, unsigned int event)
Definition: IPC.cxx:528
long fCPU
Process CPU usage.
Definition: IPCBlock.h:44
Class to manage the shared memory segment.
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:111
int HandleHistogramRequests()
Definition: IPC.cxx:550
long fRSIZE
Process size.
Definition: IPCBlock.h:45
unsigned int fHeader
Definition: IPCBlock.h:55
unsigned int fN
Definition: IPCBlock.h:59
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
int RequestHistoList(std::list< std::string > &hlist)
Definition: IPC.cxx:225
static const unsigned int BLOCK_HEADER
Definition: IPCBlock.h:15
OStream cerr
Definition: OStream.cxx:7
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
int fShmId
ID of shared memory segment.
Definition: IPC.h:147
static const int HISTO_NBINS_SZ
Definition: IPCBlock.h:22
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
unsigned int fHeader
Definition: IPCBlock.h:70
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
static const int kIPC_CLIENT
Definition: IPC.h:24
int RequestCurrentWatchList(std::vector< int > &db, std::vector< int > &dcm, std::vector< int > &feb, std::vector< int > &pix)
Definition: IPC.cxx:284
WatchList fWatchList
Definition: IPCBlock.h:135
static const unsigned int HISTO_NAME_SZ
Definition: IPCBlock.h:19
virtual void AddToWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.h:130
virtual TH1F * FindTH1F(const char *nm)
Definition: IPC.h:88
float fY1
Y range lo side.
Definition: IPCBlock.h:100
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:112
char fShmHdl[kHdlSz]
Shared memory handle.
Definition: IPC.h:149
static const int kIPC_SERVER
Definition: IPC.h:23
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:89
const XML_Char * s
Definition: expat.h:262
TH2F * UnpackTH2F()
Definition: IPC.cxx:479
int HandleRequests()
Definition: IPC.cxx:516
int fFEB
Front end board identifier.
Definition: IPCBlock.h:117
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
virtual void CurrentWatchList(std::vector< int > &db, std::vector< int > &dcm, std::vector< int > &feb, std::vector< int > &pix)
Definition: IPC.h:103
float fData[HISTO_NBINS_SZ]
Size of histogram buffer.
Definition: IPCBlock.h:102
pid_t fPID
Process ID.
Definition: IPCBlock.h:41
unsigned int fHeader
Definition: IPCBlock.h:110
char fServerLock
Definition: IPCBlock.h:72
int Publish2DHistogram(const TH2F *obj)
Definition: IPC.cxx:777
std::vector< int > fPIX
std::vector< int > fDB
const double j
Definition: BetheBloch.cxx:29
int fDB
Diblock identifier.
Definition: IPCBlock.h:115
int fAddOrRemove
Add this channel / remove this channel.
Definition: IPCBlock.h:114
char fHistoOK
Is the published histogram info OK?
Definition: IPCBlock.h:92
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:113
HistogramList fHistoList
Definition: IPCBlock.h:132
char fRequestPending
Definition: IPCBlock.h:73
unsigned int fN
Definition: IPCBlock.h:74
int HandleCurrentWatchListRequests()
Definition: IPC.cxx:673
unsigned int fFooter
Definition: IPCBlock.h:103
key_t * fKey
Shared memory key.
Definition: IPC.h:148
unsigned int fN1
Number of X bins.
Definition: IPCBlock.h:96
int fDCM
DCM identifier.
Definition: IPCBlock.h:116
void * fShm
Pointer to shared segment.
Definition: IPC.h:150
unsigned int fRun
Run number of last update.
Definition: IPCBlock.h:38
Definition: run.py:1
TH1F * h2
Definition: plot.C:45
virtual ~IPC()
Definition: IPC.cxx:94
unsigned int fN2
Number of Y bins.
Definition: IPCBlock.h:97
int HandleChangeWatchList()
Definition: IPC.cxx:637
unsigned int fNclient
Definition: IPCBlock.h:130
TH1F * h1
unsigned int fHeader
Definition: IPCBlock.h:129
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int fPIX
Pixel identifier.
Definition: IPCBlock.h:118
char fTitle[HISTO_NAME_SZ]
Histogram title.
Definition: IPCBlock.h:95
char fRequestPending
Definition: IPCBlock.h:58
TH1F * UnpackTH1F()
Definition: IPC.cxx:458
static const unsigned int BLOCK_FOOTER
Definition: IPCBlock.h:16
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
unsigned int fHeader
Definition: IPCBlock.h:88
int Publish1DHistogram(const TH1F *obj)
Definition: IPC.cxx:712
virtual void RemoveFromWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.h:132
unsigned int fEvent
Event number of last update.
Definition: IPCBlock.h:40
unsigned int fFooter
Definition: IPCBlock.h:79
exit(0)
IPC(int mode, const char *shm_handle)
Definition: IPC.cxx:26
unsigned int fFooter
Definition: IPCBlock.h:119
TH1F * RequestTH1F(const char *n)
Definition: IPC.cxx:109
static const unsigned int kWait
Definition: IPC.cxx:22
int RequestRemoveFromWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.cxx:402
TH2F * RequestTH2F(const char *n)
Definition: IPC.cxx:165
static const int kHdlSz
Definition: IPC.h:145
unsigned int fHeader
Start data block marker.
Definition: IPCBlock.h:37
float fX1
X range lo side.
Definition: IPCBlock.h:98
char fName[NMAX_HISTOS][HISTO_NAME_SZ]
Definition: IPCBlock.h:60
long fUTIME
User time.
Definition: IPCBlock.h:43
static const unsigned int kSleep
Definition: IPC.cxx:21
unsigned int fFooter
End data block marker.
Definition: IPCBlock.h:47
std::vector< int > fFEB
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:90
void ResetAllLocks()
Definition: IPC.cxx:843
int Request(const char *n, const char *t)
Definition: IPC.cxx:506
float fX2
X range hi side.
Definition: IPCBlock.h:99
ProducerResources fProcessResources
Definition: IPCBlock.h:131
float fY2
Y range hi side.
Definition: IPCBlock.h:101
Online Monitoring package header.
std::string key_t
Definition: KeyAssembler.h:71