GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Display.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 "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  0), // negotiationport - 0 = root will find next free port automatically
32  fxAnalysis(nullptr)
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) {
54  fxAnalysis->DisplayDeleted(this); // will also clear back referenc to us
55  TGo4Slot *pslot = fxAnalysis->ParentSlot();
56  if (pslot) {
57  pslot->Delete();
58  } else {
59  delete fxAnalysis; // regularly, we cleanup the analysis proxy.
60  }
61  }
62  TGo4Log::Info("------- TGO4DISPLAY DESTRUCTOR FINISHED. ------");
63 }
64 
65 void TGo4Display::DisplayData(TObject *data)
66 {
67  if (fxAnalysis)
68  fxAnalysis->ReceiveObject(dynamic_cast<TNamed*>(data));
69  else
70  delete data;
71 }
72 
74 {
75  if (fxAnalysis)
76  fxAnalysis->ReceiveStatus(status);
77  else
78  delete status;
79 }
80 
81 Bool_t TGo4Display::DisconnectSlave(const char *name, Bool_t waitforslave)
82 {
83 
84  // Note: taskhandlerabortexception and shutdown of analysis server
85  // both will schedule a TGo4ComDisconnectSlave into local command queue
86  // of master task, calling TGo4Master::DisconnectSlave()
87  // here we override this method to inform gui about this
89  //
90  // before disconnecting, gui might stop monitoring timers here....
91  //...
92  Bool_t rev = TGo4Master::DisconnectSlave(name, waitforslave); // should do all required things for disconnection
93  // after disconnecting, gui might react on result by cleaning up browser, window caption etc.
94  // for example:
95  if (rev && fxAnalysis)
97 
98  return rev;
99 }
100 
void DisplayData(TObject *)
Definition: TGo4Display.cxx:65
void DisplayDeleted(TGo4Display *displ)
TGo4Display(Bool_t isserver=kTRUE)
Definition: TGo4Display.cxx:27
static void Info(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:294
TGo4Task * GetTask() const
Definition: TGo4TaskOwner.h:42
virtual ~TGo4Display()
Definition: TGo4Display.cxx:45
void ReceiveStatus(TGo4Status *status)
TGo4AnalysisProxy * fxAnalysis
Definition: TGo4Display.h:47
Bool_t DisconnectSlave(const char *name=nullptr, Bool_t waitforslave=kTRUE) override
Definition: TGo4Display.cxx:81
void ReceiveObject(TNamed *obj)
void DisplayDisconnected(TGo4Display *displ)
virtual Bool_t DisconnectSlave(const char *name=nullptr, Bool_t waitforslave=kTRUE)
Definition: TGo4Master.cxx:78
TGo4Slot * ParentSlot()
TGo4DisplayDrawerTimer * fxDrawTimer
Definition: TGo4Display.h:42
void DisplayLog(TGo4Status *Status)
Definition: TGo4Display.cxx:73
TGo4ThreadHandler * GetWorkHandler() const
#define GO4TRACE(X)
Definition: TGo4Log.h:25
TGo4DisplayLoggerTimer * fxLogTimer
Definition: TGo4Display.h:45
void Delete(Option_t *opt="") override
Definition: TGo4Slot.cxx:171