GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4AnalysisProxy.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 "TGo4AnalysisProxy.h"
15
16#include <iostream>
17
18#include "TH1.h"
19#include "TFolder.h"
20#include "TTree.h"
21#include "TTime.h"
22#include "TSystem.h"
23
24#include "TGo4Log.h"
25
26#include "TGo4Slot.h"
27#include "TGo4ObjectProxy.h"
28
29#include "TGo4RemoteCommand.h"
31#include "TGo4ObjEnvelope.h"
32#include "TGo4ComExecLine.h"
33
34#include "TGo4Display.h"
35#include "TGo4TaskManager.h"
36#include "TGo4TaskHandler.h"
37#include "TGo4ClientTask.h"
38#include "TGo4ServerTask.h"
39#include "TGo4BufferQueue.h"
40
41#include "TGo4Parameter.h"
42
43#include "TGo4AnalysisStatus.h"
46#include "TGo4TreeStructure.h"
47#include "TGo4BranchStatus.h"
48#include "TGo4ParameterStatus.h"
49#include "TGo4MemberStatus.h"
50
52
53
54class TGo4AnalysisObjectAccess : public TObject, public TGo4Access {
55 public:
56
58 Int_t proxykind,
59 const char *name,
60 const char *classname,
61 const char *fullpath) :
62 TObject(),
63 TGo4Access(),
64 fxAnalProxy(cont),
65 fProxyKind(proxykind),
66 fxObjName(name),
67 fxObjClassName(classname),
68 fxFullPath(fullpath),
69 fxReceiver(nullptr),
72 {
73 }
74
76
77 Bool_t IsRemote() const override { return kTRUE; }
78 Bool_t CanGetObject() const override { return kFALSE; }
79 const char *GetObjectName() const override { return fxObjName.Data(); }
80 const char *GetObjectClassName() const override { return fxObjClassName.Data(); }
81
82 const char *GetPathName() const { return fxFullPath.Data(); }
83
84 Int_t AssignObjectTo(TGo4ObjectManager *rcv, const char *path) override
85 {
86 if (!rcv || !fxAnalProxy) return 0;
87 fxReceiver = rcv;
88 fxReceiverPath = path;
89 if (fxAnalProxy->SubmitProxy(this)) return 2;
90 return 0;
91 }
92
93 Int_t ProxyKind() const { return fProxyKind; }
94
95 void ChangeObjectName(const char *newname) { fxObjName = newname; }
96
97 void SetSubmitTime() { fxSubmitTime = gSystem->Now(); }
98
99 Bool_t CheckLifeTime(long int millisec)
100 {
101 long int res = gSystem->Now() - fxSubmitTime;
102 return (res<0) || (res > millisec);
103 }
104
105 void ReceiveObject(TObject *obj, const char *objfolder, const char *objname, Bool_t owner)
106 {
108 TString path = fxReceiverPath;
109 if (objfolder && (strlen(objfolder) != 0)) {
110 path += objfolder; path += "/";
111 }
112 if (objname && (strlen(objname) != 0)) path += objname;
113 DoObjectAssignement(fxReceiver, path.Data(), obj, owner);
114
115 } else {
116 DoObjectAssignement(fxReceiver, fxReceiverPath.Data(), obj, owner);
117 }
118 }
119
120 void SetDefaultReceiver(TGo4ObjectManager *rcv, const char *path)
121 {
122 fxReceiver = rcv;
123 fxReceiverPath = path;
124 }
125
126 protected:
128 Int_t fProxyKind{0};
129 TString fxObjName;
131 TString fxFullPath;
135};
136
137
138// ****************************************************************
139
141 public:
143
144 TGo4AnalysisLevelIter(TFolder *folder, Bool_t istree = kFALSE) :
146 fIsTree(istree)
147 {
148 fIter = folder->GetListOfFolders()->MakeIterator();
149 }
150
152 {
153 delete fIter;
154 }
155
156 Bool_t next() override
157 {
158 fCurrent = fIter->Next();
159 return fCurrent != nullptr;
160 }
161
162 Bool_t isfolder() override
163 {
164 return dynamic_cast<TFolder *>(fCurrent) ||
165 dynamic_cast<TGo4TreeStructure *>(fCurrent);
166 }
167
168 Int_t getflag(const char *flagname) override
169 {
170 if (strcmp(flagname, "IsRemote") == 0)
171 return 1;
172 if (strcmp(flagname, "IsDeleteProtect") == 0) {
173 auto sts = dynamic_cast<TGo4ObjectStatus *> (fCurrent);
174 if (sts)
175 return sts->IsDeleteProtect() ? 1 : 0;
176 }
177 if (strcmp(flagname,"IsResetProtect") == 0) {
178 auto sts = dynamic_cast<TGo4ObjectStatus *> (fCurrent);
179 if (sts)
180 return sts->IsResetProtect() ? 1 : 0;
181 }
182
183 return -1;
184 }
185
187 {
188 auto tr = dynamic_cast<TGo4TreeStructure *>(fCurrent);
189 if (tr) return new TGo4AnalysisLevelIter(tr->GetNamesFolder(), kTRUE);
190 return new TGo4AnalysisLevelIter((TFolder *)fCurrent, fIsTree);
191 }
192
193 const char *name() override
194 {
195 return fCurrent->GetName();
196 }
197
198 const char *info() override
199 {
200 return fCurrent->GetTitle();
201 }
202
203 Int_t sizeinfo() override
204 {
205 auto status = dynamic_cast <TGo4ObjectStatus*> (fCurrent);
206 return status ? status->GetObjectSize() : 0;
207 }
208
209 Int_t GetKind() override
210 {
211 Int_t kind = TGo4Access::kndNone;
212 if (fIsTree) {
213 if (isfolder())
215 else
217 } else if (isfolder()) {
219 } else {
221 if (fCurrent && fCurrent->InheritsFrom(TGo4ParameterStatus::Class()))
223 else if (fCurrent && fCurrent->InheritsFrom(TGo4MemberStatus::Class()))
225 }
226
227 return kind;
228 }
229
230 const char *GetClassName() override
231 {
232 return EntryClassName(fCurrent);
233 }
234
235 static const char *EntryClassName(TObject *entry)
236 {
237 if (!entry) return nullptr;
238
239 if (entry->InheritsFrom(TGo4TreeStructure::Class()))
240 return TTree::Class()->GetName();
241
242 if (entry->InheritsFrom(TGo4BranchStatus::Class())) {
243 TGo4BranchStatus *status = dynamic_cast<TGo4BranchStatus *>(entry);
244 if (status)
245 return status->GetObjectClass();
246 }
247
248 if (entry->InheritsFrom(TGo4ParameterStatus::Class())) {
249 TGo4ParameterStatus *status = dynamic_cast<TGo4ParameterStatus *>(entry);
250 if (status)
251 return status->GetObjectClass();
252 }
253
254 if (entry->InheritsFrom(TGo4AnalysisStatus::Class()))
255 return TGo4AnalysisStatus::Class()->GetName();
256
257 if (entry->InheritsFrom(TGo4ObjectStatus::Class())) {
258 TGo4ObjectStatus *status = dynamic_cast<TGo4ObjectStatus *>(entry);
259 if (status)
260 return status->GetObjectClass();
261 }
262
263 return entry->ClassName();
264 }
265
266 protected:
267 TIterator *fIter{nullptr};
268 TObject *fCurrent{nullptr};
269 Bool_t fIsTree{kFALSE};
270};
271
272// **********************************************************************
273
276 fIsServer(isserver),
277 fAnalysisNames(nullptr),
279 fxDefaultProxy(nullptr),
280 fbNamesListReceived(kFALSE),
281 fbAnalysisRunning(kFALSE),
282 fDisconectCounter(-111),
283 fxDisplay(nullptr),
284 fActualRole(-1),
285 fxRefreshTimer(nullptr),
286 fxConnectionTimer(nullptr),
288{
289 fxDisplay = new TGo4Display(!isserver);
290
291 fxDisplay->SetAnalysis(this);
292
293 fxDisplay->GetTask()->Initialization();
294}
295
297{
298// Info("~TGo4AnalysisProxy","%x",this);
299
300 if (fxRefreshTimer) delete fxRefreshTimer;
302
304 fxSubmittedProxy.Delete();
305
306 delete fxDefaultProxy;
307 fxDefaultProxy = nullptr;
308
309 delete fAnalysisNames;
310
311 if (fxDisplay) {
312 // if no disconnect attempt was done, send at the end quit command
313 // never delete display directly
314 if (fDisconectCounter == -111)
315 fxDisplay->SubmitCommand("MRQuit");
316
317 if (fxDisplay) {
318 fxDisplay->SetAnalysis(nullptr);
319 TGo4Log::Debug("TGo4Display instance is not deleted correctly when analysis proxy is destroyed");
320 }
321 }
322}
323
325{
327
328 TGo4Slot *subslot = new TGo4Slot(fxParentSlot, "Settings", "Analysis configuration");
329 subslot->SetProxy(new TGo4ObjectProxy());
330
331 subslot = new TGo4Slot(fxParentSlot, "Ratemeter", "Analysis ratemeter");
332 subslot->SetProxy(new TGo4ObjectProxy());
333
334 subslot = new TGo4Slot(fxParentSlot, "Loginfo", "Analysis logging message");
335 subslot->SetProxy(new TGo4ObjectProxy());
336
337 subslot = new TGo4Slot(fxParentSlot, "UpdateObject", "Result of update object");
338 subslot->SetProxy(new TGo4ObjectProxy());
339}
340
342{
343 return !fxParentSlot ? nullptr : fxParentSlot->FindChild("UpdateObject");
344}
345
346
348{
349// Info("Finalize","Parent %x %x", slot, fxParentSlot);
350
351 slot->DeleteChilds();
352
353 fxParentSlot = nullptr;
354}
355
357{
358 return fAnalysisNames != nullptr;
359}
360
362{
363 if (!fAnalysisNames) return nullptr;
364
365 return new TGo4AnalysisLevelIter(fAnalysisNames->GetNamesFolder(), kFALSE);
366}
367
368void TGo4AnalysisProxy::WriteData(TGo4Slot *slot, TDirectory *dir, Bool_t onlyobjs)
369{
370}
371
372void TGo4AnalysisProxy::ReadData(TGo4Slot *slot, TDirectory *dir)
373{
374}
375
377{
378 if (!fxDisplay) return kGo4ComModeRefused;
379
380 Int_t res = kGo4ComModeRefused;
381
382 if (IsAnalysisServer()) {
383 if (fActualRole >= 0)
384 res = fActualRole;
385 } else if (fxDisplay->GetTask())
386 if (fxDisplay->GetTask()->GetTaskHandler())
387 res = fxDisplay->GetTask()->GetTaskHandler()->GetRole();
388 return res;
389}
390
392{
393 return GetRole() == kGo4ComModeObserver;
394}
395
397{
398 return GetRole() == kGo4ComModeController;
399}
400
405
407{
408 TGo4ServerProxy::GetContainedObjectInfo(); // evaluate roles
409 fInfoStr +="@";
411 if (IsConnected() && fAnalysisNames && (strcmp(fAnalysisNames->GetName(),"Go4NamesList") != 0)) {
412 fInfoStr += " name:";
413 fInfoStr += fAnalysisNames->GetName();
414 }
415 return fInfoStr.Data();
416}
417
418TGo4AnalysisObjectAccess* TGo4AnalysisProxy::FindSubmittedProxy(const char *pathname, const char *objname)
419{
420 for (int n = 0; n <= fxSubmittedProxy.GetLast(); n++) {
422 if (!proxy) continue;
423 if (strcmp(proxy->GetObjectName(), objname) != 0) continue;
424 if (pathname && (strcmp(proxy->GetPathName(), pathname) != 0)) continue;
425 return proxy;
426 }
427 return nullptr;
428}
429
431{
432 bool docompress = false;
433 if (proxytodelete) {
434 fxSubmittedProxy.Remove(proxytodelete);
435 delete proxytodelete;
436 docompress = true;
438 }
439
440 for (int n = 0; n <= fxSubmittedProxy.GetLast(); n++) {
442 if (!proxy) continue;
443 if (proxy->CheckLifeTime(100000)) {
444 fxSubmittedProxy.Remove(proxy);
445 docompress = true;
446 delete proxy;
448 }
449 }
450
451 if (docompress)
452 fxSubmittedProxy.Compress();
453}
454
456{
457 if (dynamic_cast<TGo4AnalysisStatus*> (status)) {
458 SetAnalysisReady(kTRUE);
459 if (SettingsSlot()) {
460 SettingsSlot()->AssignObject(status, kTRUE);
461 status = nullptr;
462 }
464 }
465
466 TGo4AnalysisClientStatus* analstatus = dynamic_cast<TGo4AnalysisClientStatus*> (status);
467 if (analstatus) {
468 // analstatus->Print();
469 fbAnalysisRunning = analstatus->IsAnalysisRunning();
471 SetAnalysisSettingsReady(kTRUE); // JAM workaround for go4 server connection: a running analysis must have been configured
472
473 if (RatemeterSlot()) {
474 RatemeterSlot()->AssignObject(status, kTRUE);
475 status = nullptr;
476 }
477 }
478
479 TGo4AnalysisObjectResult* obres = dynamic_cast<TGo4AnalysisObjectResult*> (status);
480 if (obres) {
481 TGo4AnalysisObjectNames *objnames = obres->GetNamesList(kTRUE);
482
483 if (objnames)
484 AssignNewNamesList(objnames);
485 if (UpdateObjectSlot()) {
486 TString fullname = obres->GetObjectFullName();
487
488 if (fxParentSlot) {
489 fullname.Prepend("/");
490 fullname.Prepend(fxParentSlot->GetName());
491 }
492
493 obres->SetObjectFullName(fullname.Data());
494
495 UpdateObjectSlot()->AssignObject(obres, kTRUE);
496 status = nullptr;
497 }
499 }
500
501 if (status) {
502 TString message = status->GetName();
503
504 if(message.Contains("event classes were initialized"))
506
507 // for gui as client at analysis server
508 if (message.Contains("is logged in at") && IsAnalysisServer())
509 for (int j = 0; j < 4; ++j)
510 if (message.Contains(TGo4Command::GetModeDescription((Go4CommandMode_t)j))) {
511 fActualRole = j;
512 break;
513 }
514
515 // this happens when analysis disconnects itself
516 if (message.Contains("is shutting down now!")) {
517 fActualRole = -1;
518 TGo4Task* task = fxDisplay ? fxDisplay->GetTask() : nullptr;
519 TGo4BufferQueue *qu = task ? task->GetCommandQueue() : nullptr;
520 if(qu) qu->Clear();
521 }
522
523 if (LoginfoSlot()) {
524 LoginfoSlot()->AssignObject(status, kTRUE);
525 status = nullptr;
526 }
527 }
528
529 if (status) delete status;
530}
531
533{
534 // object should be cleaned at the end
535
536 if (!obj) return;
537
538 TGo4ObjEnvelope* envelope = dynamic_cast<TGo4ObjEnvelope*> (obj);
539 if (envelope) {
540 TGo4AnalysisObjectAccess* proxy = FindSubmittedProxy(envelope->GetObjFolder(), envelope->GetObjName());
541 if (!proxy) proxy = fxDefaultProxy;
542
543 if (proxy) {
544 TObject *envelopeobj = envelope->TakeObject();
545 if (envelopeobj && envelopeobj->InheritsFrom(TH1::Class()))
546 ((TH1 *) envelopeobj)->SetDirectory(nullptr);
547 proxy->ReceiveObject(envelopeobj, envelope->GetObjFolder(), envelope->GetObjName(), kTRUE);
548
549
550 if (proxy != fxDefaultProxy) DeleteSubmittedProxy(proxy);
551 }
552 delete envelope;
553 return;
554 }
555
556 TGo4AnalysisObjectNames *objnames = dynamic_cast<TGo4AnalysisObjectNames*> (obj);
557 if (objnames) {
558 AssignNewNamesList(objnames);
559 return;
560 }
561
562 TGo4AnalysisObjectAccess* proxy = FindSubmittedProxy(nullptr, obj->GetName());
563 if (proxy) {
564 proxy->ReceiveObject(obj, nullptr, obj->GetName(), kTRUE);
566 return;
567 }
568
569 delete obj;
570}
571
573{
574 delete fAnalysisNames;
575 fAnalysisNames = objnames;
576 fbNamesListReceived = kTRUE;
577
578 SetAnalysisReady(kTRUE);
579
580 if (fxParentSlot)
582}
583
585{
586// std::cout << " TGo4AnalysisProxy::RefreshNamesList() " << std::endl;
587 //fxDisplay->SubmitCommand(new TGo4ComGetNamesList());
588 fxDisplay->SubmitCommand("ANNames");
589 fbNamesListReceived = kFALSE;
590 return kTRUE;
591}
592
594{
595 if (!fxRefreshTimer) fxRefreshTimer = new TTimer(this, 10, kTRUE);
596
597 fxRefreshTimer->Start(delay_sec*1000, kTRUE);
598
599 return kTRUE;
600}
601
606
607std::unique_ptr<TGo4Access> TGo4AnalysisProxy::ProvideAccess(const char *name)
608{
609 if (!name || !*name || !fAnalysisNames) return nullptr;
610
611 TObject *entry = fAnalysisNames->GetNamesFolder()->FindObjectAny(name);
612
613 const char *classname = TGo4AnalysisLevelIter::EntryClassName(entry);
614
615 if (!classname) return nullptr;
616
617 TString objfolder, objname;
618 TGo4Slot::ProduceFolderAndName(name, objfolder, objname);
619
620 return std::make_unique<TGo4AnalysisObjectAccess>(this, cmdEnvelope, objname.Data(), classname, objfolder.Data());
621}
622
623void TGo4AnalysisProxy::Update(TGo4Slot *slot, Bool_t strong)
624{
625 if (strong)
627}
628
629
631{
632 if (!proxy) return kFALSE;
633
634 fxSubmittedProxy.Add(proxy);
635
637
638 proxy->SetSubmitTime();
639
640 if (proxy->ProxyKind()==cmdEnvelope) {
641 //TGo4ComGetEnvelope* com = new TGo4ComGetEnvelope(proxy->GetObjectName(), proxy->GetPathName());
642 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANGetEnvelope");
643
644 com->SetString(proxy->GetObjectName(), 0);
645 com->SetString(proxy->GetPathName(), 1);
646 fxDisplay->SubmitCommand(com);
647 } else
648 if (proxy->ProxyKind()==cmdStatus) {
649// TGo4ComGetObjectStatus *com = new TGo4ComGetObjectStatus(proxy->GetObjectName());
650// com->SetFolderName(proxy->GetPathName());
651 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANObjectStatus");
652 com->SetString(proxy->GetObjectName(),0);
653 com->SetString(proxy->GetPathName(),1);
654 TString rcvname = proxy->GetObjectName();
655 rcvname.Append("_status");
656 proxy->ChangeObjectName(rcvname.Data());
657 fxDisplay->SubmitCommand(com);
658 } else
659 if (proxy->ProxyKind()==cmdEvStatus) {
660// TGo4ComGetCurrentEvent *com = new TGo4ComGetCurrentEvent(proxy->GetObjectName());
661// com->SetPrintoutOnly(kFALSE);
662// com->SetOutputEvent(kFALSE);
663 Bool_t astree = strcmp(proxy->GetPathName(),"Tree") == 0;
664// com->SetTreeMode(astree);
665 TGo4RemoteCommand *com= new TGo4RemoteCommand("ANGetEvent");
666 com->SetString(proxy->GetObjectName(), 0);
667 com->SetValue(kFALSE,0); // use output event
668 com->SetValue(kFALSE,1); // printout only
669 com->SetValue(astree,2); // treemode on or off
670 fxDisplay->SubmitCommand(com);
671 }
672
673 return kTRUE;
674}
675
676Bool_t TGo4AnalysisProxy::RequestObjectStatus(const char *fullname, TGo4Slot *tgtslot)
677{
678 if (!fullname || !tgtslot) return kFALSE;
679
680 TString objfolder, objname;
681 TGo4Slot::ProduceFolderAndName(fullname, objfolder, objname);
682
684 new TGo4AnalysisObjectAccess(this, cmdStatus, objname, "", objfolder);
685
686 access->AssignObjectToSlot(tgtslot);
687
688 return kTRUE;
689}
690
691void TGo4AnalysisProxy::RequestEventStatus(const char *evname, Bool_t astree, TGo4Slot *tgtslot)
692{
693 if (!evname) return;
694
695 TString folder, name;
696 TGo4Slot::ProduceFolderAndName(evname, folder, name);
697
698 if (!tgtslot) {
699// TGo4ComGetCurrentEvent *com = new TGo4ComGetCurrentEvent(name);
700// com->SetPrintoutOnly(kTRUE);
701// com->SetOutputEvent(kFALSE);
702// com->SetTreeMode(astree);
703 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANGetEvent");
704 com->SetString(name,0);
705 com->SetValue(kFALSE,0); // use output event
706 com->SetValue(kTRUE,1); // printout only
707 com->SetValue(astree,2); // treemode on or off
708 fxDisplay->SubmitCommand(com);
709 } else {
710 if (astree) folder = "Tree";
711 else folder = "Event";
712
714 new TGo4AnalysisObjectAccess(this, cmdEvStatus, name, "", folder);
715
716 access->AssignObjectToSlot(tgtslot);
717 }
718}
719
720
721void TGo4AnalysisProxy::RemoteTreeDraw(const char *treename,
722 const char *varexp,
723 const char *cutcond,
724 const char *hname)
725{
726 TString tfoldername, tobjectname;
727 TGo4Slot::ProduceFolderAndName(treename, tfoldername, tobjectname);
728
729 TString hfoldername, hobjectname;
730 TGo4Slot::ProduceFolderAndName(hname, hfoldername, hobjectname);
731
732 //fxDisplay->SubmitCommand(new TGo4ComAddTreeHistogram(hobjectname.Data(), tobjectname.Data(), varexp, cutcond));
733 TGo4RemoteCommand *remcom = new TGo4RemoteCommand("ANAddTreeHis");
734 remcom->SetString(hobjectname.Data(),0);
735 remcom->SetString(tobjectname.Data(),1);
736 remcom->SetString(varexp,2);
737 remcom->SetString(cutcond,3);
738 fxDisplay->SubmitCommand(remcom);
739}
740
742 Int_t evnumber,
743 Int_t subid,
744 Bool_t ishex,
745 Bool_t islong)
746{
747 TGo4RemoteCommand *com= new TGo4RemoteCommand("ANSetPrintEvent");
748 com->SetString(evname,0);
749 com->SetValue(evnumber, 0);
750 com->SetValue(subid, 1);
751 com->SetValue(islong, 2);
752 com->SetValue(ishex, 3);
753 com->SetValue(!ishex, 4);
754 fxDisplay->SubmitCommand(com);
755}
756
757Bool_t TGo4AnalysisProxy::UpdateAnalysisObject(const char *fullpath, TObject *obj)
758{
759 if (!obj) return kFALSE;
760
761 const char *objname = obj->GetName();
762 if (!objname || (*objname == 0)) return kFALSE;
763
765 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANSetObject");
766 com->SetString(objname,0); // object name
767 com->SetAggregate(obj); // parameter
768 fxDisplay->SubmitCommand(com);
769
770 return kTRUE;
771}
772
774{
775 if(!fname || (strlen(fname) == 0)) {
776 fxDisplay->SubmitCommand("ANLoad");
777 } else {
778 //TGo4ComLoadAnalysisStatus *com = new TGo4ComLoadAnalysisStatus(fname);
779 TGo4RemoteCommand *com= new TGo4RemoteCommand("ANLoad");
780 com->SetString(fname,0); // name of status file
781 fxDisplay->SubmitCommand(com);
782 }
783}
784
786{
787 if(!fname || (strlen(fname) == 0)) {
788 fxDisplay->SubmitCommand("ANSave");
789 } else {
790 //TGo4ComSaveAnalysisStatus *com = new TGo4ComSaveAnalysisStatus(fname);
791 TGo4RemoteCommand *com= new TGo4RemoteCommand("ANSave");
792 com->SetString(fname,0); // name of status file
793 fxDisplay->SubmitCommand(com);
794 }
795}
796
797void TGo4AnalysisProxy::WriteAutoSave(const char *fname,
798 Int_t complevel,
799 Bool_t overwrite)
800{
801// TGo4ComAutosave *com = new TGo4ComAutosave();
802// com->SetAutoFileName(fname);
803// com->SetAutoSaveCompression(complevel);
804// com->SetAutoSaveOverwrite(overwrite);
805 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANAutosave");
806 com->SetString(fname,0); // name of asf file
807 com->SetValue(complevel,0); // file compression level
808 com->SetValue(overwrite,1); // overwrite on or off
809 fxDisplay->SubmitCommand(com);
810}
811
813{
814 fxDisplay->SubmitCommand("THStart");
815 fbAnalysisRunning = kTRUE;
816}
817
819{
820 fxDisplay->SubmitCommand("THStop");
821 fbAnalysisRunning = kFALSE;
822}
823
824void TGo4AnalysisProxy::ExecuteLine(const char *line)
825{
826 TGo4ComExecLine *com = new TGo4ComExecLine();
827 com->SetLine(line);
828 fxDisplay->SubmitCommand(com);
829}
830
832{
833 ClearAnalysisObject("Histograms");
834 ClearAnalysisObject("Conditions");
835}
836
837
839{
840 TString foldername, objectname;
841 TGo4Slot::ProduceFolderAndName(fullpath, foldername, objectname);
842 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANClearObject");
843 com->SetString(objectname.Data(),0);
844 fxDisplay->SubmitCommand(com);
845}
846
847void TGo4AnalysisProxy::ChageObjectProtection(const char *fullpath, const char *flags)
848{
849 TString foldername, objectname;
850 TGo4Slot::ProduceFolderAndName(fullpath, foldername, objectname);
851 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANSetProtect");
852 com->SetString(objectname.Data(),0);
853 com->SetString(flags,2);
854 fxDisplay->SubmitCommand(com);
855}
856
858{
859 TString foldername, objectname;
860 TGo4Slot::ProduceFolderAndName(fullpath, foldername, objectname);
861 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANDelete");
862 com->SetString(objectname.Data(),0);
863 fxDisplay->SubmitCommand(com);
864}
865
867{
868 fxDisplay->SubmitCommand("ANGetStatus");
869}
870
872{
873 TGo4AnalysisStatus *status = nullptr;
874 if (SettingsSlot())
875 status = dynamic_cast<TGo4AnalysisStatus*>(SettingsSlot()->GetAssignedObject());
876 if (status) {
878 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANSetStatus");
879 com->SetAggregate(status);
880 fxDisplay->SubmitCommand(com);
881 fxDisplay->SubmitCommand("ANInit");
882 }
883}
884
886{
888
889 fxDisplay->SubmitCommand("ANClose");
890}
891
892void TGo4AnalysisProxy::PrintDynListEntry(const char *fullpath)
893{
894 TString foldername, objectname;
895 TGo4Slot::ProduceFolderAndName(fullpath, foldername, objectname);
896 TGo4RemoteCommand *com = new TGo4RemoteCommand("ANPrdyn");
897 com->SetString(objectname.Data(),0);
898 fxDisplay->SubmitCommand(com);
899}
900
902{
903 if (!fxDisplay) return 0;
904
905 TGo4ServerTask *tsk = dynamic_cast<TGo4ServerTask *>(fxDisplay->GetTask());
906 if (!tsk) return 0;
907
908 return tsk->GetTaskManager()->GetNegotiationPort();
909}
910
911
912Bool_t TGo4AnalysisProxy::LaunchAsClient(TString &launchcmd,
913 TString &killcmd,
914 Int_t usessh,
915 Int_t konsole,
916 const char *name,
917 const char *remotehost,
918 const char *remotedir,
919 const char *remoteexe,
920 Int_t exe_kind,
921 const char *exeargs)
922{
923 if (!fxDisplay) return kFALSE;
924
925 TGo4ServerTask *tsk = dynamic_cast<TGo4ServerTask *> (fxDisplay->GetTask());
926 if (!tsk) return kFALSE;
927
928 Int_t guiport = tsk->GetTaskManager()->GetNegotiationPort();
929
930 if (!GetLaunchString(launchcmd, killcmd,
931 0, usessh, konsole,
932 name, remotehost, remotedir, remoteexe,
933 guiport, exe_kind, exeargs)) return kFALSE;
934
936
937 if ((konsole==2) || (konsole==3))
938 gSystem->Exec(launchcmd.Data());
939
940 fNodeName.Form("%s:%d",remotehost,guiport);
941 return kTRUE;
942}
943
944Bool_t TGo4AnalysisProxy::LaunchAsServer(TString &launchcmd,
945 TString &killcmd,
946 Int_t usessh,
947 Int_t konsole,
948 const char *name,
949 const char *remotehost,
950 Int_t remoteport,
951 const char *remotedir,
952 const char *remoteexe,
953 Int_t exe_kind,
954 const char *exeargs)
955{
956 if (!GetLaunchString(launchcmd, killcmd,
957 1, usessh, konsole,
958 name, remotehost, remotedir, remoteexe,
959 remoteport, exe_kind, exeargs)) return kFALSE;
960
961 if ((konsole==2) || (konsole==3))
962 gSystem->Exec(launchcmd.Data());
963
964 return kTRUE;
965}
966
967Bool_t TGo4AnalysisProxy::ConnectToServer(const char *remotehost,
968 Int_t remoteport,
969 Int_t ascontroller,
970 const char *accesspass)
971{
972
973 TGo4ClientTask* client = dynamic_cast<TGo4ClientTask*> (fxDisplay->GetTask());
974 if(client) {
976 switch (ascontroller) {
977 case 0: mode = kGo4ComModeObserver; break;
978 case 1: mode = kGo4ComModeController; break;
979 case 2: mode = kGo4ComModeAdministrator; break;
980 }
981 if (!accesspass)
982 switch (mode) {
983 case kGo4ComModeObserver: accesspass = "go4view"; break;
984 case kGo4ComModeController: accesspass = "go4ctrl"; break;
985 case kGo4ComModeAdministrator: accesspass = "go4super"; break;
987 default: accesspass = ""; break;
988 }
989
990 client->ConnectServer(remotehost, remoteport, mode, accesspass);
991 fNodeName.Form("%s:%d",remotehost,remoteport);
993 }
994
995 return client != nullptr;
996}
997
999{
1000 Int_t period = seconds*1000;
1001 while (period > 0) {
1002 if (IsConnected()) return kTRUE;
1003 gSystem->Sleep(100);
1004 gSystem->ProcessEvents();
1005 period-=100;
1006 }
1007 return IsConnected();
1008}
1009
1010
1011void TGo4AnalysisProxy::DisconnectAnalysis(Int_t waittime, Bool_t servershutdown)
1012{
1013 if (fDisconectCounter > 0) return;
1014
1015 if (fxDisplay) {
1016 if (servershutdown)
1017 fxDisplay->SubmitCommand("SVQuit");
1018 else
1019 fxDisplay->SubmitCommand("MRQuit");
1020 }
1021
1022 fDisconectCounter = waittime*10;
1023
1024 fActualRole = -1;
1025
1027
1028 if (!fxConnectionTimer)
1029 fxConnectionTimer = new TTimer(this, 10, kTRUE);
1030
1031 fxConnectionTimer->Start(100, kTRUE);
1032}
1033
1035{
1036 if (!fxDisplay) return kFALSE;
1037
1038 if (!fxDisplay->IsConnected()) return kFALSE;
1039
1040 return !IsAnalysisServer() || (fActualRole >= 0);
1041}
1042
1044{
1045 if (fxDisplay==displ) fxDisplay = nullptr;
1046}
1047
1049{
1050 if ((fxDisplay == displ) && displ)
1051 DisconnectAnalysis(5, false);
1052}
1053
1059
1061{
1062 if (timer == fxRefreshTimer) {
1064 } else
1065 if (timer == fxConnectionTimer) {
1066 if (fxDisplay) {
1067 // this is emergency handling only if display did not shutdown and deleted our proxy before.
1068 if (fDisconectCounter > 0) {
1070 fxConnectionTimer->Start(100, kTRUE);
1071 } else {
1072 // this is an emergency disconnect! regularly, the TGo4Display will destroy us now
1073
1074 std::cout<< " TGo4AnalysisProxy::HandleTimer still sees not that display is gone. Cleanup myself!"<< std::endl;
1075 fxConnectionTimer->TurnOff();
1076 fxConnectionTimer = nullptr; // avoid that timer is deleted in dtor, since this function runs within timer notify!
1077 if (fxParentSlot) {
1078 // this will also delete Analysis proxy itself
1079 // practically the same as delete fxParentSlot;
1080 fxParentSlot->Delete();
1081 //fxParentSlot = nullptr;
1082 //fxParentSlot->GetOM()->DeleteObject(fxParentSlot);
1083 } else {
1084 delete this;
1085 }
1086 } // if(fDisconectCounter > 0)
1087 } //if(fxDisplay)
1088 }
1089 return kFALSE;
1090}
1091
1093{
1094 if (!rcv) {
1095 delete fxDefaultProxy;
1096 fxDefaultProxy = nullptr;
1097 } else {
1099 fxDefaultProxy->SetDefaultReceiver(rcv, path);
1100 }
1101}
@ cmdEvStatus
@ cmdDefualtEnvelope
@ cmdStatus
@ cmdEnvelope
Go4CommandMode_t
These values define command execution rights.
Definition TGo4Command.h:27
@ kGo4ComModeController
Definition TGo4Command.h:30
@ kGo4ComModeRefused
Definition TGo4Command.h:28
@ kGo4ComModeObserver
Definition TGo4Command.h:29
@ kGo4ComModeAdministrator
Definition TGo4Command.h:31
void DoObjectAssignement(TGo4ObjectManager *rcv, const char *path, TObject *obj, Bool_t owner)
Definition TGo4Proxy.cxx:63
@ kndTreeBranch
Definition TGo4Proxy.h:37
@ kndDataMember
Definition TGo4Proxy.h:40
Int_t AssignObjectToSlot(TGo4Slot *slot)
Made for convenience - extracts OM and slot path and calls AssignObjectTo method.
Definition TGo4Proxy.cxx:54
const char * GetClassName() override
const char * name() override
Int_t getflag(const char *flagname) override
static const char * EntryClassName(TObject *entry)
const char * info() override
TGo4LevelIter * subiterator() override
TGo4AnalysisLevelIter(TFolder *folder, Bool_t istree=kFALSE)
void ChangeObjectName(const char *newname)
TGo4ObjectManager * fxReceiver
void SetDefaultReceiver(TGo4ObjectManager *rcv, const char *path)
Bool_t IsRemote() const override
Indicate if object is remote.
Bool_t CheckLifeTime(long int millisec)
Int_t AssignObjectTo(TGo4ObjectManager *rcv, const char *path) override
Have to assign object to provided receiver.
const char * GetObjectName() const override
TGo4AnalysisObjectAccess(TGo4AnalysisProxy *cont, Int_t proxykind, const char *name, const char *classname, const char *fullpath)
void ReceiveObject(TObject *obj, const char *objfolder, const char *objname, Bool_t owner)
TGo4AnalysisProxy * fxAnalProxy
const char * GetObjectClassName() const override
const char * GetPathName() const
Bool_t CanGetObject() const override
Returns kTRUE, when object can be directly obtained with GetObject() method.
Contains the name (key) list of all objects in the analysis scope.
const char * GetObjectFullName() const
TGo4AnalysisObjectNames * GetNamesList(Bool_t chown=kTRUE)
Take out the nameslist.
void SetObjectFullName(const char *nam)
TGo4Display * fxDisplay
void ReceiveObject(TNamed *obj)
Bool_t IsAdministrator() const override
void ChageObjectProtection(const char *fullpath, const char *flags) override
void DeleteSubmittedProxy(TGo4AnalysisObjectAccess *proxy)
Bool_t IsConnected() const override
void RequestEventStatus(const char *evname, Bool_t astree, TGo4Slot *tgtslot) override
const char * GetContainedObjectInfo() override
Bool_t DelayedRefreshNamesList(Int_t delay_sec) override
void StartAnalysis() override
void StopAnalysis() override
TGo4AnalysisProxy(Bool_t isserver=kFALSE)
Bool_t SubmitProxy(TGo4AnalysisObjectAccess *proxy)
void ClearAllAnalysisObjects() override
void CloseAnalysisSettings() override
void RequestAnalysisSettings() override
void ClearAnalysisObject(const char *fullpath) override
void DisplayDisconnected(TGo4Display *displ)
void WriteData(TGo4Slot *slot, TDirectory *dir, Bool_t onlyobjs) override
TGo4AnalysisObjectAccess * FindSubmittedProxy(const char *pathname, const char *objname)
void SaveConfigFile(const char *fname) override
Bool_t ConnectToServer(const char *remotehost, Int_t remoteport, Int_t ascontroller, const char *accesspass)
TGo4AnalysisObjectNames * fAnalysisNames
Bool_t HandleTimer(TTimer *timer) override
TGo4LevelIter * MakeIter() override
void SubmitAnalysisSettings() override
TGo4AnalysisObjectAccess * fxDefaultProxy
void AssignNewNamesList(TGo4AnalysisObjectNames *objnames)
TGo4Slot * UpdateObjectSlot()
Bool_t RefreshNamesList() override
void RemoveObjectFromAnalysis(const char *fullpath) override
std::unique_ptr< TGo4Access > ProvideAccess(const char *name) override
void Finalize(TGo4Slot *slot) override
Bool_t IsAnalysisServer() const override
void DisconnectAnalysis(Int_t waittime=30, Bool_t servershutdown=kFALSE) override
Close connection to analysis and destroys proxy with correspondent slot.
Bool_t IsViewer() const override
Bool_t LaunchAsClient(TString &launchcmd, TString &killcmd, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, const char *remotedir, const char *remoteexe, Int_t exe_kind=0, const char *exeargs=nullptr)
Bool_t RequestObjectStatus(const char *objectname, TGo4Slot *tgtslot) override
void ExecuteLine(const char *line) override
void Update(TGo4Slot *slot, Bool_t strong) override
void Initialize(TGo4Slot *slot) override
void RemoteTreeDraw(const char *treename, const char *varexp, const char *cutcond, const char *hname) override
void RemotePrintEvent(const char *evname, Int_t evnumber, Int_t subid, Bool_t ishex, Bool_t islong) override
void DisplayDeleted(TGo4Display *displ)
Bool_t HasSublevels() const override
static Bool_t LaunchAsServer(TString &launchcmd, TString &killcmd, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, Int_t remoteport, const char *remotedir, const char *remoteexe, Int_t exe_kind=0, const char *exeargs=nullptr)
Bool_t IsController() const override
void ReadData(TGo4Slot *slot, TDirectory *dir) override
void SetDefaultReceiver(TGo4ObjectManager *rcv, const char *path)
Set receiver for object envelopes, which coming from analysis without request.
void LoadConfigFile(const char *fname) override
Bool_t WaitForConnection(Int_t seconds)
void PrintDynListEntry(const char *fullpath) override
Bool_t UpdateAnalysisObject(const char *objectname, TObject *obj) override
void ReceiveStatus(TGo4Status *status)
Bool_t NamesListReceived() const override
void WriteAutoSave(const char *fname, Int_t complevel, Bool_t overwrite) override
Status of the analysis instance.
Class containing a pointer queue for TBuffers.
void Clear(Option_t *opt="") override
Empty the queue and give free buffers back.
This class controls a client application running in a task which is controlled by another server task...
Bool_t ConnectServer(const char *node, UInt_t negport, Go4CommandMode_t role=kGo4ComModeRefused, const char *passwd=nullptr)
Connect this client to a waiting server task on node with negotiation channel negport.
Command executes string as CINT macro.
void SetLine(const char *name)
set the object name under command.
static const char * GetModeDescription(Go4CommandMode_t mode)
text description of current execution mode
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
const char * GetObjName() const
const char * GetObjFolder() const
TObject * TakeObject()
One entry of the object names folder.
const char * GetObjectClass() const
ClassName of the described object.
Int_t GetObjectSize() const
Size of described object in byte.
Bool_t IsResetProtect() const
Object's reset protection state.
Bool_t IsDeleteProtect() const
Object's delete protection state.
Status object for an analysis parameter.
This command is a container for commands to be send from master to slave via inter-process transport.
void SetAggregate(TObject *ob)
Wrap any object ob into this command container.
void SetString(const char *txt, Int_t i)
Specify string parameter txt for index i to be used in executed command.
void SetValue(Int_t num, Int_t i)
Specify integer parameters to be used in executed command.
const char * GetContainedObjectInfo() override
TGo4Slot * LoginfoSlot()
TString fNodeName
0 - not launched, 1 - external shell, 2 - in qt shell
void SetAnalysisReady(Bool_t on=kTRUE)
virtual const char * GetServerName() const
TGo4Slot * fxParentSlot
TString fInfoStr
name of remote node
TGo4ServerProxy()
contained object info
TGo4Slot * RatemeterSlot()
void Initialize(TGo4Slot *slot) override
TGo4Slot * SettingsSlot()
void SetAnalysisSettingsReady(Bool_t on=kTRUE)
static Bool_t GetLaunchString(TString &launchcmd, TString &killcmd, Int_t serverkind, Int_t shellkind, Int_t konsole, const char *name, const char *remotehost, const char *remotedir, const char *remoteexe, Int_t guiport, Int_t exe_kind=0, const char *exeargs=nullptr)
Server task.
virtual Bool_t StartConnectorThread()
starts the thread that listens to the connector port for a client negotiation request; used after lau...
TGo4TaskManager * GetTaskManager()
void SetProxy(TGo4Proxy *cont)
Definition TGo4Slot.cxx:296
@ evObjUpdated
Definition TGo4Slot.h:49
@ evObjAssigned
Definition TGo4Slot.h:47
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
Definition TGo4Slot.cxx:646
Bool_t AssignObject(TObject *obj, Bool_t owner)
Definition TGo4Slot.cxx:344
void DeleteChilds(const char *startedwith=nullptr)
Definition TGo4Slot.cxx:202
TObject * GetAssignedObject()
Definition TGo4Slot.cxx:356
UInt_t GetNegotiationPort()
returns the portnumber for client server negotiation port which is actually used by the running taskm...
Go4 Task.
Definition TGo4Task.h:39
virtual TGo4BufferQueue * GetCommandQueue(const char *task=nullptr)
Definition TGo4Task.h:105
Contains the branchelement structure of a certain TTree on the analysis side.