Fitter.h

00001 #ifndef FITTER_H
00002 #define FITTER_H
00003 
00004 #include <is/info.h>
00005 #include <is/inforeceiver.h>
00006 
00007 #include <ipc/object.h>
00008 #include <ipc/server.h>
00009 
00010 #include <string>
00011 #include <memory>
00012 
00013 #include <boost/thread.hpp>
00014 
00015 #include "FitterInterface.hh"
00016 #include "FitterArguments.h"
00017 #include "Sct/Exception.h"
00018 #include "Sct/ConfigurationException.h"
00019 #include "Sct/LogicErrors.h"
00020 #include "Sct/IoExceptions.h"
00021 
00022 class TH1;
00023 class TF1;
00024 
00025 using namespace Sct;
00026 
00030 namespace SctFitter {
00031     class FitStrategy;
00032     class FitterWorkerGroup;
00033 
00043 class Fitter:
00044   public IPCNamedObject<POA_FitterI::FitterInterface,
00045                         ipc::multi_thread>,
00046   private boost::noncopyable {
00047 private:
00049   void shutdown();
00051   Fitter(FitterArguments args) throw(ConfigurationException);
00053   ~Fitter() throw();
00054   static Fitter* fitter;
00055     
00056 public:
00061     static Fitter& instance();
00062     
00068     static Fitter& initialize(FitterArguments args) throw(ConfigurationException);
00069     
00073     void go() throw(IsException);
00074   private:
00075     // INTERNAL METHODS:
00079     std::string internal_status() const throw();
00083     std::string internal_lastScan() const throw();
00085   public:
00086     FitStrategy& internal_getFitStrategy() const throw(LogicError) ;
00087   private:
00088     void internal_setFitOptions(const string & opt) throw(LogicError) ;
00093     void internal_setFitStrategy(const string & name) throw(LogicError) ;
00097     long internal_nFitsDone() const throw();
00101     long internal_nFitErrors() const throw();
00109     static void doFits(ISCallbackInfo * isc) throw(IsException, LogicError);
00110     
00111   public:
00112     // CORBA METHODS:
00117     virtual char* status() throw();
00121     char* lastScan() throw();
00125     virtual char* getFitOptions() throw() ;
00129     virtual char* getFitStrategy() throw() ;
00137 
00138     virtual void setFitOptions(const char* opt) throw() ;
00145     virtual void setFitStrategy(const char* strategy) throw() ;
00146     // Fit all RawScanResults currently in IS.
00147     void fitAll() throw();
00149     void fit(const char* name) throw();
00151     long busy();
00153     long queueLength();
00157     long nFitsDone() throw();
00161     long nFitErrors() throw();
00165     void setFifo(bool);
00169     bool isFifo();
00173     FitterI::StringList* listFitAlgorithms();
00177     FitterI::StringList* listFitStrategies();
00181     void setDebug(CORBA::Boolean value);
00185     bool debug();
00187   public:
00191     void incrementFitErrors() throw();
00192     
00196     void incrementFitsDone() throw();
00197     
00201     void scanDone(double time) throw();
00202     
00207     void addIOTime(double time) throw();
00208     
00212     double getAverageTimePerScan() const throw();
00213     
00217     std::string getOutputIsServer() const;
00218     
00222     static IPCServer& getFitterServer() throw();
00223     
00224 private:      
00225 
00226     /*
00227      * counters:      
00228      */
00229     long m_nFitsDone;
00230     long m_nFitErrors;
00231     long m_nScans;
00232     double m_scanTimeTaken;
00233     double m_ioTimeTaken;
00235     mutable boost::recursive_mutex counterMutex;
00236     
00237     /*
00238      * name of the last scan attempted.
00239      */
00240     string m_scan;
00244     mutable string m_status;
00248     FitStrategy* m_fitStrategy;
00250     FitterWorkerGroup* workergroup;    
00254     std::auto_ptr<ISInfoReceiver> m_infoReceiver;
00255 
00257     void setLastScanName(const std::string& name){
00258     m_scan = name;
00259     }
00260 
00261     void updateSubscriptions();
00262 
00264     friend class FitterWorkerGroup;
00265     FitterArguments m_args;
00266 }
00267 ; // end of definition of class Fitter;
00268 }// end of namespace SctFitter
00269 #endif // #ifndef FITTER_H

Generated on Mon Feb 6 14:01:20 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6