8 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"L1RPCHwConfigSourceHandler")),
9 m_dummy(ps.getUntrackedParameter<
int>(
"WriteDummy", 0)),
10 m_validate(ps.getUntrackedParameter<
int>(
"Validate", 0)),
11 m_disableCrates(ps.getUntrackedParameter<
std::vector<
int> >(
"DisabledCrates")),
12 m_disableTowers(ps.getUntrackedParameter<
std::vector<
int> >(
"DisabledTowers")),
13 m_connect(ps.getUntrackedParameter<
std::
string>(
"OnlineConn",
"")),
14 m_authpath(ps.getUntrackedParameter<
std::
string>(
"OnlineAuthPath",
".")) {}
19 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects begins\n";
34 if (m_validate == 1) {
35 std::cout <<
" Validation was requested, so will check present contents" << std::endl;
36 std::cout <<
"Name of tag : " <<
tagInfo().name <<
", tag size : " <<
tagInfo().size <<
", last object valid since "
37 <<
tagInfo().lastInterval.since << std::endl;
40 std::cout <<
"L1RPCHwConfigSourceHandler: no validation requested" << std::endl;
46 std::vector<int>::iterator crIt = m_disableCrates.begin();
47 for (; crIt != m_disableCrates.end(); ++crIt) {
48 disabledDevs->enableCrate(*crIt,
false);
50 std::vector<int>::iterator twIt = m_disableTowers.begin();
51 for (; twIt != m_disableTowers.end(); ++twIt) {
52 disabledDevs->enableTower(*twIt,
false);
55 ConnectOnlineDB(m_connect, m_authpath);
65 difference = Compare2Configs(
payload, disabledDevs);
67 std::cout <<
"No changes - will not write anything!!!" << std::endl;
68 if (difference == 1) {
69 std::cout <<
"Will write new object to offline DB!!!" << std::endl;
70 m_to_transfer.push_back(std::make_pair((
L1RPCHwConfig*)disabledDevs, snc + 1));
73 std::cout <<
"L1RPCHwConfigSourceHandler: L1RPCHwConfigSourceHandler::getNewObjects ends\n";
77 std::cout <<
"L1RPCHwConfigSourceHandler: connecting to " <<
connect <<
"..." << std::flush;
89 session.transaction().start(
true);
90 coral::ISchema& schema = session.nominalSchema();
92 coral::AttributeList conditionData;
94 <<
"L1RPCHwConfigSourceHandler: start to build L1RPC Hw Config..." << std::flush << std::endl
98 coral::IQuery* query1 = schema.newQuery();
99 query1->addToTableList(
"CRATEDISABLED");
100 query1->addToTableList(
"CRATE");
101 query1->addToTableList(
"BOARD");
102 query1->addToTableList(
"TRIGGERBOARD");
103 query1->addToOutputList(
"TRIGGERBOARD.TOWERTO",
"TOWERTO");
104 query1->addToOutputList(
"TRIGGERBOARD.TOWERFROM",
"TOWERFROM");
105 query1->addToOutputList(
"TRIGGERBOARD.SECTOR",
"SECTOR");
106 query1->addToOrderList(
"TOWERTO");
107 query1->addToOrderList(
"SECTOR");
109 "CRATE.CRATEID=CRATEDISABLED.CRATE_CRATEID AND BOARD.CRATE_CRATEID=CRATE.CRATEID AND "
110 "BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CRATE.TYPE='TRIGGERCRATE'";
111 query1->setCondition(
condition, conditionData);
112 coral::ICursor& cursor1 = query1->execute();
113 while (cursor1.next()) {
115 const coral::AttributeList& row = cursor1.currentRow();
116 int sector = atoi((row[
"SECTOR"].data<std::string>()).c_str());
117 int first = atoi((row[
"TOWERTO"].data<std::string>()).c_str());
118 int last = atoi((row[
"TOWERFROM"].data<std::string>()).c_str());
119 for (
int iTower =
first; iTower <=
last; iTower++) {
120 for (
int jSegment = 0; jSegment < 12; jSegment++) {
121 disabledDevs->enablePAC(iTower, sector, jSegment,
false);
128 coral::IQuery* query2 = schema.newQuery();
129 query2->addToTableList(
"BOARDDISABLED");
130 query2->addToTableList(
"BOARD");
131 query2->addToTableList(
"TRIGGERBOARD");
132 query2->addToOutputList(
"TRIGGERBOARD.TOWERTO",
"TOWERTO");
133 query2->addToOutputList(
"TRIGGERBOARD.TOWERFROM",
"TOWERFROM");
134 query2->addToOutputList(
"TRIGGERBOARD.SECTOR",
"SECTOR");
135 query2->addToOrderList(
"TOWERTO");
136 query2->addToOrderList(
"SECTOR");
137 condition =
"BOARD.BOARDID=BOARDDISABLED.BOARD_BOARDID AND BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID";
138 query2->setCondition(
condition, conditionData);
139 coral::ICursor& cursor2 = query2->execute();
140 while (cursor2.next()) {
142 const coral::AttributeList& row = cursor2.currentRow();
143 int sector = atoi((row[
"SECTOR"].data<std::string>()).c_str());
144 int first = atoi((row[
"TOWERTO"].data<std::string>()).c_str());
145 int last = atoi((row[
"TOWERFROM"].data<std::string>()).c_str());
146 for (
int iTower =
first; iTower <=
last; iTower++) {
147 for (
int jSegment = 0; jSegment < 12; jSegment++) {
148 disabledDevs->enablePAC(iTower, sector, jSegment,
false);
187 coral::IQuery* query4 = schema.newQuery();
188 query4->addToTableList(
"CHIPDISABLED");
189 query4->addToTableList(
"CHIP");
190 query4->addToTableList(
"BOARD");
191 query4->addToTableList(
"TRIGGERBOARD");
192 query4->addToOutputList(
"TRIGGERBOARD.TOWERTO",
"TOWERTO");
193 query4->addToOutputList(
"TRIGGERBOARD.TOWERFROM",
"TOWERFROM");
194 query4->addToOutputList(
"TRIGGERBOARD.SECTOR",
"SECTOR");
195 query4->addToOutputList(
"CHIP.POSITION",
"POSITION");
196 query4->addToOrderList(
"TOWERTO");
197 query4->addToOrderList(
"SECTOR");
198 query4->addToOrderList(
"POSITION");
200 "CHIP.CHIPID=CHIPDISABLED.CHIP_CHIPID AND CHIP.BOARD_BOARDID=BOARD.BOARDID AND "
201 "BOARD.BOARDID=TRIGGERBOARD.TRIGGERBOARDID AND CHIP.TYPE='PAC'";
202 query4->setCondition(
condition, conditionData);
203 coral::ICursor& cursor4 = query4->execute();
204 while (cursor4.next()) {
206 const coral::AttributeList& row = cursor4.currentRow();
207 int sector = atoi((row[
"SECTOR"].data<std::string>()).c_str());
208 int first = atoi((row[
"TOWERTO"].data<std::string>()).c_str());
209 int last = atoi((row[
"TOWERFROM"].data<std::string>()).c_str());
210 int chipPos = row[
"POSITION"].data<
short>();
213 for (
int jSegment = 0; jSegment < 12; jSegment++) {
214 disabledDevs->enablePAC(
tower, sector, jSegment,
false);
222 const Ref& set1 = _set1;
223 std::cout <<
"Size of new object is : " << std::flush;
225 std::cout <<
"Size of ref object is : " << std::flush;
228 if (set1->size() != set2->
size()) {
229 std::cout <<
" Number of disabled devices changed " << std::endl;
233 for (
int sector = 0; sector < 12; sector++) {
234 for (
int segment = 0; segment < 12; segment++)
235 if (set1->isActive(
tower, sector, segment) != set2->
isActive(
tower, sector, segment)) {
236 std::cout <<
" Configuration changed for tower " <<
tower <<
", sector " << sector <<
", segment " << segment