Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

Fitter.h

00001 #ifndef FITTER_H
00002 #define FITTER_H
00003 
00004 #include <is/isinfo.h>
00005 #include <ipc/object.h>
00006 #include <ipc/server.h>
00007 
00008 #include <string>
00009 #include <memory>
00010 
00011 #include <boost/thread.hpp>
00012 
00013 #include "FitterInterface.hh"
00014 #include "FitterArguments.h"
00015 #include "Sct/Exception.h"
00016 #include "Sct/ConfigurationException.h"
00017 #include "Sct/LogicErrors.h"
00018 #include "Sct/IoExceptions.h"
00019 
00020 class TH1;
00021 class TF1;
00022 
00023 using namespace Sct;
00024 
00028 namespace SctFitter {
00029     class FitStrategy;
00030     class FitterWorkerGroup;
00031 
00041 class Fitter:
00042   public IPCNamedObject<POA_FitterI::FitterInterface,
00043                         ipc::multi_thread>,
00044   private boost::noncopyable {
00045 private:
00047   void shutdown();
00049   Fitter(FitterArguments args) throw(ConfigurationException);
00051   ~Fitter() throw();
00052   static Fitter* fitter;
00053     
00054 public:
00059     static Fitter& instance();
00060     
00066     static Fitter& initialize(FitterArguments args) throw(ConfigurationException);
00067     
00071     void go() throw(IsException);
00072   private:
00073     // INTERNAL METHODS:
00077     const char* internal_status() const throw();
00081     const char* internal_lastScan() const throw();
00083   public:
00084     FitStrategy& internal_getFitStrategy() const throw(LogicError) ;
00085   private:
00086     void internal_setFitOptions(const string & opt) throw(LogicError) ;
00091     void internal_setFitStrategy(const string & name) throw(LogicError) ;
00095     long internal_nFitsDone() const throw();
00099     long internal_nFitErrors() const throw();
00103     bool internal_isUsingAnalyticAlgorithm() const;
00111     static void doFits(ISCallbackInfo * isc) throw(IsException, LogicError);
00112     
00113   public:
00114     // CORBA METHODS:
00119     virtual char* status() throw();
00123     char* lastScan() throw();
00127     virtual char* getFitOptions() throw() ;
00131     virtual char* getFitStrategy() throw() ;
00139 
00140     virtual void setFitOptions(const char* opt) throw() ;
00147     virtual void setFitStrategy(const char* strategy) throw() ;
00148     // Fit all RawScanResults currently in IS.
00149     void fitAll() throw();
00151     void fit(const char* name) throw();
00153     long busy();
00155     long queueLength();
00159     long nFitsDone() throw();
00163     long nFitErrors() throw();
00167     void useAnalyticAlgorithm (CORBA::Boolean use);
00171     CORBA::Boolean isUsingAnalyticAlgorithm();
00172 
00173     
00175   public:
00179     void incrementFitErrors() throw();
00180     
00184     void incrementFitsDone() throw();
00185     
00189     void scanDone(double time) throw();
00190     
00195     void addIOTime(double time) throw();
00196     
00200     double getAverageTimePerScan() const throw();
00201     
00205     std::string getOutputIsServer() const;
00206     
00210     static IPCServer& getFitterServer() throw();
00211     
00212 private:      
00213 
00214     /*
00215      * counters:      
00216      */
00217     long m_nFitsDone;
00218     long m_nFitErrors;
00219     long m_nScans;
00220     double m_scanTimeTaken;
00221     double m_ioTimeTaken;
00223     mutable boost::recursive_mutex counterMutex;
00224     
00225     /*
00226      * name of the last scan attempted.
00227      */
00228     string m_scan;
00232     mutable string m_status;
00236     FitStrategy* m_fitStrategy;
00238     FitterWorkerGroup* workergroup;    
00242     std::auto_ptr<ISInfoReceiver> m_infoReceiver;
00243 
00245     void setLastScanName(const std::string& name){
00246     m_scan = name;
00247     }
00248 
00249     void updateSubscriptions();
00250 
00252     friend class FitterWorkerGroup;
00253     FitterArguments m_args;
00254 }
00255 ; // end of definition of class Fitter;
00256 }// end of namespace SctFitter
00257 #endif // #ifndef FITTER_H

Generated on Thu Feb 3 17:37:35 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5