GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ExampleClient.cxx
Go to the documentation of this file.
1 // $Id: TGo4ExampleClient.cxx 999 2013-07-25 11:58:59Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ExampleClient.h"
15 
16 #include "Riostream.h"
17 
18 #include "TGo4Log.h"
19 #include "TGo4TaskHandler.h"
20 #include "TGo4ThreadHandler.h"
21 
23 #include "TGo4ExampleApplication.h"
24 #include "TGo4MainRunnable.h"
25 #include "TGo4WatchRunnable.h"
26 
27 const char* TGo4ExampleClient::fgcWATCHTHREAD="WATCH-";
28 const char* TGo4ExampleClient::fgcMAINTHREAD="MAIN-";
29 
30 
32  const char* host,
33  UInt_t negport,
34  Bool_t blockingmode)
35 : TGo4ClientTask(name, host, negport , blockingmode, kFALSE)
36 {
37  GO4TRACE((15,"TGo4ExampleClient::TGo4ExampleClient(const char*, const char*, Uint_t, Bool_t) constructor",__LINE__, __FILE__));
38  SetMaster(kFALSE);
39  TGo4Log::Debug(" ExampleClient ''%s'' started ",GetName());
41  TGo4MainRunnable* mainrun = new TGo4MainRunnable(Form("MainRunnable of %s",GetName()), this);
42  TGo4WatchRunnable* watchrun = new TGo4WatchRunnable(Form("WatchRunnable of %s",GetName()), this);
43  // adding runnables to thread handler who takes over the responsibility...:
44  fcMainName.Form("%s%s", fgcMAINTHREAD, GetName());
45  fxWorkHandler->NewThread(fcMainName.Data(), mainrun);
46  fcWatchName.Form("%s%s", fgcWATCHTHREAD, GetName());
47  fxWorkHandler->NewThread(fcWatchName.Data(), watchrun);
48  Launch();
49 }
50 
52 {
53  GO4TRACE((15,"TGo4ExampleClient::~TGo4ExampleClient() destructor",__LINE__, __FILE__));
54  fxWorkHandler->CancelAll(); // make sure threads wont work on application when its deleted
55  delete fxApplication;
56 }
57 
59 {
60  GO4TRACE((12,"TGo4ExampleClient::CreateStatus()",__LINE__, __FILE__));
62  UpdateStatus(stat); // set the internals
63  return stat;
64 
65 }
67 {
68  GO4TRACE((12,"TGo4ExampleClient::UpdateStatus(TGo4ClientStatus*)",__LINE__, __FILE__));
69  TGo4ClientTask::UpdateStatus(state); // fill superclass attributes
72  exstate->SetNames(fcMainName.Data(), fcWatchName.Data());
73 
74 }
75 
77 {
78  GO4TRACE((12,"TGo4ExampleClient::Stop()",__LINE__, __FILE__));
79  std::cout << "Stop of example client!"<<std::endl;
80 
81  TGo4Log::Debug(" ExampleClient ''%s'' executing Stop(): stop main thread",GetName());
82  fxWorkHandler->Stop(fcMainName.Data());
83 }
85 {
86  GO4TRACE((12,"TGo4ExampleClient::Start()",__LINE__, __FILE__));
87  std::cout << "Start of example client!"<<std::endl;
88 
89  TGo4Log::Debug(" ExampleClient ''%s'' executing Start(): start main thread",GetName());
91 }
93 {
94  GO4TRACE((12,"TGo4ExampleClient::GetApplication()",__LINE__, __FILE__));
95  return fxApplication;
96 }
static const char * fgcWATCHTHREAD
TGo4ThreadHandler * fxWorkHandler
TGo4ExampleApplication * fxApplication
TGo4BufferQueue * GetDataQueue(const char *task=0)
Bool_t NewThread(const char *name, TGo4Runnable *runnable)
TH1D * GetHistogram(const char *HistogramName)
Definition: Example1.cxx:43
void SetHistoStatus(TH1 *histogram)
void SetNames(const char *main, const char *watch)
Bool_t Stop(const char *thname)
virtual void Start()
Bool_t Start(const char *thname)
void SetMaster(Bool_t on=kTRUE)
Definition: TGo4Task.h:291
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4TaskHandler * GetTaskHandler()
virtual TGo4TaskStatus * CreateStatus()
TGo4ExampleApplication * GetApplication()
virtual void UpdateStatus(TGo4ClientStatus *state)
static const char * fgcMAINTHREAD
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:270
virtual void UpdateStatus(TGo4TaskStatus *state)