GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ExampleClient.cxx
Go to the documentation of this file.
1 // $Id: TGo4ExampleClient.cxx 2757 2020-04-16 11:45:21Z 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 fuer 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 <iostream>
17 
18 #include "TGo4Log.h"
19 #include "TGo4TaskHandler.h"
20 #include "TGo4ThreadHandler.h"
21 
23 #include "TGo4MainRunnable.h"
24 #include "TGo4WatchRunnable.h"
25 
26 const char* TGo4ExampleClient::fgcWATCHTHREAD="WATCH-";
27 const char* TGo4ExampleClient::fgcMAINTHREAD="MAIN-";
28 
29 
31  const char* host,
32  UInt_t negport,
33  Bool_t blockingmode)
34 : TGo4ClientTask(name, host, negport , blockingmode, kFALSE)
35 {
36  GO4TRACE((15,"TGo4ExampleClient::TGo4ExampleClient(const char*, const char*, Uint_t, Bool_t) constructor",__LINE__, __FILE__));
37  SetMaster(kFALSE);
38  TGo4Log::Debug(" ExampleClient ''%s'' started ",GetName());
40  TGo4MainRunnable* mainrun = new TGo4MainRunnable(Form("MainRunnable of %s",GetName()), this);
41  TGo4WatchRunnable* watchrun = new TGo4WatchRunnable(Form("WatchRunnable of %s",GetName()), this);
42  // adding runnables to thread handler who takes over the responsibility...:
43  fcMainName.Form("%s%s", fgcMAINTHREAD, GetName());
44  fxWorkHandler->NewThread(fcMainName.Data(), mainrun);
45  fcWatchName.Form("%s%s", fgcWATCHTHREAD, GetName());
46  fxWorkHandler->NewThread(fcWatchName.Data(), watchrun);
47  Launch();
48 }
49 
51 {
52  GO4TRACE((15,"TGo4ExampleClient::~TGo4ExampleClient() destructor",__LINE__, __FILE__));
53  fxWorkHandler->CancelAll(); // make sure threads wont work on application when its deleted
54  delete fxApplication;
55 }
56 
58 {
59  GO4TRACE((12,"TGo4ExampleClient::CreateStatus()",__LINE__, __FILE__));
61  UpdateStatus(stat); // set the internals
62  return stat;
63 
64 }
66 {
67  GO4TRACE((12,"TGo4ExampleClient::UpdateStatus(TGo4ClientStatus*)",__LINE__, __FILE__));
68  TGo4ClientTask::UpdateStatus(state); // fill superclass attributes
69  TGo4ExampleClientStatus* exstate= dynamic_cast<TGo4ExampleClientStatus*> (state);
70  if (exstate) {
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 }
84 
86 {
87  GO4TRACE((12,"TGo4ExampleClient::Start()",__LINE__, __FILE__));
88  std::cout << "Start of example client!" << std::endl;
89 
90  TGo4Log::Debug(" ExampleClient ''%s'' executing Start(): start main thread",GetName());
92 }
93 
95 {
96  GO4TRACE((12,"TGo4ExampleClient::GetApplication()",__LINE__, __FILE__));
97  return fxApplication;
98 }
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:290
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4TaskHandler * GetTaskHandler()
virtual TGo4TaskStatus * CreateStatus()
TGo4ExampleApplication * GetApplication()
virtual void UpdateStatus(TGo4TaskStatus *state)
static const char * fgcMAINTHREAD
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:284
virtual void UpdateStatus(TGo4TaskStatus *state)