forked from avartak/TkCommissioner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmaddskip.cpp
87 lines (76 loc) · 2.9 KB
/
frmaddskip.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "frmaddskip.h"
#include "Debug.h"
#include "cmssw/SiStripFedKey.h"
#include "cmssw/SiStripFecKey.h"
#include <QMessageBox>
AddSkipChannel::AddSkipChannel(bool fed, bool crate, bool fec, bool ring, bool ccu, bool ccuchan, bool lldchan, QWidget *parent):
QDialog(parent),
enableFed(fed),
enableCrate(crate),
enableFec(fec),
enableRing(ring),
enableCcu(ccu),
enableCcuChan(ccuchan),
enableLLDChan(lldchan)
{
setupUi(this);
lineFed ->setEnabled(enableFed );
lineCrate ->setEnabled(enableCrate );
lineFec ->setEnabled(enableFec );
lineRing ->setEnabled(enableRing );
lineCcu ->setEnabled(enableCcu );
lineCcuChan->setEnabled(enableCcuChan);
lineLLDChan->setEnabled(enableLLDChan);
if (!enableFed ) lineFed ->setText("0");
if (!enableCrate ) lineCrate ->setText("0");
if (!enableFec ) lineFec ->setText("0");
if (!enableRing ) lineRing ->setText("0");
if (!enableCcu ) lineCcu ->setText("0");
if (!enableCcuChan) lineCcuChan->setText("0");
if (!enableLLDChan) lineLLDChan->setText("0");
}
AddSkipChannel::~AddSkipChannel() {
}
void AddSkipChannel::accept() {
bool ok = true;
unsigned vfed = lineFed ->text().toUInt(&ok);
unsigned vcrate = lineCrate ->text().toUInt(&ok);
unsigned vfec = lineFec ->text().toUInt(&ok);
unsigned vring = lineRing ->text().toUInt(&ok);
unsigned vccu = lineCcu ->text().toUInt(&ok);
unsigned vccuchan = lineCcuChan->text().toUInt(&ok);
unsigned vlldchan = lineLLDChan->text().toUInt(&ok);
if (!ok) {
QMessageBox::critical(0, tr("Add Channel"), tr("Invalid entries. Please correct") );
return;
}
if (enableFed) {
if (vfed == 0) {
QMessageBox::critical(0, tr("Add Channel"), tr("Enter non-zero FED ID") );
return;
}
SiStripFedKey fedkey(vfed, 0, 0, 0);
emit key(QPair<unsigned, unsigned>(fedkey.key(),0));
}
else if (enableFed && enableCrate) {
if (vfed == 0 || vcrate == 0 || vfec == 0) {
QMessageBox::critical(0, tr("Add Channel"), tr("FED, FEC crate, FEC slot values need to be non-zero") );
return;
}
SiStripFedKey fedkey(vfed, 0, 0, 0);
SiStripFecKey feckey(vcrate, vfec, vring, vccu, vccuchan, vlldchan, 0);
emit key(QPair<unsigned, unsigned>(fedkey.key(),feckey.key()));
}
else {
if (vcrate == 0 || vfec == 0) {
QMessageBox::critical(0, tr("Add Channel"), tr("Crate and FEC slot values need to be non-zero") );
return;
}
SiStripFecKey feckey(vcrate, vfec, vring, vccu, vccuchan, vlldchan, 0);
emit key(QPair<unsigned, unsigned>(0,feckey.key()));
}
done(QDialog::Accepted);
}
void AddSkipChannel::reject() {
done(QDialog::Rejected);
}