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