#include #include #include "ISlowControlDatabase.hxx" /// Example program showing some sample access to the M11 slow control /// database for TPC. int main(int argc,char **argv){ // Start by showing all tables. ISlowControlDatabase::Get().ShowTables(); // The following is unix time (in seconds). // This corresponds to Jan 20, 2010. int utime = 1263945600; ISlowControlDatabase::Get().PrintTable(utime,"tpc1temp_tpc1"); // _____________________________________________________ // Cached database access: double tpc_temperature = ISlowControlDatabase::Get().QueryShowField(1263945600,"tpc1temp_tpc1","tafrontcenter_tpc1"); std::cout << "TPC temperature: " << tpc_temperature << std::endl; // _____________________________________________________ // Multi-row database access: // First make up the list of table variables we want std::vector table_fields; // Add three variables from particular TPC temperature table. table_fields.push_back("tatopcenterfront_tpc1"); table_fields.push_back("tarp1leftbackhi_tpc1"); table_fields.push_back("tafrontcenter_tpc1"); // Now choose the starting and ending times int start_time = utime; int end_time = start_time + 60*60; // 1 hour later. // Now execute database query. std::vector > > returned_values = ISlowControlDatabase::Get().QueryGetFieldStartEndTime("tpc1temp_tpc1", table_fields, start_time, end_time); // Now let's look at what we got back. // The overall loop contains the information for each row of database that was between start_time and end_time. for(unsigned int row = 0; row < returned_values.size(); row++){ // The first part of pair for this row stores the timestamp for this row int row_time = returned_values[row].first; // The second part of pair for this row contains the vector of the variables you asked for. std::vector temperatures = returned_values[row].second; // Now retrieve the individual temperature measurements we asked for: double temp_topcenterfront_tpc1 = temperatures[0]; double temp_rp1leftbackhi_tpc1 = temperatures[1]; double temp_frontcenter_tpc1 = temperatures[2]; std::cout << "For row time = " << row_time << " we found following TPC temperatures: " << temp_topcenterfront_tpc1 << " " << " " << temp_rp1leftbackhi_tpc1 << " " << temp_frontcenter_tpc1 << std::endl; } }