GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ComSetObject.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 "TGo4ComSetObject.h"
15
16#include "TFolder.h"
17#include "TH1.h"
18
19#include "TGo4Log.h"
21#include "TGo4AnalysisImp.h"
22#include "TGo4RemoteCommand.h"
24#include "TGo4Parameter.h"
25#include "TGo4ParameterStatus.h"
26#include "TGo4Condition.h"
27#include "TGo4DynamicEntry.h"
29#include "TGo4Picture.h"
30
31
33 TGo4AnalysisObjectCommand("ANSetObject","Set existing object to new values or create new object","mypara")
34{
35 SetReceiverName("AnalysisClient"); // this command needs client as receiver
36 // override default receiver
38}
39
40
42 TGo4AnalysisObjectCommand("ANSetObject","Set existing object to new values or create new object",obname)
43{
44 SetReceiverName("AnalysisClient"); // this command needs client as receiver
45 // override default receiver
47}
48
49
51{
52 //delete fxObject; // cleanup is done depending on ExeCom
53 delete fxResult; //
54}
55
57{
58 if(!remcom) return;
60 TObject *ob = remcom->GetAggregate(); // we take over ownership
61 if(ob && ob!=fxObject) {
62 delete fxObject;
63 fxObject = ob;
64 }
65}
66
68{
70 if (!fxClient) {
71 GO4TRACE((11,"TGo4ComSetObject::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
72 TGo4Log::Debug(" !!! %s : NO RECEIVER ERROR!!!",GetName());
73 return 1;
74 }
75
76 if(!fxObject) {
77 fxClient->SendStatusMessage(3, kTRUE, TString::Format("SetObject - ERROR: no source object specified for %s", GetObjectName()));
78 return 0;
79 }
80
81 SetObjectName(fxObject->GetName()); // override target name...
82 TGo4Log::Debug(" %s : Setting object %s ", GetName(), GetObjectName());
85 // evaluate object type here:
86 if(ExeSetParStatus(dynamic_cast<TGo4ParameterStatus *>(fxObject)) == 0) {
87 ;
88 } else if(ExeSetPar(dynamic_cast<TGo4Parameter *>(fxObject)) == 0) {
89 ;
90 } else if(ExeSetCon(dynamic_cast<TGo4Condition *>(fxObject)) == 0) {
91 ;
92 } else if(ExeSetDyn(dynamic_cast<TGo4DynamicEntry *>(fxObject)) == 0) {
93 ;
94 } else if(ExeSetHis(dynamic_cast<TH1 *>(fxObject)) == 0) {
95 ;
96 } else if(ExeSetPic(dynamic_cast<TGo4Picture *>(fxObject)) == 0) {
97 ;
98 } else {
100 }
101
102 fxAna->UpdateNamesList();
103 TGo4AnalysisObjectNames *state = fxAna->GetNamesList();
104 fxResult->SetNamesList(state); // note: nameslist is not owned by result object!
105 if(fxResult->Action() != kGo4ActionError) {
106 TFolder *top = fxAna->GetObjectFolder();
107 TString fullname = top->FindFullPathName(GetObjectName());
108 fullname.Remove(0, 6); // remove //Go4/ top folder name
109 fxResult->SetObjectFullName(fullname);
110 }
111 fxClient->SendStatus(fxResult);
112 return -1;
113}
114
116{
117 if (!par) return -1;
118 TString buf;
119 if(fxAna->SetParameterStatus(GetObjectName(),par)) {
120 buf = TString::Format("Parameter %s was set to new values.", GetObjectName());
121 fxClient->SendStatusMessage(1, kTRUE, buf);
122 fxResult->SetAction(kGo4ActionEdit);
123 } else {
124 buf = TString::Format("SetObject - ERROR: failed to set parameter %s",GetObjectName());
125 fxClient->SendStatusMessage(3, kTRUE, buf);
126 fxResult->SetAction(kGo4ActionError);
127 }
128 fxResult->SetMessage(buf.Data());
129 delete fxObject;
130 fxObject = nullptr;
131 return 0;
132}
133
135{
136 if(!par) return -1;
137 TString buf;
138 if(fxAna->SetParameter(GetObjectName(),par)) {
139 buf = TString::Format("Parameter %s was set to new values.", GetObjectName());
140 fxClient->SendStatusMessage(1, kTRUE, buf);
141 fxResult->SetAction(kGo4ActionEdit);
142 } else {
143 buf = TString::Format("SetObject - ERROR: failed to set parameter %s",GetObjectName());
144 fxClient->SendStatusMessage(3, kTRUE, buf);
145 fxResult->SetAction(kGo4ActionError);
146 }
147 fxResult->SetMessage(buf.Data());
148 delete fxObject;
149 fxObject = nullptr;
150 return 0;
151}
152
154{
155 if(!conny) return -1;
156 TString buf;
157 if(fxAna->SetAnalysisCondition(GetObjectName(),conny, kFALSE)) {
158 buf = TString::Format("Condition %s was set to new values.", GetObjectName());
159 fxClient->SendStatusMessage(1, kTRUE, buf);
160 fxResult->SetAction(kGo4ActionEdit);
161 } else {
162 buf = TString::Format("SetCondition - ERROR: failed to set %s", GetObjectName());
163 fxClient->SendStatusMessage(3, kTRUE, buf);
164 fxResult->SetAction(kGo4ActionError);
165 }
166 fxResult->SetMessage(buf.Data());
167 delete fxObject;
168 fxObject = nullptr;
169 return 0;
170}
171
173{
174 if(!his) return -1;
175 TString buf;
176 if(fxAna->AddHistogram(his)) {
177 his->SetBit(TGo4Status::kGo4CanDelete); // dynamic objects may be deleted from gui
178 fxResult->SetAction(kGo4ActionPlot);
179 buf = TString::Format("Added new histogram %s to Go4 folders.", GetObjectName());
180 fxClient->SendStatusMessage(1, kFALSE, buf);
181 } else {
182 buf = TString::Format("ERROR on adding new histogram %s ", GetObjectName());
183 fxClient->SendStatusMessage(3, kFALSE, buf);
184 fxResult->SetAction(kGo4ActionError);
185 delete his;
186 }
187 fxResult->SetMessage(buf.Data());
188 return 0;
189}
190
192{
193 if(!dyn) return -1;
194 TString buf;
195 if(fxAna->AddDynamicEntry((TGo4DynamicEntry *)dyn->Clone())) {
196 TGo4TreeHistogramEntry* tentry = dynamic_cast<TGo4TreeHistogramEntry*> (dyn);
197 if (tentry && tentry->IsEnabledProcessing())
198 fxAna->SetDynListInterval(tentry->GetDynListInterval());
199 fxResult->SetAction(kGo4ActionEdit);
200 buf = TString::Format("Set new status for entry %s of dynamic list %s.", GetObjectName(), GetFolderName());
201 fxClient->SendStatusMessage(1, kTRUE, buf);
202 } else {
203 buf = TString::Format("Could not set status for entry %s of dynamic list %s !!!", GetObjectName(), GetFolderName());
204 fxResult->SetAction(kGo4ActionError);
205 fxClient->SendStatusMessage(2, kTRUE, buf);
206 }
207 fxResult->SetMessage(buf.Data());
208 delete fxObject;
209 fxObject = nullptr;
210 return 0;
211}
212
214{
215 if(!pic) return -1;
216 TString buf;
217 if(fxAna->SetPicture(GetObjectName(),pic)) {
218 fxResult->SetAction(kGo4ActionPlot);
219 buf = TString::Format("Picture %s was set to new values.", GetObjectName());
220 fxClient->SendStatusMessage(1, kFALSE, buf);
221 } else {
222 buf = TString::Format("SetPicture - ERROR: failed to set %s",GetObjectName());
223 fxClient->SendStatusMessage(3, kFALSE, buf);
224 fxResult->SetAction(kGo4ActionError);
225 }
226 fxResult->SetMessage(buf.Data());
227 delete fxObject;
228 fxObject = nullptr;
229 return 0;
230}
231
233{
234 TString buf;
235 if(fxAna->AddObject(dynamic_cast<TNamed*>(ob))) {
236 fxResult->SetAction(kGo4ActionRefresh);
237 buf = TString::Format("Added new object %s to Go4 folders.", GetObjectName());
238 fxClient->SendStatusMessage(1, kFALSE, buf);
239 } else {
240 fxResult->SetAction(kGo4ActionError);
241 buf = TString::Format("ERROR on adding new object %s ", GetObjectName());
242 fxClient->SendStatusMessage(3, kFALSE, buf);
243 delete ob;
244 }
245 fxResult->SetMessage(buf.Data());
246 return 0;
247}
@ kGo4ComModeController
Definition TGo4Command.h:30
#define GO4TRACE(X)
Definition TGo4Log.h:25
const char * GetObjectName() const
access to the object name under command.
void SetObjectName(const char *name)
set the object name under command.
void Set(TGo4RemoteCommand *remcon) override
Set internals of this command from specification of external remote command (command container).
Contains the name (key) list of all objects in the analysis scope.
static TGo4Analysis * Instance()
return analysis instance
Int_t ExeSetDyn(TGo4DynamicEntry *dyn)
Int_t ExeSetCon(TGo4Condition *con)
Int_t ExeCom() override
Do the command action.
Int_t ExeSetPic(TGo4Picture *pic)
void Set(TGo4RemoteCommand *remcon) override
Set internals of this command from specification of external remote command (command container).
Int_t ExeSetObj(TObject *ob)
Int_t ExeSetParStatus(TGo4ParameterStatus *par)
TGo4AnalysisObjectResult * fxResult
structure to keep result of setting action
Int_t ExeSetHis(TH1 *his)
Int_t ExeSetPar(TGo4Parameter *par)
TGo4AnalysisClient * fxClient
TGo4Analysis * fxAna
TObject * fxObject
The object to be set.
void SetProtection(Go4CommandMode_t m)
TGo4CommandReceiver * fxReceiverBase
void SetReceiverName(const char *)
Go4 condition class.
ABC for all entries that can be kept in a dynamic list.
Bool_t IsEnabledProcessing() const
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
Status object for an analysis parameter.
Base class for all parameter aggregations, e.g.
Picture cconfiguration in Go4.
Definition TGo4Picture.h:40
This command is a container for commands to be send from master to slave via inter-process transport.
TObject * GetAggregate(Bool_t chown=kTRUE)
Dynamic list entry which links a histogram to a certain tree.