GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ExampleClient.cxx
Go to the documentation of this file.
1// $Id$
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
26const char *TGo4ExampleClient::fgcWATCHTHREAD="WATCH-";
27const 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)",__LINE__, __FILE__));
37 SetMaster(kFALSE);
38 TGo4Log::Debug(" ExampleClient ''%s'' started ",GetName());
40 TGo4MainRunnable* mainrun = new TGo4MainRunnable(TString::Format("MainRunnable of %s",GetName()).Data(), this);
41 TGo4WatchRunnable* watchrun = new TGo4WatchRunnable(TString::Format("WatchRunnable of %s",GetName()).Data(), 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()",__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());
91 fxWorkHandler->Start(fcMainName.Data());
92}
93
95{
96 GO4TRACE((12,"TGo4ExampleClient::GetApplication()",__LINE__, __FILE__));
97 return fxApplication;
98}
TH1D * GetHistogram(const char *HistogramName)
Definition Example1.cxx:45
#define GO4TRACE(X)
Definition TGo4Log.h:25
Class containing a pointer queue for TBuffers.
TGo4ClientTask(const char *name, const char *serverhost="localhost", UInt_t negotiationport=0, Bool_t blockingmode=kTRUE, Bool_t standalone=kFALSE, Bool_t autostart=kFALSE, Bool_t autocreate=kTRUE, Bool_t ismaster=kFALSE, Bool_t autoconnect=kTRUE)
void UpdateStatus(TGo4TaskStatus *state) override
method needed by method CreateStatus of any status subclasses to set the values of the clienttask spe...
TGo4BufferQueue * GetDataQueue(const char *task=nullptr) override
TGo4TaskHandler * GetTaskHandler() override
Example application class; this class may also run as standalone application without the threaded cli...
void SetHistoStatus(TH1 *histogram)
Set histogram status.
void SetNames(const char *main, const char *watch)
Set names of the work runnables of example.
void Start() override
General start method of client application to be called from remote command; should be re-implemented...
static const char * fgcWATCHTHREAD
Suffix for watch thread name.
TString fcWatchName
Remember name of watch thread.
TString fcMainName
Remember name of main thread.
void UpdateStatus(TGo4TaskStatus *state) override
method needed by method CreateStatus of any status subclasses to set the values of the clienttask spe...
TGo4ExampleApplication * fxApplication
aggregationByValue 1 0..1
TGo4TaskStatus * CreateStatus() override
create a status object with information on the current client state.
void Stop() override
General stop method of client application to be called from remote command; should be re-implemented ...
static const char * fgcMAINTHREAD
Suffix for main thread name.
TGo4ExampleApplication * GetApplication()
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
runnable performing the main action of example client task: getting commands out of command queue,...
Task status.
void SetMaster(Bool_t on=kTRUE)
Definition TGo4Task.h:298
TGo4ThreadHandler * fxWorkHandler
Thread handler aggregate (threadsafe list of go4 threads) aggregationByValue 1 1.
void Launch()
This Method has to be called to create the startup threads and to turn on the application control tim...
runnable performing control watcher functions of example client task: status of application is send t...