Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4TaskHandler/TGo4Slave.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 /* Generated by Together */
00017 
00018 #include "TGo4Slave.h"
00019 
00020 #include "Go4Log/TGo4Log.h"
00021 #include "Go4LockGuard/TGo4LockGuard.h"
00022 #include "TGo4Task.h"
00023 #include "TGo4ServerTask.h"
00024 #include "TGo4ClientTask.h"
00025 #include "Go4ThreadManager/TGo4ThreadHandler.h"
00026 #include "Go4CommandsBase/TGo4CommandInvoker.h"
00027 
00028 TGo4Slave::TGo4Slave(const char* name, Bool_t isserver, const char* serverhost, UInt_t negotport) 
00029 :TGo4TaskOwner(isserver), 
00030  fbMainIsRunning(kTRUE)
00031 { 
00032    TGo4CommandInvoker::Instance(); // make sure a command invoker exists
00033    TGo4CommandInvoker::Register("SlaveTask", this);
00034    TGo4Task* task=0;
00035    if(IsServer())
00036       {
00037          task=new TGo4ServerTask(name, negotport, 
00038                kFALSE, //blockingmode
00039                kFALSE, //standalone 
00040                kTRUE,  //autostart
00041                kTRUE,  //autocreate 
00042                kFALSE   //ismaster 
00043                );  
00044       }     
00045    else
00046       {
00047          task=new TGo4ClientTask(name, serverhost, negotport,
00048                      kFALSE, //blockingmode
00049                      kFALSE, //standalone
00050                      kFALSE, //autostart
00051                      kTRUE,  //autocreate
00052                      kFALSE, //ismaster
00053                      kTRUE );//autoconnect 
00054       }
00055    SetTask(task);
00056 }
00057 
00058 TGo4Slave::TGo4Slave():fbMainIsRunning(kTRUE) 
00059 { 
00060    
00061 }
00062 
00063 TGo4Slave::~TGo4Slave() 
00064 { 
00065    
00066 }
00067 
00068 
00069 void TGo4Slave::Start()
00070 {
00071    TGo4Log::Debug(" Slave ''%s'' default Start method, please override",GetName());
00072    fbMainIsRunning=kTRUE;
00073 }
00074 void TGo4Slave::Stop()
00075 {
00076    TGo4Log::Debug(" Slave ''%s'' default Stop method, please override",GetName());
00077    fbMainIsRunning=kFALSE;
00078 }
00079 
00080 void TGo4Slave::KillMain()
00081 {
00082 // may be overridden by concrete slave implementation
00083 
00084 }
00085 void TGo4Slave::RestartMain()
00086 {
00087 // may be overridden by concrete slave implementation
00088 }
00089 
00090 void TGo4Slave::Terminate (Bool_t termapp)
00091 {
00092    if(GetTask())
00093       GetTask()->TGo4ThreadManager::Terminate(termapp);   
00094 }    
00095 
00096 void TGo4Slave::TerminateFast ()
00097 {
00098    Terminate();    
00099 }
00100 
00101 
00102 TGo4TaskStatus* TGo4Slave::CreateStatus()
00103 {
00104    TGo4TaskStatus* stat= new TGo4TaskStatus((Text_t*) GetName());
00105    UpdateStatus(stat); // set the internals
00106    return stat;
00107 }
00108 
00109 void TGo4Slave::UpdateStatus(TGo4TaskStatus* state)
00110 {
00111    if(GetTask())
00112       GetTask()->UpdateStatus(state);
00113 }
00114 
00115 TGo4Command* TGo4Slave::NextCommand()
00116 {
00117    if(GetTask())
00118       return (GetTask()->NextCommand());
00119    else
00120       return 0;
00121 }
00122 
00123 void TGo4Slave::SendObject(TObject * obj, const char* receiver)
00124 {
00125    if(GetTask())
00126       GetTask()->SendObject(obj, receiver);
00127 }
00128 
00129 void TGo4Slave::SendStatus(TGo4Status * stat, const char* receiver)
00130 {
00131    if(GetTask())
00132       GetTask()->SendStatus(stat, receiver);
00133 }
00134 
00135 Int_t TGo4Slave::Initialization()
00136 {
00137 // may be overridden by concrete slave implementation
00138     return 0;
00139 }
00140 
00141 TGo4ThreadHandler* TGo4Slave::GetThreadHandler()
00142 {
00143    if(GetTask())
00144       return(GetTask()->GetWorkHandler());   
00145    else 
00146       return 0;
00147 }
00148 
00149 
00150 void TGo4Slave::SendStatusBuffer()
00151 {
00152    if(GetTask()) GetTask()->SendStatusBuffer();
00153 }
00154 
00155 void TGo4Slave::SendStatusMessage(Int_t level, Bool_t printout, const char* text,...)
00156 {
00157    if(GetTask()==0) return;
00158    Int_t lbuflen=256;
00159    // put potential printf arguments in text:
00160    Text_t txtbuf[lbuflen];
00161    va_list args;
00162    va_start(args, text);
00163    vsnprintf(txtbuf, lbuflen, text, args);
00164    va_end(args);
00165    GetTask()->SendStatusMessage(level, printout, txtbuf);
00166 }
00167 
00168 
00169 void TGo4Slave::UpdateStatusBuffer()
00170 {
00171    if(GetTask()) GetTask()->UpdateStatusBuffer();
00172 }
00173 void TGo4Slave::ExecuteString(const Text_t* command)
00174 {
00175    gROOT->ProcessLine(command);
00176 }
00177 
00178 
00179 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:06 2005 for Go4-v2.10-5 by doxygen1.2.15