GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ConfigStep.cpp
Go to the documentation of this file.
1 // $Id: TGo4ConfigStep.cpp 3121 2021-03-30 07:56:48Z 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 "TGo4ConfigStep.h"
15 
16 #include <QFileDialog>
17 
18 #include "TGo4AnalysisStepStatus.h"
22 #include "TGo4UserStoreParameter.h"
23 #include "TGo4RevServParameter.h"
24 #include "TGo4FileStoreParameter.h"
25 #include "TGo4BackStoreParameter.h"
27 #include "TGo4MbsFileParameter.h"
28 #include "TGo4MbsStreamParameter.h"
31 #include "TGo4MbsRandomParameter.h"
32 
33 #ifdef __GO4HDF5__
34 //#include "H5Cpp.h"
35 #include "TGo4HDF5StoreParameter.h"
37 #endif
38 
39 #include "Go4EventServerTypes.h"
41 
42 const char* TGo4MbsFile__fgcNOTAGFILE = "GO4-NOLMDTAG";
43 const char* TGo4MbsFile__fgcLMDSUF = ".lmd";
44 const char* TGo4MbsFile__fgcFILELISTSUF = ".lml";
45 
56 };
57 
58 
59 TGo4ConfigStep::TGo4ConfigStep( QWidget* parent, const char* name, Qt::WindowFlags fl )
60  : QWidget( parent, fl )
61 {
62  setObjectName( name ? name : "Go4ConfigStep");
63 
64  setupUi(this);
65 
66  QObject::connect(EnableStepBox, SIGNAL(stateChanged(int)), this, SLOT(StepStateChanged(int)));
67  QObject::connect(EnableSourceBox, SIGNAL(stateChanged(int)), this, SLOT(InputStateChanged(int)));
68  QObject::connect(EnableStoreBox, SIGNAL(stateChanged(int)), this, SLOT(OutputStateChanged(int)));
69  QObject::connect(SourceNameEdit, SIGNAL(textChanged(QString)), this, SLOT(InputSourceText(QString)));
70  QObject::connect(EventSourceCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(SourceComboHighlighted(int)));
71  QObject::connect(OutputCombo, SIGNAL(activated(int)), this, SLOT(StoreComboHighlighted(int)));
72  QObject::connect(StoreNameEdit, SIGNAL(textChanged(QString)), this, SLOT(OutputNameText(QString)));
73  QObject::connect(FileNameOutput, SIGNAL(clicked()), this, SLOT(OutputFileDialog()));
74  QObject::connect(CompLevel, SIGNAL(valueChanged(int)), this, SLOT(StoreCompLevel(int)));
75  QObject::connect(BufferSize, SIGNAL(valueChanged(int)), this, SLOT(StoreBufferSize(int)));
76  QObject::connect(SplitLevel, SIGNAL(valueChanged(int)), this, SLOT(StoreSplitLevel(int)));
77  QObject::connect(StoreOverwriteMode, SIGNAL(toggled(bool)), this, SLOT(StoreOverWrite(bool)));
78  QObject::connect(LineEditArgs, SIGNAL(textChanged(QString)), this, SLOT(InputArguments(QString)));
79  QObject::connect(LineEditTagfile, SIGNAL(textChanged(QString)), this, SLOT(InputTagfile(QString)));
80  QObject::connect(SpinBoxStartEvent, SIGNAL(valueChanged(int)), this, SLOT(ChangeStartEvent(int)));
81  QObject::connect(SpinBoxStopEvent, SIGNAL(valueChanged(int)), this, SLOT(ChangeStopEvent(int)));
82  QObject::connect(FileNameBtn, SIGNAL(clicked()), this, SLOT(InputFileDialog()));
83  QObject::connect(SpinBoxInterEvent, SIGNAL(valueChanged(int)), this, SLOT(ChangeEventInterval(int)));
84  QObject::connect(SpinBoxTimeout, SIGNAL(valueChanged(int)), this, SLOT(ChangeSourceTimeout(int)));
85  QObject::connect(ExtraBtn, SIGNAL(clicked()), this, SLOT(ExtraBtn_clicked()));
86  QObject::connect(MbsMonitorBtn, SIGNAL(clicked()), this, SLOT(MbsMonitorBtn_clicked()));
87  QObject::connect(SpinBoxPortNumber, SIGNAL(valueChanged(int)), this, SLOT(InputPortChanged(int)));
88  QObject::connect(SpinBoxRetryNumber, SIGNAL(valueChanged(int)), this, SLOT(RetryCntChanged(int)));
89  QObject::connect(TreeAutosave, SIGNAL(valueChanged(int)), this, SLOT(StoreTreeAutoSave(int)));
90 
91  fStepNumber=0;
92  fxPanel = 0;
93  fStepStatus = 0;
94 
95  SpinBoxPortNumber->setVisible(false);
96  TextLabelPortNumber->setVisible(false);
97  SpinBoxRetryNumber->setVisible(false);
98  TextLabelRetryNumber->setVisible(false);
99  SpinBoxTimeout->setVisible(false);
100  TextLabelTimeout->setVisible(false);
101 
102  SpinBoxStartEvent->setVisible(false);
103  SpinBoxStopEvent->setVisible(false);
104  SpinBoxInterEvent->setVisible(false);
105 
106  LineEditArgs->setVisible(false);
107  TextLabelArgs->setVisible(false);
108  LineEditTagfile->setVisible(false);
109  TextLabelTagfile->setVisible(false);
110 
111  for (int n=0;n<ParsSize;n++)
112  fPars[n]=0;
113 
114  fLastSrcKind = -1;
115  fBlocked = 0;
116  fExtra = false;
117  ExtraBtn->setText(fExtra ? "-" : "+");
118 
119 #ifndef __GO4HDF5__
120  OutputCombo->removeItem(3);
121  EventSourceCombo->removeItem(8);
122 #endif
123 
124 }
125 
127 {
128  for (int n=0;n<ParsSize;n++) {
129  delete fPars[n];
130  fPars[n] = 0;
131  }
132 }
133 
134 
135 void TGo4ConfigStep::InputArguments(const QString& Arg)
136 {
138  int ParId=SourcePar->GetID();
139  if (ParId==GO4EV_USER){ // user defined source class
140  TGo4UserSourceParameter* usrpar=dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
141  if (usrpar!=0)
142  usrpar->SetExpression(Arg.trimmed().toLatin1().constData());
143  }
144 }
145 
147 {
148  bool stepon = EnableStepBox->isChecked();
149  bool on = EnableSourceBox->isChecked();
150 
152  SourceBox->setEnabled(stepon && on);
153 
155 }
156 
158 {
159  if (fBlocked) return;
160 
162 
163  switch (SourcePar->GetID()) {
164 
165  case GO4EV_MBS_TRANSPORT:
166  case GO4EV_MBS_STREAM:
168  case GO4EV_MBS_REVSERV: {
169  TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
170  if (par!=0)
171  par->SetPort(port);
172  break;
173  }
174 
175  case GO4EV_USER: { // user defined source class
176  TGo4UserSourceParameter* usrpar=dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
177  if (usrpar!=0)
178  usrpar->SetPort(port);
179  break;
180  }
181 
182  default: {
183  // do nothing
184  break;
185  }
186  }
187 }
188 
190 {
191  if (fBlocked) return;
192 
194 
195  switch (SourcePar->GetID()) {
196 
197  case GO4EV_MBS_TRANSPORT:
198  case GO4EV_MBS_STREAM:
200  case GO4EV_MBS_REVSERV: {
201  TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
202  if (par!=0)
203  par->SetRetryCnt(cnt);
204  break;
205  }
206 
207  default: {
208  // do nothing
209  break;
210  }
211  }
212 }
213 
214 void TGo4ConfigStep::InputSourceText(const QString& name)
215 {
216  if (fBlocked) return;
217 
219  fStepStatus->GetSourcePar()->SetName(name.trimmed().toLatin1().constData());
220 
221  if (EventSourceCombo->currentIndex() == kind_MbsFile) {
222  bool islml = name.contains(TGo4MbsFile__fgcFILELISTSUF);
223  LineEditTagfile->setVisible(!islml);
224  TextLabelTagfile->setVisible(!islml);
225 
226  SpinBoxStartEvent->setEnabled(!islml);
227  SpinBoxStopEvent->setEnabled(!islml);
228  SpinBoxInterEvent->setEnabled(!islml);
229  }
230 }
231 
233 {
234  bool stepon = EnableStepBox->isChecked();
235  bool on = EnableStoreBox->isChecked();
236 
238  StoreBox->setEnabled(stepon && on);
239  StoreBox->setVisible(on);
240 
242 
243  adjustSize();
244  parentWidget()->adjustSize();
245  parentWidget()->parentWidget()->adjustSize();
246 
247  fxPanel->adjustSize();
248  fxPanel->parentWidget()->adjustSize();
249 }
250 
251 void TGo4ConfigStep::OutputNameText(const QString& Name)
252 {
253  fStepStatus->GetStorePar()->SetName(Name.trimmed().toLatin1().constData());
254 }
255 
257 {
258  bool on = EnableStepBox->isChecked();
259 
261  EnableSourceBox->setEnabled(on);
262  EnableStoreBox->setEnabled(on);
263 
265 
268 }
269 
271 {
272  if (StepStatus==0) return;
273  //std::cout <<"TGo4ConfigStep::SetStepStatus for "<< StepStatus->GetName()<< std::endl;
274 
275  fxPanel = panel;
276  fStepStatus = StepStatus;
277  fStepNumber = number;
278  fLastSrcKind = -1; // indicate that status (and its parameter) is changed
279 
280  //----------------------------------------------------//
281  //Source:
282 
283  /*
284  Qt use following order to display the source parameter:
285 
286  0) root file with one tree TGo4FileSourceParameter
287  1) mbs listmode file (input only) TGo4MbsFileParameter
288  2) mbs stream server (input only) TGo4MbsStreamParameter
289  3) mbs transport server (input only) TGo4MbsTransportParameter
290  4) mbs event server (input only) TGo4MbsEventServerParameter
291  5) rev serv TGo4RevServParameter
292  6) mbs random generator TGo4MbsRandomParameter
293  7) user source TGo4UserSourceParameter
294 
295  */
296 
297  int srckind = CurrentSourceKind();
298  fBlocked++;
299  EventSourceCombo->setCurrentIndex(srckind);
300  fBlocked--;
301 
302 
303  //----------------------------------------------------//
304  //Store
305 
307 
308  if (StorePar!=0)
309  switch(StorePar->GetID()) {
310  case GO4EV_FILE: {
311  TGo4FileStoreParameter* fstor = dynamic_cast<TGo4FileStoreParameter*>(StorePar);
312  SetFileStore(fstor->GetName(),
313  fstor->IsOverwriteMode(),
314  fstor->GetBufsize(),
315  fstor->GetSplitlevel(),
316  fstor->GetCompression(),
317  fstor->GetAutosaveSize());
318  break;
319  }
320  case GO4EV_BACK: {
321  TGo4BackStoreParameter* bstor = dynamic_cast<TGo4BackStoreParameter*>(StorePar);
322  SetBackStore(bstor->GetName(),
323  bstor->GetBufsize(),
324  bstor->GetSplitlevel());
325  break;
326  }
327  case GO4EV_USER: {
328  TGo4UserStoreParameter *ustor = dynamic_cast<TGo4UserStoreParameter*>(StorePar);
329  SetUserStore(ustor->GetName());
330  break;
331  }
332 
333 #ifdef __GO4HDF5__
334  case GO4EV_HDF5: {
335  TGo4HDF5StoreParameter* hstor = dynamic_cast<TGo4HDF5StoreParameter*>(StorePar);
336  SetHDF5Store(hstor->GetName(), hstor->GetHDF5Flags());
337  break;
338  }
339 #endif
340 
341 
342  default:
343  break;
344  } // switch StorePar->GetID()
345 
346  //----------------------------------------------------//
347  // enable or disable processing:
348 
352 }
353 
354 
356 {
357  if ((fStepStatus==0) || (fStepStatus->GetSourcePar()==0)) return kind_MbsFile;
358 
359  switch(fStepStatus->GetSourcePar()->GetID()) {
360  case GO4EV_FILE: return kind_RootFile;
361  case GO4EV_MBS_FILE: return kind_MbsFile;
362  case GO4EV_MBS_STREAM: return kind_MbsStream;
365  case GO4EV_MBS_REVSERV: return kind_MbsREvent;
366  case GO4EV_MBS_RANDOM: return kind_MbsRandom;
367  case GO4EV_USER: return kind_UserSource;
368  case GO4EV_HDF5: return kind_HDF5;
369  } // SourcePar->GetID()
370 
371  return kind_MbsFile;
372 }
373 
375 {
376  if (fStepStatus==0) return;
377 
379  bool delsrcpar(true);
380  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*> (srcpar);
381 
382  if (fLastSrcKind >= 0) {
383  if (fPars[fLastSrcKind]!=0) delete fPars[fLastSrcKind];
384  fPars[fLastSrcKind] = srcpar;
385  delsrcpar = false;
386  }
387 
388  if (fPars[kind]) {
390  fLastSrcKind = kind;
391  if (delsrcpar) delete srcpar;
392  return;
393  }
394 
395  TString filename, hostname;
396  Int_t port(0);
397 
398  switch(srcpar->GetID()) {
399  case GO4EV_FILE:
400  case GO4EV_MBS_FILE:
401  case GO4EV_HDF5:
402  filename = srcpar->GetName();
403  break;
404 
405  case GO4EV_MBS_STREAM:
406  case GO4EV_MBS_TRANSPORT:
408  case GO4EV_MBS_REVSERV:
409  hostname = srcpar->GetName();
410  port = mbspar ? mbspar->GetPort() : 0;
411  break;
412 
413  case GO4EV_MBS_RANDOM:
414  break;
415  case GO4EV_USER:
416  break;
417  default:
418  break;
419  }
420 
421  TGo4EventSourceParameter* newpar = 0;
422 
423  switch (kind) {
424  case kind_RootFile:
425  newpar = new TGo4FileSourceParameter(filename);
426  break;
427 
428  case kind_MbsFile:
429  newpar = new TGo4MbsFileParameter(filename);
430  break;
431 
432  case kind_MbsStream:
433  newpar = new TGo4MbsStreamParameter(hostname);
434  break;
435 
436  case kind_MbsTransport:
437  newpar = new TGo4MbsTransportParameter(hostname);
438  break;
439 
440  case kind_MbsEvent:
441  newpar = new TGo4MbsEventServerParameter(hostname);
442  break;
443 
444  case kind_MbsREvent:
445  newpar = new TGo4RevServParameter(hostname);
446  break;
447 
448  case kind_MbsRandom:
449  newpar = new TGo4MbsRandomParameter("random");
450  break;
451 
452  case kind_UserSource:
453  newpar = new TGo4UserSourceParameter(filename,"",port);
454  break;
455 #ifdef __GO4HDF5__
456  case kind_HDF5:
457  newpar = new TGo4HDF5SourceParameter(filename);
458  break;
459 #endif
460 
461  }
462 
463  TGo4MbsSourceParameter* newmbspar = dynamic_cast<TGo4MbsSourceParameter*> (newpar);
464 
465  if (newmbspar) {
466  newmbspar->SetPort(port);
467 
468  if (mbspar) {
469  newmbspar->SetStartEvent(mbspar->GetStartEvent());
470  newmbspar->SetStopEvent(mbspar->GetStopEvent());
471  newmbspar->SetEventInterval(mbspar->GetEventInterval());
472  }
473  }
474 
475  newpar->SetTimeout(srcpar->GetTimeout());
476 
477  fPars[kind] = newpar;
478 
479  // here parameter will be cloned
481 
482  fLastSrcKind = kind;
483 
484  if (delsrcpar) delete srcpar;
485 }
486 
487 void TGo4ConfigStep::SetSourceWidgets( const QString & name, int timeout)
488 {
489  SourceNameEdit->setText(name);
490  SpinBoxTimeout->setValue(timeout);
491 }
492 
493 void TGo4ConfigStep::SetMbsSourceWidgets(int start, int stop, int interval, int port)
494 {
495  SpinBoxStartEvent->setValue(start);
496  SpinBoxStopEvent->setValue(stop);
497  SpinBoxInterEvent->setValue(interval);
498  SpinBoxPortNumber->setValue(port);
499  SpinBoxRetryNumber->setValue(0);
500 }
501 
503 {
504  // FIXME: do it only interactively
505  if (fBlocked == 0) ChangeSourceParameter(kind);
506 
507  fBlocked++;
508 
509  // first disable everything which can be disabled
510 
511  SpinBoxPortNumber->setVisible(false);
512  TextLabelPortNumber->setVisible(false);
513  SpinBoxRetryNumber->setVisible(false);
514  TextLabelRetryNumber->setVisible(false);
515  LineEditArgs->setVisible(false);
516  TextLabelArgs->setVisible(false);
517  LineEditTagfile->setVisible(false);
518  TextLabelTagfile->setVisible(false);
519 
520  SpinBoxStartEvent->setVisible(false);
521  SpinBoxStopEvent->setVisible(false);
522  SpinBoxInterEvent->setVisible(false);
523  SpinBoxTimeout->setVisible(false);
524  TextLabelTimeout->setVisible(false);
525  FileNameBtn->setEnabled(false);
526  MbsMonitorBtn->setEnabled(false);
527 
528  // evaluate previous source if existing
529 
531 
532  SourceNameEdit->setText(srcpar->GetName());
533  SpinBoxTimeout->setValue(srcpar->GetTimeout());
534 
535  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*> (srcpar);
536 
537  if (mbspar) {
538  SpinBoxStartEvent->setValue(mbspar->GetStartEvent());
539  SpinBoxStopEvent->setValue(mbspar->GetStopEvent());
540  SpinBoxInterEvent->setValue(mbspar->GetEventInterval());
541  SpinBoxPortNumber->setValue(mbspar->GetPort());
542  SpinBoxRetryNumber->setValue(mbspar->GetRetryCnt());
543 
544 // if ((mbspar->GetPort()!=0) || (mbspar->GetRetryCnt()>0) ||
545 // (mbspar->GetStartEvent()!=0) || (mbspar->GetStopEvent()!=0) || (mbspar->GetEventInterval()>1)) fExtra = true;
546  }
547 
548  TGo4MbsFileParameter* mbsfilpar = dynamic_cast<TGo4MbsFileParameter*>(srcpar);
549  TGo4UserSourceParameter* userpar = dynamic_cast<TGo4UserSourceParameter*>(srcpar);
550 
551  switch (kind) {
552  case kind_RootFile: // root file with one tree
553  FileNameBtn->setEnabled(true);
554  break;
555  case kind_MbsFile: { // mbs listmode file (input only)
556  // in this special case spin boxes will be enabled/disabled when file name is changed
557  FileNameBtn->setEnabled(true);
558 
559  QString tagfile = mbsfilpar->GetTagName();
560 
561  if(!tagfile.contains(TGo4MbsFile__fgcNOTAGFILE)) {
562  LineEditTagfile->setText(tagfile);
563 // fExtra = true;
564  } else {
565  LineEditTagfile->setText("");
566  }
567 
568  LineEditTagfile->setVisible(fExtra);
569  TextLabelTagfile->setVisible(fExtra);
570 
571  SpinBoxStartEvent->setVisible(fExtra);
572  SpinBoxStopEvent->setVisible(fExtra);
573  SpinBoxInterEvent->setVisible(fExtra);
574  break;
575  }
576  case kind_MbsStream: // mbs stream server (input only)
577  case kind_MbsTransport: // mbs transport server (input only)
578  case kind_MbsEvent: // mbs event server (input only)
579  case kind_MbsREvent: // rev serv
580  TextLabelTimeout->setVisible(fExtra);
581  SpinBoxTimeout->setVisible(fExtra);
582  TextLabelPortNumber->setVisible(fExtra);
583  SpinBoxPortNumber->setVisible(fExtra);
584  TextLabelRetryNumber->setVisible(fExtra);
585  SpinBoxRetryNumber->setVisible(fExtra);
586  MbsMonitorBtn->setEnabled(kind != kind_MbsREvent);
587  SpinBoxStartEvent->setVisible(fExtra);
588  SpinBoxStopEvent->setVisible(fExtra);
589  SpinBoxInterEvent->setVisible(fExtra);
590  break;
591 
592  case kind_MbsRandom: // mbs random
593  break;
594 
595  case kind_UserSource: // user source
596  FileNameBtn->setEnabled(true);
597  SpinBoxPortNumber->setValue(userpar->GetPort());
598  LineEditArgs->setText(userpar->GetExpression());
599  SpinBoxPortNumber->setVisible(fExtra);
600  TextLabelPortNumber->setVisible(fExtra);
601  LineEditArgs->setVisible(fExtra);
602  TextLabelArgs->setVisible(fExtra);
603  TextLabelTimeout->setVisible(fExtra);
604  SpinBoxTimeout->setVisible(fExtra);
605  break;
606 
607  case kind_HDF5: // hdf5 file
608  FileNameBtn->setEnabled(true);
609  break;
610  }
611 
612  fBlocked--;
613 
614  adjustSize();
615  parentWidget()->adjustSize();
616  parentWidget()->parentWidget()->adjustSize();
617 
618  fxPanel->adjustSize();
619  fxPanel->parentWidget()->adjustSize();
620 }
621 
623 {
624  if(k==0) {
625  StoreNameEdit->setDisabled(false);
626  TGo4FileStoreParameter newpar0(StoreNameEdit->text().toLatin1().constData());
627  fStepStatus->SetStorePar(&newpar0);
628  SplitLevel->setDisabled(false);
629  BufferSize->setDisabled(false);
630  CompLevel->setDisabled(false);
631  StoreOverwriteMode->setDisabled(false);
632  FileNameOutput->setDisabled(false);
633  TreeAutosave->setDisabled(false);
634  } else if(k==1) {
635  StoreNameEdit->setDisabled(true);
636  TGo4BackStoreParameter newpar1(GetBackStoreName().toLatin1().constData());
637  fStepStatus->SetStorePar(&newpar1);
638  SplitLevel->setDisabled(false);
639  BufferSize->setDisabled(false);
640  CompLevel->setDisabled(true);
641  StoreOverwriteMode->setDisabled(true);
642  FileNameOutput->setDisabled(true);
643  TreeAutosave->setDisabled(true);
644  } else if(k==2) {
645  StoreNameEdit->setDisabled(false);
646  TGo4UserStoreParameter newpar2(StoreNameEdit->text().toLatin1().constData());
647  fStepStatus->SetStorePar(&newpar2);
648  SplitLevel->setDisabled(true);
649  BufferSize->setDisabled(true);
650  CompLevel->setDisabled(true);
651  StoreOverwriteMode->setDisabled(true);
652  FileNameOutput->setDisabled(false);
653  TreeAutosave->setDisabled(true);
654  } else if(k==3) {
655 #ifdef __GO4HDF5__
656  StoreNameEdit->setDisabled(false);
657  TGo4HDF5StoreParameter newpar3(StoreNameEdit->text().toLatin1().constData(), GO4_H5F_ACC_TRUNC);
658  fStepStatus->SetStorePar(&newpar3);
659  StoreOverwriteMode->setDisabled(false);
660  FileNameOutput->setDisabled(false);
661  CompLevel->setDisabled(true);
662  TreeAutosave->setDisabled(true);
663  SplitLevel->setDisabled(true);
664  BufferSize->setDisabled(true);
665 #endif
666  }
667 }
668 
670 {
671  QString filters;
672  if(fStepStatus!=0) {
674  if(storepar->InheritsFrom(TGo4FileStoreParameter::Class()))
675  filters = "Go4FileSource (*.root)";
676  else if (storepar->InheritsFrom(TGo4UserStoreParameter::Class()))
677  filters = "Go4UserStore (*.root)";
678 #ifdef __GO4HDF5__
679  else if (storepar->InheritsFrom(TGo4HDF5StoreParameter::Class())) {
680  filters="Go4HDF5 (*.h5)";
681  }
682 #endif
683  else
684  std::cout <<"Unknown storepar " <<storepar->ClassName() << std::endl;
685  }
686 
687 
688 
689  QFileDialog fd( this, "Select file name for step output",
690  fxPanel->GetStorePath(), filters);
691  fd.setFileMode( QFileDialog::AnyFile);
692  if ( fd.exec() != QDialog::Accepted ) return;
693 
694  QStringList flst = fd.selectedFiles();
695  if (flst.isEmpty()) return;
696 
697  QString fileName = flst[0];
698  std::cout << "output file is "<<fileName.toLatin1().constData() << std::endl;
699  fxPanel->SetStorePath(fd.directory().path());
700  if(!fileName.endsWith(".h5")) fileName.append(".h5");
701  std::cout << "output file is now "<<fileName.toLatin1().constData() << std::endl;
702  StoreNameEdit->setText(fileName);
703 }
704 
706 {
707  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
709  StorePar->SetBufsize(1000*t);
710  } else
711  if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())){
713  StorePar->SetBufsize(1000*t);
714  }
715 }
716 
718 {
719  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
721  StorePar->SetSplitlevel(t);
722  } else
723  if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())) {
725  StorePar->SetSplitlevel(t);
726  }
727 }
728 
730 {
731  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
733  StorePar->SetCompression(t);
734  }
735 }
736 
737 void TGo4ConfigStep::StoreOverWrite( bool overwrite)
738 {
739  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
741  if(overwrite)StorePar->SetOverwriteMode(kTRUE);
742  else StorePar->SetOverwriteMode(kFALSE);
743  }
744 #ifdef __GO4HDF5__
745  else if(fStepStatus->GetStorePar()->InheritsFrom(TGo4HDF5StoreParameter::Class())){
747  StorePar->SetHDF5Flags(overwrite ? GO4_H5F_ACC_TRUNC : GO4_H5F_ACC_RDWR);
748  }
749 #endif
750 }
751 
752 
754 {
755  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
757  StorePar->SetAutosaveSize(t);
758  }
759 
760 }
761 
762 
763 void TGo4ConfigStep::InputTagfile( const QString & tag )
764 {
765  if (fBlocked) return;
767  int ParId=SourcePar->GetID();
768  if (ParId!=GO4EV_MBS_FILE) return;
769  // tagfile only for mbs lmd file
770  TGo4MbsFileParameter* filpar = dynamic_cast<TGo4MbsFileParameter*>(SourcePar);
771 
772  if (filpar==0) return;
773 
774  if(tag.isEmpty())
776  else
777  filpar->SetTagName(tag.trimmed().toLatin1().constData());
778 }
779 
781 {
782  if (fBlocked) return;
783 
784  // only for mbs sources
787  if (par!=0) par->SetStartEvent(num);
788 }
789 
791 {
792  if (fBlocked) return;
793 
794  // only for mbs sources
797  if (par!=0) par->SetStopEvent(num);
798 }
799 
801 {
802  if (fBlocked) return;
803 
804  // only for mbs sources
807  if (par!=0) par->SetEventInterval(num);
808 }
809 
811 {
812  if (fBlocked) return;
813 
815  if (sourcepar!=0)
816  sourcepar->SetTimeout(tim);
817 }
818 
820 {
821  QString filters;
822  bool mbsfilemode = false;
823  if(fStepStatus!=0) {
825  if(sourcepar->InheritsFrom(TGo4FileSourceParameter::Class()))
826  filters = "Go4FileSource (*.root)";
827  else
828  if (sourcepar->InheritsFrom(TGo4MbsFileParameter::Class())) {
829  mbsfilemode=true;
830  filters="Go4MbsFile (*";
831  filters+=TGo4MbsFile__fgcLMDSUF;
832  filters+=" *";
833  filters+=QString(TGo4MbsFile__fgcLMDSUF).toUpper();
834  filters+=");;Go4 list mode list (*";
836  filters+=")";
837 
838  }
839  else
840  if (sourcepar->InheritsFrom(TGo4UserSourceParameter::Class())) {
841  filters = "all files (*.*)";
842  }
843 #ifdef __GO4HDF5__
844  else if (sourcepar->InheritsFrom(TGo4HDF5SourceParameter::Class())) {
845  filters="Go4HDF5 (*.h5)";
846  }
847 #endif
848  else
849  std::cout <<"Unknown sourcepar " <<sourcepar->ClassName() << std::endl;
850  }
851 
852  //std::cout <<"FFFFFFFF chose filter-"<< filters.toLatin1().constData() <<"-" << std::endl;
853  QFileDialog fd( this, "Select file name for step input",
854  fxPanel->GetSourcePath(), filters);
855  fd.setFileMode(QFileDialog::ExistingFile);
856 
857  if ( fd.exec() != QDialog::Accepted ) return;
858 
859  QStringList flst = fd.selectedFiles();
860  if (flst.isEmpty()) return;
861 
862  QString fileName = flst[0];
863  fxPanel->SetSourcePath(fd.directory().path());
864  SourceNameEdit->setText(fileName);
865  if(mbsfilemode) {
866  bool islml = fd.selectedNameFilter().contains(TGo4MbsFile__fgcFILELISTSUF);
867 
868  LineEditTagfile->setVisible(!islml);
869  TextLabelTagfile->setVisible(!islml);
870  SpinBoxStartEvent->setEnabled(!islml);
871  SpinBoxStopEvent->setEnabled(!islml);
872  SpinBoxInterEvent->setEnabled(!islml);
873  }
874 }
875 
877 {
878  return fStepStatus->GetName();
879 }
880 
882 {
883  QString res = fStepStatus->GetName();
884  if (fStepNumber>=0) {
885  res += " ";
886  res += EnableStepBox->isChecked() ? "x" : "o";
887  res += EnableSourceBox->isChecked() ? "x" : "o";
888  res += EnableStoreBox->isChecked() ? "x" : "o";
889  }
890  return res;
891 }
892 
893 void TGo4ConfigStep::SetStepControl(bool process, bool source, bool store)
894 {
895  EnableStepBox->setChecked(process);
896  EnableSourceBox->setChecked(source);
897  EnableStoreBox->setChecked(store);
898 
899  StepStateChanged(0);
900 }
901 
902 void TGo4ConfigStep::GetStepControl(bool& process, bool& source, bool& store)
903 {
904  process = EnableStepBox->isChecked();
905  source = EnableSourceBox->isChecked();
906  store = EnableStoreBox->isChecked();
907 }
908 
910 {
911  EventSourceCombo->setCurrentIndex(kind_RootFile);
912 }
913 
914 void TGo4ConfigStep::SetMbsFileSource(const QString& TagFile)
915 {
916  EventSourceCombo->setCurrentIndex(kind_MbsFile);
917 
918  if(!TagFile.contains(TGo4MbsFile__fgcNOTAGFILE))
919  LineEditTagfile->setText(TagFile);
920  else
921  LineEditTagfile->setText("");
922 }
923 
925 {
926  EventSourceCombo->setCurrentIndex(kind_MbsStream);
927 }
928 
930 {
931  EventSourceCombo->setCurrentIndex(kind_MbsTransport);
932 }
933 
935 {
936  EventSourceCombo->setCurrentIndex(kind_MbsEvent);
937 }
938 
940 {
941  EventSourceCombo->setCurrentIndex(kind_MbsREvent);
942 
943  SpinBoxPortNumber->setValue(port>0 ? port : 0);
944 }
945 
947 {
948  SpinBoxPortNumber->setValue(port > 0 ? port : 0);
949 }
950 
952 {
953  SpinBoxRetryNumber->setValue(retry > 0 ? retry : 0);
954 }
955 
956 
958 {
959  EventSourceCombo->setCurrentIndex(kind_MbsRandom);
960 }
961 
962 void TGo4ConfigStep::SetUserSource(int port, QString expr)
963 {
964  EventSourceCombo->setCurrentIndex(kind_UserSource);
965 
966  SpinBoxPortNumber->setValue(port);
967  LineEditArgs->setText(expr);
968 }
969 
971 {
972 #ifdef __GO4HDF5__
973  EventSourceCombo->setCurrentIndex(kind_HDF5);
974  LineEditArgs->setText(name);
975 #endif
976 }
977 
978 
979 int TGo4ConfigStep::GetSourceSetup(QString& name, int& timeout, int& start, int& stop, int& interval, int& nport, int & nretry)
980 {
981  name = SourceNameEdit->text();
982  timeout = SpinBoxTimeout->value();
983  start = SpinBoxStartEvent->value();
984  stop = SpinBoxStopEvent->value();
985  interval = SpinBoxInterEvent->value();
986  nport = -1;
987  nretry = 0;
988  switch (fStepStatus->GetSourcePar()->GetID()) {
989  case GO4EV_MBS_TRANSPORT:
990  case GO4EV_MBS_STREAM:
992  case GO4EV_MBS_REVSERV: {
994  if (par!=0) {
995  nport = SpinBoxPortNumber->value();
996  nretry = SpinBoxRetryNumber->value();
997  }
998  break;
999  }
1000  }
1001  return EventSourceCombo->currentIndex();
1002 }
1003 
1004 void TGo4ConfigStep::GetMbsFileSource(QString& TagFile)
1005 {
1006  TagFile = LineEditTagfile->text();
1007 // if (TagFile.length()==0) TagFile = TGo4MbsFile__fgcNOTAGFILE;
1008 }
1009 
1010 void TGo4ConfigStep::GetUserSource(int& port, QString& expr)
1011 {
1012  port = SpinBoxPortNumber->value();
1013  expr = LineEditArgs->text();
1014 }
1015 
1016 void TGo4ConfigStep::SetFileStore(QString name, bool overwrite, int bufsize, int splitlevel, int compression, int autosave)
1017 {
1018  StoreNameEdit->setEnabled(true);
1019  StoreNameEdit->setText(name);
1020  OutputCombo->setCurrentIndex(0);
1021  StoreOverwriteMode->setChecked(overwrite);
1022  StoreOverwriteMode->setEnabled(true);
1023  BufferSize->setEnabled(true);
1024  SplitLevel->setEnabled(true);
1025  BufferSize->setValue(bufsize/1000);
1026  SplitLevel->setValue(splitlevel);
1027  CompLevel->setValue(compression);
1028  TreeAutosave->setValue(autosave);
1029  CompLevel->setEnabled(true);
1030  FileNameOutput->setEnabled(true);
1032 }
1033 
1034 void TGo4ConfigStep::SetBackStore(QString name, int bufsize, int splitlevel)
1035 {
1036  StoreNameEdit->setEnabled(false);
1037  StoreNameEdit->setText(GetBackStoreName());
1038  OutputCombo->setCurrentIndex(1);
1039  BufferSize->setEnabled(true);
1040  SplitLevel->setEnabled(true);
1041  BufferSize->setValue(bufsize/1000);
1042  SplitLevel->setValue(splitlevel);
1043  StoreOverwriteMode->setEnabled(false);
1044  CompLevel->setEnabled(false);
1045  FileNameOutput->setEnabled(false);
1047 }
1048 
1050 {
1051  StoreNameEdit->setEnabled(true);
1052  StoreNameEdit->setText(name);
1053  OutputCombo->setCurrentIndex(2);
1054 
1055  BufferSize->setEnabled(false);
1056  SplitLevel->setEnabled(false);
1057  StoreOverwriteMode->setEnabled(false);
1058  CompLevel->setEnabled(false);
1059  FileNameOutput->setEnabled(true);
1060 
1062 }
1063 
1064 void TGo4ConfigStep::SetHDF5Store(QString name, int flags)
1065 {
1066 #ifdef __GO4HDF5__
1067  StoreNameEdit->setEnabled(false);
1068  StoreNameEdit->setText(name);
1069  OutputCombo->setCurrentIndex(3);
1070  StoreOverwriteMode->setEnabled(true);
1071  StoreOverwriteMode->setChecked(flags==GO4_H5F_ACC_TRUNC ? true : false);
1072 // JAM2019: here evaluate the file access flags
1073 // Valid values of flags include://
1074 // H5F_ACC_TRUNC - Truncate file, if it already exists, erasing all data previously stored in the file.
1075 // H5F_ACC_EXCL - Fail if file already exists. H5F_ACC_TRUNC and H5F_ACC_EXCL are mutually exclusive
1076 // H5F_ACC_RDONLY - Open file as read-only, if it already exists, and fail, otherwise
1077 // H5F_ACC_RDWR - Open file for read/write, if it already exists, and fail, otherwise
1078  FileNameOutput->setEnabled(true);
1080 #endif
1081 }
1082 
1083 
1085 {
1086  QString name = "BackStoreTree_";
1087  name += GetStepName();
1088  return name;
1089 }
1090 
1092 {
1093  int typ = OutputCombo->currentIndex();
1094  if (typ==1) name = GetBackStoreName();
1095  else name = StoreNameEdit->text();
1096  return typ;
1097 }
1098 
1099 void TGo4ConfigStep::GetFileStore(bool& overwrite, int& bufsize, int& splitlevel, int& compression, int& autosaveperiod)
1100 {
1101  overwrite = StoreOverwriteMode->isChecked();
1102  bufsize = BufferSize->value() * 1000;
1103  splitlevel = SplitLevel->value();
1104  compression = CompLevel->value();
1105  autosaveperiod = TreeAutosave->value();
1106 }
1107 
1108 void TGo4ConfigStep::GetBackStore(int& bufsize, int& splitlevel)
1109 {
1110  bufsize = BufferSize->value() * 1000;
1111  splitlevel = SplitLevel->value();
1112 }
1113 
1115 {
1116 #ifdef __GO4HDF5__
1117  StoreOverwriteMode->isChecked() ? flags=GO4_H5F_ACC_TRUNC : flags=0;
1118 #endif
1119 }
1120 
1122 {
1123  if (fxPanel!=0)
1124  fxPanel->DisplayMbsMonitor(SourceNameEdit->text());
1125 }
1126 
1128 {
1129  fExtra = !fExtra;
1130  ExtraBtn->setText(fExtra ? "-" : "+");
1131 
1132  fBlocked++;
1133 
1134  SourceComboHighlighted(EventSourceCombo->currentIndex());
1135 
1136  fBlocked--;
1137 }
SourceComboKinds
virtual void ChangeEventInterval(int num)
void SetStartEvent(UInt_t firstindex)
void SetProcessEnabled(Bool_t on=kTRUE)
virtual ~TGo4ConfigStep()
void SetStoreEnabled(Bool_t on=kTRUE)
TGo4EventStoreParameter * GetStorePar() const
virtual void InputStateChanged(int)
void SetSplitlevel(Int_t split)
TGo4AnalysisConfiguration * fxPanel
virtual void SetStepStatus(TGo4AnalysisConfiguration *panel, TGo4AnalysisStepStatus *StepStatus, int number=-1)
void SetSplitlevel(Int_t split)
virtual void SetMbsStreamSource()
virtual void SetUserSource(int port, QString expr)
virtual void OutputNameText(const QString &Name)
void SetStopEvent(UInt_t lastindex)
virtual void InputTagfile(const QString &tag)
virtual void OutputStateChanged(int)
virtual void StoreBufferSize(int t)
virtual void RetryCntChanged(int)
virtual void StoreOverWrite(bool overwrite)
virtual QString GetTabTitle()
virtual void SetBackStore(QString name, int bufsize, int splitlevel)
virtual void GetHDF5Store(int &flags)
virtual void SetMbsRetryCnt(int retry)
virtual void SetHDF5Store(QString name, int flags)
virtual QString GetBackStoreName()
virtual void SetSourcePath(const QString &v)
virtual void ChangeSourceTimeout(int tim)
void SetSourceEnabled(Bool_t on=kTRUE)
virtual void SetMbsRevServSource(int port)
virtual void ExtraBtn_clicked()
virtual void StepStateChanged(int)
const char * TGo4MbsFile__fgcLMDSUF
void SetAutosaveSize(Int_t interval)
virtual void GetFileStore(bool &overwrite, int &bufsize, int &splitlevel, int &compression, int &autosaveinterval)
TGo4EventSourceParameter * fPars[ParsSize]
void SetTagName(const char *name)
virtual void InputPortChanged(int)
virtual void MbsMonitorBtn_clicked()
void SetStorePar(TGo4EventStoreParameter *kind)
void ChangeSourceParameter(int kind)
void SetSourcePar(TGo4EventSourceParameter *kind)
virtual void GetMbsFileSource(QString &TagFile)
TGo4EventSourceParameter * GetSourcePar() const
virtual void SetHDF5Source(QString name)
void SetOverwriteMode(Bool_t over=kTRUE)
virtual int GetStoreSetup(QString &name)
virtual void GetStepControl(bool &process, bool &source, bool &store)
const char * TGo4MbsFile__fgcFILELISTSUF
virtual void SetMbsFileSource(const QString &TagFile)
virtual void SetRandomSource()
TGo4EventSourceParameter * TakeSourcePar()
virtual void SetFileSource()
virtual QString GetStepName()
virtual void StoreComboHighlighted(int k)
virtual void SetFileStore(QString name, bool overwrite, int bufsize, int splitlevel, int compression, int autosave=0)
const char * TGo4MbsFile__fgcNOTAGFILE
virtual void SetStepControl(bool process, bool source, bool store)
void SetEventInterval(UInt_t skipinterval)
void SetBufsize(Int_t bufsize)
TGo4AnalysisStepStatus * fStepStatus
virtual void SetSourceWidgets(const QString &name, int timeout)
virtual void GetBackStore(int &bufsize, int &splitlevel)
virtual void SetMbsTransportSource()
virtual void SetMbsSourceWidgets(int start, int stop, int interval, int port=0)
Go4_H5_File_Flags GetHDF5Flags() const
virtual void OutputFileDialog()
void SetHDF5Flags(Go4_H5_File_Flags flags)
virtual void GetUserSource(int &port, QString &expr)
const char * GetExpression() const
virtual void InputSourceText(const QString &Name)
void SetExpression(const char *name)
virtual void ChangeStartEvent(int num)
TGo4ConfigStep(QWidget *parent=0, const char *name=0, Qt::WindowFlags fl=Qt::Widget)
virtual void SetStorePath(const QString &v)
virtual int GetSourceSetup(QString &name, int &timeout, int &start, int &stop, int &interval, int &port, int &nretry)
void SetBufsize(Int_t bufsize)
virtual void DisplayMbsMonitor(const QString &mbsname)
virtual void StoreCompLevel(int t)
virtual void InputArguments(const QString &Arg)
virtual void InputFileDialog()
virtual void StoreTreeAutoSave(int t)
virtual void SourceComboHighlighted(int kind)
void ChangeTabTitle(TGo4ConfigStep *step, int number)
virtual void SetUserStore(QString name)
virtual void SetMbsEventServerSource()
virtual void SetMbsPort(int port)
virtual void ChangeStopEvent(int num)
virtual void StoreSplitLevel(int t)
const char * GetTagName() const