- Timestamp:
- 07/17/08 16:12:18 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9006 r9007 85 85 - use telescope number as argument 86 86 - simplified and improved 87 88 * datacenter/macros/filldotrun.C: 89 - some changes to output 90 - skip comment line at the beginning 91 - skip the line with the telescope number 92 - removed ISNULL from telescope/run/file check 93 - added fPriority to RunProcessStatus 94 - added telescope und file number to RunData and RunProcessStatus 87 95 88 96 -
trunk/MagicSoft/Mars/datacenter/macros/resetallruns.C
r8996 r9007 44 44 // 45 45 ///////////////////////////////////////////////////////////////////////////// 46 47 46 #include <iostream> 48 47 #include <iomanip> 49 48 #include <fstream> 50 49 51 #include <TSQLRow.h> 52 #include <TSQLResult.h> 50 #include <TPRegexp.h> 53 51 54 #include "MSQL Server.h"52 #include "MSQLMagic.h" 55 53 56 54 using namespace std; 57 55 58 59 int resetallruns(TString filename, TString column) 56 int resetallruns(TString filename, TString column, Bool_t dummy=kTRUE) 60 57 { 61 MSQL Serverserv("sql.rc");58 MSQLMagic serv("sql.rc"); 62 59 if (!serv.IsConnected()) 63 60 { … … 65 62 return 0; 66 63 } 64 67 65 cout << "resetallruns" << endl; 68 66 cout << "------------" << endl; … … 70 68 cout << "Connected to " << serv.GetName() << endl; 71 69 cout << endl; 70 cout << "File: " << filename << endl; 71 cout << "Column: " << column << endl; 72 cout << endl; 72 73 73 //reset column to NULL 74 TString query(Form("UPDATE RunProcessStatus SET %s=NULL", 75 column.Data())); 76 //if the column is fCaCoFileAvail, reset also the column fCaCoFileFound 74 serv.SetIsDummy(dummy); 75 76 //reset column to NULL, if the column is fCaCoFileAvail, 77 //reset also the column fCaCoFileFound 78 TString vars(column); 79 vars += "=NULL"; 77 80 if (column.Contains("CaCo")) 78 query+=", fCaCoFileFound=NULL";81 vars += ", fCaCoFileFound=NULL"; 79 82 80 cout << "q: " << query << endl; 81 82 TSQLResult *res = serv.Query(query); 83 if (!res) 84 { 85 cout << "updating (setting " << column.Data() << "= NULL) didn't work " << endl; 86 return 0; 87 } 88 delete res; 89 83 if (serv.Update("RunProcessStatus", vars)==kFALSE) 84 return 2; 90 85 91 86 //read in file … … 93 88 if (!fin) 94 89 { 95 cout << " file:" << filename << " missing!" << endl;96 return 0;90 cout << "ERROR - File " << filename << " missing!" << endl; 91 return 2; 97 92 } 93 94 TPRegexp regtel("^_M[0-9]_"); 95 TPRegexp regrun("_[0-9]{5,8}"); 96 TPRegexp regfile("[.][0-9]{3,5}_$"); 98 97 while (1) 99 98 { 100 99 //get runnumber 101 TString runnumber;102 runnumber.ReadLine(fin);100 TString str; 101 str.ReadLine(fin); 103 102 if (!fin) 104 103 break; 105 104 105 const TString tel = str(regtel); 106 const TString run = str(regrun); 107 const TString file = str(regfile); 108 109 const UInt_t ntel = tel.IsNull() ? 1 : atoi(tel.Data()+2); 110 const UInt_t nfile = file.IsNull() ? 0 : atoi(file.Data()+1); 111 const UInt_t nrun = atoi(run.Data()+1); 112 113 if (nrun>999999 && (tel.IsNull() || file.IsNull())) 114 { 115 cout << "ERROR - Run number " << nrun << ">999999 and telescope and/or run-number missing!" << endl; 116 cout << str << endl; 117 continue; 118 } 119 120 const UInt_t id = nrun*1000+nfile; 121 106 122 //build query and set status for this run to Now() 107 TString query(Form("UPDATE RunProcessStatus SET %s=Now()", column.Data())); 123 TString vars2(column); 124 vars2 += "=Now()"; 125 if (column.Contains("CaCo")) 126 vars2 += Form(", fCaCoFileFound=%d", id); 108 127 109 if (column.Contains("CaCo"))110 query+=Form(", fCaCoFileFound=%d", atoi(runnumber));128 TString where = Form("fTelescopeNumber=%d AND fRunNumber=%d AND fFileNumber=%d ", 129 ntel, nrun, nfile); 111 130 112 query+=Form(" WHERE fRunNumber=%d ", atoi(runnumber)); 113 114 cout << "q2: " << query << endl; 115 116 res = serv.Query(query); 117 if (!res) 118 { 119 cout << "updating (setting " << column.Data() << " = Now()) for run# " << atoi(runnumber) << ") didn't work " << endl; 120 return 0; 121 } 122 delete res; 131 if (serv.Update("RunProcessStatus", vars2, where)==kFALSE) 132 return 2; 123 133 } 124 134 125 135 return 1; 126 136 } 127 128
Note:
See TracChangeset
for help on using the changeset viewer.