7 #include <CoralBase/Attribute.h>
8 #include <CoralBase/AttributeList.h>
10 #include "RelationalAccess/SchemaException.h"
11 #include "RelationalAccess/ITransaction.h"
12 #include "RelationalAccess/ITable.h"
13 #include "RelationalAccess/ISchema.h"
14 #include "RelationalAccess/ICursor.h"
15 #include "RelationalAccess/IQuery.h"
31 TRG_MSG_INFO(
"Not loading L1 TopoMenu from a run 1 database");
41 TRG_MSG_ERROR(
"L1TopoMenuLoader::load >> Standard C++ exception: " <<
e.what());
58 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
59 query0->addToTableList(
"SUPER_MASTER_TABLE",
"SM");
60 query0->addToTableList(
"TOPO_MASTER_TABLE",
"TMT");
61 query0->addToTableList(
"TOPO_TRIGGER_MENU",
"TTM");
62 query0->addToTableList(
"TTM_TO_TA",
"TTM2TA");
63 query0->addToTableList(
"TOPO_ALGO",
"TA");
64 query0->setRowCacheSize(1000);
68 bindList0.extend<
unsigned int>(
"tmtId");
69 std::string cond =
"TMT_ID = :tmtId";
70 bindList0[0].data<
unsigned int>() = tcaTarget.
getSMK();
72 string theCondition0 =
"";
73 theCondition0 += string(
" SM.SMT_ID = :tmtId");
74 theCondition0 += string(
" AND TMT.TMT_ID = SM.SMT_TOPO_MASTER_TABLE_ID ");
75 theCondition0 += string(
" AND TTM.TTM_ID = TMT.TMT_TRIGGER_MENU_ID ");
76 theCondition0 += string(
" AND TTM2TA.TTM2TA_MENU_ID = TTM.TTM_ID ");
77 theCondition0 += string(
" AND TA.TA_ID = TTM2TA.TTM2TA_ALGO_ID ");
78 query0->setCondition( theCondition0, bindList0 );
85 attList0.extend<
string>(
"TTM.TTM_NAME" );
87 attList0.extend<
int>(
"TTM.TTM_CTPLINK_ID" );
88 attList0.extend<
int>(
"TA.TA_ID" );
89 attList0.extend<
string>(
"TA.TA_NAME" );
90 attList0.extend<
string>(
"TA.TA_OUTPUT" );
91 attList0.extend<
string>(
"TA.TA_TYPE" );
92 attList0.extend<
int>(
"TA.TA_BITS" );
93 attList0.extend<
string>(
"TA.TA_SORT_DECI" );
94 attList0.extend<
int>(
"TA.TA_ALGO_ID" );
95 query0->defineOutput(attList0);
98 coral::ICursor& cursor0 = query0->execute();
102 std::map<uint, TXC::L1TopoConfigAlg> idToAlgMap;
104 while(cursor0.next()){
106 int ta_id = row0[
"TA.TA_ID"].data<
int>();
107 string ta_name = row0[
"TA.TA_NAME"].data<
string>();
108 string ta_output = row0[
"TA.TA_OUTPUT"].data<
string>();
109 string ta_type = row0[
"TA.TA_TYPE"].data<
string>();
111 string ta_sort_deci = row0[
"TA.TA_SORT_DECI"].data<
string>();
112 int ta_algo_id = row0[
"TA.TA_ALGO_ID"].data<
int>();
113 ctplinkid = row0[
"TTM.TTM_CTPLINK_ID"].data<
int>();
114 tcaTarget.
setName(row0[
"TTM.TTM_NAME"].data<string>());
122 alg.setAlgOutput(ta_output);
123 alg.setAlgoID(ta_algo_id);
128 idToAlgMap.emplace(ta_id,std::move(
alg));
137 for(
auto &
e : idToAlgMap ) {
144 TRG_MSG_ERROR(
"loadTopoAlgos >> Standard C++ exception: " <<
e.what());
157 for(
auto &
e : idToAlgMap ) {
158 algIds.insert(
e.first);
161 string algIdsConc =
"(";
163 for(
int id : algIds ) {
164 if(
first) {
first =
false; }
else { algIdsConc +=
","; }
175 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
176 query0->addToTableList(
"TA_TO_TI",
"TA2TI");
177 query0->addToTableList(
"TOPO_ALGO_INPUT",
"TAI");
180 string theCondition0 =
"";
181 theCondition0 +=
" TA2TI.TA2TI_ALGO_ID IN " + algIdsConc;
182 theCondition0 += string(
" AND TA2TI.TA2TI_INPUT_ID = TAI.TAI_ID");
183 query0->setCondition( theCondition0, bindList0 );
186 attList0.extend<
int>(
"TA2TI.TA2TI_ALGO_ID" );
187 attList0.extend<
string>(
"TAI.TAI_NAME" );
188 attList0.extend<
string>(
"TAI.TAI_VALUE" );
189 attList0.extend<
int>(
"TAI.TAI_POSITION" );
190 query0->defineOutput(attList0);
193 coral::ICursor& cursor0 = query0->execute();
196 while(cursor0.next()){
202 string tai_name = row0[
"TAI.TAI_NAME"].data<
string>();
203 string tai_value = row0[
"TAI.TAI_VALUE"].data<
string>();
204 int tai_pos = row0[
"TAI.TAI_POSITION"].data<
int>();
205 if(tai_pos<0) tai_pos=0;
208 int algoId = row0[
"TA2TI.TA2TI_ALGO_ID"].data<
int>();
209 auto match = idToAlgMap.find(algoId);
211 alg.addInput(tai_name,tai_value,tai_pos);
217 TRG_MSG_ERROR(
"loadAlgInput >> Standard C++ exception: " <<
e.what());
229 for(
auto &
e : idToAlgMap ) {
230 algIds.insert(
e.first);
233 string algIdsConc =
"(";
235 for(
int id : algIds ) {
236 if(
first) {
first =
false; }
else { algIdsConc +=
","; }
243 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
244 query0->addToTableList(
"TOPO_ALGO",
"TA");
245 query0->addToTableList(
"TA_TO_TO",
"TA2TO");
246 query0->addToTableList(
"TOPO_ALGO_OUTPUT",
"TAO");
252 string theCondition0 =
"";
253 theCondition0 +=
" TA.TA_ID IN " + algIdsConc;
254 theCondition0 +=
" AND TA.TA_ID = TA2TO.TA2TO_ALGO_ID";
255 theCondition0 +=
" AND TA2TO.TA2TO_OUTPUT_ID = TAO.TAO_ID";
256 query0->setCondition( theCondition0, bindList0 );
259 attList0.extend<
int>(
"TA2TO.TA2TO_ALGO_ID" );
260 attList0.extend<
string>(
"TAO.TAO_NAME" );
261 attList0.extend<
string>(
"TAO.TAO_VALUE" );
262 attList0.extend<
string>(
"TAO.TAO_BITNAME" );
263 attList0.extend<
int>(
"TAO.TAO_SELECTION" );
264 attList0.extend<
int>(
"TA.TA_BITS" );
265 query0->defineOutput(attList0);
268 coral::ICursor& cursor0 = query0->execute();
271 uint outputCount = 0;
272 while(cursor0.next()){
277 string tao_name = row0[
"TAO.TAO_NAME"].data<
string>();
278 string tao_value = row0[
"TAO.TAO_VALUE"].data<
string>();
279 string tao_bitname = row0[
"TAO.TAO_BITNAME"].data<
string>();
280 int tao_sel = row0[
"TAO.TAO_SELECTION"].data<
int>();
281 int ta_bits = row0[
"TA.TA_BITS"].data<
int>();
284 int algoId = row0[
"TA2TO.TA2TO_ALGO_ID"].data<
int>();
285 auto match = idToAlgMap.find(algoId);
287 alg.addOutput(tao_name,tao_value,ta_bits,tao_bitname, tao_sel);
293 TRG_MSG_ERROR(
"loadAlgOutput >> Standard C++ exception: " <<
e.what());
307 for(
auto &
e : idToAlgMap ) {
308 algIds.insert(
e.first);
311 string algIdsConc =
"(";
313 for(
int id : algIds ) {
314 if(
first) {
first =
false; }
else { algIdsConc +=
","; }
322 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
323 query0->addToTableList(
"TA_TO_TP",
"TA2TP");
324 query0->addToTableList(
"TOPO_PARAMETER",
"TP");
330 string theCondition0 =
"";
331 theCondition0 +=
" TA2TP.TA2TP_ALGO_ID IN " + algIdsConc;
332 theCondition0 +=
" AND TA2TP.TA2TP_PARAM_ID = TP.TP_ID";
333 query0->setCondition( theCondition0, bindList0 );
336 attList0.extend<
int>(
"TA2TP.TA2TP_ALGO_ID" );
337 attList0.extend<
string>(
"TP.TP_NAME" );
338 attList0.extend<
long>(
"TP.TP_VALUE" );
339 attList0.extend<
int>(
"TP.TP_POSITION" );
340 attList0.extend<
int>(
"TP.TP_SELECTION" );
341 query0->defineOutput(attList0);
344 coral::ICursor& cursor0 = query0->execute();
346 uint registerCount(0);
347 while(cursor0.next()){
351 string tp_name = row0[
"TP.TP_NAME"].data<
string>();
352 long tp_value = row0[
"TP.TP_VALUE"].data<
long>();
353 int tp_pos = row0[
"TP.TP_POSITION"].data<
int>();
354 int tp_sel = row0[
"TP.TP_SELECTION"].data<
int>();
355 if(tp_pos<0) tp_pos=0;
356 if(tp_sel<0) tp_sel=0;
360 int algoId = row0[
"TA2TP.TA2TP_ALGO_ID"].data<
int>();
361 auto match = idToAlgMap.find(algoId);
363 alg.addParameter(tp_name,
to_string(tp_value),tp_pos, tp_sel);
369 TRG_MSG_ERROR(
"loadAlgRegister >> Standard C++ exception: " <<
e.what());
383 for(
auto &
e : idToAlgMap ) {
384 algIds.insert(
e.first);
387 string algIdsConc =
"(";
389 for(
int id : algIds ) {
390 if(
first) {
first =
false; }
else { algIdsConc +=
","; }
398 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
399 query0->addToTableList(
"TA_TO_TG",
"TA2TG");
400 query0->addToTableList(
"TOPO_GENERIC",
"TG");
406 string theCondition0 =
"";
407 theCondition0 += string(
" TA2TG.TA2TG_ALGO_ID IN " + algIdsConc);
408 theCondition0 += string(
" AND TA2TG.TA2TG_GENERIC_ID = TG.TG_ID");
409 query0->setCondition( theCondition0, bindList0 );
411 query0->addToOrderList(
"TG.TG_NAME");
414 attList0.extend<
int>(
"TA2TG.TA2TG_ALGO_ID" );
415 attList0.extend<
string>(
"TG.TG_NAME" );
416 attList0.extend<
string>(
"TG.TG_VALUE" );
417 query0->defineOutput(attList0);
420 coral::ICursor& cursor0 = query0->execute();
423 while(cursor0.next()){
427 string tg_name = row0[
"TG.TG_NAME"].data<
string>();
428 string tg_value = row0[
"TG.TG_VALUE"].data<
string>();
431 int algoId = row0[
"TA2TG.TA2TG_ALGO_ID"].data<
int>();
432 auto match = idToAlgMap.find(algoId);
434 alg.addFixedParameter(tg_name,tg_value);
440 TRG_MSG_ERROR(
"loadAlgFixed >> Standard C++ exception: " <<
e.what());
625 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
626 query0->addToTableList(
"TOPO_OUTPUT_LIST",
"TOL");
627 query0->addToTableList(
"TOPO_OUTPUT_LINK",
"TOLK");
628 query0->addToTableList(
"TOPO_OUTPUT_LINE",
"TOLINE");
631 bindList0.extend<
int>(
"ctpLId");
632 bindList0[0].data<
int>() = ctplinkid;
634 string theCondition0 =
"";
635 theCondition0 += string(
" TOL.OL_ID = :ctpLId" );
636 theCondition0 += string(
" AND TOLK.TL_LINK_ID = TOL.OL_ID");
637 theCondition0 += string(
" AND TOLK.TL_OUTPUT_ID = TOLINE.TOL_ID");
638 query0->setCondition( theCondition0, bindList0 );
641 attList0.extend<
int>(
"TOLINE.TOL_ID" );
642 attList0.extend<
string>(
"TOLINE.TOL_ALGO_NAME" );
643 attList0.extend<
string>(
"TOLINE.TOL_TRIGGERLINE" );
644 attList0.extend<
unsigned int>(
"TOLINE.TOL_ALGO_ID" );
645 attList0.extend<
unsigned int>(
"TOLINE.TOL_MODULE" );
646 attList0.extend<
unsigned int>(
"TOLINE.TOL_FPGA" );
647 attList0.extend<
unsigned int>(
"TOLINE.TOL_FIRST_BIT" );
648 attList0.extend<
unsigned int>(
"TOLINE.TOL_CLOCK" );
649 query0->defineOutput(attList0);
652 coral::ICursor& cursor0 = query0->execute();
653 while(cursor0.next()){
656 string tol_name = row0[
"TOLINE.TOL_ALGO_NAME"].data<
string>();
657 unsigned int tol_algoId = row0[
"TOLINE.TOL_ALGO_ID"].data<
unsigned int>();
658 unsigned int tol_module = row0[
"TOLINE.TOL_MODULE"].data<
unsigned int>();
659 unsigned int tol_fpga = row0[
"TOLINE.TOL_FPGA"].data<
unsigned int>();
660 unsigned int tol_clock = row0[
"TOLINE.TOL_CLOCK"].data<
unsigned int>();
661 unsigned int tol_firstbit = row0[
"TOLINE.TOL_FIRST_BIT"].data<
unsigned int>();
666 TRG_MSG_ERROR(
"loadOutputList >> Standard C++ exception: " <<
e.what());
678 unique_ptr<coral::IQuery> query0(
m_session.nominalSchema().newQuery());
679 query0->addToTableList(
"SUPER_MASTER_TABLE",
"SM");
680 query0->addToTableList(
"TOPO_MASTER_TABLE",
"TMT");
681 query0->addToTableList(
"TOPO_TRIGGER_MENU",
"TTM");
682 query0->addToTableList(
"TTM_TO_TC",
"TTM2TC");
683 query0->addToTableList(
"TOPO_CONFIG",
"TC");
684 query0->setRowCacheSize(5);
688 bindList0.extend<
unsigned int>(
"tmtId");
689 std::string cond =
"TMT_ID = :tmtId";
690 bindList0[0].data<
unsigned int>() = tcaTarget.
getSMK();
692 string theCondition0 =
"";
693 theCondition0 += string(
" SM.SMT_ID = :tmtId");
694 theCondition0 += string(
" AND TMT.TMT_ID = SM.SMT_TOPO_MASTER_TABLE_ID ");
695 theCondition0 += string(
" AND TTM.TTM_ID = TMT.TMT_TRIGGER_MENU_ID ");
696 theCondition0 += string(
" AND TTM2TC.TTM2TC_ID = TTM.TTM_ID ");
697 theCondition0 += string(
" AND TC.TC_ID = TTM2TC.TTM2TC_CONFIG_ID ");
698 query0->setCondition( theCondition0, bindList0 );
701 attList0.extend<
string>(
"TC.TC_NAME" );
702 attList0.extend<
string>(
"TC.TC_VALUE" );
703 query0->defineOutput(attList0);
705 coral::ICursor& cursor0 = query0->execute();
707 while(cursor0.next()){
710 string tc_name = row0[
"TC.TC_NAME"].data<
string>();
711 string tc_value = row0[
"TC.TC_VALUE"].data<
string>();
717 TRG_MSG_ERROR(
"loadTopoConfig >> Standard C++ exception: " <<
e.what());