GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4AnalysisWebStatus.cxx
Go to the documentation of this file.
1 // $Id: TGo4AnalysisWebStatus.cxx 3466 2022-01-18 13:13:51Z linev $
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 "TGo4AnalysisWebStatus.h"
15 
16 #include "TUrl.h"
17 #include "RVersion.h"
18 
19 #include "TGo4AnalysisStepStatus.h"
20 
21 #include "TGo4Analysis.h"
22 #include "TGo4AnalysisClient.h"
23 
25 TString TGo4AnalysisWebStatus::fgxURL_CLOSE = "close";
26 
27 TString TGo4AnalysisWebStatus::fgxURL_ENABLESTEP = "stepenabled";
28 TString TGo4AnalysisWebStatus::fgxURL_ENABLESOURCE = "sourceenabled";
29 TString TGo4AnalysisWebStatus::fgxURL_ENABLESTORE = "storeenabled";
30 
31 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_TYPE = "sourcesel";
32 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_NAME = "sourcename";
33 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_TAG = "sourcetag";
34 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_PORT = "sourceport";
35 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_TIMEOUT = "sourcetmout";
36 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_RETRY = "sourceretry";
37 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_FIRST = "sourcefirst";
38 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_LAST = "sourcelast";
39 TString TGo4AnalysisWebStatus::fgxURL_SOURCE_SKIP = "sourceskip";
40 TString TGo4AnalysisWebStatus::fgxURL_STORE_TYPE = "storesel";
41 TString TGo4AnalysisWebStatus::fgxURL_STORE_NAME = "storename";
42 TString TGo4AnalysisWebStatus::fgxURL_STORE_SPLIT = "storesplit";
43 TString TGo4AnalysisWebStatus::fgxURL_STORE_BUF = "storebuf";
44 TString TGo4AnalysisWebStatus::fgxURL_STORE_COMP = "storecomp";
45 TString TGo4AnalysisWebStatus::fgxURL_STORE_ASF = "storeasf";
47 
48 TString TGo4AnalysisWebStatus::fgxURL_ASF_SAVE = "saveasf";
49 TString TGo4AnalysisWebStatus::fgxURL_ASF_ENABLED = "asfenabled";
50 TString TGo4AnalysisWebStatus::fgxURL_ASF_NAME = "asfname";
52 TString TGo4AnalysisWebStatus::fgxURL_ASF_COMP = "asfcomp";
53 TString TGo4AnalysisWebStatus::fgxURL_ASF_OVERWRITE = "asfoverwrite";
54 
55 TString TGo4AnalysisWebStatus::fgxURL_PREFS_NAME = "anaprefsname";
56 TString TGo4AnalysisWebStatus::fgxURL_PREFS_LOAD = "loadprefs";
57 TString TGo4AnalysisWebStatus::fgxURL_PREFS_SAVE = "saveprefs";
58 
59 
60 // Method TUrl::HasOption is not available for older ROOT versions, use workaround:
61 #if ROOT_VERSION_CODE < ROOT_VERSION(5,34,20)
62 #define HasOption(x) GetValueFromOptions(x)!=0
63 #endif
64 
65 
66 Bool_t TGo4AnalysisWebStatus::UpdateFromUrl(const char* rest_url_opt)
67 {
68  std::cout << "\nTGo4AnalysisWebStatus Update From Url with " << rest_url_opt << std::endl;
69 // TGo4LockGuard gard; // test: can we avoid deadlock with monitoring sniffer here?
70 // std::cout << "\nTGo4AnalysisWebStatus AFTER lockguard." << std::endl;
71  TString message;
72  message.Form("TGo4AnalysisWebStatus::UpdateFromUrl ");
74  TUrl url;
75  url.SetOptions(rest_url_opt); // this time try to use ROOT default class
76  TString theKey;
77 
78  //handle first pseudo commands that should not initialize analysis:
79 
80  // close analysis:
82  if (url.HasOption(theKey.Data()))
83  {
84  ana->StopAnalysis();
85  ana->CloseAnalysis();
86  message.Append(TString::Format(", CLOSING analysis"));
87  TGo4Log::Message(1, message.Data());
88  return kTRUE;
89  }
90 
91  // save asf:
93  if (url.HasOption(theKey.Data()))
94  {
95  const char* filename = url.GetValueFromOptions(theKey.Data());
97  message.Append(TString::Format(", saving autosave file %s", filename));
98  TGo4Log::Message(1, message.Data());
99  return kTRUE;
100  }
101 
102  // save setup:
104  if (url.HasOption(theKey.Data()))
105  {
106  const char* filename = url.GetValueFromOptions(theKey.Data());
107  SaveStatus(filename);
108  message.Append(TString::Format(", saving configuration file %s", filename));
109  TGo4Log::Message(1, message.Data());
110  return kTRUE;
111  }
112 
113  // load setup and initialize:
115  if (url.HasOption(theKey.Data()))
116  {
117  const char* filename = url.GetValueFromOptions(theKey.Data());
118  ana->StopAnalysis();
119  if (LoadStatus(filename))
120  {
121  ana->InitEventClasses();
122  message.Append(TString::Format(", loaded configuration file %s", filename));
123  }
124  else
125  {
126  message.Append(TString::Format(", /!\\ FAILED to load configuration file %s !!!", filename));
127  }
128  TGo4Log::Message(1, message.Data());
129  return kTRUE;
130  }
131 
132  // first stepwise options here:
133 
135  TGo4AnalysisStepStatus* step = 0;
136  Int_t stepindex = 0;
137  while ((step = NextStepStatus()) != 0)
138  {
139  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_ENABLESTEP.Data(), stepindex);
140  if (url.HasOption(theKey.Data()))
141  {
142 
143  //std::cout <<"---- found stepenabled key:"<<theKey.Data()<< std::endl;
144  Bool_t enablestep = ((TString(url.GetValueFromOptions(theKey.Data())) == "true") ? kTRUE : kFALSE);
145  message.Append(TString::Format(", %s=%d", theKey.Data(), enablestep));
146  step->SetProcessEnabled(enablestep);
147  }
148  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_ENABLESOURCE.Data(), stepindex);
149  if (url.HasOption(theKey.Data()))
150  {
151  //std::cout <<"---- found sourceenabled key:"<<theKey.Data()<< std::endl;
152  Bool_t enablesource = ((TString(url.GetValueFromOptions(theKey.Data())) == "true") ? kTRUE : kFALSE);
153  message.Append(TString::Format(", %s=%d", theKey.Data(), enablesource));
154  step->SetSourceEnabled(enablesource);
155  }
156  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_ENABLESTORE.Data(), stepindex);
157  if (url.HasOption(theKey.Data()))
158  {
159  //std::cout <<"---- found storeenabled key:"<<theKey.Data()<< std::endl;
160  Bool_t enablestore = ((TString(url.GetValueFromOptions(theKey.Data())) == "true") ? kTRUE : kFALSE);
161  message.Append(TString::Format(", %s=%d", theKey.Data(), enablestore));
162  step->SetStoreEnabled(enablestore);
163  }
164 
165  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_TYPE.Data(), stepindex);
166  if (url.HasOption(theKey.Data()))
167  {
168  Int_t srctype = url.GetIntValueFromOptions(theKey.Data());
169  message.Append(TString::Format(", %s=%d", theKey.Data(), srctype));
170 
171  // extract values of old source parameter and save them into the new if matching:
172  TGo4EventSourceParameter* oldsrcpar = step->GetSourcePar();
173  TGo4MbsSourceParameter* oldmbspar = dynamic_cast<TGo4MbsSourceParameter*>(oldsrcpar);
174  TGo4UserSourceParameter* olduserpar = dynamic_cast<TGo4UserSourceParameter*>(oldsrcpar);
175  TString srcname = oldsrcpar->GetName();
176  Int_t port = oldmbspar ? oldmbspar->GetPort() : 0;
177  if (port == 0)
178  port = olduserpar ? olduserpar->GetPort() : 0;
179  // JAM: the above shows that event source hierarchy interface is still not optimized
180  // however, currently (March 2015) no manpower to improve or redesign Go4 if it is working...
181 
182  TGo4EventSourceParameter* newpar = 0;
183  switch (srctype)
184  {
185  case GO4EV_FILE:
186  newpar = new TGo4FileSourceParameter(srcname);
187  break;
188 
189  case GO4EV_MBS_FILE:
190  newpar = new TGo4MbsFileParameter(srcname);
191  break;
192 
193  case GO4EV_MBS_STREAM:
194  newpar = new TGo4MbsStreamParameter(srcname);
195  break;
196 
197  case GO4EV_MBS_TRANSPORT:
198  newpar = new TGo4MbsTransportParameter(srcname);
199  break;
200 
202  newpar = new TGo4MbsEventServerParameter(srcname);
203  break;
204 
205  case GO4EV_MBS_REVSERV:
206  newpar = new TGo4RevServParameter(srcname);
207  break;
208 
209  case GO4EV_MBS_RANDOM:
210  newpar = new TGo4MbsRandomParameter("random");
211  break;
212 
213  case GO4EV_USER:
214  newpar = new TGo4UserSourceParameter(srcname, "", port);
215  break;
216  };
217 
218  TGo4MbsSourceParameter* newmbspar = dynamic_cast<TGo4MbsSourceParameter*>(newpar);
219  if (newmbspar)
220  {
221  newmbspar->SetPort(port);
222  if (oldmbspar)
223  {
224  newmbspar->SetStartEvent(oldmbspar->GetStartEvent());
225  newmbspar->SetStopEvent(oldmbspar->GetStopEvent());
226  newmbspar->SetEventInterval(oldmbspar->GetEventInterval());
227  }
228  }
229  newpar->SetTimeout(oldsrcpar->GetTimeout());
230 
231  step->SetSourcePar(newpar);
232  delete newpar; // SetSourcePar does clone argument, we do not need it further
233  } // fgxURL_SOURCE_TYPE
234 
235  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_NAME.Data(), stepindex);
236  if (url.HasOption(theKey.Data())) {
237  TString srcname = url.GetValueFromOptions(theKey.Data());
238  message.Append(TString::Format(", %s=%s", theKey.Data(), srcname.Data()));
239  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
240  srcpar->SetName(srcname.Data());
241  } // fgxURL_SOURCE_NAME;
242 
243  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_TAG.Data(), stepindex);
244  if (url.HasOption(theKey.Data())) {
245  TString tagname = url.GetValueFromOptions(theKey.Data());
246  message.Append(TString::Format(", %s=%s", theKey.Data(), tagname.Data()));
247  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
248  TGo4MbsFileParameter* mbsfilepar = dynamic_cast<TGo4MbsFileParameter*>(srcpar);
249  if (mbsfilepar)
250  mbsfilepar->SetTagName(tagname.Data());
251  else
252  message.Append(TString::Format(" - /!\\ NEVER COME HERE: Could not set tag name to type %s ", srcpar->ClassName()));
253  } // fgxURL_SOURCE_TAG;
254 
255  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_PORT.Data(), stepindex);
256  if (url.HasOption(theKey.Data()))
257  {
258  Int_t port = url.GetIntValueFromOptions(theKey.Data());
259  message.Append(TString::Format(", %s=%d", theKey.Data(), port));
260  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
261  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*>(srcpar);
262  TGo4UserSourceParameter* userpar = dynamic_cast<TGo4UserSourceParameter*>(srcpar);
263  if (mbspar)
264  mbspar->SetPort(port);
265  else if (userpar)
266  userpar->SetPort(port);
267  else
268  message.Append(TString::Format(" - /!\\ NEVER COME HERE: Could not set port to type %s ", srcpar->ClassName()));
269  } //fgxURL_SOURCE_PORT;
270 
271  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_TIMEOUT.Data(), stepindex);
272  if (url.HasOption(theKey.Data()))
273  {
274  Int_t timeout = url.GetIntValueFromOptions(theKey.Data());
275  message.Append(TString::Format(", %s=%d", theKey.Data(), timeout));
276  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
277  srcpar->SetTimeout(timeout);
278  } //fgxURL_SOURCE_TIMEOUT;
279 
280  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_RETRY.Data(), stepindex);
281  if (url.HasOption(theKey.Data()))
282  {
283  Int_t retry = url.GetIntValueFromOptions(theKey.Data());
284  message.Append(TString::Format(", %s=%d", theKey.Data(), retry));
285  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
286  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*>(srcpar);
287  if (mbspar)
288  mbspar->SetRetryCnt(retry);
289  else
290  message.Append(
291  TString::Format(" - /!\\ NEVER COME HERE: Could not set retry count to type %s ",
292  srcpar->ClassName()));
293  } //fgxURL_SOURCE_RETRY;
294 
295  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_FIRST.Data(), stepindex);
296  if (url.HasOption(theKey.Data()))
297  {
298  Int_t startevent = url.GetIntValueFromOptions(theKey.Data());
299  message.Append(TString::Format(", %s=%d", theKey.Data(), startevent));
300  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
301  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*>(srcpar);
302  if (mbspar)
303  mbspar->SetStartEvent(startevent);
304  else
305  message.Append(
306  TString::Format(" - /!\\ NEVER COME HERE: Could not set start event to type %s ",
307  srcpar->ClassName()));
308  } //fgxURL_SOURCE_FIRST;
309 
310  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_LAST.Data(), stepindex);
311  if (url.HasOption(theKey.Data()))
312  {
313  Int_t stopevent = url.GetIntValueFromOptions(theKey.Data());
314  message.Append(TString::Format(", %s=%d", theKey.Data(), stopevent));
315  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
316  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*>(srcpar);
317  if (mbspar)
318  mbspar->SetStopEvent(stopevent);
319  else
320  message.Append(
321  TString::Format(" - /!\\ NEVER COME HERE: Could not set stop event to type %s ",
322  srcpar->ClassName()));
323  } //fgxURL_SOURCE_LAST;
324 
325  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_SOURCE_SKIP.Data(), stepindex);
326  if (url.HasOption(theKey.Data()))
327  {
328  Int_t skipevents = url.GetIntValueFromOptions(theKey.Data());
329  message.Append(TString::Format(", %s=%d", theKey.Data(), skipevents));
330  TGo4EventSourceParameter* srcpar = step->GetSourcePar();
331  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*>(srcpar);
332  if (mbspar)
333  mbspar->SetEventInterval(skipevents);
334  else
335  message.Append(
336  TString::Format(" - /!\\ NEVER COME HERE: Could not set event interval to type %s ",
337  srcpar->ClassName()));
338  } //fgxURL_SOURCE_SKIP;
339 
340  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_TYPE.Data(), stepindex);
341  if (url.HasOption(theKey.Data()))
342  {
343  Int_t storetype = url.GetIntValueFromOptions(theKey.Data());
344  message.Append(TString::Format(", %s=%d", theKey.Data(), storetype));
345 
346  // extract values of old store parameter and save them into the new if matching:
347  TGo4EventStoreParameter* oldstorepar = step->GetStorePar();
348  TString storename = oldstorepar->GetName();
349  TGo4FileStoreParameter* oldfilepar = dynamic_cast<TGo4FileStoreParameter*>(oldstorepar);
350  TGo4BackStoreParameter* oldbackpar = dynamic_cast<TGo4BackStoreParameter*>(oldstorepar);
351 
352  // JAM NOTE: what is missing here completely is support of user defined storages!
353  // this does not exist in Qt GUI either, because nobody has ever used this feature... ;-(
354  // shall we provide this in the future?
355 
356  Int_t oldsplit = -1, oldbuf = -1, oldcomp = -1, oldauto = -1, oldover = -1;
357  if (oldfilepar)
358  {
359  oldsplit = oldfilepar->GetSplitlevel();
360  oldbuf = oldfilepar->GetBufsize();
361  oldcomp = oldfilepar->GetCompression();
362  oldauto = oldfilepar->GetAutosaveSize();
363  oldover = oldfilepar->IsOverwriteMode();
364  }
365  else if (oldbackpar)
366  {
367  oldsplit = oldbackpar->GetSplitlevel();
368  oldbuf = oldbackpar->GetBufsize();
369  }
370  else
371  {
372  message.Append(
373  TString::Format(" - /!\\ NEVER COME HERE: old event store parameter is type %s ",
374  oldstorepar ? oldstorepar->ClassName() : "nullpointer"));
375  }
376 
377  TGo4EventStoreParameter* newpar = 0;
378  switch (storetype)
379  {
380  default:
381  case GO4EV_FILE:
382  {
383  TGo4FileStoreParameter* filestore = new TGo4FileStoreParameter(storename);
384  if (oldsplit >= 0)
385  filestore->SetSplitlevel(oldsplit); // restore my soul...
386  if (oldbuf >= 0)
387  filestore->SetBufsize(oldbuf);
388  if (oldcomp >= 0)
389  filestore->SetCompression(oldcomp);
390  if (oldauto >= 0)
391  filestore->SetAutosaveSize(oldauto);
392  if (oldover >= 0)
393  filestore->SetOverwriteMode(oldover);
394  newpar = filestore;
395  }
396  break;
397  case GO4EV_BACK:
398  {
399  TGo4BackStoreParameter* bckstore = new TGo4BackStoreParameter(storename);
400  if (oldsplit >= 0)
401  bckstore->SetSplitlevel(oldsplit);
402  if (oldbuf >= 0)
403  bckstore->SetBufsize(oldbuf);
404  newpar = bckstore;
405  }
406  break;
407  };
408  step->SetStorePar(newpar);
409  delete newpar; // SetStorePar does clone argument, we do not need it further
410 
411  } //fgxURL_STORE_TYPE;
412 
413  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_NAME.Data(), stepindex);
414  if (url.HasOption(theKey.Data()))
415  {
416  TString storename = url.GetValueFromOptions(theKey.Data());
417  message.Append(TString::Format(", %s=%s", theKey.Data(), storename.Data()));
418  TGo4EventStoreParameter* storepar = step->GetStorePar();
419  storepar->SetName(storename.Data());
420  } // fgxURL_STORE_NAME
421 
422  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_SPLIT.Data(), stepindex);
423  if (url.HasOption(theKey.Data()))
424  {
425  Int_t split = url.GetIntValueFromOptions(theKey.Data());
426  message.Append(TString::Format(", %s=%d", theKey.Data(), split));
427  TGo4EventStoreParameter* storepar = step->GetStorePar();
428  TGo4FileStoreParameter* filepar = dynamic_cast<TGo4FileStoreParameter*>(storepar);
429  TGo4BackStoreParameter* backpar = dynamic_cast<TGo4BackStoreParameter*>(storepar);
430  if (filepar)
431  filepar->SetSplitlevel(split);
432  else if (backpar)
433  backpar->SetSplitlevel(split);
434  else
435  message.Append(
436  TString::Format(" - /!\\ NEVER COME HERE: can not set split level to eventstore type %s ",
437  storepar ? storepar->ClassName() : "nullpointer"));
438 
439  } //ffgxURL_STORE_SPLIT
440 
441  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_BUF.Data(), stepindex);
442  if (url.HasOption(theKey.Data()))
443  {
444  Int_t bufsize = url.GetIntValueFromOptions(theKey.Data());
445  message.Append(TString::Format(", %s=%d", theKey.Data(), bufsize));
446  TGo4EventStoreParameter* storepar = step->GetStorePar();
447  TGo4FileStoreParameter* filepar = dynamic_cast<TGo4FileStoreParameter*>(storepar);
448  TGo4BackStoreParameter* backpar = dynamic_cast<TGo4BackStoreParameter*>(storepar);
449  if (filepar)
450  filepar->SetBufsize(bufsize);
451  else if (backpar)
452  backpar->SetBufsize(bufsize);
453  else
454  message.Append(
455  TString::Format(" - /!\\ NEVER COME HERE: can not set bufsize to eventstore type %s ",
456  storepar ? storepar->ClassName() : "nullpointer"));
457  } //fgxURL_STORE_BUF
458 
459  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_COMP.Data(), stepindex);
460  if (url.HasOption(theKey.Data()))
461  {
462  Int_t bufsize = url.GetIntValueFromOptions(theKey.Data());
463  message.Append(TString::Format(", %s=%d", theKey.Data(), bufsize));
464  TGo4EventStoreParameter* storepar = step->GetStorePar();
465  TGo4FileStoreParameter* filepar = dynamic_cast<TGo4FileStoreParameter*>(storepar);
466  if (filepar)
467  filepar->SetBufsize(bufsize);
468  else
469  message.Append(
470  TString::Format(" - /!\\ NEVER COME HERE: can not set compression to eventstore type %s ",
471  storepar ? storepar->ClassName() : "nullpointer"));
472  } //fgxURL_STORE_COMP
473 
474  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_ASF.Data(), stepindex);
475  if (url.HasOption(theKey.Data()))
476  {
477  Int_t treeautosave = url.GetIntValueFromOptions(theKey.Data());
478  message.Append(TString::Format(", %s=%d", theKey.Data(), treeautosave));
479  TGo4EventStoreParameter* storepar = step->GetStorePar();
480  TGo4FileStoreParameter* filepar = dynamic_cast<TGo4FileStoreParameter*>(storepar);
481  if (filepar)
482  filepar->SetAutosaveSize(treeautosave);
483  else
484  message.Append(
485  TString::Format(" - /!\\ NEVER COME HERE: can not set tree autosave interval to eventstore type %s ",
486  storepar ? storepar->ClassName() : "nullpointer"));
487  } //fgxURL_STORE_COMP
488 
489  theKey.Form("%s_%d", TGo4AnalysisWebStatus::fgxURL_STORE_OVERWRITE.Data(), stepindex);
490  if (url.HasOption(theKey.Data()))
491  {
492  Int_t overwrite = url.GetIntValueFromOptions(theKey.Data());
493  message.Append(TString::Format(", %s=%d", theKey.Data(), overwrite));
494  TGo4EventStoreParameter* storepar = step->GetStorePar();
495  TGo4FileStoreParameter* filepar = dynamic_cast<TGo4FileStoreParameter*>(storepar);
496  if (filepar)
497  filepar->SetOverwriteMode(overwrite);
498  else
499  message.Append(
500  TString::Format(" - /!\\ NEVER COME HERE: can not set overwrite mode to eventstore type %s ",
501  storepar ? storepar->ClassName() : "nullpointer"));
502  } //fgxURL_STORE_OVERWRITE
503 
504  step->PrintStatus();
505  stepindex++;
506  } // while step
507 
509  // step independent options:
510 
512  if (url.HasOption(theKey.Data()))
513  {
514  Int_t asfenabled = url.GetIntValueFromOptions(theKey.Data());
515  message.Append(TString::Format(", %s=%d", theKey.Data(), asfenabled));
516  SetAutoSaveOn(asfenabled);
517  } //fgxURL_ASF_ENABLED
518 
520  if (url.HasOption(theKey.Data()))
521  {
522  TString asfname = url.GetValueFromOptions(theKey.Data());
523  message.Append(TString::Format(", %s=%s", theKey.Data(), asfname.Data()));
524  SetAutoFileName(asfname.Data());
525  } //fgxURL_ASF_NAME
526 
528  if (url.HasOption(theKey.Data()))
529  {
530  Int_t asftime = url.GetIntValueFromOptions(theKey.Data());
531  message.Append(TString::Format(", %s=%d", theKey.Data(), asftime));
532  SetAutoSaveInterval(asftime);
533  } //fgxURL_ASF_INTERVAL
534 
536  if (url.HasOption(theKey.Data()))
537  {
538  Int_t asfcomp = url.GetIntValueFromOptions(theKey.Data());
539  message.Append(TString::Format(", %s=%d", theKey.Data(), asfcomp));
540  SetAutoSaveCompression(asfcomp);
541  } //fgxURL_ASF_COMP
542 
544  if (url.HasOption(theKey.Data()))
545  {
546  Int_t asfover = url.GetIntValueFromOptions(theKey.Data());
547  message.Append(TString::Format(", %s=%d", theKey.Data(), asfover));
548  SetAutoSaveOverwrite(asfover);
549  } //fgxURL_ASF_OVERWRITE
550 
552  if (url.HasOption(theKey.Data()))
553  {
554  TString prefsname = url.GetValueFromOptions(theKey.Data());
555  message.Append(TString::Format(", %s=%s", theKey.Data(), prefsname.Data()));
556  SetConfigFileName(prefsname.Data());
557  } //fgxURL_PREFS_NAME
558 
559  // apply this setup to analysis:
560  std::cout << "\nTGo4AnalysisWebStatus Update From Url :StopAnalysis..."<< std::endl;
561  ana->StopAnalysis(); // need this to correctly invoke UserPreLoop later!
562  std::cout << "\nTGo4AnalysisWebStatus Update From Url :SetStatus..."<< std::endl;
563  ana->SetStatus(this);
564 
565  // update status for ourself
566  ana->UpdateStatus(this);
567 
568  std::cout << "\nTGo4AnalysisWebStatus Update From Url :InitEventClasses..."<< std::endl;
569  ana->InitEventClasses();
570 
571  // if we find start key restart analysis for submit and start button:
572  if (url.HasOption(TGo4AnalysisWebStatus::fgxURL_STARTRUN.Data()))
573  {
574  std::cout << "\nTGo4AnalysisWebStatus Update From Url :StartAnalysis..."<< std::endl;
575  ana->StartAnalysis(); // this can cause deadlock ?!
576  std::cout << "\nTGo4AnalysisWebStatus Update From Url :After StartAnalysis"<< std::endl;
577  message.Append("\n Analysis was started!");
578  }
579 
580  TGo4Log::Message(1, message.Data());
581  return kTRUE;
582 }
583 
585 {
587  return an ? an->CreateStatus() : 0;
588 }
589 
590 
592 {
594  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
595 
596  if ((an==0) || (status==0)) return kFALSE;
597 
598  if(cli) {
599  if (cli->MainIsRunning()) an->PostLoop(); // if submit is done on running analysis,
600  } else {
601  if (!an->IsStopWorking()) an->PostLoop();
602  }
603 
604  an->SetStatus(status);
605 
606  // also copy values to ourself
607  an->UpdateStatus(this);
608 
609  if (an->InitEventClasses()) {
610  if(cli) {
611  if (cli->MainIsRunning()) an->PreLoop(); // if submit is done on running analysis,
612  } else {
613  if (!an->IsStopWorking()) an->PreLoop();
614  }
615  }
616 
617  return kTRUE;
618 }
619 
620 
621 Bool_t TGo4AnalysisWebStatus::LoadStatus(const char* fname)
622 {
623  // make it here to be able use via http interface
624 
626 
627  return ana ? ana->LoadStatus(fname) : kFALSE;
628 
629 }
630 
631 Bool_t TGo4AnalysisWebStatus::SaveStatus(const char* fname)
632 {
633  // make it here to be able use via http interface
634 
636 
637  return ana ? ana->SaveStatus(fname) : kFALSE;
638 }
639 
640 
641 Bool_t TGo4AnalysisWebStatus::WriteAutoSave(const char* fname,
642  Bool_t overwrite,
643  Int_t complevel)
644 {
645  // make it here to be able use via http interface
646 
648  if (ana==0) return kFALSE;
649 
650  ana->SetAutoSaveFile(fname, overwrite, complevel);
651  ana->AutoSave();
652 
653  return kTRUE;
654 }
655 
656 Bool_t TGo4AnalysisWebStatus::ExecuteLine(const char* exeline)
657 {
658  if ((exeline==0) || (*exeline==0)) return kFALSE;
660  if(ana==0) return kFALSE;
661 
662  Int_t errcode=0;
663  ana->ExecuteLine(exeline, &errcode);
664  fflush(stdout);
665  return errcode!=0 ? kFALSE : kTRUE;
666 }
void SetAutoFileName(const char *name)
void SetStartEvent(UInt_t firstindex)
void SetProcessEnabled(Bool_t on=kTRUE)
static TString fgxURL_PREFS_SAVE
static TString fgxURL_SOURCE_TYPE
void SetStoreEnabled(Bool_t on=kTRUE)
TGo4EventStoreParameter * GetStorePar() const
static TString fgxURL_SOURCE_TAG
void SetSplitlevel(Int_t split)
static TString fgxURL_SOURCE_PORT
Bool_t LoadStatus(const char *filename=0)
void SetSplitlevel(Int_t split)
virtual Int_t PrintStatus(Text_t *buffer=0, Int_t buflen=0)
Bool_t ExecuteLine(const char *cmd)
void SetStopEvent(UInt_t lastindex)
void UpdateStatus(TGo4AnalysisStatus *state)
virtual void CloseAnalysis()
static TString fgxURL_ENABLESTORE
static TString fgxURL_STORE_SPLIT
void SetAutoSaveOn(Bool_t on=kTRUE)
static TString fgxURL_SOURCE_NAME
static TString fgxURL_STORE_COMP
Bool_t MainIsRunning()
Definition: TGo4Slave.h:92
static TString fgxURL_ENABLESTEP
static TString fgxURL_STORE_OVERWRITE
TGo4AnalysisStepStatus * NextStepStatus()
static TString fgxURL_PREFS_LOAD
void SetSourceEnabled(Bool_t on=kTRUE)
static TString fgxURL_ENABLESOURCE
static TString fgxURL_SOURCE_FIRST
static TString fgxURL_SOURCE_LAST
TGo4AnalysisClient * GetAnalysisClient() const
static TString fgxURL_PREFS_NAME
Bool_t IsStopWorking() const
TGo4AnalysisStatus * CreateStatus()
void SetAutosaveSize(Int_t interval)
void SetTagName(const char *name)
Bool_t ApplyStatus(TGo4AnalysisStatus *status)
static TString fgxURL_SOURCE_TIMEOUT
void SetStorePar(TGo4EventStoreParameter *kind)
Bool_t SaveStatus(const char *fname)
void SetSourcePar(TGo4EventSourceParameter *kind)
TGo4EventSourceParameter * GetSourcePar() const
void SetOverwriteMode(Bool_t over=kTRUE)
static TString fgxURL_SOURCE_SKIP
static TString fgxURL_SOURCE_RETRY
void SetEventInterval(UInt_t skipinterval)
void SetBufsize(Int_t bufsize)
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:207
Bool_t UpdateFromUrl(const char *rest_url_opt)
static TString fgxURL_STORE_TYPE
static TString fgxURL_ASF_INTERVAL
virtual Bool_t InitEventClasses()
static TString fgxURL_ASF_OVERWRITE
static TString fgxURL_STORE_NAME
void SetAutoSaveOverwrite(Bool_t over=kTRUE)
Long_t ExecuteLine(const char *command, Int_t *errcode=0)
void SetAutoSaveFile(const char *filename=0, Bool_t overwrite=kFALSE, Int_t compression=5)
Bool_t LoadStatus(const char *fname)
Bool_t SaveStatus(const char *filename=0)
void SetConfigFileName(const char *name)
void SetBufsize(Int_t bufsize)
void SetAutoSaveInterval(Int_t i)
static TString fgxURL_ASF_ENABLED
TGo4AnalysisStatus * CreateStatus()
static TGo4Analysis * Instance()
void SetAutoSaveCompression(Int_t i=5)
Bool_t WriteAutoSave(const char *fname, Bool_t overwrite, Int_t complevel)
void SetStatus(TGo4AnalysisStatus *state)