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