Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:53

0001 #ifndef __PMONSTATE__
0002 #define __PMONSTATE__
0003 
0004 #define ETSTREAM   1001
0005 #define FILESTREAM 1002
0006 #define TESTSTREAM 1003
0007 #define RCDAQSTREAM 1004
0008 
0009 #include "Event/Eventiterator.h"
0010 
0011 #include "Event/msg_profile.h"
0012 #include "Event/msg_control.h"
0013 
0014 #include <iostream>
0015 
0016 class pmonstate
0017 { 
0018 
0019   friend std::ostream& operator<< (std::ostream& os, pmonstate &c)
0020     {
0021       //      std::cout << "Status:" << std::endl;
0022 
0023       if (c.isRunning())
0024         {
0025           std::cout << "Running at Event " << c.getNoevt() << "  ";
0026         }
0027       else
0028     {
0029         std::cout << "Not running  ";
0030     }
0031 
0032       if ( c.streamOpened() )
0033         {
0034           os << "Stream open:  ";
0035         }
0036       else
0037         {
0038           os << "no stream open.";
0039         }
0040       return os;
0041     };
0042 
0043 
0044 
0045  private:
0046   int stream;
0047   int initstatus;
0048   int eventloopexitstatus;
0049   int running;
0050   int number_of_events;
0051   char * Name;
0052   int idflag;
0053 
0054 //  Eventiterator * it;
0055 
0056  public:
0057   pmonstate()
0058     {
0059       eventloopexitstatus = 0;
0060 
0061 
0062       idflag = stream = running = number_of_events = 0;
0063       Name = 0;
0064       msg_control *Message = new msg_control(MSG_TYPE_ONLINE,
0065                                          MSG_SOURCE_ET,
0066                                          MSG_SEV_INFORMATIONAL, "pmonitor");
0067       std::cout << *Message << "Welcome to pmonitor.  Type phelp() for help " << std::endl;
0068       delete Message;
0069       initstatus = pinit();
0070     };
0071 
0072   virtual ~pmonstate()
0073     {
0074       if (Name)
0075         delete [] Name;
0076     };
0077 
0078   inline virtual int streamOpened() const
0079     {
0080       return stream;
0081     };
0082 
0083   virtual int setETOpened(const char *name )
0084     {
0085       stream = ETSTREAM;
0086       Name = new char[strlen(name) + 1];
0087       strcpy (Name, name);
0088       return 0;
0089     };
0090 
0091   virtual int setFileOpened(const char *name)
0092     {
0093       stream = FILESTREAM;
0094       Name = new char[strlen(name) + 1];
0095       strcpy (Name, name);
0096       return 0;
0097     };
0098 
0099   virtual int setRCDAQOpened(const char *name)
0100     {
0101       stream = RCDAQSTREAM;
0102       Name = new char[strlen(name) + 1];
0103       strcpy (Name, name);
0104       return 0;
0105     };
0106 
0107   virtual int setTestOpened()
0108     {
0109       stream = TESTSTREAM;
0110       Name = new char[strlen("Test") + 1];
0111       strcpy (Name, "Test");
0112       return 0;
0113     };
0114 
0115   virtual int clearOpened()
0116     {
0117       stream = 0;
0118       delete [] Name;
0119       Name = 0;
0120       return 0;
0121     };
0122 
0123 
0124   virtual int isRunning() const
0125     {
0126       return running;
0127       return 0;
0128     };
0129 
0130   virtual int setRunning()
0131     {
0132       running = 1;
0133       return 0;
0134     };
0135 
0136   virtual int clearRunning()
0137     {
0138       running = 0;
0139       return 0;
0140     }
0141 
0142   virtual int isBroken() const
0143     {
0144       return initstatus;
0145     }
0146 
0147 
0148   virtual int getNoevt() const
0149     {
0150       return number_of_events;
0151     };
0152 
0153   virtual int setNoevt(const int n)
0154     {
0155       number_of_events = n ;
0156       return 0;
0157     };
0158 
0159   virtual int clearNoevt()
0160     {
0161       number_of_events = 0 ;
0162       return 0;
0163     };
0164 
0165   virtual int incrementNoevt()
0166     {
0167       number_of_events++;
0168       return 0;
0169     };
0170 
0171   virtual int getloopStatus()
0172     {
0173       return eventloopexitstatus;
0174     };
0175 
0176   virtual void setloopStatus(const int s)
0177     {
0178       eventloopexitstatus = s;
0179     };
0180 
0181   virtual int setIdentifyFlag(const int n = -1)
0182     {
0183       idflag = n;
0184       return 0;
0185     };
0186 
0187   virtual int isIdentifyFlag()
0188     {
0189       int i = idflag;
0190       if (idflag > 0)
0191         {
0192           idflag--;
0193         }
0194       return i;
0195     };
0196 
0197   virtual char *name() const
0198     {
0199       return Name;
0200     }
0201 };
0202 
0203 #endif /* __PMONSTATE__ */