00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00017
00018 #include "Fabrication/FabSteelPlate.h"
00019 #include "MessageService/MsgService.h"
00020 #include "DatabaseInterface/DbiOutRowStream.h"
00021 #include "DatabaseInterface/DbiResultSet.h"
00022 #include "DatabaseInterface/DbiValidityRec.h"
00023
00024 #include "Conventions/Munits.h"
00025
00026 #include "TString.h"
00027
00028 #include <cassert>
00029 #include <string.h>
00030
00031 using std::string;
00032 using std::vector;
00033
00034 ClassImp(FabSteelPlate)
00035
00036
00037
00038
00039 CVSID("$Id: FabSteelPlate.cxx,v 1.8 2013/07/30 21:00:18 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00040 Bool_t FabSteelPlate::fgDefensiveUnpkg = kFALSE;
00041
00042
00043
00044
00045 #include "DatabaseInterface/DbiResultPtr.tpl"
00046 template class DbiResultPtr<FabSteelPlate>;
00047
00048 #include "DatabaseInterface/DbiWriter.tpl"
00049 template class DbiWriter<FabSteelPlate>;
00050
00051
00052
00053
00054
00055
00056
00057 void FabSteelPlate::Fill(DbiResultSet& rs,
00058 const DbiValidityRec* vrec) {
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 if (fgDefensiveUnpkg) {
00084
00085
00086
00087 Int_t numCol = rs.NumCols();
00088
00089 for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00090 string colName = rs.CurColName();
00091 if ( colName == "SERIALNO" ) rs >> fSteelSlabMfgId;
00092 else if ( colName == "PARTNO") rs >> fSteelSlabPartId;
00093 else if ( colName == "HEAT") rs >> fSteelSlabHeatId;
00094 else if ( colName == "NOMINALMASSLBS") rs >> fSteelSlabNomWt;
00095 else if ( colName == "SCALEMASSLBS") rs >> fSteelSlabScaleWt;
00096 else {
00097 static int nmsg = 25;
00098 if (nmsg-- > 0) {
00099 MSG("Fab",Msg::kWarning)
00100 << "Ignoring column " << rs.CurColNum()
00101 << " (of " << rs.NumCols() << ")"
00102 << " \""<< colName << "\"; not part of "
00103 << ClassName() << endl;
00104 }
00105 rs.IncrementCurCol();
00106 }
00107 }
00108 }
00109 else {
00110 rs >> fSteelSlabMfgId
00111 >> fSteelSlabPartId
00112 >> fSteelSlabHeatId
00113 >> fSteelSlabNomWt
00114 >> fSteelSlabScaleWt;
00115 }
00116
00117
00118 fSteelSlabMfgId = ToUpper(fSteelSlabMfgId).Strip(TString::kBoth).Data();
00119 fSteelSlabPartId = ToUpper(fSteelSlabPartId).Strip(TString::kBoth).Data();
00120 fSteelSlabHeatId = ToUpper(fSteelSlabHeatId).Strip(TString::kBoth).Data();
00121
00122 fDetector =
00123 (Detector::Detector_t)
00124 ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00125
00126 fAggregateNo = (vrec) ? vrec->GetAggregateNo() : -1 ;
00127
00128 }
00129
00130
00131
00132 void FabSteelPlate::Store(DbiOutRowStream& ors,
00133 const DbiValidityRec* ) const {
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 vector< pair<string,string> > components;
00158 components.push_back(pair<string,string>("SEQNO","int"));
00159 components.push_back(pair<string,string>("SERIALNO","char"));
00160 components.push_back(pair<string,string>("PARTNO","char"));
00161 components.push_back(pair<string,string>("HEAT","char"));
00162 components.push_back(pair<string,string>("NOMINALMASSLBS","mediumint"));
00163 components.push_back(pair<string,string>("SCALEMASSLBS","mediumint"));
00164 int n = components.size();
00165
00166 for (int i=0; i<n; i++) {
00167 pair<string,string> colPair = components[i];
00168 string colName = colPair.first;
00169 if ( colName == "SERIALNO") ors << fSteelSlabMfgId;
00170 else if ( colName == "PARTNO") ors << fSteelSlabPartId;
00171 else if ( colName == "HEAT") ors << fSteelSlabHeatId;
00172 else if ( colName == "NOMINALMASSLBS") ors << fSteelSlabNomWt;
00173 else if ( colName == "SCALEMASSLBS") ors << fSteelSlabScaleWt;
00174 else if ( colName == "ROW_COUNTER" ) {;}
00175 else if ( colName == "SEQNO" ) {;}
00176 else {
00177 MSG("Fab",Msg::kFatal)
00178 << "Column name '" << colName << "' not correctly handled" << endl;
00179 assert(0);
00180 }
00181 }
00182 }
00183
00184
00185 Double_t FabSteelPlate::GetNominalMasskg() const
00186 {
00187 return (double)fSteelSlabNomWt * Munits::pound / Munits::kilogram;
00188 }
00189
00190
00191 Double_t FabSteelPlate::GetScaleMasskg() const
00192 {
00193 return (double)fSteelSlabScaleWt * Munits::pound / Munits::kilogram;
00194 }
00195
00196
00197 std::ostream& operator<<(std::ostream& os, const FabSteelPlate& pi)
00198 { return pi.FormatToOStream(os); }
00199
00200
00201 void FabSteelPlate::Print(Option_t *option) const
00202 { FormatToOStream(cout,option); }
00203
00204
00205 std::ostream& FabSteelPlate::FormatToOStream(std::ostream& os,
00206 Option_t * ) const
00207 {
00208 os << GetName() << " "
00209 << fSteelSlabMfgId << " "
00210 << fSteelSlabPartId << " "
00211 << fSteelSlabHeatId << " "
00212 << fSteelSlabNomWt << " (lbs) "
00213 << fSteelSlabScaleWt << " (lbs) "
00214 << endl;
00215
00216 os.setf(ios::right);
00217 return os;
00218 }
00219
00220
00221
00222 const char* FabSteelPlate::GetTableDescr()
00223 {
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 const char* const_tabledescr = "(\
00244 SEQNO int, \
00245 ROW_COUNTER int, \
00246 SERIALNO char(8), \
00247 PARTNO char(8), \
00248 HEAT char(10), \
00249 NOMINALMASSLBS int, \
00250 SCALEMASSLBS int, \
00251 primary key (SEQNO,ROW_COUNTER) \
00252 )";
00253
00254 return const_tabledescr;
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287