GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ControllerRunnable.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 "TGo4ControllerRunnable.h"
15 
16 #include "TGo4Log.h"
17 #include "TGo4Thread.h"
18 #include "TGo4ExampleServer.h"
19 
21 
23 : TGo4Runnable(name,serv)
24 {
25  GO4TRACE((15,"TGo4ControllerRunnable::TGo4ControllerRunnable(const char*,TGo4ExampleServer*) constructor",__LINE__, __FILE__));
26  fxController = serv->GetController();
27  fxServer = serv;
28 }
29 
31 {
32  GO4TRACE((15,"TGo4ControllerRunnable::~TGo4ControllerRunnable() destructor",__LINE__, __FILE__));
33 }
34 
36 {
37  GO4TRACE((12,"TGo4ControllerRunnable::Run()",__LINE__, __FILE__));
38 
39  // we have to update the queues according to the current task handler
41  if (!currenttask) {
42  GO4TRACE((11, "TGo4ControllerRunnable::Run()-- no current client existing", __LINE__, __FILE__));
43  TGo4Thread::Sleep(fguCOMMANDINTERVAL); // wait before sending next command
44  // no client has connected to server so far, we do nothing!
45  } else {
46  GO4TRACE((11, "TGo4ControllerRunnable::Run()-- working on client's taskhandler queues", __LINE__, __FILE__));
47  // at least one client is there
48  TGo4Thread::Sleep(fguCOMMANDINTERVAL); // wait before sending next command
49  // send first command object created by controller:
50  TGo4Command *com = fxController->GetCommand(); // command from controller instance, may poll here
51  fxServer->SubmitCommand(com); // send controller command to client
52  // send second command object by name:
53  fxServer->SubmitCommand("EXAction2"); // send command by name
54  TObject *data = fxServer->NextObject(); // get data from client
55  fxController->DisplayData(data); // display data here on gui
56  }
57  return 0;
58 }
static const UInt_t fguCOMMANDINTERVAL
static void Sleep(UInt_t millisecs)
Definition: TGo4Thread.cxx:295
Int_t Run(void *) override
Bool_t SubmitCommand(const char *name)
Definition: TGo4Task.cxx:409
TObject * NextObject(Bool_t wait=kTRUE)
Definition: TGo4Task.cxx:189
TGo4ExampleServer * fxServer
#define GO4TRACE(X)
Definition: TGo4Log.h:25
TGo4ExampleController * GetController()
TGo4TaskHandler * GetCurrentTaskHandler()
TGo4ExampleController * fxController