GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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
34
35#ifdef __GO4HDF5__
36//#include "H5Cpp.h"
39#endif
40
41#include "Go4EventServerTypes.h"
43
44const char *TGo4MbsFile__fgcNOTAGFILE = "GO4-NOLMDTAG";
45const char *TGo4MbsFile__fgcLMDSUF = ".lmd";
46const char *TGo4MbsFile__fgcFILELISTSUF = ".lml";
47
59
60
61TGo4ConfigStep::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#if QT_VERSION < QT_VERSION_CHECK(6, 8, 0)
69 QObject::connect(EnableStepBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::StepStateChanged);
70 QObject::connect(EnableSourceBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::InputStateChanged);
71 QObject::connect(EnableStoreBox, &QCheckBox::stateChanged, this, &TGo4ConfigStep::OutputStateChanged);
72#else
73 QObject::connect(EnableStepBox, &QCheckBox::checkStateChanged, this, &TGo4ConfigStep::StepStateChanged);
74 QObject::connect(EnableSourceBox, &QCheckBox::checkStateChanged, this, &TGo4ConfigStep::InputStateChanged);
75 QObject::connect(EnableStoreBox, &QCheckBox::checkStateChanged, this, &TGo4ConfigStep::OutputStateChanged);
76#endif
77 QObject::connect(SourceNameEdit, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputSourceText);
78 QObject::connect(EventSourceCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &TGo4ConfigStep::SourceComboHighlighted);
79 QObject::connect(OutputCombo, QOverload<int>::of(&QComboBox::activated), this, &TGo4ConfigStep::StoreComboHighlighted);
80 QObject::connect(StoreNameEdit, &QLineEdit::textChanged, this, &TGo4ConfigStep::OutputNameText);
81 QObject::connect(FileNameOutput, &QPushButton::clicked, this, &TGo4ConfigStep::OutputFileDialog);
82 QObject::connect(CompLevel, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreCompLevel);
83 QObject::connect(BufferSize, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreBufferSize);
84 QObject::connect(SplitLevel, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreSplitLevel);
85 QObject::connect(StoreOverwriteMode, &QCheckBox::toggled, this, &TGo4ConfigStep::StoreOverWrite);
86 QObject::connect(LineEditArgs, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputArguments);
87 QObject::connect(LineEditTagfile, &QLineEdit::textChanged, this, &TGo4ConfigStep::InputTagfile);
88 QObject::connect(SpinBoxStartEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeStartEvent);
89 QObject::connect(SpinBoxStopEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeStopEvent);
90 QObject::connect(FileNameBtn, &QPushButton::clicked, this, &TGo4ConfigStep::InputFileDialog);
91 QObject::connect(SpinBoxInterEvent, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeEventInterval);
92 QObject::connect(SpinBoxTimeout, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::ChangeSourceTimeout);
93 QObject::connect(ExtraBtn, &QPushButton::clicked, this, &TGo4ConfigStep::ExtraBtn_clicked);
94 QObject::connect(MbsMonitorBtn, &QPushButton::clicked, this, &TGo4ConfigStep::MbsMonitorBtn_clicked);
95 QObject::connect(SpinBoxPortNumber, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::InputPortChanged);
96 QObject::connect(SpinBoxRetryNumber, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::RetryCntChanged);
97 QObject::connect(TreeAutosave, QOverload<int>::of(&QSpinBox::valueChanged), this, &TGo4ConfigStep::StoreTreeAutoSave);
98
99 fStepNumber = 0;
100 fxPanel = nullptr;
101 fStepStatus = nullptr;
102
103 SpinBoxPortNumber->setVisible(false);
104 TextLabelPortNumber->setVisible(false);
105 SpinBoxRetryNumber->setVisible(false);
106 TextLabelRetryNumber->setVisible(false);
107 SpinBoxTimeout->setVisible(false);
108 TextLabelTimeout->setVisible(false);
109
110 SpinBoxStartEvent->setVisible(false);
111 SpinBoxStopEvent->setVisible(false);
112 SpinBoxInterEvent->setVisible(false);
113
114 LineEditArgs->setVisible(false);
115 TextLabelArgs->setVisible(false);
116 LineEditTagfile->setVisible(false);
117 TextLabelTagfile->setVisible(false);
118
119 for (int n = 0; n < ParsSize; n++)
120 fPars[n] = nullptr;
121
122 fLastSrcKind = -1;
123 fBlocked = 0;
124 fExtra = false;
125 ExtraBtn->setText(fExtra ? "-" : "+");
126
127#ifndef __GO4HDF5__
128 OutputCombo->removeItem(3);
129 EventSourceCombo->removeItem(8);
130#endif
131
132}
133
135{
136 for (int n = 0; n < ParsSize; n++) {
137 delete fPars[n];
138 fPars[n] = nullptr;
139 }
140}
141
142
143void TGo4ConfigStep::InputArguments(const QString& Arg)
144{
145 TGo4EventSourceParameter *SourcePar=fStepStatus->GetSourcePar();
146 int ParId=SourcePar->GetID();
147 if (ParId==GO4EV_USER){ // user defined source class
148 TGo4UserSourceParameter* usrpar = dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
149 if (usrpar)
150 usrpar->SetExpression(Arg.trimmed().toLatin1().constData());
151 }
152}
153
155{
156 bool stepon = EnableStepBox->isChecked();
157 bool on = EnableSourceBox->isChecked();
158
159 fStepStatus->SetSourceEnabled(on);
160 SourceBox->setEnabled(stepon && on);
161
162 fxPanel->ChangeTabTitle(this, fStepNumber);
163}
164
166{
167 if (fBlocked) return;
168
169 TGo4EventSourceParameter *SourcePar = fStepStatus->GetSourcePar();
170
171 switch (SourcePar->GetID()) {
172
174 case GO4EV_MBS_STREAM:
176 case GO4EV_MBS_REVSERV: {
177 TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
178 if (par)
179 par->SetPort(port);
180 break;
181 }
182
183 case GO4EV_USER: { // user defined source class
184 TGo4UserSourceParameter* usrpar=dynamic_cast<TGo4UserSourceParameter*>(SourcePar);
185 if (usrpar)
186 usrpar->SetPort(port);
187 break;
188 }
189
190 default: {
191 // do nothing
192 break;
193 }
194 }
195}
196
198{
199 if (fBlocked) return;
200
201 TGo4EventSourceParameter *SourcePar = fStepStatus->GetSourcePar();
202
203 switch (SourcePar->GetID()) {
204
206 case GO4EV_MBS_STREAM:
208 case GO4EV_MBS_REVSERV: {
209 TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(SourcePar);
210 if (par)
211 par->SetRetryCnt(cnt);
212 break;
213 }
214
215 default: {
216 // do nothing
217 break;
218 }
219 }
220}
221
222void TGo4ConfigStep::InputSourceText(const QString& name)
223{
224 if (fBlocked) return;
225
226 if (fStepStatus && fStepStatus->GetSourcePar())
227 fStepStatus->GetSourcePar()->SetName(name.trimmed().toLatin1().constData());
228
229 if (EventSourceCombo->currentIndex() == kind_MbsFile) {
230 bool islml = name.contains(TGo4MbsFile__fgcFILELISTSUF);
231 LineEditTagfile->setVisible(!islml);
232 TextLabelTagfile->setVisible(!islml);
233
234 SpinBoxStartEvent->setEnabled(!islml);
235 SpinBoxStopEvent->setEnabled(!islml);
236 SpinBoxInterEvent->setEnabled(!islml);
237 }
238}
239
241{
242 bool stepon = EnableStepBox->isChecked();
243 bool on = EnableStoreBox->isChecked();
244
245 fStepStatus->SetStoreEnabled(on);
246 StoreBox->setEnabled(stepon && on);
247 StoreBox->setVisible(on);
248
249 fxPanel->ChangeTabTitle(this, fStepNumber);
250
251 adjustSize();
252 parentWidget()->adjustSize();
253 parentWidget()->parentWidget()->adjustSize();
254
255 fxPanel->adjustSize();
256 fxPanel->parentWidget()->adjustSize();
257}
258
259void TGo4ConfigStep::OutputNameText(const QString& Name)
260{
261 fStepStatus->GetStorePar()->SetName(Name.trimmed().toLatin1().constData());
262}
263
265{
266 bool on = EnableStepBox->isChecked();
267
268 fStepStatus->SetProcessEnabled(on);
269 EnableSourceBox->setEnabled(on);
270 EnableStoreBox->setEnabled(on);
271
272 fxPanel->ChangeTabTitle(this, fStepNumber);
273
276}
277
279{
280 if (!StepStatus) return;
281
282 fxPanel = panel;
283 fStepStatus = StepStatus;
284 fStepNumber = number;
285 fLastSrcKind = -1; // indicate that status (and its parameter) is changed
286
287 //----------------------------------------------------//
288 //Source:
289
290 /*
291 Qt use following order to display the source parameter:
292
293 0) root file with one tree TGo4FileSourceParameter
294 1) mbs listmode file (input only) TGo4MbsFileParameter
295 2) mbs stream server (input only) TGo4MbsStreamParameter
296 3) mbs transport server (input only) TGo4MbsTransportParameter
297 4) mbs event server (input only) TGo4MbsEventServerParameter
298 5) rev serv TGo4RevServParameter
299 6) mbs random generator TGo4MbsRandomParameter
300 7) user source TGo4UserSourceParameter
301
302 */
303
304 int srckind = CurrentSourceKind();
305 fBlocked++;
306 EventSourceCombo->setCurrentIndex(srckind);
307 fBlocked--;
308
309
310 //----------------------------------------------------//
311 //Store
312
313 TGo4EventStoreParameter *StorePar = fStepStatus->GetStorePar();
314
315 if (StorePar)
316 switch(StorePar->GetID()) {
317 case GO4EV_FILE: {
318 TGo4FileStoreParameter* fstor = dynamic_cast<TGo4FileStoreParameter*>(StorePar);
319 SetFileStore(fstor->GetName(),
320 fstor->IsOverwriteMode(),
321 fstor->GetBufsize(),
322 fstor->GetSplitlevel(),
323 fstor->GetCompression(),
324 fstor->GetAutosaveSize());
325 break;
326 }
327 case GO4EV_BACK: {
328 TGo4BackStoreParameter* bstor = dynamic_cast<TGo4BackStoreParameter*>(StorePar);
329 SetBackStore(bstor->GetName(),
330 bstor->GetBufsize(),
331 bstor->GetSplitlevel());
332 break;
333 }
334 case GO4EV_USER: {
335 TGo4UserStoreParameter *ustor = dynamic_cast<TGo4UserStoreParameter*>(StorePar);
336 SetUserStore(ustor->GetName());
337 break;
338 }
339
340#ifdef __GO4HDF5__
341 case GO4EV_HDF5: {
342 TGo4HDF5StoreParameter* hstor = dynamic_cast<TGo4HDF5StoreParameter*>(StorePar);
343 SetHDF5Store(hstor->GetName(), hstor->GetHDF5Flags());
344 break;
345 }
346#endif
347
348
349 default:
350 break;
351 } // switch StorePar->GetID()
352
353 //----------------------------------------------------//
354 // enable or disable processing:
355
356 SetStepControl(fStepStatus->IsProcessEnabled(),
357 fStepStatus->IsSourceEnabled(),
358 fStepStatus->IsStoreEnabled());
359}
360
361
363{
364 if (!fStepStatus || !fStepStatus->GetSourcePar()) return kind_MbsFile;
365
366 switch(fStepStatus->GetSourcePar()->GetID()) {
367 case GO4EV_FILE: return kind_RootFile;
368 case GO4EV_MBS_FILE: return kind_MbsFile;
369 case GO4EV_MBS_STREAM: return kind_MbsStream;
373 case GO4EV_MBS_RANDOM: return kind_MbsRandom;
374 case GO4EV_USER: return kind_UserSource;
375 case GO4EV_HDF5: return kind_HDF5;
376 } // SourcePar->GetID()
377
378 return kind_MbsFile;
379}
380
382{
383 if (!fStepStatus) return;
384
385 TGo4EventSourceParameter *srcpar = fStepStatus->TakeSourcePar();
386 bool delsrcpar = true;
387 TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*> (srcpar);
388
389 if (fLastSrcKind >= 0) {
390 if (fPars[fLastSrcKind]) delete fPars[fLastSrcKind];
391 fPars[fLastSrcKind] = srcpar;
392 delsrcpar = false;
393 }
394
395 if (fPars[kind]) {
396 fStepStatus->SetSourcePar(fPars[kind]);
397 fLastSrcKind = kind;
398 if (delsrcpar) delete srcpar;
399 return;
400 }
401
402 TString filename, hostname;
403 Int_t port = 0;
404
405 switch(srcpar->GetID()) {
406 case GO4EV_FILE:
407 case GO4EV_MBS_FILE:
408 case GO4EV_HDF5:
409 filename = srcpar->GetName();
410 break;
411
412 case GO4EV_MBS_STREAM:
416 hostname = srcpar->GetName();
417 port = mbspar ? mbspar->GetPort() : 0;
418 break;
419
420 case GO4EV_MBS_RANDOM:
421 break;
422 case GO4EV_USER:
423 break;
424 default:
425 break;
426 }
427
428 TGo4EventSourceParameter *newpar = nullptr;
429
430 switch (kind) {
431 case kind_RootFile:
432 newpar = new TGo4FileSourceParameter(filename);
433 break;
434
435 case kind_MbsFile:
436 newpar = new TGo4MbsFileParameter(filename);
437 break;
438
439 case kind_MbsStream:
440 newpar = new TGo4MbsStreamParameter(hostname);
441 break;
442
444 newpar = new TGo4MbsTransportParameter(hostname);
445 break;
446
447 case kind_MbsEvent:
448 newpar = new TGo4MbsEventServerParameter(hostname);
449 break;
450
451 case kind_MbsREvent:
452 newpar = new TGo4RevServParameter(hostname);
453 break;
454
455 case kind_MbsRandom:
456 newpar = new TGo4MbsRandomParameter("random");
457 break;
458
459 case kind_UserSource:
460 newpar = new TGo4UserSourceParameter(filename,"",port);
461 break;
462#ifdef __GO4HDF5__
463 case kind_HDF5:
464 newpar = new TGo4HDF5SourceParameter(filename);
465 break;
466#endif
467 }
468
469 TGo4MbsSourceParameter* newmbspar = dynamic_cast<TGo4MbsSourceParameter*> (newpar);
470
471 if (newmbspar) {
472 newmbspar->SetPort(port);
473
474 if (mbspar) {
475 newmbspar->SetStartEvent(mbspar->GetStartEvent());
476 newmbspar->SetStopEvent(mbspar->GetStopEvent());
477 newmbspar->SetEventInterval(mbspar->GetEventInterval());
478 }
479 }
480
481 newpar->SetTimeout(srcpar->GetTimeout());
482
483 fPars[kind] = newpar;
484
485 // here parameter will be cloned
486 fStepStatus->SetSourcePar(fPars[kind]);
487
488 fLastSrcKind = kind;
489
490 if (delsrcpar) delete srcpar;
491}
492
493void TGo4ConfigStep::SetSourceWidgets( const QString & name, int timeout)
494{
495 SourceNameEdit->setText(name);
496 SpinBoxTimeout->setValue(timeout);
497}
498
499void TGo4ConfigStep::SetMbsSourceWidgets(int start, int stop, int interval, int port)
500{
501 SpinBoxStartEvent->setValue(start);
502 SpinBoxStopEvent->setValue(stop);
503 SpinBoxInterEvent->setValue(interval);
504 SpinBoxPortNumber->setValue(port);
505 SpinBoxRetryNumber->setValue(0);
506}
507
509{
510 // FIXME: do it only interactively
511 if (fBlocked == 0) ChangeSourceParameter(kind);
512
513 fBlocked++;
514
515 // first disable everything which can be disabled
516
517 SpinBoxPortNumber->setVisible(false);
518 TextLabelPortNumber->setVisible(false);
519 SpinBoxRetryNumber->setVisible(false);
520 TextLabelRetryNumber->setVisible(false);
521 LineEditArgs->setVisible(false);
522 TextLabelArgs->setVisible(false);
523 LineEditTagfile->setVisible(false);
524 TextLabelTagfile->setVisible(false);
525
526 SpinBoxStartEvent->setVisible(false);
527 SpinBoxStopEvent->setVisible(false);
528 SpinBoxInterEvent->setVisible(false);
529 SpinBoxTimeout->setVisible(false);
530 TextLabelTimeout->setVisible(false);
531 FileNameBtn->setEnabled(false);
532 MbsMonitorBtn->setEnabled(false);
533
534 // evaluate previous source if existing
535
536 TGo4EventSourceParameter *srcpar = fStepStatus->GetSourcePar();
537
538 SourceNameEdit->setText(srcpar->GetName());
539 SpinBoxTimeout->setValue(srcpar->GetTimeout());
540
541 TGo4MbsSourceParameter* mbspar = dynamic_cast<TGo4MbsSourceParameter*> (srcpar);
542
543 if (mbspar) {
544 SpinBoxStartEvent->setValue(mbspar->GetStartEvent());
545 SpinBoxStopEvent->setValue(mbspar->GetStopEvent());
546 SpinBoxInterEvent->setValue(mbspar->GetEventInterval());
547 SpinBoxPortNumber->setValue(mbspar->GetPort());
548 SpinBoxRetryNumber->setValue(mbspar->GetRetryCnt());
549
550// if ((mbspar->GetPort() != 0) || (mbspar->GetRetryCnt() > 0) ||
551// (mbspar->GetStartEvent() != 0) || (mbspar->GetStopEvent() != 0) || (mbspar->GetEventInterval()>1)) fExtra = true;
552 }
553
554 TGo4MbsFileParameter* mbsfilpar = dynamic_cast<TGo4MbsFileParameter*>(srcpar);
555 TGo4UserSourceParameter* userpar = dynamic_cast<TGo4UserSourceParameter*>(srcpar);
556
557 switch (kind) {
558 case kind_RootFile: // root file with one tree
559 FileNameBtn->setEnabled(true);
560 break;
561 case kind_MbsFile: { // mbs listmode file (input only)
562 // in this special case spin boxes will be enabled/disabled when file name is changed
563 FileNameBtn->setEnabled(true);
564
565 QString tagfile = mbsfilpar->GetTagName();
566
567 if(!tagfile.contains(TGo4MbsFile__fgcNOTAGFILE)) {
568 LineEditTagfile->setText(tagfile);
569// fExtra = true;
570 } else {
571 LineEditTagfile->setText("");
572 }
573
574 LineEditTagfile->setVisible(fExtra);
575 TextLabelTagfile->setVisible(fExtra);
576
577 SpinBoxStartEvent->setVisible(fExtra);
578 SpinBoxStopEvent->setVisible(fExtra);
579 SpinBoxInterEvent->setVisible(fExtra);
580 break;
581 }
582 case kind_MbsStream: // mbs stream server (input only)
583 case kind_MbsTransport: // mbs transport server (input only)
584 case kind_MbsEvent: // mbs event server (input only)
585 case kind_MbsREvent: // rev serv
586 TextLabelTimeout->setVisible(fExtra);
587 SpinBoxTimeout->setVisible(fExtra);
588 TextLabelPortNumber->setVisible(fExtra);
589 SpinBoxPortNumber->setVisible(fExtra);
590 TextLabelRetryNumber->setVisible(fExtra);
591 SpinBoxRetryNumber->setVisible(fExtra);
592 MbsMonitorBtn->setEnabled(kind != kind_MbsREvent);
593 SpinBoxStartEvent->setVisible(fExtra);
594 SpinBoxStopEvent->setVisible(fExtra);
595 SpinBoxInterEvent->setVisible(fExtra);
596 break;
597
598 case kind_MbsRandom: // mbs random
599 break;
600
601 case kind_UserSource: // user source
602 FileNameBtn->setEnabled(true);
603 SpinBoxPortNumber->setValue(userpar->GetPort());
604 LineEditArgs->setText(userpar->GetExpression());
605 SpinBoxPortNumber->setVisible(fExtra);
606 TextLabelPortNumber->setVisible(fExtra);
607 LineEditArgs->setVisible(fExtra);
608 TextLabelArgs->setVisible(fExtra);
609 TextLabelTimeout->setVisible(fExtra);
610 SpinBoxTimeout->setVisible(fExtra);
611 break;
612
613 case kind_HDF5: // hdf5 file
614 FileNameBtn->setEnabled(true);
615 break;
616 }
617
618 fBlocked--;
619
620 adjustSize();
621 parentWidget()->adjustSize();
622 parentWidget()->parentWidget()->adjustSize();
623
624 fxPanel->adjustSize();
625 fxPanel->parentWidget()->adjustSize();
626}
627
629{
630 if(k == 0) {
631 StoreNameEdit->setDisabled(false);
632 TGo4FileStoreParameter newpar0(StoreNameEdit->text().toLatin1().constData());
633 fStepStatus->SetStorePar(&newpar0);
634 SplitLevel->setDisabled(false);
635 BufferSize->setDisabled(false);
636 CompLevel->setDisabled(false);
637 StoreOverwriteMode->setDisabled(false);
638 FileNameOutput->setDisabled(false);
639 TreeAutosave->setDisabled(false);
640 } else if(k == 1) {
641 StoreNameEdit->setDisabled(true);
642 TGo4BackStoreParameter newpar1(GetBackStoreName().toLatin1().constData());
643 fStepStatus->SetStorePar(&newpar1);
644 SplitLevel->setDisabled(false);
645 BufferSize->setDisabled(false);
646 CompLevel->setDisabled(true);
647 StoreOverwriteMode->setDisabled(true);
648 FileNameOutput->setDisabled(true);
649 TreeAutosave->setDisabled(true);
650 } else if(k == 2) {
651 StoreNameEdit->setDisabled(false);
652 TGo4UserStoreParameter newpar2(StoreNameEdit->text().toLatin1().constData());
653 fStepStatus->SetStorePar(&newpar2);
654 SplitLevel->setDisabled(true);
655 BufferSize->setDisabled(true);
656 CompLevel->setDisabled(true);
657 StoreOverwriteMode->setDisabled(true);
658 FileNameOutput->setDisabled(false);
659 TreeAutosave->setDisabled(true);
660 } else if(k == 3) {
661#ifdef __GO4HDF5__
662 StoreNameEdit->setDisabled(false);
663 TGo4HDF5StoreParameter newpar3(StoreNameEdit->text().toLatin1().constData(), GO4_H5F_ACC_TRUNC);
664 fStepStatus->SetStorePar(&newpar3);
665 StoreOverwriteMode->setDisabled(false);
666 FileNameOutput->setDisabled(false);
667 CompLevel->setDisabled(true);
668 TreeAutosave->setDisabled(true);
669 SplitLevel->setDisabled(true);
670 BufferSize->setDisabled(true);
671#endif
672 }
673}
674
676{
677 QString filters;
678 if(fStepStatus) {
679 TGo4EventStoreParameter *storepar = fStepStatus->GetStorePar();
680 if(storepar->InheritsFrom(TGo4FileStoreParameter::Class()))
681 filters = "Go4FileSource (*.root)";
682 else if (storepar->InheritsFrom(TGo4UserStoreParameter::Class()))
683 filters = "Go4UserStore (*.root)";
684#ifdef __GO4HDF5__
685 else if (storepar->InheritsFrom(TGo4HDF5StoreParameter::Class())) {
686 filters="Go4HDF5 (*.h5)";
687 }
688#endif
689 else
690 std::cout <<"Unknown storepar " <<storepar->ClassName() << std::endl;
691 }
692
693 QFileDialog fd( this, "Select file name for step output",
694 fxPanel->GetStorePath(), filters);
695 fd.setFileMode( QFileDialog::AnyFile);
696 if (fd.exec() != QDialog::Accepted) return;
697
698 QStringList flst = fd.selectedFiles();
699 if (flst.isEmpty()) return;
700
701 QString fileName = flst[0];
702 std::cout << "output file is "<<fileName.toLatin1().constData() << std::endl;
703 fxPanel->SetStorePath(fd.directory().path());
704 if(!fileName.endsWith(".h5")) fileName.append(".h5");
705 std::cout << "output file is now "<<fileName.toLatin1().constData() << std::endl;
706 StoreNameEdit->setText(fileName);
707}
708
710{
711 if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
712 TGo4FileStoreParameter *StorePar = (TGo4FileStoreParameter *)fStepStatus->GetStorePar();
713 StorePar->SetBufsize(1000*t);
714 } else
715 if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())){
716 TGo4BackStoreParameter * StorePar = (TGo4BackStoreParameter *)fStepStatus->GetStorePar();
717 StorePar->SetBufsize(1000*t);
718 }
719}
720
722{
723 if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
724 TGo4FileStoreParameter *StorePar = (TGo4FileStoreParameter *)fStepStatus->GetStorePar();
725 StorePar->SetSplitlevel(t);
726 } else
727 if (fStepStatus->GetStorePar()->InheritsFrom(TGo4BackStoreParameter::Class())) {
728 TGo4BackStoreParameter * StorePar = (TGo4BackStoreParameter *)fStepStatus->GetStorePar();
729 StorePar->SetSplitlevel(t);
730 }
731}
732
734{
735 if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
737 StorePar->SetCompression(t);
738 }
739}
740
742{
743 if(fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())){
744 TGo4FileStoreParameter *StorePar=dynamic_cast <TGo4FileStoreParameter *> (fStepStatus->GetStorePar());
745 if(overwrite)StorePar->SetOverwriteMode(kTRUE);
746 else StorePar->SetOverwriteMode(kFALSE);
747 }
748#ifdef __GO4HDF5__
749 else if(fStepStatus->GetStorePar()->InheritsFrom(TGo4HDF5StoreParameter::Class())){
750 TGo4HDF5StoreParameter *StorePar=dynamic_cast <TGo4HDF5StoreParameter *> (fStepStatus->GetStorePar());
751 StorePar->SetHDF5Flags(overwrite ? GO4_H5F_ACC_TRUNC : GO4_H5F_ACC_RDWR);
752 }
753#endif
754}
755
756
758{
759 if (fStepStatus->GetStorePar()->InheritsFrom(TGo4FileStoreParameter::Class())) {
760 TGo4FileStoreParameter *StorePar = (TGo4FileStoreParameter *)fStepStatus->GetStorePar();
761 StorePar->SetAutosaveSize(t);
762 }
763}
764
765
766void TGo4ConfigStep::InputTagfile( const QString & tag )
767{
768 if (fBlocked) return;
769 TGo4EventSourceParameter *SourcePar=fStepStatus->GetSourcePar();
770 int ParId=SourcePar->GetID();
771 if (ParId!=GO4EV_MBS_FILE) return;
772 // tagfile only for mbs lmd file
773 TGo4MbsFileParameter* filpar = dynamic_cast<TGo4MbsFileParameter*>(SourcePar);
774
775 if (!filpar) return;
776
777 if(tag.isEmpty())
779 else
780 filpar->SetTagName(tag.trimmed().toLatin1().constData());
781}
782
784{
785 if (fBlocked) return;
786
787 // only for mbs sources
789 dynamic_cast<TGo4MbsSourceParameter*>(fStepStatus->GetSourcePar());
790 if (par) par->SetStartEvent(num);
791}
792
794{
795 if (fBlocked) return;
796
797 // only for mbs sources
799 dynamic_cast<TGo4MbsSourceParameter*>(fStepStatus->GetSourcePar());
800 if (par) par->SetStopEvent(num);
801}
802
804{
805 if (fBlocked) return;
806
807 // only for mbs sources
809 dynamic_cast<TGo4MbsSourceParameter*>(fStepStatus->GetSourcePar());
810 if (par) par->SetEventInterval(num);
811}
812
814{
815 if (fBlocked) return;
816
817 TGo4EventSourceParameter *sourcepar = fStepStatus->GetSourcePar();
818 if (sourcepar)
819 sourcepar->SetTimeout(tim);
820}
821
823{
824 QString filters;
825 bool mbsfilemode = false;
826 if(fStepStatus) {
827 TGo4EventSourceParameter *sourcepar = fStepStatus->GetSourcePar();
828 if(sourcepar->InheritsFrom(TGo4FileSourceParameter::Class()))
829 filters = "Go4FileSource (*.root)";
830 else
831 if (sourcepar->InheritsFrom(TGo4MbsFileParameter::Class())) {
832 mbsfilemode=true;
833 filters="Go4MbsFile (*";
834 filters+=TGo4MbsFile__fgcLMDSUF;
835 filters+=" *";
836 filters+=QString(TGo4MbsFile__fgcLMDSUF).toUpper();
837 filters+=");;Go4 list mode list (*";
839 filters+=")";
840
841 }
842 else
843 if (sourcepar->InheritsFrom(TGo4UserSourceParameter::Class())) {
844 filters = "all files (*.*)";
845 }
846#ifdef __GO4HDF5__
847 else if (sourcepar->InheritsFrom(TGo4HDF5SourceParameter::Class())) {
848 filters="Go4HDF5 (*.h5)";
849 }
850#endif
851 else
852 std::cout <<"Unknown sourcepar " <<sourcepar->ClassName() << std::endl;
853 }
854
855 QFileDialog fd(this, "Select file name for step input", fxPanel->GetSourcePath(), filters);
856 fd.setFileMode(QFileDialog::ExistingFile);
857
858 if (fd.exec() != QDialog::Accepted) return;
859
860 QStringList flst = fd.selectedFiles();
861 if (flst.isEmpty()) return;
862
863 QString fileName = flst[0];
864 fxPanel->SetSourcePath(fd.directory().path());
865 SourceNameEdit->setText(fileName);
866 if(mbsfilemode) {
867 bool islml = fd.selectedNameFilter().contains(TGo4MbsFile__fgcFILELISTSUF);
868
869 LineEditTagfile->setVisible(!islml);
870 TextLabelTagfile->setVisible(!islml);
871 SpinBoxStartEvent->setEnabled(!islml);
872 SpinBoxStopEvent->setEnabled(!islml);
873 SpinBoxInterEvent->setEnabled(!islml);
874 }
875}
876
878{
879 return fStepStatus->GetName();
880}
881
883{
884 QString res = fStepStatus->GetName();
885 if (fStepNumber >= 0) {
886 res += " ";
887 res += EnableStepBox->isChecked() ? "x" : "o";
888 res += EnableSourceBox->isChecked() ? "x" : "o";
889 res += EnableStoreBox->isChecked() ? "x" : "o";
890 }
891 return res;
892}
893
894void TGo4ConfigStep::SetStepControl(bool process, bool source, bool store)
895{
896 EnableStepBox->setChecked(process);
897 EnableSourceBox->setChecked(source);
898 EnableStoreBox->setChecked(store);
899
901}
902
903void TGo4ConfigStep::GetStepControl(bool& process, bool& source, bool& store)
904{
905 process = EnableStepBox->isChecked();
906 source = EnableSourceBox->isChecked();
907 store = EnableStoreBox->isChecked();
908}
909
911{
912 EventSourceCombo->setCurrentIndex(kind_RootFile);
913}
914
915void TGo4ConfigStep::SetMbsFileSource(const QString& TagFile)
916{
917 EventSourceCombo->setCurrentIndex(kind_MbsFile);
918
919 if(!TagFile.contains(TGo4MbsFile__fgcNOTAGFILE))
920 LineEditTagfile->setText(TagFile);
921 else
922 LineEditTagfile->setText("");
923}
924
926{
927 EventSourceCombo->setCurrentIndex(kind_MbsStream);
928}
929
931{
932 EventSourceCombo->setCurrentIndex(kind_MbsTransport);
933}
934
936{
937 EventSourceCombo->setCurrentIndex(kind_MbsEvent);
938}
939
941{
942 EventSourceCombo->setCurrentIndex(kind_MbsREvent);
943
944 SpinBoxPortNumber->setValue(port>0 ? port : 0);
945}
946
948{
949 SpinBoxPortNumber->setValue(port > 0 ? port : 0);
950}
951
953{
954 SpinBoxRetryNumber->setValue(retry > 0 ? retry : 0);
955}
956
958{
959 EventSourceCombo->setCurrentIndex(kind_MbsRandom);
960}
961
962void 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
979int 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()) {
990 case GO4EV_MBS_STREAM:
992 case GO4EV_MBS_REVSERV: {
993 TGo4MbsSourceParameter* par = dynamic_cast<TGo4MbsSourceParameter*>(fStepStatus->GetSourcePar());
994 if (par) {
995 nport = SpinBoxPortNumber->value();
996 nretry = SpinBoxRetryNumber->value();
997 }
998 break;
999 }
1000 }
1001 return EventSourceCombo->currentIndex();
1002}
1003
1005{
1006 TagFile = LineEditTagfile->text();
1007// if (TagFile.isEmpty()) TagFile = TGo4MbsFile__fgcNOTAGFILE;
1008}
1009
1010void TGo4ConfigStep::GetUserSource(int& port, QString& expr)
1011{
1012 port = SpinBoxPortNumber->value();
1013 expr = LineEditArgs->text();
1014}
1015
1016void 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
1034void 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
1064void 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
1099void 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
1108void TGo4ConfigStep::GetBackStore(int& bufsize, int& splitlevel)
1109{
1110 bufsize = BufferSize->value() * 1000;
1111 splitlevel = SplitLevel->value();
1112}
1113
1115{
1116#ifdef __GO4HDF5__
1117 flags = StoreOverwriteMode->isChecked() ? GO4_H5F_ACC_TRUNC : 0;
1118#endif
1119}
1120
1122{
1123 if (fxPanel)
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}
@ GO4EV_FILE
@ GO4EV_MBS_TRANSPORT
@ GO4EV_BACK
@ GO4EV_MBS_REVSERV
@ GO4EV_MBS_RANDOM
@ GO4EV_MBS_EVENTSERVER
@ GO4EV_MBS_STREAM
@ GO4EV_HDF5
@ GO4EV_USER
@ GO4EV_MBS_FILE
@ GO4_H5F_ACC_TRUNC
Definition Go4HDF5.h:43
@ GO4_H5F_ACC_RDWR
Definition Go4HDF5.h:46
const char * TGo4MbsFile__fgcLMDSUF
const char * TGo4MbsFile__fgcFILELISTSUF
SourceComboKinds
@ kind_MbsFile
@ kind_MbsEvent
@ kind_MbsTransport
@ kind_HDF5
@ kind_MbsStream
@ kind_MbsREvent
@ kind_RootFile
@ kind_UserSource
@ kind_MbsRandom
const char * TGo4MbsFile__fgcNOTAGFILE
Status object of one analysis step.
void SetBufsize(Int_t bufsize)
virtual void OutputFileDialog()
virtual void OutputStateChanged(int)
virtual void SetMbsTransportSource()
virtual void ChangeStopEvent(int num)
virtual void GetBackStore(int &bufsize, int &splitlevel)
virtual void SetMbsFileSource(const QString &TagFile)
virtual void ExtraBtn_clicked()
virtual void StoreComboHighlighted(int k)
virtual void InputArguments(const QString &Arg)
virtual void SetFileSource()
virtual void InputPortChanged(int)
virtual void ChangeEventInterval(int num)
virtual void SetMbsSourceWidgets(int start, int stop, int interval, int port=0)
virtual void GetUserSource(int &port, QString &expr)
TGo4AnalysisStepStatus * fStepStatus
virtual void GetHDF5Store(int &flags)
virtual void SetMbsRetryCnt(int retry)
virtual void StepStateChanged(int)
virtual void GetStepControl(bool &process, bool &source, bool &store)
virtual void SetHDF5Source(QString name)
virtual void SetMbsPort(int port)
virtual void SetMbsRevServSource(int port)
virtual void StoreBufferSize(int t)
virtual void OutputNameText(const QString &Name)
virtual void SetUserStore(QString name)
virtual void StoreOverWrite(bool overwrite)
virtual QString GetBackStoreName()
virtual void SetSourceWidgets(const QString &name, int timeout)
void ChangeSourceParameter(int kind)
TGo4AnalysisConfiguration * fxPanel
virtual void InputTagfile(const QString &tag)
virtual void SetHDF5Store(QString name, int flags)
virtual ~TGo4ConfigStep()
virtual void RetryCntChanged(int)
virtual void InputFileDialog()
virtual void SetBackStore(QString name, int bufsize, int splitlevel)
TGo4EventSourceParameter * fPars[ParsSize]
virtual void StoreTreeAutoSave(int t)
virtual void StoreSplitLevel(int t)
virtual void SetUserSource(int port, QString expr)
virtual void SetRandomSource()
virtual void ChangeSourceTimeout(int tim)
virtual void SourceComboHighlighted(int kind)
virtual void GetMbsFileSource(QString &TagFile)
virtual void SetStepStatus(TGo4AnalysisConfiguration *panel, TGo4AnalysisStepStatus *StepStatus, int number=-1)
virtual void StoreCompLevel(int t)
virtual void GetFileStore(bool &overwrite, int &bufsize, int &splitlevel, int &compression, int &autosaveinterval)
virtual int GetSourceSetup(QString &name, int &timeout, int &start, int &stop, int &interval, int &port, int &nretry)
virtual void ChangeStartEvent(int num)
virtual void InputSourceText(const QString &Name)
virtual int GetStoreSetup(QString &name)
virtual void SetStepControl(bool process, bool source, bool store)
virtual void InputStateChanged(int)
virtual void SetMbsEventServerSource()
virtual QString GetStepName()
virtual void SetFileStore(QString name, bool overwrite, int bufsize, int splitlevel, int compression, int autosave=0)
TGo4ConfigStep(QWidget *parent=nullptr, const char *name=nullptr, Qt::WindowFlags fl=Qt::Widget)
virtual void SetMbsStreamSource()
virtual void MbsMonitorBtn_clicked()
virtual QString GetTabTitle()
Basic type for all classes containing information to parameterize the event source.
Basic type for all classes containing information to parametrize the event store.
void SetOverwriteMode(Bool_t over=kTRUE)
void SetBufsize(Int_t bufsize)
void SetAutosaveSize(Int_t interval)
void SetHDF5Flags(Go4_H5_File_Flags flags)
Go4_H5_File_Flags GetHDF5Flags() const
MBS file parameter.
const char * GetTagName() const
Name of the Tagfile.
void SetTagName(const char *name)
Name of the Tagfile.
void SetStartEvent(UInt_t firstindex)
Define the Start index for the NextEvent.
void SetPort(Int_t port)
Set optional port number, 0 or negative value means that default port number will be used.
Int_t GetPort() const
Return optional port number, 0 or negative value means that default port number will be used.
UInt_t GetEventInterval() const
Returns event interval.
UInt_t GetStopEvent() const
Returns the index of Stop event.
Int_t GetRetryCnt() const
Return allowed number of reconnection retries.
void SetStopEvent(UInt_t lastindex)
Define the index of Stop event.
void SetRetryCnt(Int_t cnt)
Set number of allowed reconnection retries.
UInt_t GetStartEvent() const
Returns the Start index for the NextEvent.
void SetEventInterval(UInt_t skipinterval)
Defines event interval.
Rev serv parameter.
const char * GetExpression() const
User expression as string.
void SetExpression(const char *name)