00001 // $Id: TGo4AnalysisWatchRunnable.cxx 999 2013-07-25 11:58:59Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TGo4AnalysisWatchRunnable.h" 00015 00016 #include "TGo4Log.h" 00017 #include "TGo4LockGuard.h" 00018 #include "TGo4Thread.h" 00019 #include "TGo4Task.h" 00020 00021 #include "TGo4ClientStatus.h" 00022 #include "TGo4AnalysisClientImp.h" 00023 #include "TGo4AnalysisImp.h" 00024 00025 const UInt_t TGo4AnalysisWatchRunnable::fguWATCHINTERVAL=1000; 00026 //const UInt_t TGo4AnalysisWatchRunnable::fguWATCHINTERVAL=50; 00027 00028 TGo4AnalysisWatchRunnable::TGo4AnalysisWatchRunnable(const char* name, TGo4AnalysisClient* cli) : 00029 TGo4Runnable(name,cli->GetTask()), fxAnalysisClient(cli) 00030 { 00031 fxAnalysis = cli->GetAnalysis(); 00032 } 00033 00034 TGo4AnalysisWatchRunnable::~TGo4AnalysisWatchRunnable() 00035 { 00036 00037 } 00038 00039 Int_t TGo4AnalysisWatchRunnable::Run(void*) 00040 { 00041 // check if ratemeter was updated 00042 if (fxAnalysis && fxAnalysis->IsInitDone()) 00043 { 00044 if(!fxAnalysisClient->TestRatemeter()) 00045 { 00046 // no, we have to update it ourselves and fill the status buffer 00047 if(fxAnalysisClient->MainIsRunning()) 00048 fxAnalysisClient->UpdateRate(0); // update with calculation of time and average rate 00049 else 00050 fxAnalysisClient->UpdateRate(-1); // stopped: keep latest values for time and average rate 00051 { 00052 //TGo4LockGuard mainguard; // in UpdateStatusBuffer now JA 00053 //std::cout << "watch runnable updated status buffer itself!!!"<< std::endl; 00054 fxAnalysisClient->UpdateStatusBuffer(); 00055 } // lock guard 00056 } 00057 else 00058 { // yes, main thread is running on that, we do nothing 00059 00060 } // if(!fxAnalysisClient->TestRatemeter()) 00061 fxAnalysisClient->SendAnalysisClientStatus(); 00062 } 00063 else 00064 { // analysis not initialized, no status to update 00065 00066 } // if (ana && ana->fbInitIsDone) 00067 00068 TGo4Thread::Sleep(fguWATCHINTERVAL); 00069 return 0; 00070 }