Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
om::IPC Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/OnlineMonitoring/util/IPC.h"

Inheritance diagram for om::IPC:
om::OnMonProdIPC

Public Member Functions

 IPC (int mode, const char *shm_handle)
 
virtual ~IPC ()
 
int HandleRequests ()
 
void PostResources (unsigned int run, unsigned int subrun, unsigned int event)
 
TH1F * RequestTH1F (const char *n)
 
TH2F * RequestTH2F (const char *n)
 
int RequestHistoList (std::list< std::string > &hlist)
 
int RequestCurrentWatchList (std::vector< int > &db, std::vector< int > &dcm, std::vector< int > &feb, std::vector< int > &pix)
 
int RequestAddToWatchList (int db, int dcm, int feb, int pix)
 
int RequestRemoveFromWatchList (int db, int dcm, int feb, int pix)
 
void ResetAllLocks ()
 

Public Attributes

int fMode
 Client or server? More...
 
int fShmId
 ID of shared memory segment. More...
 
key_t * fKey
 Shared memory key. More...
 
char fShmHdl [kHdlSz]
 Shared memory handle. More...
 
voidfShm
 Pointer to shared segment. More...
 
struct IPCBlockfIPC
 Pointer to struct. More...
 

Static Public Attributes

static const int kHdlSz = sizeof(key_t)+1
 

Private Member Functions

virtual TH1F * FindTH1F (const char *nm)
 
virtual TH2F * FindTH2F (const char *nm)
 
virtual void HistoList (std::list< std::string > &hlist)
 
virtual void CurrentWatchList (std::vector< int > &db, std::vector< int > &dcm, std::vector< int > &feb, std::vector< int > &pix)
 
int Request (const char *n, const char *t)
 
TH1F * UnpackTH1F ()
 
TH2F * UnpackTH2F ()
 
int Publish1DHistogram (const TH1F *obj)
 
int Publish2DHistogram (const TH2F *obj)
 
virtual void AddToWatchList (int db, int dcm, int feb, int pix)
 
virtual void RemoveFromWatchList (int db, int dcm, int feb, int pix)
 
int HandleHistogramRequests ()
 
int HandleHistoListRequests ()
 
int HandleChangeWatchList ()
 
int HandleCurrentWatchListRequests ()
 

Detailed Description

Class to manage the shared memory segment

Definition at line 29 of file IPC.h.

Constructor & Destructor Documentation

IPC::IPC ( int  mode,
const char *  shm_handle 
)

Definition at line 26 of file IPC.cxx.

References BLOCK_FOOTER, BLOCK_HEADER, om::cerr, allTimeWatchdog::endl, exit(), om::IPCBlock::fChangeWatchList, om::ProducerResources::fFooter, om::HistogramList::fFooter, om::WatchList::fFooter, om::ProducerHistogram::fFooter, om::ChangeWatchList::fFooter, om::IPCBlock::fFooter, om::ProducerResources::fHeader, om::HistogramList::fHeader, om::WatchList::fHeader, om::ProducerHistogram::fHeader, om::ChangeWatchList::fHeader, om::IPCBlock::fHeader, om::IPCBlock::fHistogram, om::IPCBlock::fHistoList, fIPC, fKey, fMode, om::IPCBlock::fNclient, om::IPCBlock::fProcessResources, fShm, fShmHdl, fShmId, om::IPCBlock::fWatchList, MECModelEnuComparisons::i, kHdlSz, om::kIPC_CLIENT, om::kIPC_SERVER, kSecond, and kSleep.

26  : 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 }
static const unsigned int kSecond
Definition: IPC.cxx:20
unsigned int fFooter
Definition: IPCBlock.h:136
unsigned int fFooter
Definition: IPCBlock.h:61
int fMode
Client or server?
Definition: IPC.h:146
unsigned int fHeader
Definition: IPCBlock.h:55
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
static const unsigned int BLOCK_HEADER
Definition: IPCBlock.h:15
OStream cerr
Definition: OStream.cxx:7
int fShmId
ID of shared memory segment.
Definition: IPC.h:147
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
unsigned int fHeader
Definition: IPCBlock.h:70
static const int kIPC_CLIENT
Definition: IPC.h:24
WatchList fWatchList
Definition: IPCBlock.h:135
char fShmHdl[kHdlSz]
Shared memory handle.
Definition: IPC.h:149
static const int kIPC_SERVER
Definition: IPC.h:23
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
unsigned int fHeader
Definition: IPCBlock.h:110
HistogramList fHistoList
Definition: IPCBlock.h:132
unsigned int fFooter
Definition: IPCBlock.h:103
key_t * fKey
Shared memory key.
Definition: IPC.h:148
void * fShm
Pointer to shared segment.
Definition: IPC.h:150
unsigned int fNclient
Definition: IPCBlock.h:130
unsigned int fHeader
Definition: IPCBlock.h:129
static const unsigned int BLOCK_FOOTER
Definition: IPCBlock.h:16
unsigned int fHeader
Definition: IPCBlock.h:88
unsigned int fFooter
Definition: IPCBlock.h:79
exit(0)
unsigned int fFooter
Definition: IPCBlock.h:119
static const int kHdlSz
Definition: IPC.h:145
unsigned int fHeader
Start data block marker.
Definition: IPCBlock.h:37
static const unsigned int kSleep
Definition: IPC.cxx:21
unsigned int fFooter
End data block marker.
Definition: IPCBlock.h:47
ProducerResources fProcessResources
Definition: IPCBlock.h:131
std::string key_t
Definition: KeyAssembler.h:71
IPC::~IPC ( )
virtual

Definition at line 94 of file IPC.cxx.

References fIPC, fMode, om::IPCBlock::fNclient, fShm, fShmId, om::kIPC_CLIENT, and om::kIPC_SERVER.

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 }
int fMode
Client or server?
Definition: IPC.h:146
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
int fShmId
ID of shared memory segment.
Definition: IPC.h:147
static const int kIPC_CLIENT
Definition: IPC.h:24
static const int kIPC_SERVER
Definition: IPC.h:23
void * fShm
Pointer to shared segment.
Definition: IPC.h:150
unsigned int fNclient
Definition: IPCBlock.h:130

Member Function Documentation

virtual void om::IPC::AddToWatchList ( int  db,
int  dcm,
int  feb,
int  pix 
)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 130 of file IPC.h.

Referenced by HandleChangeWatchList().

131  { abort(); }
virtual void om::IPC::CurrentWatchList ( std::vector< int > &  db,
std::vector< int > &  dcm,
std::vector< int > &  feb,
std::vector< int > &  pix 
)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 103 of file IPC.h.

References Publish1DHistogram(), Publish2DHistogram(), Request(), confusionMatrixTree::t, UnpackTH1F(), and UnpackTH2F().

Referenced by HandleCurrentWatchListRequests().

106  { abort(); }
virtual TH1F* om::IPC::FindTH1F ( const char *  nm)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 88 of file IPC.h.

Referenced by HandleHistogramRequests().

88 { return 0; }
virtual TH2F* om::IPC::FindTH2F ( const char *  nm)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 89 of file IPC.h.

Referenced by HandleHistogramRequests().

89 { return 0; }
int IPC::HandleChangeWatchList ( )
private

Definition at line 637 of file IPC.cxx.

References AddToWatchList(), om::cerr, allTimeWatchdog::endl, om::ChangeWatchList::fAddOrRemove, om::IPCBlock::fChangeWatchList, om::ChangeWatchList::fDB, om::ChangeWatchList::fDCM, om::ChangeWatchList::fFEB, fIPC, fMode, om::ChangeWatchList::fPIX, om::ChangeWatchList::fRequestPending, om::ChangeWatchList::fServerLock, om::kIPC_CLIENT, and RemoveFromWatchList().

Referenced by HandleRequests(), and RemoveFromWatchList().

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 }
int fMode
Client or server?
Definition: IPC.h:146
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
static const int kIPC_CLIENT
Definition: IPC.h:24
virtual void AddToWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.h:130
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:112
int fFEB
Front end board identifier.
Definition: IPCBlock.h:117
int fDB
Diblock identifier.
Definition: IPCBlock.h:115
int fAddOrRemove
Add this channel / remove this channel.
Definition: IPCBlock.h:114
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:113
int fDCM
DCM identifier.
Definition: IPCBlock.h:116
int fPIX
Pixel identifier.
Definition: IPCBlock.h:118
virtual void RemoveFromWatchList(int db, int dcm, int feb, int pix)
Definition: IPC.h:132
int IPC::HandleCurrentWatchListRequests ( )
private

Definition at line 673 of file IPC.cxx.

References om::cerr, CurrentWatchList(), allTimeWatchdog::endl, om::WatchList::fDB, om::WatchList::fDCM, om::WatchList::fFEB, fIPC, fMode, om::WatchList::fN, om::WatchList::fPIX, om::WatchList::fRequestPending, om::WatchList::fServerLock, om::IPCBlock::fWatchList, calib::j, and om::kIPC_CLIENT.

Referenced by HandleRequests(), and RemoveFromWatchList().

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 }
std::vector< int > fDCM
int fMode
Client or server?
Definition: IPC.h:146
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
static const int kIPC_CLIENT
Definition: IPC.h:24
WatchList fWatchList
Definition: IPCBlock.h:135
virtual void CurrentWatchList(std::vector< int > &db, std::vector< int > &dcm, std::vector< int > &feb, std::vector< int > &pix)
Definition: IPC.h:103
char fServerLock
Definition: IPCBlock.h:72
std::vector< int > fPIX
std::vector< int > fDB
const double j
Definition: BetheBloch.cxx:29
char fRequestPending
Definition: IPCBlock.h:73
unsigned int fN
Definition: IPCBlock.h:74
std::vector< int > fFEB
int IPC::HandleHistogramRequests ( )
private

Definition at line 550 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::IPCBlock::fHistogram, FindTH1F(), FindTH2F(), fIPC, fMode, om::ProducerHistogram::fName, om::ProducerHistogram::fRequestPending, om::ProducerHistogram::fServerLock, om::ProducerHistogram::fType, h1, h2, om::kIPC_CLIENT, Publish1DHistogram(), Publish2DHistogram(), and string.

Referenced by HandleRequests(), and RemoveFromWatchList().

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 }
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
virtual TH2F * FindTH2F(const char *nm)
Definition: IPC.h:89
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
static const int kIPC_CLIENT
Definition: IPC.h:24
virtual TH1F * FindTH1F(const char *nm)
Definition: IPC.h:88
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
int Publish2DHistogram(const TH2F *obj)
Definition: IPC.cxx:777
TH1F * h2
Definition: plot.C:45
TH1F * h1
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
int Publish1DHistogram(const TH1F *obj)
Definition: IPC.cxx:712
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:90
enum BeamMode string
int IPC::HandleHistoListRequests ( )
private

Definition at line 596 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::IPCBlock::fHistoList, fIPC, fMode, om::HistogramList::fN, om::HistogramList::fName, om::HistogramList::fRequestPending, om::HistogramList::fServerLock, HistoList(), om::kIPC_CLIENT, getGoodRuns4SAM::n, and NMAX_HISTOS.

Referenced by HandleRequests(), and RemoveFromWatchList().

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 }
static const unsigned int NMAX_HISTOS
Definition: IPCBlock.h:25
virtual void HistoList(std::list< std::string > &hlist)
Definition: IPC.h:96
int fMode
Client or server?
Definition: IPC.h:146
unsigned int fN
Definition: IPCBlock.h:59
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
static const int kIPC_CLIENT
Definition: IPC.h:24
HistogramList fHistoList
Definition: IPCBlock.h:132
char fRequestPending
Definition: IPCBlock.h:58
char fName[NMAX_HISTOS][HISTO_NAME_SZ]
Definition: IPCBlock.h:60
int IPC::HandleRequests ( )

Method for server application check to see if there are any requests pending

Definition at line 516 of file IPC.cxx.

References HandleChangeWatchList(), HandleCurrentWatchListRequests(), HandleHistogramRequests(), and HandleHistoListRequests().

Referenced by om::OnMonProd::analyze().

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 }
int HandleHistoListRequests()
Definition: IPC.cxx:596
int HandleHistogramRequests()
Definition: IPC.cxx:550
int HandleCurrentWatchListRequests()
Definition: IPC.cxx:673
int HandleChangeWatchList()
Definition: IPC.cxx:637
virtual void om::IPC::HistoList ( std::list< std::string > &  hlist)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 96 of file IPC.h.

Referenced by HandleHistoListRequests().

96 { abort(); }
void IPC::PostResources ( unsigned int  run,
unsigned int  subrun,
unsigned int  event 
)

Post information about producer resource usage

Definition at line 528 of file IPC.cxx.

References om::ProducerResources::fCLOCK, om::ProducerResources::fCPU, om::ProducerResources::fEvent, fIPC, om::ProducerResources::fPID, om::IPCBlock::fProcessResources, om::ProducerResources::fRSIZE, om::ProducerResources::fRun, om::ProducerResources::fSTIME, om::ProducerResources::fSubrun, om::ProducerResources::fUTIME, updateRunHistoryTables::run, and getGoodRuns4SAM::subrun.

Referenced by om::OnMonProd::analyze().

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 }
unsigned int fSubrun
Subrun number of last update.
Definition: IPCBlock.h:39
long fSTIME
System time.
Definition: IPCBlock.h:42
time_t fCLOCK
Time of update.
Definition: IPCBlock.h:46
long fCPU
Process CPU usage.
Definition: IPCBlock.h:44
long fRSIZE
Process size.
Definition: IPCBlock.h:45
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
pid_t fPID
Process ID.
Definition: IPCBlock.h:41
unsigned int fRun
Run number of last update.
Definition: IPCBlock.h:38
unsigned int fEvent
Event number of last update.
Definition: IPCBlock.h:40
TRandom3 r(0)
long fUTIME
User time.
Definition: IPCBlock.h:43
ProducerResources fProcessResources
Definition: IPCBlock.h:131
int IPC::Publish1DHistogram ( const TH1F *  obj)
private

Definition at line 712 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::ProducerHistogram::fData, om::IPCBlock::fHistogram, om::ProducerHistogram::fHistoOK, fIPC, om::ProducerHistogram::fN1, om::ProducerHistogram::fN2, om::ProducerHistogram::fName, om::ProducerHistogram::fTitle, om::ProducerHistogram::fType, om::ProducerHistogram::fX1, om::ProducerHistogram::fX2, om::ProducerHistogram::fY1, om::ProducerHistogram::fY2, HISTO_NAME_SZ, HISTO_NBINS_SZ, and plotROC::title.

Referenced by CurrentWatchList(), and HandleHistogramRequests().

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 }
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
static const int HISTO_NBINS_SZ
Definition: IPCBlock.h:22
static const unsigned int HISTO_NAME_SZ
Definition: IPCBlock.h:19
float fY1
Y range lo side.
Definition: IPCBlock.h:100
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
float fData[HISTO_NBINS_SZ]
Size of histogram buffer.
Definition: IPCBlock.h:102
char fHistoOK
Is the published histogram info OK?
Definition: IPCBlock.h:92
unsigned int fN1
Number of X bins.
Definition: IPCBlock.h:96
unsigned int fN2
Number of Y bins.
Definition: IPCBlock.h:97
char fTitle[HISTO_NAME_SZ]
Histogram title.
Definition: IPCBlock.h:95
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
float fX1
X range lo side.
Definition: IPCBlock.h:98
float fX2
X range hi side.
Definition: IPCBlock.h:99
float fY2
Y range hi side.
Definition: IPCBlock.h:101
int IPC::Publish2DHistogram ( const TH2F *  obj)
private

Definition at line 777 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::ProducerHistogram::fData, om::IPCBlock::fHistogram, om::ProducerHistogram::fHistoOK, fIPC, om::ProducerHistogram::fN1, om::ProducerHistogram::fN2, om::ProducerHistogram::fName, om::ProducerHistogram::fTitle, om::ProducerHistogram::fType, om::ProducerHistogram::fX1, om::ProducerHistogram::fX2, om::ProducerHistogram::fY1, om::ProducerHistogram::fY2, HISTO_NAME_SZ, HISTO_NBINS_SZ, and plotROC::title.

Referenced by CurrentWatchList(), and HandleHistogramRequests().

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 }
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
static const int HISTO_NBINS_SZ
Definition: IPCBlock.h:22
static const unsigned int HISTO_NAME_SZ
Definition: IPCBlock.h:19
float fY1
Y range lo side.
Definition: IPCBlock.h:100
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
float fData[HISTO_NBINS_SZ]
Size of histogram buffer.
Definition: IPCBlock.h:102
char fHistoOK
Is the published histogram info OK?
Definition: IPCBlock.h:92
unsigned int fN1
Number of X bins.
Definition: IPCBlock.h:96
unsigned int fN2
Number of Y bins.
Definition: IPCBlock.h:97
char fTitle[HISTO_NAME_SZ]
Histogram title.
Definition: IPCBlock.h:95
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
float fX1
X range lo side.
Definition: IPCBlock.h:98
float fX2
X range hi side.
Definition: IPCBlock.h:99
float fY2
Y range hi side.
Definition: IPCBlock.h:101
virtual void om::IPC::RemoveFromWatchList ( int  db,
int  dcm,
int  feb,
int  pix 
)
inlineprivatevirtual

Reimplemented in om::OnMonProdIPC.

Definition at line 132 of file IPC.h.

References HandleChangeWatchList(), HandleCurrentWatchListRequests(), HandleHistogramRequests(), and HandleHistoListRequests().

Referenced by HandleChangeWatchList().

133  { abort(); }
int IPC::Request ( const char *  n,
const char *  t 
)
private

Submit a request to the server. It is assumed that the caller has already checked that the server and client locks are clear

Definition at line 506 of file IPC.cxx.

References om::IPCBlock::fHistogram, fIPC, om::ProducerHistogram::fName, om::ProducerHistogram::fRequestPending, and om::ProducerHistogram::fType.

Referenced by CurrentWatchList(), RequestTH1F(), and RequestTH2F().

507 {
509  strcpy(fIPC->fHistogram.fName, n);
510  strcpy(fIPC->fHistogram.fType, t);
511  return 1;
512 }
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
int IPC::RequestAddToWatchList ( int  db,
int  dcm,
int  feb,
int  pix 
)

Client tells server to add item to the watchlist db, dcm, feb, pix = hardware to be added

Parameters
sel= selected item to be removed
Returns
1 if aok

Definition at line 346 of file IPC.cxx.

References om::cerr, febshutoff_auto::db, febshutoff_auto::dcm, allTimeWatchdog::endl, om::ChangeWatchList::fAddOrRemove, om::IPCBlock::fChangeWatchList, om::ChangeWatchList::fClientLock, om::ChangeWatchList::fDB, om::ChangeWatchList::fDCM, APDHVSetting::feb, om::ChangeWatchList::fFEB, fIPC, fMode, om::ChangeWatchList::fPIX, om::ChangeWatchList::fRequestPending, om::ChangeWatchList::fServerLock, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, and kWait.

Referenced by om::WatchListBox::HandleAddToList().

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 }
int fMode
Client or server?
Definition: IPC.h:146
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:111
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:112
static const int kIPC_SERVER
Definition: IPC.h:23
int fFEB
Front end board identifier.
Definition: IPCBlock.h:117
int fDB
Diblock identifier.
Definition: IPCBlock.h:115
int fAddOrRemove
Add this channel / remove this channel.
Definition: IPCBlock.h:114
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:113
int fDCM
DCM identifier.
Definition: IPCBlock.h:116
int fPIX
Pixel identifier.
Definition: IPCBlock.h:118
static const unsigned int kWait
Definition: IPC.cxx:22
static const unsigned int kSleep
Definition: IPC.cxx:21
int IPC::RequestCurrentWatchList ( std::vector< int > &  db,
std::vector< int > &  dcm,
std::vector< int > &  feb,
std::vector< int > &  pix 
)

Client call to request the current watchlist

Definition at line 284 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::WatchList::fClientLock, om::WatchList::fDB, om::WatchList::fDCM, om::WatchList::fFEB, fIPC, fMode, om::WatchList::fN, om::WatchList::fPIX, om::WatchList::fRequestPending, om::WatchList::fServerLock, om::IPCBlock::fWatchList, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, and kWait.

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 }
std::vector< int > fDCM
int fMode
Client or server?
Definition: IPC.h:146
char fClientLock
Definition: IPCBlock.h:71
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
WatchList fWatchList
Definition: IPCBlock.h:135
static const int kIPC_SERVER
Definition: IPC.h:23
char fServerLock
Definition: IPCBlock.h:72
std::vector< int > fPIX
std::vector< int > fDB
char fRequestPending
Definition: IPCBlock.h:73
unsigned int fN
Definition: IPCBlock.h:74
static const unsigned int kWait
Definition: IPC.cxx:22
static const unsigned int kSleep
Definition: IPC.cxx:21
std::vector< int > fFEB
int IPC::RequestHistoList ( std::list< std::string > &  hlist)

Client call to request the histogram list

Definition at line 225 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::HistogramList::fClientLock, om::IPCBlock::fHistoList, fIPC, fMode, om::HistogramList::fN, om::HistogramList::fName, om::HistogramList::fRequestPending, om::HistogramList::fServerLock, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, and kWait.

Referenced by om::HistoSHM::GetHistogramList().

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 }
int fMode
Client or server?
Definition: IPC.h:146
unsigned int fN
Definition: IPCBlock.h:59
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
static const int kIPC_SERVER
Definition: IPC.h:23
HistogramList fHistoList
Definition: IPCBlock.h:132
char fRequestPending
Definition: IPCBlock.h:58
static const unsigned int kWait
Definition: IPC.cxx:22
char fName[NMAX_HISTOS][HISTO_NAME_SZ]
Definition: IPCBlock.h:60
static const unsigned int kSleep
Definition: IPC.cxx:21
int IPC::RequestRemoveFromWatchList ( int  db,
int  dcm,
int  feb,
int  pix 
)

Definition at line 402 of file IPC.cxx.

References om::cerr, febshutoff_auto::db, febshutoff_auto::dcm, allTimeWatchdog::endl, om::ChangeWatchList::fAddOrRemove, om::IPCBlock::fChangeWatchList, om::ChangeWatchList::fClientLock, om::ChangeWatchList::fDB, om::ChangeWatchList::fDCM, APDHVSetting::feb, om::ChangeWatchList::fFEB, fIPC, fMode, om::ChangeWatchList::fPIX, om::ChangeWatchList::fRequestPending, om::ChangeWatchList::fServerLock, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, and kWait.

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 }
int fMode
Client or server?
Definition: IPC.h:146
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:111
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:112
static const int kIPC_SERVER
Definition: IPC.h:23
int fFEB
Front end board identifier.
Definition: IPCBlock.h:117
int fDB
Diblock identifier.
Definition: IPCBlock.h:115
int fAddOrRemove
Add this channel / remove this channel.
Definition: IPCBlock.h:114
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:113
int fDCM
DCM identifier.
Definition: IPCBlock.h:116
int fPIX
Pixel identifier.
Definition: IPCBlock.h:118
static const unsigned int kWait
Definition: IPC.cxx:22
static const unsigned int kSleep
Definition: IPC.cxx:21
TH1F * IPC::RequestTH1F ( const char *  n)

Client calls to request a histogram from the server.

Parameters
n- name of histogram to retrieve
Returns
A new histogram. Called takes ownership

Definition at line 109 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::ProducerHistogram::fClientLock, om::IPCBlock::fHistogram, fIPC, fMode, om::ProducerHistogram::fRequestPending, om::ProducerHistogram::fServerLock, make_syst_table_plots::h, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, kWait, Request(), and UnpackTH1F().

Referenced by om::HistoSHM::GetTH1FCopy().

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 }
int fMode
Client or server?
Definition: IPC.h:146
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
static const int kIPC_SERVER
Definition: IPC.h:23
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:89
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
TH1F * UnpackTH1F()
Definition: IPC.cxx:458
static const unsigned int kWait
Definition: IPC.cxx:22
static const unsigned int kSleep
Definition: IPC.cxx:21
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:90
int Request(const char *n, const char *t)
Definition: IPC.cxx:506
TH2F * IPC::RequestTH2F ( const char *  n)

Definition at line 165 of file IPC.cxx.

References om::cerr, allTimeWatchdog::endl, om::ProducerHistogram::fClientLock, om::IPCBlock::fHistogram, fIPC, fMode, om::ProducerHistogram::fRequestPending, om::ProducerHistogram::fServerLock, make_syst_table_plots::h, MECModelEnuComparisons::i, om::kIPC_SERVER, kSleep, kWait, Request(), and UnpackTH2F().

Referenced by om::HistoSHM::GetTH2FCopy().

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 }
int fMode
Client or server?
Definition: IPC.h:146
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
OStream cerr
Definition: OStream.cxx:7
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
static const int kIPC_SERVER
Definition: IPC.h:23
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:89
TH2F * UnpackTH2F()
Definition: IPC.cxx:479
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
static const unsigned int kWait
Definition: IPC.cxx:22
static const unsigned int kSleep
Definition: IPC.cxx:21
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:90
int Request(const char *n, const char *t)
Definition: IPC.cxx:506
void IPC::ResetAllLocks ( )

For "emergency use" only. Clear all locks in the event they get stuck.

Definition at line 843 of file IPC.cxx.

References om::IPCBlock::fChangeWatchList, om::HistogramList::fClientLock, om::WatchList::fClientLock, om::ProducerHistogram::fClientLock, om::ChangeWatchList::fClientLock, om::IPCBlock::fHistogram, om::IPCBlock::fHistoList, om::ProducerHistogram::fHistoOK, fIPC, om::HistogramList::fRequestPending, om::WatchList::fRequestPending, om::ProducerHistogram::fRequestPending, om::ChangeWatchList::fRequestPending, om::HistogramList::fServerLock, om::WatchList::fServerLock, om::ProducerHistogram::fServerLock, om::ChangeWatchList::fServerLock, and om::IPCBlock::fWatchList.

Referenced by om::MenuBar::ResetLocks().

844 {
848 
852  fIPC->fHistogram.fHistoOK = 0;
853 
857 
861 }
char fClientLock
Definition: IPCBlock.h:71
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:111
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
char fRequestPending
Is there a request pending?
Definition: IPCBlock.h:91
ChangeWatchList fChangeWatchList
Definition: IPCBlock.h:134
WatchList fWatchList
Definition: IPCBlock.h:135
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:112
char fClientLock
Is access locked by the server?
Definition: IPCBlock.h:89
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
char fServerLock
Definition: IPCBlock.h:72
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
char fRequestPending
Definition: IPCBlock.h:58
char fServerLock
Is access locked by the client?
Definition: IPCBlock.h:90
TH1F * IPC::UnpackTH1F ( )
private

Definition at line 458 of file IPC.cxx.

References om::ProducerHistogram::fData, om::IPCBlock::fHistogram, om::ProducerHistogram::fHistoOK, fIPC, om::ProducerHistogram::fN1, om::ProducerHistogram::fName, om::ProducerHistogram::fTitle, om::ProducerHistogram::fType, om::ProducerHistogram::fX1, om::ProducerHistogram::fX2, make_syst_table_plots::h, MECModelEnuComparisons::i, and string.

Referenced by CurrentWatchList(), and RequestTH1F().

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 }
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
const XML_Char * s
Definition: expat.h:262
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
float fData[HISTO_NBINS_SZ]
Size of histogram buffer.
Definition: IPCBlock.h:102
char fHistoOK
Is the published histogram info OK?
Definition: IPCBlock.h:92
unsigned int fN1
Number of X bins.
Definition: IPCBlock.h:96
char fTitle[HISTO_NAME_SZ]
Histogram title.
Definition: IPCBlock.h:95
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
float fX1
X range lo side.
Definition: IPCBlock.h:98
float fX2
X range hi side.
Definition: IPCBlock.h:99
enum BeamMode string
TH2F * IPC::UnpackTH2F ( )
private

Definition at line 479 of file IPC.cxx.

References om::ProducerHistogram::fData, om::IPCBlock::fHistogram, om::ProducerHistogram::fHistoOK, fIPC, om::ProducerHistogram::fN1, om::ProducerHistogram::fN2, om::ProducerHistogram::fName, om::ProducerHistogram::fTitle, om::ProducerHistogram::fType, om::ProducerHistogram::fX1, om::ProducerHistogram::fX2, om::ProducerHistogram::fY1, om::ProducerHistogram::fY2, make_syst_table_plots::h, MECModelEnuComparisons::i, and string.

Referenced by CurrentWatchList(), and RequestTH2F().

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 }
char fName[HISTO_NAME_SZ]
What is the name of this histogram?
Definition: IPCBlock.h:94
struct IPCBlock * fIPC
Pointer to struct.
Definition: IPC.h:151
float fY1
Y range lo side.
Definition: IPCBlock.h:100
const XML_Char * s
Definition: expat.h:262
ProducerHistogram fHistogram
Definition: IPCBlock.h:133
float fData[HISTO_NBINS_SZ]
Size of histogram buffer.
Definition: IPCBlock.h:102
char fHistoOK
Is the published histogram info OK?
Definition: IPCBlock.h:92
unsigned int fN1
Number of X bins.
Definition: IPCBlock.h:96
unsigned int fN2
Number of Y bins.
Definition: IPCBlock.h:97
char fTitle[HISTO_NAME_SZ]
Histogram title.
Definition: IPCBlock.h:95
char fType[HISTO_NAME_SZ]
What type of histogram is this?
Definition: IPCBlock.h:93
float fX1
X range lo side.
Definition: IPCBlock.h:98
float fX2
X range hi side.
Definition: IPCBlock.h:99
float fY2
Y range hi side.
Definition: IPCBlock.h:101
enum BeamMode string

Member Data Documentation

struct IPCBlock* om::IPC::fIPC
key_t* om::IPC::fKey

Shared memory key.

Definition at line 148 of file IPC.h.

Referenced by IPC().

int om::IPC::fMode
void* om::IPC::fShm

Pointer to shared segment.

Definition at line 150 of file IPC.h.

Referenced by IPC(), and ~IPC().

char om::IPC::fShmHdl[kHdlSz]

Shared memory handle.

Definition at line 149 of file IPC.h.

Referenced by om::HistoSHM::GetStatus(), and IPC().

int om::IPC::fShmId

ID of shared memory segment.

Definition at line 147 of file IPC.h.

Referenced by IPC(), and ~IPC().

const int om::IPC::kHdlSz = sizeof(key_t)+1
static

Definition at line 145 of file IPC.h.

Referenced by IPC().


The documentation for this class was generated from the following files: