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