GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ConfigStep.cpp
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 "TGo4ConfigStep.h"
15 
16 #include <iostream>
17 
18 #include <QFileDialog>
19 
20 #include "TGo4AnalysisStepStatus.h"
24 #include "TGo4UserStoreParameter.h"
25 #include "TGo4RevServParameter.h"
26 #include "TGo4FileStoreParameter.h"
27 #include "TGo4BackStoreParameter.h"
29 #include "TGo4MbsFileParameter.h"
30 #include "TGo4MbsStreamParameter.h"
33 #include "TGo4MbsRandomParameter.h"
34 
35 #ifdef __GO4HDF5__
36 //#include "H5Cpp.h"
37 #include "TGo4HDF5StoreParameter.h"
39 #endif
40 
41 #include "Go4EventServerTypes.h"
43 
44 const char *TGo4MbsFile__fgcNOTAGFILE = "GO4-NOLMDTAG";
45 const char *TGo4MbsFile__fgcLMDSUF = ".lmd";
46 const char *TGo4MbsFile__fgcFILELISTSUF = ".lml";
47 
58 };
59 
60 
61 TGo4ConfigStep::TGo4ConfigStep( QWidget *parent, const char *name, Qt::WindowFlags fl )
62  : QWidget( parent, fl )
63 {
64  setObjectName( name ? name : "Go4ConfigStep");
65 
66  setupUi(this);
67 
68  QObject::connect(EnableStepBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::StepStateChanged);
69  QObject::connect(EnableSourceBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::InputStateChanged);
70  QObject::connect(EnableStoreBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::OutputStateChanged);
71  QObject::connect(SourceNameEdit, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputSourceText);
72  QObject::connect(EventSourceCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TGo4ConfigStep::SourceComboHighlighted);
73  QObject::connect(OutputCombo, QOverload<int>::of(&QComboBox::activated), this, &TGo4ConfigStep::StoreComboHighlighted);
74  QObject::connect(StoreNameEdit, &QLineEdit::textChanged, this, &TGo4ConfigStep::OutputNameText);
75  QObject::connect(FileNameOutput, &QPushButton::clicked, this, &TGo4ConfigStep::OutputFileDialog);
76  QObject::connect(CompLevel, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreCompLevel);
77  QObject::connect(BufferSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreBufferSize);
78  QObject::connect(SplitLevel, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreSplitLevel);
79  QObject::connect(StoreOverwriteMode, &QCheckBox::toggled, this, &TGo4ConfigStep::StoreOverWrite);
80  QObject::connect(LineEditArgs, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputArguments);
81  QObject::connect(LineEditTagfile, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputTagfile);
82  QObject::connect(SpinBoxStartEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeStartEvent);
83  QObject::connect(SpinBoxStopEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeStopEvent);
84  QObject::connect(FileNameBtn, &QPushButton::clicked, this, &TGo4ConfigStep::InputFileDialog);
85  QObject::connect(SpinBoxInterEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeEventInterval);
86  QObject::connect(SpinBoxTimeout, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeSourceTimeout);
87  QObject::connect(ExtraBtn, &QPushButton::clicked, this, &TGo4ConfigStep::ExtraBtn_clicked);
88  QObject::connect(MbsMonitorBtn, &QPushButton::clicked, this, &TGo4ConfigStep::MbsMonitorBtn_clicked);
89  QObject::connect(SpinBoxPortNumber, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::InputPortChanged);
90  QObject::connect(SpinBoxRetryNumber, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::RetryCntChanged);
91  QObject::connect(TreeAutosave, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreTreeAutoSave);
92 
93  fStepNumber = 0;
94  fxPanel = nullptr;
95  fStepStatus = nullptr;
96 
97  SpinBoxPortNumber->setVisible(false);
98  TextLabelPortNumber->setVisible(false);
99  SpinBoxRetryNumber->setVisible(false);
100  TextLabelRetryNumber->setVisible(false);
101  SpinBoxTimeout->setVisible(false);
102  TextLabelTimeout->setVisible(false);
103 
104  SpinBoxStartEvent->setVisible(false);
105  SpinBoxStopEvent->setVisible(false);
106  SpinBoxInterEvent->setVisible(false);
107 
108  LineEditArgs->setVisible(false);
109  TextLabelArgs->setVisible(false);
110  LineEditTagfile->setVisible(false);
111  TextLabelTagfile->setVisible(false);
112 
113  for (int n = 0; n < ParsSize; n++)
114  fPars[n] = nullptr;
115 
116  fLastSrcKind = -1;
117  fBlocked = 0;
118  fExtra = false;
119  ExtraBtn->setText(fExtra ? "-" : "+");
120 
121 #ifndef __GO4HDF5__
122  OutputCombo->removeItem(3);
123  EventSourceCombo->removeItem(8);
124 #endif
125 
126 }
127 
129 {
130  for (int n = 0; n < ParsSize; n++) {
131  delete fPars[n];
132  fPars[n] = nullptr;
133  }
134 }
135 
136 
137 void TGo4ConfigStep::InputArguments(const QString& Arg)
138 {
140  int ParId=SourcePar->GetID();
141  if (ParId==GO4EV_USER){ // user defined source class
142  TGo4UserSourceParameter* usrpar = dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
143  if (usrpar)
144  usrpar->SetExpression(Arg.trimmed().toLatin1().constData());
145  }
146 }
147 
149 {
150  bool stepon = EnableStepBox->isChecked();
151  bool on = EnableSourceBox->isChecked();
152 
154  SourceBox->setEnabled(stepon && on);
155 
157 }
158 
160 {
161  if (fBlocked) return;
162 
164 
165  switch (SourcePar->GetID()) {
166 
167  case GO4EV_MBS_TRANSPORT:
168  case GO4EV_MBS_STREAM:
170  case GO4EV_MBS_REVSERV: {
171  TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
172  if (par)
173  par->SetPort(port);
174  break;
175  }
176 
177  case GO4EV_USER: { // user defined source class
178  TGo4UserSourceParameter* usrpar=dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
179  if (usrpar)
180  usrpar->SetPort(port);
181  break;
182  }
183 
184  default: {
185  // do nothing
186  break;
187  }
188  }
189 }
190 
192 {
193  if (fBlocked) return;
194 
196 
197  switch (SourcePar->GetID()) {
198 
199  case GO4EV_MBS_TRANSPORT:
200  case GO4EV_MBS_STREAM:
202  case GO4EV_MBS_REVSERV: {
203  TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
204  if (par)
205  par->SetRetryCnt(cnt);
206  break;
207  }
208 
209  default: {
210  // do nothing
211  break;
212  }
213  }
214 }
215 
216 void TGo4ConfigStep::InputSourceText(const QString& name)
217 {
218  if (fBlocked) return;
219 
221  fStepStatus->GetSourcePar()->SetName(name.trimmed().toLatin1().constData());
222 
223  if (EventSourceCombo->currentIndex() == kind_MbsFile) {
224  bool islml = name.contains(TGo4MbsFile__fgcFILELISTSUF);
225  LineEditTagfile->setVisible(!islml);
226  TextLabelTagfile->setVisible(!islml);
227 
228  SpinBoxStartEvent->setEnabled(!islml);
229  SpinBoxStopEvent->setEnabled(!islml);
230  SpinBoxInterEvent->setEnabled(!islml);
231  }
232 }
233 
235 {
236  bool stepon = EnableStepBox->isChecked();
237  bool on = EnableStoreBox->isChecked();
238 
240  StoreBox->setEnabled(stepon && on);
241  StoreBox->setVisible(on);
242 
244 
245  adjustSize();
246  parentWidget()->adjustSize();
247  parentWidget()->parentWidget()->adjustSize();
248 
249  fxPanel->adjustSize();
250  fxPanel->parentWidget()->adjustSize();
251 }
252 
253 void TGo4ConfigStep::OutputNameText(const QString& Name)
254 {
255  fStepStatus->GetStorePar()->SetName(Name.trimmed().toLatin1().constData());
256 }
257 
259 {
260  bool on = EnableStepBox->isChecked();
261 
263  EnableSourceBox->setEnabled(on);
264  EnableStoreBox->setEnabled(on);
265 
267 
270 }
271 
273 {
274  if (!StepStatus) return;
275 
276  fxPanel = panel;
277  fStepStatus = StepStatus;
278  fStepNumber = number;
279  fLastSrcKind = -1; // indicate that status (and its parameter) is changed
280 
281  //----------------------------------------------------//
282  //Source:
283 
284  /*
285  Qt use following order to display the source parameter:
286 
287  0) root file with one tree TGo4FileSourceParameter
288  1) mbs listmode file (input only) TGo4MbsFileParameter
289  2) mbs stream server (input only) TGo4MbsStreamParameter
290  3) mbs transport server (input only) TGo4MbsTransportParameter
291  4) mbs event server (input only) TGo4MbsEventServerParameter
292  5) rev serv TGo4RevServParameter
293  6) mbs random generator TGo4MbsRandomParameter
294  7) user source TGo4UserSourceParameter
295 
296  */
297 
298  int srckind = CurrentSourceKind();
299  fBlocked++;
300  EventSourceCombo->setCurrentIndex(srckind);
301  fBlocked--;
302 
303 
304  //----------------------------------------------------//
305  //Store
306 
308 
309  if (StorePar)
310  switch(StorePar->GetID()) {
311  case GO4EV_FILE: {
312  TGo4FileStoreParameter* fstor = dynamic_cast<TGo4FileStoreParameter*>(StorePar);
313  SetFileStore(fstor->GetName(),
314  fstor->IsOverwriteMode(),
315  fstor->GetBufsize(),
316  fstor->GetSplitlevel(),
317  fstor->GetCompression(),
318  fstor->GetAutosaveSize());
319  break;
320  }
321  case GO4EV_BACK: {
322  TGo4BackStoreParameter* bstor = dynamic_cast<TGo4BackStoreParameter*>(StorePar);
323  SetBackStore(bstor->GetName(),
324  bstor->GetBufsize(),
325  bstor->GetSplitlevel());
326  break;
327  }
328  case GO4EV_USER: {
329  TGo4UserStoreParameter *ustor = dynamic_cast<TGo4UserStoreParameter*>(StorePar);
330  SetUserStore(ustor->GetName());
331  break;
332  }
333 
334 #ifdef __GO4HDF5__
335  case GO4EV_HDF5: {
336  TGo4HDF5StoreParameter* hstor = dynamic_cast<TGo4HDF5StoreParameter*>(StorePar);
337  SetHDF5Store(hstor->GetName(), hstor->GetHDF5Flags());
338  break;
339  }
340 #endif
341 
342 
343  default:
344  break;
345  } // switch StorePar->GetID()
346 
347  //----------------------------------------------------//
348  // enable or disable processing:
349 
353 }
354 
355 
357 {
358  if (!fStepStatus || !fStepStatus->GetSourcePar()) return kind_MbsFile;
359 
360  switch(fStepStatus->GetSourcePar()->GetID()) {
361  case GO4EV_FILE: return kind_RootFile;
362  case GO4EV_MBS_FILE: return kind_MbsFile;
363  case GO4EV_MBS_STREAM: return kind_MbsStream;
366  case GO4EV_MBS_REVSERV: return kind_MbsREvent;
367  case GO4EV_MBS_RANDOM: return kind_MbsRandom;
368  case GO4EV_USER: return kind_UserSource;
369  case GO4EV_HDF5: return kind_HDF5;
370  } // SourcePar->GetID()
371 
372  return kind_MbsFile;
373 }
374 
376 {
377  if (!fStepStatus) return;
378 
380  bool delsrcpar = true;
381  TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*> (srcpar);
382 
383  if (fLastSrcKind >= 0) {
384  if (fPars[fLastSrcKind]) delete fPars[fLastSrcKind];
385  fPars[fLastSrcKind] = srcpar;
386  delsrcpar = false;
387  }
388 
389  if (fPars[kind]) {
391  fLastSrcKind = kind;
392  if (delsrcpar) delete srcpar;
393  return;
394  }
395 
396  TString filename, hostname;
397  Int_t port = 0;
398 
399  switch(srcpar->GetID()) {
400  case GO4EV_FILE:
401  case GO4EV_MBS_FILE:
402  case GO4EV_HDF5:
403  filename = srcpar->GetName();
404  break;
405 
406  case GO4EV_MBS_STREAM:
407  case GO4EV_MBS_TRANSPORT:
409  case GO4EV_MBS_REVSERV:
410  hostname = srcpar->GetName();
411  port = mbspar ? mbspar->GetPort() : 0;
412  break;
413 
414  case GO4EV_MBS_RANDOM:
415  break;
416  case GO4EV_USER:
417  break;
418  default:
419  break;
420  }
421 
422  TGo4EventSourceParameter *newpar = nullptr;
423 
424  switch (kind) {
425  case kind_RootFile:
426  newpar = new TGo4FileSourceParameter(filename);
427  break;
428 
429  case kind_MbsFile:
430  newpar = new TGo4MbsFileParameter(filename);
431  break;
432 
433  case kind_MbsStream:
434  newpar = new TGo4MbsStreamParameter(hostname);
435  break;
436 
437  case kind_MbsTransport:
438  newpar = new TGo4MbsTransportParameter(hostname);
439  break;
440 
441  case kind_MbsEvent:
442  newpar = new TGo4MbsEventServerParameter(hostname);
443  break;
444 
445  case kind_MbsREvent:
446  newpar = new TGo4RevServParameter(hostname);
447  break;
448 
449  case kind_MbsRandom:
450  newpar = new TGo4MbsRandomParameter("random");
451  break;
452 
453  case kind_UserSource:
454  newpar = new TGo4UserSourceParameter(filename,"",port);
455  break;
456 #ifdef __GO4HDF5__
457  case kind_HDF5:
458  newpar = new TGo4HDF5SourceParameter(filename);
459  break;
460 #endif
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) {
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  QFileDialog fd( this, "Select file name for step output",
688  fxPanel->GetStorePath(), filters);
689  fd.setFileMode( QFileDialog::AnyFile);
690  if ( fd.exec() != QDialog::Accepted ) return;
691 
692  QStringList flst = fd.selectedFiles();
693  if (flst.isEmpty()) return;
694 
695  QString fileName = flst[0];
696  std::cout << "output file is "<<fileName.toLatin1().constData() << std::endl;
697  fxPanel->SetStorePath(fd.directory().path());
698  if(!fileName.endsWith(".h5")) fileName.append(".h5");
699  std::cout << "output file is now "<<fileName.toLatin1().constData() << std::endl;
700  StoreNameEdit->setText(fileName);
701 }
702 
704 {
705  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
707  StorePar->SetBufsize(1000*t);
708  } else
709  if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())){
711  StorePar->SetBufsize(1000*t);
712  }
713 }
714 
716 {
717  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
719  StorePar->SetSplitlevel(t);
720  } else
721  if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())) {
723  StorePar->SetSplitlevel(t);
724  }
725 }
726 
728 {
729  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
731  StorePar->SetCompression(t);
732  }
733 }
734 
735 void TGo4ConfigStep::StoreOverWrite( bool overwrite)
736 {
737  if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
739  if(overwrite)StorePar->SetOverwriteMode(kTRUE);
740  else StorePar->SetOverwriteMode(kFALSE);
741  }
742 #ifdef __GO4HDF5__
743  else if(fStepStatus->GetStorePar()->InheritsFrom(TGo4HDF5StoreParameter::Class())){
745  StorePar->SetHDF5Flags(overwrite ? GO4_H5F_ACC_TRUNC : GO4_H5F_ACC_RDWR);
746  }
747 #endif
748 }
749 
750 
752 {
753  if (fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
755  StorePar->SetAutosaveSize(t);
756  }
757 }
758 
759 
760 void TGo4ConfigStep::InputTagfile( const QString & tag )
761 {
762  if (fBlocked) return;
764  int ParId=SourcePar->GetID();
765  if (ParId!=GO4EV_MBS_FILE) return;
766  // tagfile only for mbs lmd file
767  TGo4MbsFileParameter* filpar = dynamic_cast<TGo4MbsFileParameter*>(SourcePar);
768 
769  if (!filpar) return;
770 
771  if(tag.isEmpty())
773  else
774  filpar->SetTagName(tag.trimmed().toLatin1().constData());
775 }
776 
778 {
779  if (fBlocked) return;
780 
781  // only for mbs sources
784  if (par) par->SetStartEvent(num);
785 }
786 
788 {
789  if (fBlocked) return;
790 
791  // only for mbs sources
794  if (par) par->SetStopEvent(num);
795 }
796 
798 {
799  if (fBlocked) return;
800 
801  // only for mbs sources
804  if (par) par->SetEventInterval(num);
805 }
806 
808 {
809  if (fBlocked) return;
810 
812  if (sourcepar)
813  sourcepar->SetTimeout(tim);
814 }
815 
817 {
818  QString filters;
819  bool mbsfilemode = false;
820  if(fStepStatus) {
822  if(sourcepar->InheritsFrom(TGo4FileSourceParameter::Class()))
823  filters = "Go4FileSource (*.root)";
824  else
825  if (sourcepar->InheritsFrom(TGo4MbsFileParameter::Class())) {
826  mbsfilemode=true;
827  filters="Go4MbsFile (*";
828  filters+=TGo4MbsFile__fgcLMDSUF;
829  filters+=" *";
830  filters+=QString(TGo4MbsFile__fgcLMDSUF).toUpper();
831  filters+=");;Go4 list mode list (*";
833  filters+=")";
834 
835  }
836  else
837  if (sourcepar->InheritsFrom(TGo4UserSourceParameter::Class())) {
838  filters = "all files (*.*)";
839  }
840 #ifdef __GO4HDF5__
841  else if (sourcepar->InheritsFrom(TGo4HDF5SourceParameter::Class())) {
842  filters="Go4HDF5 (*.h5)";
843  }
844 #endif
845  else
846  std::cout <<"Unknown sourcepar " <<sourcepar->ClassName() << std::endl;
847  }
848 
849  QFileDialog fd(this, "Select file name for step input", fxPanel->GetSourcePath(), filters);
850  fd.setFileMode(QFileDialog::ExistingFile);
851 
852  if ( fd.exec() != QDialog::Accepted ) return;
853 
854  QStringList flst = fd.selectedFiles();
855  if (flst.isEmpty()) return;
856 
857  QString fileName = flst[0];
858  fxPanel->SetSourcePath(fd.directory().path());
859  SourceNameEdit->setText(fileName);
860  if(mbsfilemode) {
861  bool islml = fd.selectedNameFilter().contains(TGo4MbsFile__fgcFILELISTSUF);
862 
863  LineEditTagfile->setVisible(!islml);
864  TextLabelTagfile->setVisible(!islml);
865  SpinBoxStartEvent->setEnabled(!islml);
866  SpinBoxStopEvent->setEnabled(!islml);
867  SpinBoxInterEvent->setEnabled(!islml);
868  }
869 }
870 
872 {
873  return fStepStatus->GetName();
874 }
875 
877 {
878  QString res = fStepStatus->GetName();
879  if (fStepNumber >= 0) {
880  res += " ";
881  res += EnableStepBox->isChecked() ? "x" : "o";
882  res += EnableSourceBox->isChecked() ? "x" : "o";
883  res += EnableStoreBox->isChecked() ? "x" : "o";
884  }
885  return res;
886 }
887 
888 void TGo4ConfigStep::SetStepControl(bool process, bool source, bool store)
889 {
890  EnableStepBox->setChecked(process);
891  EnableSourceBox->setChecked(source);
892  EnableStoreBox->setChecked(store);
893 
894  StepStateChanged(0);
895 }
896 
897 void TGo4ConfigStep::GetStepControl(bool& process, bool& source, bool& store)
898 {
899  process = EnableStepBox->isChecked();
900  source = EnableSourceBox->isChecked();
901  store = EnableStoreBox->isChecked();
902 }
903 
905 {
906  EventSourceCombo->setCurrentIndex(kind_RootFile);
907 }
908 
909 void TGo4ConfigStep::SetMbsFileSource(const QString& TagFile)
910 {
911  EventSourceCombo->setCurrentIndex(kind_MbsFile);
912 
913  if(!TagFile.contains(TGo4MbsFile__fgcNOTAGFILE))
914  LineEditTagfile->setText(TagFile);
915  else
916  LineEditTagfile->setText("");
917 }
918 
920 {
921  EventSourceCombo->setCurrentIndex(kind_MbsStream);
922 }
923 
925 {
926  EventSourceCombo->setCurrentIndex(kind_MbsTransport);
927 }
928 
930 {
931  EventSourceCombo->setCurrentIndex(kind_MbsEvent);
932 }
933 
935 {
936  EventSourceCombo->setCurrentIndex(kind_MbsREvent);
937 
938  SpinBoxPortNumber->setValue(port>0 ? port : 0);
939 }
940 
942 {
943  SpinBoxPortNumber->setValue(port > 0 ? port : 0);
944 }
945 
947 {
948  SpinBoxRetryNumber->setValue(retry > 0 ? retry : 0);
949 }
950 
952 {
953  EventSourceCombo->setCurrentIndex(kind_MbsRandom);
954 }
955 
956 void TGo4ConfigStep::SetUserSource(int port, QString expr)
957 {
958  EventSourceCombo->setCurrentIndex(kind_UserSource);
959 
960  SpinBoxPortNumber->setValue(port);
961  LineEditArgs->setText(expr);
962 }
963 
965 {
966 #ifdef __GO4HDF5__
967  EventSourceCombo->setCurrentIndex(kind_HDF5);
968  LineEditArgs->setText(name);
969 #endif
970 }
971 
972 
973 int TGo4ConfigStep::GetSourceSetup(QString& name, int& timeout, int& start, int& stop, int& interval, int& nport, int & nretry)
974 {
975  name = SourceNameEdit->text();
976  timeout = SpinBoxTimeout->value();
977  start = SpinBoxStartEvent->value();
978  stop = SpinBoxStopEvent->value();
979  interval = SpinBoxInterEvent->value();
980  nport = -1;
981  nretry = 0;
982  switch (fStepStatus->GetSourcePar()->GetID()) {
983  case GO4EV_MBS_TRANSPORT:
984  case GO4EV_MBS_STREAM:
986  case GO4EV_MBS_REVSERV: {
988  if (par) {
989  nport = SpinBoxPortNumber->value();
990  nretry = SpinBoxRetryNumber->value();
991  }
992  break;
993  }
994  }
995  return EventSourceCombo->currentIndex();
996 }
997 
998 void TGo4ConfigStep::GetMbsFileSource(QString& TagFile)
999 {
1000  TagFile = LineEditTagfile->text();
1001 // if (TagFile.isEmpty()) TagFile = TGo4MbsFile__fgcNOTAGFILE;
1002 }
1003 
1004 void TGo4ConfigStep::GetUserSource(int& port, QString& expr)
1005 {
1006  port = SpinBoxPortNumber->value();
1007  expr = LineEditArgs->text();
1008 }
1009 
1010 void TGo4ConfigStep::SetFileStore(QString name, bool overwrite, int bufsize, int splitlevel, int compression, int autosave)
1011 {
1012  StoreNameEdit->setEnabled(true);
1013  StoreNameEdit->setText(name);
1014  OutputCombo->setCurrentIndex(0);
1015  StoreOverwriteMode->setChecked(overwrite);
1016  StoreOverwriteMode->setEnabled(true);
1017  BufferSize->setEnabled(true);
1018  SplitLevel->setEnabled(true);
1019  BufferSize->setValue(bufsize/1000);
1020  SplitLevel->setValue(splitlevel);
1021  CompLevel->setValue(compression);
1022  TreeAutosave->setValue(autosave);
1023  CompLevel->setEnabled(true);
1024  FileNameOutput->setEnabled(true);
1026 }
1027 
1028 void TGo4ConfigStep::SetBackStore(QString name, int bufsize, int splitlevel)
1029 {
1030  StoreNameEdit->setEnabled(false);
1031  StoreNameEdit->setText(GetBackStoreName());
1032  OutputCombo->setCurrentIndex(1);
1033  BufferSize->setEnabled(true);
1034  SplitLevel->setEnabled(true);
1035  BufferSize->setValue(bufsize/1000);
1036  SplitLevel->setValue(splitlevel);
1037  StoreOverwriteMode->setEnabled(false);
1038  CompLevel->setEnabled(false);
1039  FileNameOutput->setEnabled(false);
1041 }
1042 
1044 {
1045  StoreNameEdit->setEnabled(true);
1046  StoreNameEdit->setText(name);
1047  OutputCombo->setCurrentIndex(2);
1048 
1049  BufferSize->setEnabled(false);
1050  SplitLevel->setEnabled(false);
1051  StoreOverwriteMode->setEnabled(false);
1052  CompLevel->setEnabled(false);
1053  FileNameOutput->setEnabled(true);
1054 
1056 }
1057 
1058 void TGo4ConfigStep::SetHDF5Store(QString name, int flags)
1059 {
1060 #ifdef __GO4HDF5__
1061  StoreNameEdit->setEnabled(false);
1062  StoreNameEdit->setText(name);
1063  OutputCombo->setCurrentIndex(3);
1064  StoreOverwriteMode->setEnabled(true);
1065  StoreOverwriteMode->setChecked(flags==GO4_H5F_ACC_TRUNC ? true : false);
1066 // JAM2019: here evaluate the file access flags
1067 // Valid values of flags include://
1068 // H5F_ACC_TRUNC - Truncate file, if it already exists, erasing all data previously stored in the file.
1069 // H5F_ACC_EXCL - Fail if file already exists. H5F_ACC_TRUNC and H5F_ACC_EXCL are mutually exclusive
1070 // H5F_ACC_RDONLY - Open file as read-only, if it already exists, and fail, otherwise
1071 // H5F_ACC_RDWR - Open file for read/write, if it already exists, and fail, otherwise
1072  FileNameOutput->setEnabled(true);
1074 #endif
1075 }
1076 
1077 
1079 {
1080  QString name = "BackStoreTree_";
1081  name += GetStepName();
1082  return name;
1083 }
1084 
1086 {
1087  int typ = OutputCombo->currentIndex();
1088  if (typ==1) name = GetBackStoreName();
1089  else name = StoreNameEdit->text();
1090  return typ;
1091 }
1092 
1093 void TGo4ConfigStep::GetFileStore(bool& overwrite, int& bufsize, int& splitlevel, int& compression, int& autosaveperiod)
1094 {
1095  overwrite = StoreOverwriteMode->isChecked();
1096  bufsize = BufferSize->value() * 1000;
1097  splitlevel = SplitLevel->value();
1098  compression = CompLevel->value();
1099  autosaveperiod = TreeAutosave->value();
1100 }
1101 
1102 void TGo4ConfigStep::GetBackStore(int& bufsize, int& splitlevel)
1103 {
1104  bufsize = BufferSize->value() * 1000;
1105  splitlevel = SplitLevel->value();
1106 }
1107 
1109 {
1110 #ifdef __GO4HDF5__
1111  flags = StoreOverwriteMode->isChecked() ? GO4_H5F_ACC_TRUNC : 0;
1112 #endif
1113 }
1114 
1116 {
1117  if (fxPanel)
1118  fxPanel->DisplayMbsMonitor(SourceNameEdit->text());
1119 }
1120 
1122 {
1123  fExtra = !fExtra;
1124  ExtraBtn->setText(fExtra ? "-" : "+");
1125 
1126  fBlocked++;
1127 
1128  SourceComboHighlighted(EventSourceCombo->currentIndex());
1129 
1130  fBlocked--;
1131 }
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)
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)
TGo4EventSourceParameter * GetSourcePar() const
const char * TGo4MbsFile__fgcLMDSUF
const char * GetTagName() const
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)
virtual void SetHDF5Source(QString name)
const char * GetExpression() const
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)
virtual void OutputFileDialog()
void SetHDF5Flags(Go4_H5_File_Flags flags)
Go4_H5_File_Flags GetHDF5Flags() const
virtual void GetUserSource(int &port, QString &expr)
virtual void InputSourceText(const QString &Name)
void SetExpression(const char *name)
virtual void ChangeStartEvent(int num)
TGo4EventStoreParameter * GetStorePar() const
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)
TGo4ConfigStep(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags fl=Qt::Widget)
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)