11 #include <TSQLServer.h>
30 SQRun*
run = findNode::getClass<SQRun >(topNode,
"SQRun");
31 SQParamDeco* par_deco = findNode::getClass<SQParamDeco>(topNode,
"SQParamDeco");
40 static int utime_pre = 0;
41 int utime_now = time(0);
42 if (utime_now - utime_pre >= 10) {
43 utime_pre = utime_now;
44 SQRun* run_header = findNode::getClass<SQRun>(topNode,
"SQRun");
46 UploadRun(run_header);
55 SQRun*
run = findNode::getClass<SQRun >(topNode,
"SQRun");
56 SQParamDeco* par_deco = findNode::getClass<SQParamDeco>(topNode,
"SQParamDeco");
67 void DbUpRun::UploadRun(
SQRun* sq)
69 const char* table_name =
"run";
77 list.
Add(
"run_id" ,
"INT",
true);
78 list.
Add(
"utime_b" ,
"INT");
79 list.
Add(
"utime_e" ,
"INT");
80 list.
Add(
"fpga1_enabled" ,
"BOOL");
81 list.
Add(
"fpga2_enabled" ,
"BOOL");
82 list.
Add(
"fpga3_enabled" ,
"BOOL");
83 list.
Add(
"fpga4_enabled" ,
"BOOL");
84 list.
Add(
"fpga5_enabled" ,
"BOOL");
85 list.
Add(
"nim1_enabled" ,
"BOOL");
86 list.
Add(
"nim2_enabled" ,
"BOOL");
87 list.
Add(
"nim3_enabled" ,
"BOOL");
88 list.
Add(
"nim4_enabled" ,
"BOOL");
89 list.
Add(
"nim5_enabled" ,
"BOOL");
90 list.
Add(
"fpga1_prescale",
"INT");
91 list.
Add(
"fpga2_prescale",
"INT");
92 list.
Add(
"fpga3_prescale",
"INT");
93 list.
Add(
"fpga4_prescale",
"INT");
94 list.
Add(
"fpga5_prescale",
"INT");
95 list.
Add(
"nim1_prescale",
"INT");
96 list.
Add(
"nim2_prescale",
"INT");
97 list.
Add(
"nim3_prescale",
"INT");
98 list.
Add(
"n_spill" ,
"INT");
99 list.
Add(
"n_evt_all" ,
"INT");
100 list.
Add(
"n_evt_dec" ,
"INT");
106 oss <<
"delete from " << table_name <<
" where run_id = " << sq->
get_run_id();
107 if (! db->
Con()->Exec(oss.str().c_str())) {
108 cerr <<
"!!ERROR!! DbUpRun::UploadRun()." << endl;
112 oss <<
"insert into " << table_name <<
" values"
124 if (! db->
Con()->Exec(oss.str().c_str())) {
125 cerr <<
"!!ERROR!! DbUpRun::UploadRun()." << endl;
133 const char* table_name =
"param_deco";
139 list.
Add(
"run_id",
"INT",
true);
140 list.
Add(
"name" ,
"VARCHAR(64)",
true);
141 list.
Add(
"value" ,
"VARCHAR(64)");
145 if (sq->
size() == 0)
return;
148 oss <<
"delete from " << table_name <<
" where run_id = " <<
run;
149 if (! db.
Con()->Exec(oss.str().c_str())) {
150 cerr <<
"!!ERROR!! DbUpRun::UploadParam()." << endl;
154 oss <<
"insert into " << table_name <<
" values";
156 oss <<
" (" << run <<
", '" << it->first <<
"', '" << it->second <<
"'),";
158 string query = oss.str();
159 query.erase(query.length()-1, 1);
160 if (! db.
Con()->Exec(query.c_str())) {
161 cerr <<
"!!ERROR!! DbUpRun::UploadParam()." << endl;
void RunUpdated(const int run, int utime=0)
virtual ParamConstIter begin() const =0
Return the begin iterator.
virtual int get_n_evt_dec() const
Return the number of decoded events. The online decoding usually skips a part of events in order to f...
virtual int get_unix_time_end() const
Return the Unix time when this run ended.
void UseSchema(const char *name, const bool do_create=false, const bool do_drop=false)
virtual int get_nim_prescale(const int chan) const
Return the prescale factor of the given channel ('chan') of the NIM trigger in this run...
int End(PHCompositeNode *topNode)
Called at the end of all processing.
virtual int get_unix_time_begin() const
Return the Unix time when this run began.
int run(const int nEvents=1)
virtual int get_n_spill() const
Return the number of spill events.
virtual int get_fpga_prescale(const int chan) const
Return the prescale factor of the given channel ('chan') of the FPGA trigger in this run...
int InitRun(PHCompositeNode *topNode)
virtual unsigned int size() const =0
Return the number of variables held.
void Add(const std::string name, const std::string type, const bool is_key=false)
static std::string GetSchemaMainDaq()
int process_event(PHCompositeNode *topNode)
void CreateTable(const std::string name, const std::vector< std::string > list_var, const std::vector< std::string > list_type, const std::vector< std::string > list_key)
DbUpRun(const std::string &name="DbUpRun")
bool HasTable(const char *name, const bool exit_on_false=false)
virtual int get_n_evt_all() const
Return the number of all recorded events.
virtual int get_run_id() const
Return the run ID.
int Init(PHCompositeNode *topNode)
virtual ParamConstIter end() const =0
Return the end iterator.
An SQ interface class to hold the run-level info.
virtual int get_nim_enabled(const int chan) const
Return 'true' if the given channel ('chan') of the NIM trigger was enabled in this run...
virtual int get_fpga_enabled(const int chan) const
Return 'true' if the given channel ('chan') of the FPGA trigger was enabled in this run...
ParamMap::const_iterator ParamConstIter