// $Id$ //----------------------------------------------------------------------- // The GSI Online Offline Object Oriented (Go4) Project // Experiment Data Processing at EE department, GSI //----------------------------------------------------------------------- // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH // Planckstr. 1, 64291 Darmstadt, Germany // Contact: http://go4.gsi.de //----------------------------------------------------------------------- // This software can be used under the license agreements as stated // in Go4License.txt file which is part of the distribution. //----------------------------------------------------------------------- #include "TGo4Display.h" #include "TGo4Log.h" #include "TGo4ThreadHandler.h" #include "TGo4Task.h" #include "TGo4TaskManager.h" #include "TGo4DisplayDrawerTimer.h" #include "TGo4DisplayLoggerTimer.h" #include "TGo4Status.h" #include "TGo4AnalysisProxy.h" #include "TGo4Slot.h" TGo4Display::TGo4Display(Bool_t isserver) : TGo4Master("Display", isserver, // servermode "dummy", //for clientmode only 1), // negotiationport fxAnalysis(0) { // start gui timers instead of threads fxDrawTimer= new TGo4DisplayDrawerTimer(this, 30); fxLogTimer= new TGo4DisplayLoggerTimer(this, 500); fxDrawTimer->TurnOn(); fxLogTimer->TurnOn(); // Start the GUI Registry GetTask()->Launch(); } TGo4Display::~TGo4Display() { GO4TRACE((15,"TGo4Display::~TGo4Display()", __LINE__, __FILE__)); //fxWorkHandler->CancelAll(); // make sure threads wont work on gui instance after it is deleted if(GetTask()) GetTask()->GetWorkHandler()->CancelAll(); delete fxDrawTimer; delete fxLogTimer; if (fxAnalysis != 0) { fxAnalysis->DisplayDeleted(this); // will also clear back referenc to us TGo4Slot* pslot = fxAnalysis->ParentSlot(); if (pslot) { //std::cout <<"TGo4Display dtor will delete analysis proxy parent slot" << std::endl; pslot->Delete(); } else { //std::cout <<"TGo4Display dtor will delete analysis proxy directly" << std::endl; delete fxAnalysis; // regularly, we cleanup the analysis proxy. } } TGo4Log::Info("------- TGO4DISPLAY DESTRUCTOR FINISHED. ------"); } void TGo4Display::DisplayData(TObject* data) { if (fxAnalysis!=0) fxAnalysis->ReceiveObject(dynamic_cast(data)); else delete data; } void TGo4Display::DisplayLog(TGo4Status * Status) { if (fxAnalysis!=0) fxAnalysis->ReceiveStatus(Status); else delete Status; } Bool_t TGo4Display::DisconnectSlave(const char* name, Bool_t waitforslave) { // std::cout <<"+++++++++ TGo4Display::DisconnectSlave..." << std::endl; // Note: taskhandlerabortexception and shutdown of analysis server // both will schedule a TGo4ComDisconnectSlave into local command queue // of master task, calling TGo4Master::DisconnectSlave() // here we override this method to inform gui about this /////////////////////////////////////////////////// // // before disconnecting, gui might stop monitoring timers here.... //... Bool_t rev=TGo4Master::DisconnectSlave(name,waitforslave); // should do all required things for disconnection // after disconnecting, gui might react on result by cleaning up browser, window caption etc. // for example: if(rev) { if (fxAnalysis!=0) fxAnalysis->DisplayDisconnected(this); // std::cout <<"+++++++++ TGo4Display::DisconnectSlave success on disconnect!!!" << std::endl; // std::cout <<"+++++++++ Please add something to inform GUI here about disconnected analysis!!!" << std::endl; } else { // std::cout <<"+++++++++ TGo4Display::DisconnectSlave failed!!!" << std::endl; // std::cout <<"+++++++++ Please add something to inform GUI here..." << std::endl; } return rev; }