00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00016
00017 #include "Fabrication/FabPlnInstall.h"
00018 #include "MessageService/MsgService.h"
00019 #include "DatabaseInterface/DbiOutRowStream.h"
00020 #include "DatabaseInterface/DbiResultSet.h"
00021 #include "DatabaseInterface/DbiValidityRec.h"
00022
00023
00024
00025 #include <cassert>
00026 #include <string.h>
00027
00028 using std::string;
00029 using std::vector;
00030
00031 ClassImp(FabPlnInstall)
00032
00033
00034
00035
00036 CVSID("$Id: FabPlnInstall.cxx,v 1.12 2008/03/04 21:44:34 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00037 Bool_t FabPlnInstall::fgDefensiveUnpkg = kFALSE;
00038
00039
00040
00041
00042 #include "DatabaseInterface/DbiResultPtr.tpl"
00043 template class DbiResultPtr<FabPlnInstall>;
00044
00045 #include "DatabaseInterface/DbiWriter.tpl"
00046 template class DbiWriter<FabPlnInstall>;
00047
00048
00049
00050
00051
00052
00053
00054 void FabPlnInstall::Fill(DbiResultSet& rs,
00055 const DbiValidityRec* vrec) {
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 UShort_t ipln = 1023;
00081
00082 if (fgDefensiveUnpkg) {
00083
00084
00085
00086 Int_t numCol = rs.NumCols();
00087
00088 for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00089 string colName = rs.CurColName();
00090 if ( colName == "INSTALLDATE" ) rs >> fInstallDate;
00091
00092 else if ( colName == "MODULEID1") rs >> fScintMdlMfgId[0];
00093 else if ( colName == "MODULEID2") rs >> fScintMdlMfgId[1];
00094 else if ( colName == "MODULEID3") rs >> fScintMdlMfgId[2];
00095 else if ( colName == "MODULEID4") rs >> fScintMdlMfgId[3];
00096 else if ( colName == "MODULEID5") rs >> fScintMdlMfgId[4];
00097 else if ( colName == "MODULEID6") rs >> fScintMdlMfgId[5];
00098 else if ( colName == "MODULEID7") rs >> fScintMdlMfgId[6];
00099 else if ( colName == "MODULEID8") rs >> fScintMdlMfgId[7];
00100
00101 else if ( colName == "STEELID1") rs >> fSteelSlabMfgId[0];
00102 else if ( colName == "STEELID2") rs >> fSteelSlabMfgId[1];
00103 else if ( colName == "STEELID3") rs >> fSteelSlabMfgId[2];
00104 else if ( colName == "STEELID4") rs >> fSteelSlabMfgId[3];
00105 else if ( colName == "STEELID5") rs >> fSteelSlabMfgId[4];
00106 else if ( colName == "STEELID6") rs >> fSteelSlabMfgId[5];
00107 else if ( colName == "STEELID7") rs >> fSteelSlabMfgId[6];
00108 else if ( colName == "STEELID8") rs >> fSteelSlabMfgId[7];
00109
00110 else if ( colName == "PLANENUM") rs >> ipln;
00111 else {
00112 static int nmsg = 25;
00113 if (nmsg-- > 0) MSG("Fab",Msg::kWarning)
00114 << "Ignoring column " << rs.CurColNum()
00115 << " (of " << rs.NumCols() << ")"
00116 << " \""<< colName << "\"; not part of "
00117 << ClassName() << endl;
00118 rs.IncrementCurCol();
00119 }
00120 }
00121 }
00122 else {
00123 rs >> fInstallDate
00124 >> fScintMdlMfgId[0]
00125 >> fScintMdlMfgId[1]
00126 >> fScintMdlMfgId[2]
00127 >> fScintMdlMfgId[3]
00128 >> fScintMdlMfgId[4]
00129 >> fScintMdlMfgId[5]
00130 >> fScintMdlMfgId[6]
00131 >> fScintMdlMfgId[7]
00132 >> fSteelSlabMfgId[0]
00133 >> fSteelSlabMfgId[1]
00134 >> fSteelSlabMfgId[2]
00135 >> fSteelSlabMfgId[3]
00136 >> fSteelSlabMfgId[4]
00137 >> fSteelSlabMfgId[5]
00138 >> fSteelSlabMfgId[6]
00139 >> fSteelSlabMfgId[7]
00140 >> ipln;
00141 }
00142
00143
00144 for (UInt_t i=0; i < 8; ++i ) {
00145 fScintMdlMfgId[i] =
00146 ToUpper(fScintMdlMfgId[i]).Strip(TString::kBoth).Data();
00147 fSteelSlabMfgId[i] =
00148 ToUpper(fSteelSlabMfgId[i]).Strip(TString::kBoth).Data();
00149 }
00150
00151 Detector::Detector_t det =
00152 (Detector::Detector_t)
00153 ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00154
00155 fPlaneId = PlexPlaneId(det,ipln,kTRUE);
00156
00157 }
00158
00159
00160
00161 void FabPlnInstall::Store(DbiOutRowStream& ors,
00162 const DbiValidityRec* ) const {
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 vector< pair<string,string> > components;
00191 components.push_back(pair<string,string>("SEQNO","int"));
00192 components.push_back(pair<string,string>("INSTALLDATE","datetime"));
00193 components.push_back(pair<string,string>("MODULEID1","tinytext"));
00194 components.push_back(pair<string,string>("MODULEID2","tinytext"));
00195 components.push_back(pair<string,string>("MODULEID3","tinytext"));
00196 components.push_back(pair<string,string>("MODULEID4","tinytext"));
00197 components.push_back(pair<string,string>("MODULEID5","tinytext"));
00198 components.push_back(pair<string,string>("MODULEID6","tinytext"));
00199 components.push_back(pair<string,string>("MODULEID7","tinytext"));
00200 components.push_back(pair<string,string>("MODULEID8","tinytext"));
00201 components.push_back(pair<string,string>("STEELID1","tinytext"));
00202 components.push_back(pair<string,string>("STEELID2","tinytext"));
00203 components.push_back(pair<string,string>("STEELID3","tinytext"));
00204 components.push_back(pair<string,string>("STEELID4","tinytext"));
00205 components.push_back(pair<string,string>("STEELID5","tinytext"));
00206 components.push_back(pair<string,string>("STEELID6","tinytext"));
00207 components.push_back(pair<string,string>("STEELID7","tinytext"));
00208 components.push_back(pair<string,string>("STEELID8","tinytext"));
00209 components.push_back(pair<string,string>("PLANENUM","int"));
00210 int n = components.size();
00211
00212 for (int i=0; i<n; i++) {
00213 pair<string,string> colPair = components[i];
00214 string colName = colPair.first;
00215 if ( colName == "INSTALLDATE") ors << fInstallDate;
00216
00217
00218 else if ( colName == "MODULEID1") ors << fScintMdlMfgId[0];
00219 else if ( colName == "MODULEID2") ors << fScintMdlMfgId[1];
00220 else if ( colName == "MODULEID3") ors << fScintMdlMfgId[2];
00221 else if ( colName == "MODULEID4") ors << fScintMdlMfgId[3];
00222 else if ( colName == "MODULEID5") ors << fScintMdlMfgId[4];
00223 else if ( colName == "MODULEID6") ors << fScintMdlMfgId[5];
00224 else if ( colName == "MODULEID7") ors << fScintMdlMfgId[6];
00225 else if ( colName == "MODULEID8") ors << fScintMdlMfgId[7];
00226
00227 else if ( colName == "STEELID1") ors << fSteelSlabMfgId[0];
00228 else if ( colName == "STEELID2") ors << fSteelSlabMfgId[1];
00229 else if ( colName == "STEELID3") ors << fSteelSlabMfgId[2];
00230 else if ( colName == "STEELID4") ors << fSteelSlabMfgId[3];
00231 else if ( colName == "STEELID5") ors << fSteelSlabMfgId[4];
00232 else if ( colName == "STEELID6") ors << fSteelSlabMfgId[5];
00233 else if ( colName == "STEELID7") ors << fSteelSlabMfgId[6];
00234 else if ( colName == "STEELID8") ors << fSteelSlabMfgId[7];
00235
00236 else if ( colName == "PLANENO") ors << fPlaneId.GetPlane();
00237
00238 else if ( colName == "ROW_COUNTER" ) {;}
00239 else if ( colName == "SEQNO" ) {;}
00240 else {
00241 MSG("Fab",Msg::kFatal)
00242 << "Column name '" << colName << "' not correctly handled" << endl;
00243 assert(0);
00244 }
00245 }
00246 }
00247
00248
00249 string FabPlnInstall::GetScintMdlMfgId(UShort_t indx) const
00250 {
00251 if (indx > fScintMdlMfgId.size()) return "no-scint-id";
00252 return fScintMdlMfgId[indx];
00253 }
00254
00255
00256 string FabPlnInstall::GetSteelSlabMfgId(UShort_t indx) const
00257 {
00258 if (indx > fSteelSlabMfgId.size()) return "no-slab-id";
00259 return fSteelSlabMfgId[indx];
00260 }
00261
00262
00263 Int_t FabPlnInstall::GetAggregateNo() const
00264 {
00265
00266 return fPlaneId.GetPlane();
00267 }
00268
00269
00270 UInt_t FabPlnInstall::GetIndex(UInt_t ) const
00271 {
00272 return fPlaneId.GetPlane();
00273 }
00274
00275
00276 std::ostream& operator<<(std::ostream& os, const FabPlnInstall& pi)
00277 { return pi.FormatToOStream(os); }
00278
00279
00280 void FabPlnInstall::Print(Option_t *option) const
00281 { FormatToOStream(cout,option); }
00282
00283
00284 std::ostream& FabPlnInstall::FormatToOStream(std::ostream& os,
00285 Option_t * ) const
00286 {
00287 os << GetName() << " "
00288 << fPlaneId.AsString("c") << " "
00289 << fInstallDate.AsString("sql") << endl;
00290 for (int i=0; i<8; ++i) {
00291 os << " [" << i << "] ";
00292
00293
00294
00295 os.fill(' ');
00296 os << setw(16);
00297 os.setf(ios::left);
00298 os << fScintMdlMfgId[i].c_str();
00299 os << " ";
00300 os.fill(' ');
00301 os << setw(16);
00302 os.setf(ios::left);
00303 os << fSteelSlabMfgId[i].c_str();
00304 os << endl;
00305 }
00306 os.setf(ios::right);
00307 return os;
00308 }
00309
00310
00311
00312 const char* FabPlnInstall::GetTableDescr()
00313 {
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 const char* const_tabledescr = "(\
00334 SEQNO int, \
00335 ROW_COUNTER int, \
00336 INSTALLDATE datetime, \
00337 MODULEID1 tinytext, \
00338 MODULEID2 tinytext, \
00339 MODULEID3 tinytext, \
00340 MODULEID4 tinytext, \
00341 MODULEID5 tinytext, \
00342 MODULEID6 tinytext, \
00343 MODULEID7 tinytext, \
00344 MODULEID8 tinytext, \
00345 STEELID1 tinytext, \
00346 STEELID2 tinytext, \
00347 STEELID3 tinytext, \
00348 STEELID4 tinytext, \
00349 STEELID5 tinytext, \
00350 STEELID6 tinytext, \
00351 STEELID7 tinytext, \
00352 STEELID8 tinytext, \
00353 PLANENUM int, \
00354 primary key (SEQNO,ROW_COUNTER) \
00355 )";
00356
00357 return const_tabledescr;
00358 }
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390