/// Class to hold magnet current as read from /// slow control database for a given time range /// Blair Jamieson (C) 2010 #ifndef TMagnetCurrent_hxx__ #define TMagnetCurrent_hxx__ #include #include #include "ISlowControlDatabase.hxx" #include "IAvgRMSPlot.hxx" #include "ICOMETEvent.hxx" #include "IEventFolder.hxx" #include "ICOMETContext.hxx" #include "oaOfflineDatabaseUtils.hxx" #include /// Class to hold magnet current as read from /// slow control database for a given time range /// Blair Jamieson (C) 2010 class IMagnetCurrent { public: /// Initialize magnet current object using unix times IMagnetCurrent( long autimemin = 1224118800, long autimemax = 1224118800 ); /// Initialize magnet current object using year, month(0-11), /// day(1-31),... IMagnetCurrent( int ayearmin, int amonthmin, int adaymin, int ahourmin, int aminmin, int asecmin, int ayearmax, int amonthmax, int adaymax, int ahourmax, int aminmax, int asecmax ); /// Destructor does nothing ~IMagnetCurrent(){}; /// Get time interval current reading is valid for void GetTimeInterval(long &start_time, long &end_time); /// Get unix time for this magnet current 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 gas properties closest /// to this time from database void SetTime( long autime ){ fTime=autime; Read(); } /// Get unix time given day, mont, year, ... long GetUnixTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0); /// Set the time for this object, but don't read yet void SetTimeNoRead( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ); /// Set the time for this object and read magnet current void SetTime( int ayear, int amonth, int aday, int ahour, int amin, int asec=0 ){ SetTimeNoRead(ayear, amonth, aday, ahour, amin, asec); Read(); } /// Read (increment time) and update all /// current reading. Argument passed is the minimum /// time increment to use (default 3 seconds) int ReadNext(int adeltat=3); /// Return timestamp for current reading char * GetTimeStamp(){ return fTimeStamp; } /// Print current to screen void Print(); // Access methods float GetI (){ return fI; } ///< Magnet current (A) float GetIAvg(){ return fIAvg.fmean;} ///< Average magnet current over full time range (A) float GetIRms(){ return fIAvg.frms; } ///< Rms magnet current over full time range (A) float GetIMin(){ return fIAvg.fmin; } ///< Minimum current reading float GetIMax(){ return fIAvg.fmax; } ///< Minimum current reading /// Plot current vs time void MakePlot(char * aname="MagI"){ fIAvg.MakePlot(aname); } /// Check if readings for current time are valid bool DBReadOK(){ return fMagI_isok; } private: long fTime; ///< Unix time for gas readings long fStart; ///< start of validity range for current gas readings long fEnd; ///< end of validity range for current gas readings long fStartTime; ///< start time for intended time range this will be used for long fEndTime; ///< end time for intended time range this will be used for char * fTimeStamp; ///< local time as character array (for titles) char * fTimeStampMin; ///< local time as character array (for titles) char * fTimeStampMax; ///< local time as character array (for titles) float fI; ///< Magnet current (A) IAvgRMSPlot fIAvg; ///< Average, RMS, min, max and plot of current /// Setup vectors of strings for field names /// that will be querried in the database void SetupFieldNames(); // values used for bulk read from slow control database std::vector< std::string > fI_names; ///< names of fields to read from PLCA /// Check if anouther chunk of data needs to be read from /// slow control database void CheckReadDB(); // Read another chunk of data from slow control database void ReadSlowDB_I(); /// > > fI_vec; ///< db query result for read from magnet currents /// Get index into each of the vectors of database query /// results for the current time void UpdateVectorTimeIdx(); unsigned int fI_idx; ///< time idx for current magnet current reading bool fMagI_isok; ///< db read ok for current PLCA /// Set character timestamp from integer unix timestamp void SetupTimeStamp(); /// Read from the database void Read(); /// Initialize void Init(); }; #endif //TMagnetCurrent_hxx__