Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4Master.h"
00015
00016 #include "TSystem.h"
00017
00018 #include "TGo4Log.h"
00019 #include "TGo4Task.h"
00020 #include "TGo4ServerTask.h"
00021 #include "TGo4ClientTask.h"
00022 #include "TGo4CommandInvoker.h"
00023 #include "TGo4TaskHandlerCommandList.h"
00024
00025 TGo4Master::TGo4Master() :
00026 TGo4TaskOwner()
00027 {
00028 }
00029
00030 TGo4Master::TGo4Master(const char* name, Bool_t isserver, const char* serverhost, UInt_t negotport)
00031 : TGo4TaskOwner(isserver)
00032 {
00033 TGo4CommandInvoker::Instance();
00034 TGo4CommandInvoker::Register("MasterTask", this);
00035 TGo4Task* task(0);
00036 if(IsServer())
00037 task = new TGo4ServerTask(name, negotport,
00038 kFALSE,
00039 kFALSE,
00040 kTRUE,
00041 kTRUE,
00042 kTRUE);
00043 else
00044 task = new TGo4ClientTask(name, serverhost, negotport,
00045 kFALSE,
00046 kFALSE,
00047 kFALSE,
00048 kTRUE,
00049 kTRUE,
00050 kFALSE);
00051 SetTask(task);
00052 }
00053
00054 TGo4Master::~TGo4Master()
00055 {
00056 TGo4CommandInvoker::UnRegister(this);
00057 }
00058
00059 TGo4TaskHandlerCommandList* TGo4Master::CreateCommandList()
00060 {
00061 return new TGo4TaskHandlerCommandList("Go4ServerTaskDefaultCommandList");
00062 }
00063
00064 Bool_t TGo4Master::SubmitCommand(const char* name)
00065 {
00066 if (GetTask()==0) return kFALSE;
00067 return GetTask()->SubmitCommand(name);
00068 }
00069
00070 Bool_t TGo4Master::SubmitEmergencyCommand(Go4EmergencyCommand_t val)
00071 {
00072 if (GetTask()==0) return kFALSE;
00073 return GetTask()->SubmitEmergencyCommand(val);
00074 }
00075
00076 Bool_t TGo4Master::SubmitCommand(TGo4Command* com)
00077 {
00078 if (GetTask()==0) return kFALSE;
00079 return GetTask()->SubmitCommand(com);
00080 }
00081
00082 Bool_t TGo4Master::DisconnectSlave(const char* name, Bool_t waitforslave)
00083 {
00084 Bool_t rev=kTRUE;
00085 if(IsServer()) {
00086 TGo4ServerTask* server = dynamic_cast<TGo4ServerTask*> (GetTask());
00087 if(server)
00088 rev=server->RemoveClient(name, waitforslave);
00089 else
00090 rev=kFALSE;
00091 } else {
00092 TGo4ClientTask* client = dynamic_cast<TGo4ClientTask*> (GetTask());
00093 if(client) {
00094 rev=client->DisconnectServer();
00095 client->Terminate(kFALSE);
00096 } else
00097 rev=kFALSE;
00098 }
00099 return rev;
00100 }