/// Class to hold TPC MM status for /// a particular time. The class /// holds information to indicate whether: /// Low Voltages are on /// FEMs are Powered /// MM HV > 245V /// DCC Power on /// Cathode HV 24950 to 25050 V /// Blair Jamieson (C) 2010 #ifndef TECALTFBStatus_hxx__ #define TECALTFBStatus_hxx__ #include #include #include #include #include #include //#include #include "ISlowControlDatabase.hxx" #include "ITPCGas.hxx" class IECALTFBStatus { public: /// Initialize TPC MM status object using unix time /// If it is intended to use this class to read many /// sequential values, set ancache to some value large /// enough to reduce the number of sql queries IECALTFBStatus( long autime = 1224118800, long atstart= 1224118800, long atend = 1224118800); /// Initialize TPC MM status object using year, month(0-11), /// day(1-31),... IECALTFBStatus( int ayear, int amonth, int aday, int ahour, int amin, int asec=0, long atstart=0, long atend=0); /// Destructor does nothing... may leave a histogram /// floating around ~IECALTFBStatus(){}; /// Get time interval this record is valid for void GetTimeInterval(long &start_time, long &end_time); /// Get unix time for this temperature reading long GetTime(){ return fTime; } /// Get time for this reading as year, month(0-11), day(1-31),... void GetTime( int &ayear, int &amonth, int &aday, int &ahour, int &amin, int &asec); /// Set the unix time for this object, and read MM properties closest /// to this time from database void SetTime( long autime ){ fTime=autime; Read(); } /// Get unix time long GetUnixTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0); /// Set the time for this object void SetTimeNoRead( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ); /// Set the time for this object and read MM status properties void SetTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ){ SetTimeNoRead(ayear, amonth, aday, ahour, amin, asec); ReadNext(); } /// Read (increment time) and update all /// object gas property readings. Argument passed is the minimum /// time increment to use (default 120 seconds) int ReadNext(int adeltat=120); /// Return timestamp char * GetTimeStamp(){ return fTimeStamp; } /// Print variables to screen void Print(); /// Set Debug output flag void SetDebug( bool aOnOff = true ){ fDebug = aOnOff; } //irmm is 0-1 //itfb is 0-27 float Temp_E (int irmm, int itfb){ return fTempexternal[irmm][itfb]; } ///< External Temperature for given TFB int TFBStatus (int irmm, int itfb) { return fTFBStatus[irmm][itfb]; } ///< Status for given TFB = 0 for good int ECALStatus(int irmm ) { return fECALStatus[irmm]; } ///< Status for given RMM = 0 for good int Status () { return fStatus; } ///< Status for All RMM = 0 for good private: long fTime; ///< Unix time for get methods long fStart; ///< start of validity range long fEnd; ///< end of validity range long fStartTime; ///< used to keep track of ultimate time range that may be queried long fEndTime; ///< used to keep track of ultimate time range that may be queried char * fTimeStamp; ///< local time as character array (for titles) //Number of TFBs per RMM int ntfb[12]; //Try External temperatures first float fTempexternal[12][44]; float fTempexternal_next[12][44]; // float fTempexternal[56]; // float fTempexternal_next[56]; std::vector< std::string > fTempexternal_names[366]; ///< database field names for Tempexternal std::vector< std::pair< double, std::vector< double > > > fTempexternal_vec[366]; ///< external temp query result unsigned int fTempexternal_idx[366]; ///< index tofTempexternal _vec for current time bool fTempexternal_isok[366]; ///< keep track of whether db query for given time is found unsigned int fTempexternal_next_idx[366]; bool fTempexternal_next_isok[366]; //Next is the 2.5V rail float fTFB_vsupplyv2v5[12][44]; float fTFB_vsupplyv2v5_next[12][44]; std::vector< std::string > fTFB_vsupplyv2v5_names[366]; ///< database field names for TFB_vsupplyv2v5 std::vector< std::pair< double, std::vector< double > > > fTFB_vsupplyv2v5_vec[366]; ///< external 2.5V query result unsigned int fTFB_vsupplyv2v5_idx[366]; ///< index to TFB_vsupplyv2v5_vec for current time bool fTFB_vsupplyv2v5_isok[366]; ///< keep track of whether db query for given time is found unsigned int fTFB_vsupplyv2v5_next_idx[366]; bool fTFB_vsupplyv2v5_next_isok[366]; //Next is the bias voltage float fTFB_vbias[12][44]; float fTFB_vbias_next[12][44]; std::vector< std::string > fTFB_vbias_names[366]; ///< database field names for TFB_vbias std::vector< std::pair< double, std::vector< double > > > fTFB_vbias_vec[366]; ///< external bias query result unsigned int fTFB_vbias_idx[366]; ///< index to TFB_vsupplyv2v5_vec for current time bool fTFB_vbias_isok[366]; ///< keep track of whether db query for given time is found unsigned int fTFB_vbias_next_idx[366]; bool fTFB_vbias_next_isok[366]; ///< database field names for TFB_V std::string fTFB_V_tabnames[366]; /// index is [RMM][TFB] int fTFBStatus[12][44]; /// Calculate overall status for each RMM /// status is 0 if all okay /// status is maximum of TFB statuses otherwise /// index is RMM int fECALStatus[12]; /// Calculate overall status for ECAL /// status is 0 if everything is okay /// status is maximum of RMM statuses otherwise int fStatus; bool fDebug; ///< Flag to print debug information to std::cout /// Set character timestamp from integer unix timestamp void SetupTimeStamp(); /// Read the TFB system readings void Read( int adeltat=120 ); /// Initialize TFB system object Sets offsets, makes histogram, /// reads properties, and fills histogram? void Init(); /// sets up the field names that are read from the slow control database void SetupFieldNames(); /// Update Status done after every read void UpdateStatus(); /// Check if any of the slow control vectors need an update void CheckReadDB( int adeltat = 120 ); // Read another chunk of data from slow control database void ReadSlowTempexternal(int adeltat = 120); void ReadSlowV2V5(int adeltat = 120); void ReadSlowVbias(int adeltat = 120); /// Get index into each of the vectors of database query /// results for the current time void UpdateVectorTimeIdx( int adeltat=120 ); }; #endif //TECALTFBStatus_hxx__