GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Display.cxx
Go to the documentation of this file.
1 // $Id: TGo4Display.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 "TGo4Display.h"
15 
16 #include "TGo4Log.h"
17 #include "TGo4ThreadHandler.h"
18 #include "TGo4Task.h"
19 #include "TGo4TaskManager.h"
20 #include "TGo4DisplayDrawerTimer.h"
21 #include "TGo4DisplayLoggerTimer.h"
22 #include "TGo4Status.h"
23 
24 #include "TGo4AnalysisProxy.h"
25 #include "TGo4Slot.h"
26 
27 
28 TGo4Display::TGo4Display(Bool_t isserver)
29  : TGo4Master("Display",
30  isserver, // servermode
31  "dummy", //for clientmode only
32  1), // negotiationport
33  fxAnalysis(0)
34 {
35  // start gui timers instead of threads
36  fxDrawTimer= new TGo4DisplayDrawerTimer(this, 30);
37  fxLogTimer= new TGo4DisplayLoggerTimer(this, 500);
38  fxDrawTimer->TurnOn();
39  fxLogTimer->TurnOn();
40 
41  // Start the GUI Registry
42  GetTask()->Launch();
43 }
44 
45 
47 {
48  GO4TRACE((15,"TGo4Display::~TGo4Display()", __LINE__, __FILE__));
49  //fxWorkHandler->CancelAll(); // make sure threads wont work on gui instance after it is deleted
50  if(GetTask())
52  delete fxDrawTimer;
53  delete fxLogTimer;
54  if (fxAnalysis != 0) {
55  fxAnalysis->DisplayDeleted(this); // will also clear back referenc to us
56  TGo4Slot* pslot = fxAnalysis->ParentSlot();
57  if (pslot) {
58  //std::cout <<"TGo4Display dtor will delete analysis proxy parent slot" << std::endl;
59  pslot->Delete();
60  } else {
61  //std::cout <<"TGo4Display dtor will delete analysis proxy directly" << std::endl;
62  delete fxAnalysis; // regularly, we cleanup the analysis proxy.
63  }
64 
65  }
66  TGo4Log::Info("------- TGO4DISPLAY DESTRUCTOR FINISHED. ------");
67 }
68 
69 void TGo4Display::DisplayData(TObject* data)
70 {
71  if (fxAnalysis!=0)
72  fxAnalysis->ReceiveObject(dynamic_cast<TNamed*>(data));
73  else
74  delete data;
75 }
76 
78 {
79  if (fxAnalysis!=0)
80  fxAnalysis->ReceiveStatus(Status);
81  else
82  delete Status;
83 }
84 
85 Bool_t TGo4Display::DisconnectSlave(const char* name, Bool_t waitforslave)
86 {
87  // std::cout <<"+++++++++ TGo4Display::DisconnectSlave..." << std::endl;
88 
89 
90 // Note: taskhandlerabortexception and shutdown of analysis server
91 // both will schedule a TGo4ComDisconnectSlave into local command queue
92 // of master task, calling TGo4Master::DisconnectSlave()
93 // here we override this method to inform gui about this
95 //
96 // before disconnecting, gui might stop monitoring timers here....
97 //...
98  Bool_t rev=TGo4Master::DisconnectSlave(name,waitforslave); // should do all required things for disconnection
99  // after disconnecting, gui might react on result by cleaning up browser, window caption etc.
100  // for example:
101  if(rev)
102  {
103  if (fxAnalysis!=0)
104 
106 
107 // std::cout <<"+++++++++ TGo4Display::DisconnectSlave success on disconnect!!!" << std::endl;
108 // std::cout <<"+++++++++ Please add something to inform GUI here about disconnected analysis!!!" << std::endl;
109  }
110  else
111  {
112 // std::cout <<"+++++++++ TGo4Display::DisconnectSlave failed!!!" << std::endl;
113 // std::cout <<"+++++++++ Please add something to inform GUI here..." << std::endl;
114  }
115 
116  return rev;
117 }
118 
void DisplayData(TObject *)
Definition: TGo4Display.cxx:69
void DisplayDeleted(TGo4Display *displ)
TGo4Display(Bool_t isserver=kTRUE)
Definition: TGo4Display.cxx:28
virtual ~TGo4Display()
Definition: TGo4Display.cxx:46
virtual Bool_t DisconnectSlave(const char *name=0, Bool_t waitforslave=kTRUE)
Definition: TGo4Master.cxx:82
void ReceiveStatus(TGo4Status *status)
TGo4AnalysisProxy * fxAnalysis
Definition: TGo4Display.h:48
virtual Bool_t DisconnectSlave(const char *name=0, Bool_t waitforslave=kTRUE)
Definition: TGo4Display.cxx:85
void ReceiveObject(TNamed *obj)
TGo4Task * GetTask()
Definition: TGo4TaskOwner.h:41
void DisplayDisconnected(TGo4Display *displ)
TGo4ThreadHandler * GetWorkHandler() const
TGo4Slot * ParentSlot()
TGo4DisplayDrawerTimer * fxDrawTimer
Definition: TGo4Display.h:43
void DisplayLog(TGo4Status *Status)
Definition: TGo4Display.cxx:77
#define GO4TRACE(X)
Definition: TGo4Log.h:26
TGo4DisplayLoggerTimer * fxLogTimer
Definition: TGo4Display.h:46
virtual void Delete(Option_t *opt="")
Definition: TGo4Slot.cxx:190
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283