QGUISmartScope.hh

00001 /*
00002  * APOLLO: A complete DAQ and Online Data Analysis Framework for Cuore
00003  * 
00004  * A.Giachero created 16/12/06 - <Andrea.Giachero@ge.infn.it> 
00005  * 
00006  $ $Id: QGUISmartScope.hh 655 2006-12-21 22:12:07Z giacher $
00007  * $Revision: 655 $
00008  *
00009  * Class QGUISmartScope: Smart Oscilloscope for real time display
00010  *
00011  */
00012 
00013 #ifndef _QGUI_SMART_SCOPE_HH_
00014 #define _QGUI_SMART_SCOPE_HH_
00015 
00016 
00017 
00018 // Apollo Includes
00019 #include "QGUIDataCollector.hh"
00020 #include "QGUIBaseFrame.hh"
00021 #include "QGUIScopeChannel.hh"
00022 
00023 #include <map>
00024 #include <vector>
00025 
00026 // ROOT Includes
00027 #include "Rtypes.h"
00028 #include "TTimer.h"
00029 #include "TH1F.h"
00030 
00031 
00032 
00033 // Used Classes
00034 class TGObject;
00035 class TRootEmbeddedCanvas;
00036 class TGNumberEntry;
00037 class TGTextEntry;
00038 class TGTextButton;
00039 class QSmartScopeChannel;
00040 class QGUINumberSelector;
00041 
00042 class QGUISmartScope: public QGUIBaseFrame
00043 {
00044 
00045 public:
00046   
00047    // ctor
00048    QGUISmartScope(const TGWindow*          p,
00049                   unsigned int             Width,
00050                   unsigned int             Height,
00051                   const QGUIDataCollector& Status);
00052 
00053    // dtor
00054    virtual ~QGUISmartScope();
00055 
00056    // ** SLOTS **   
00057    // histogram Y range
00058    void UpdateUpperEdge();
00059    void UpdateLowerEdge();
00060    void UpdateChannel();
00061 
00063    void Close();
00064   
00066    void DoRefresh();
00067    
00069    void UpdateTimeCtr();
00070 
00072    void StartHistoUpdate();
00073 
00075    void StopHistoUpdate();
00076 
00077    // toggle AutoRange flag
00078    void SetAutoRange(bool isTrue);
00079 
00080    // invert autorange status and update Gui buttons accordingly
00081    void FlipAutoRange();
00082 
00083    // Set RefreshTime on Timer
00084    void SetRefreshTime(long Time);
00085 
00086    // Start Refresh Timer
00087    void StartRefreshTime();
00088   
00089    // Stop Refresh Timer
00090    void StopRefreshTime();
00091 
00092 private:
00093   
00094 
00095    std::vector<unsigned short> fActiveChannels;
00096 
00097    // Local Obj Status
00098    const QGUIDataCollector& fStatus;
00099 
00100    // Timer for display update
00101    TTimer fRefreshTimer;
00102    TTimer fRealTimer;
00103 
00104    unsigned long fTimeCtr;
00105 
00106    bool   fIsHistoUpdate;  // if fIsHistoUpddate=true Histo Update is enabled 
00107    
00108    bool fAutoRangeChanged;
00109 
00110    // Online Scope Shared Memory 
00111    QSmartScopeChannel *fScope;
00112 
00113    // Histogram
00114    TH1F fh1;
00115   
00116    // histogram aspect handler
00117    QGUIScopeChannel fGraphix;
00118 
00119    QGUINumberSelector* fChSelector;
00120     
00121    // ******* Widget Pointers *******
00122    TGCompositeFrame*    fTopHFrame;       // Top Horizontal Frame 
00123    TGCompositeFrame*    fBottomHFrame;    // Bottom Horizontal Frame
00124    TGCompositeFrame*    fControlVFrame;   // Scope Control Vertical Frame 
00125    TGCompositeFrame*    fCanvasHFrame;    // Canvas Frame
00126    TRootEmbeddedCanvas* fEmbCanvas;       // Embedded Canvas
00127 
00128    TGCompositeFrame*    fStartStopVFrame; // Start Stop Vertical Frame;
00129   
00130    TGTextEntry*         fRunNumb;         // Text Entry for Run Number
00131    TGTextEntry*         fChDisplay;
00132 
00133    TGTextButton*        fAutoRangeBtn;    // Buttons for autorange ON/OFF
00134    TGNumberEntry*       fUpperEntry;      // Numeric Entry for Upper Choice
00135    TGNumberEntry*       fLowerEntry;      // Numeric Entry for Lower Choice
00136 
00137    TGTextEntry*         fMeanVal;         // Text Entry for Mean Value
00138    TGTextEntry*         fSigmaVal;        // Text Entry for Sigma Value
00139    TGTextEntry*         fMaxVal;          // Text Entry for Max Value (Y Axis)
00140    TGTextEntry*         fMinVal;          // Text Entry for Min Value (Y Axis)
00141 
00142    TGTextButton*        fStartBtn;        // Start Button
00143    TGTextButton*        fStopBtn;         // Stop Button
00144    TGTextButton*        fExitBtn;         // Exit Button
00145     
00146    // Init
00147    void _Init();
00148 
00149    // read list of active channels from db
00150    void GetActiveChannels();
00151 
00152    // Init Refresh Timer
00153    void _InitRefreshTimer(long Time);
00154 
00155    // Create Frames into main window
00156    void _CreateFrames();
00157 
00158    // Add Widget into Control Scope Frame
00159    void _AddLateralWidgets();
00160 
00161    // Add Buttons into Start/Stop Frame
00162    void _AddStartStopButtons();
00163   
00164    // Set all Widget Pointers to Zero;
00165    void _Zeros();
00166 
00167    // Set Histogram gStyle
00168    void _SetStyleOptions();
00169 
00170    // Draw Histogram and Update widgets
00171    void _DrawHistogram(TH1F& Histo);
00172 
00173    // ******* Boolean Getters *******
00174    inline const bool _IsHistoUpdate() const {return fIsHistoUpdate;}
00175 
00176    ClassDef(QGUISmartScope,0)
00177 };
00178 
00179 #endif // _QGUI_SMART_SCOPE_HH_

Generated on Fri Mar 6 13:40:39 2009 for CUORE Software by  doxygen 1.5.1