21#include <CoralBase/Attribute.h>
22#include <CoralBase/AttributeList.h>
24#include "RelationalAccess/SchemaException.h"
25#include "RelationalAccess/ITransaction.h"
26#include "RelationalAccess/ITable.h"
27#include "RelationalAccess/ISchema.h"
28#include "RelationalAccess/ICursor.h"
29#include "RelationalAccess/IQuery.h"
41 msg() <<
"DeadTimeLoader: Start loading data via ID. ID=" << dtTarget.
id() << std::endl;
46 coral::ITable& table =
m_session.nominalSchema().tableHandle(
"L1_DEAD_TIME");
47 coral::IQuery*
query = table.newQuery();
48 query->setRowCacheSize( 5 );
51 coral::AttributeList bindList;
52 bindList.extend<
long>(
"dtId");
53 std::string cond =
"L1DT_ID = :dtId";
54 bindList[0].data<
long>() = dtTarget.
id();
55 query->setCondition( cond, bindList );
58 coral::AttributeList attList;
59 attList.extend<
int>(
"L1DT_VERSION" );
60 attList.extend<
string>(
"L1DT_NAME" );
61 attList.extend<
int>(
"L1DT_SIMPLE" );
62 attList.extend<
int>(
"L1DT_COMPLEX1_LEVEL" );
63 attList.extend<
int>(
"L1DT_COMPLEX1_RATE" );
64 attList.extend<
int>(
"L1DT_COMPLEX2_LEVEL" );
65 attList.extend<
int>(
"L1DT_COMPLEX2_RATE" );
66 attList.extend<
long>(
"L1DT_ID" );
67 query->defineOutput(attList);
69 query->addToOutputList(
"L1DT_VERSION" );
70 query->addToOutputList(
"L1DT_NAME" );
71 query->addToOutputList(
"L1DT_SIMPLE" );
72 query->addToOutputList(
"L1DT_COMPLEX1_LEVEL" );
73 query->addToOutputList(
"L1DT_COMPLEX1_RATE" );
74 query->addToOutputList(
"L1DT_COMPLEX2_LEVEL" );
75 query->addToOutputList(
"L1DT_COMPLEX2_RATE" );
76 query->addToOutputList(
"L1DT_ID" );
77 query->addToOrderList(
"L1DT_ID" );
79 coral::ICursor& cursor =
query->execute();
81 if ( ! cursor.next() ) {
82 msg() <<
"DeadTimeLoader >> No such deadtime exists " << dtTarget.
id() << std::endl;
85 throw std::runtime_error(
"DeadTimeLoader >> DeadTime not available" );
88 const coral::AttributeList& row = cursor.currentRow();
89 std::string
name = row[
"L1DT_NAME"].data<std::string>();
90 int version = row[
"L1DT_VERSION"].data<
int>();
91 int simple = row[
"L1DT_SIMPLE"].data<
int>();
92 int complex1_level = row[
"L1DT_COMPLEX1_LEVEL"].data<
int>();
93 int complex1_rate = row[
"L1DT_COMPLEX1_RATE"].data<
int>();
94 int complex2_level = row[
"L1DT_COMPLEX2_LEVEL"].data<
int>();
95 int complex2_rate = row[
"L1DT_COMPLEX2_RATE"].data<
int>();
97 if ( cursor.next() ) {
98 msg() <<
"DeadTimeLoader >> More than one DeadTime exists "
99 << dtTarget.
id() << std::endl;
101 throw std::runtime_error(
"DeadTimeLoader >> DeadTime not available" );
116 }
catch(
const coral::SchemaException& e ) {
117 msg() <<
"DeadTimeLoader >> SchemaException: "
118 << e.what() << std::endl;
121 }
catch(
const std::exception& e ) {
122 msg() <<
"DeadTimeLoader >> Standard C++ exception: " << e.what() << std::endl;
126 msg() <<
"DeadTimeLoader >> Unknown C++ exception" << std::endl;
virtual int verbose() const override
void commitSession()
commit session if not already done
coral::ISessionProxy & m_session
CORAL interface to database session.
void startSession()
start session if not already active
virtual bool load(DeadTime &data) override
void setComplex1Rate(int i)
void setComplex2Rate(int i)
void setComplex2Level(int i)
void setComplex1Level(int i)
void setName(const std::string &name)
void setVersion(unsigned int version)
MsgStreamTC & msg() const
The standard message stream.