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.7 2008/03/04 21:38:50 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) MSG("Fab",Msg::kWarning)
00099 << "Ignoring column " << rs.CurColNum()
00100 << " (of " << rs.NumCols() << ")"
00101 << " \""<< colName << "\"; not part of "
00102 << ClassName() << endl;
00103 rs.IncrementCurCol();
00104 }
00105 }
00106 }
00107 else {
00108 rs >> fSteelSlabMfgId
00109 >> fSteelSlabPartId
00110 >> fSteelSlabHeatId
00111 >> fSteelSlabNomWt
00112 >> fSteelSlabScaleWt;
00113 }
00114
00115
00116 fSteelSlabMfgId = ToUpper(fSteelSlabMfgId).Strip(TString::kBoth).Data();
00117 fSteelSlabPartId = ToUpper(fSteelSlabPartId).Strip(TString::kBoth).Data();
00118 fSteelSlabHeatId = ToUpper(fSteelSlabHeatId).Strip(TString::kBoth).Data();
00119
00120 fDetector =
00121 (Detector::Detector_t)
00122 ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00123
00124 fAggregateNo = (vrec) ? vrec->GetAggregateNo() : -1 ;
00125
00126 }
00127
00128
00129
00130 void FabSteelPlate::Store(DbiOutRowStream& ors,
00131 const DbiValidityRec* ) const {
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 vector< pair<string,string> > components;
00156 components.push_back(pair<string,string>("SEQNO","int"));
00157 components.push_back(pair<string,string>("SERIALNO","char"));
00158 components.push_back(pair<string,string>("PARTNO","char"));
00159 components.push_back(pair<string,string>("HEAT","char"));
00160 components.push_back(pair<string,string>("NOMINALMASSLBS","mediumint"));
00161 components.push_back(pair<string,string>("SCALEMASSLBS","mediumint"));
00162 int n = components.size();
00163
00164 for (int i=0; i<n; i++) {
00165 pair<string,string> colPair = components[i];
00166 string colName = colPair.first;
00167 if ( colName == "SERIALNO") ors << fSteelSlabMfgId;
00168 else if ( colName == "PARTNO") ors << fSteelSlabPartId;
00169 else if ( colName == "HEAT") ors << fSteelSlabHeatId;
00170 else if ( colName == "NOMINALMASSLBS") ors << fSteelSlabNomWt;
00171 else if ( colName == "SCALEMASSLBS") ors << fSteelSlabScaleWt;
00172 else if ( colName == "ROW_COUNTER" ) {;}
00173 else if ( colName == "SEQNO" ) {;}
00174 else {
00175 MSG("Fab",Msg::kFatal)
00176 << "Column name '" << colName << "' not correctly handled" << endl;
00177 assert(0);
00178 }
00179 }
00180 }
00181
00182
00183 Double_t FabSteelPlate::GetNominalMasskg() const
00184 {
00185 return (double)fSteelSlabNomWt * Munits::pound / Munits::kilogram;
00186 }
00187
00188
00189 Double_t FabSteelPlate::GetScaleMasskg() const
00190 {
00191 return (double)fSteelSlabScaleWt * Munits::pound / Munits::kilogram;
00192 }
00193
00194
00195 std::ostream& operator<<(std::ostream& os, const FabSteelPlate& pi)
00196 { return pi.FormatToOStream(os); }
00197
00198
00199 void FabSteelPlate::Print(Option_t *option) const
00200 { FormatToOStream(cout,option); }
00201
00202
00203 std::ostream& FabSteelPlate::FormatToOStream(std::ostream& os,
00204 Option_t * ) const
00205 {
00206 os << GetName() << " "
00207 << fSteelSlabMfgId << " "
00208 << fSteelSlabPartId << " "
00209 << fSteelSlabHeatId << " "
00210 << fSteelSlabNomWt << " (lbs) "
00211 << fSteelSlabScaleWt << " (lbs) "
00212 << endl;
00213
00214 os.setf(ios::right);
00215 return os;
00216 }
00217
00218
00219
00220 const char* FabSteelPlate::GetTableDescr()
00221 {
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 const char* const_tabledescr = "(\
00242 SEQNO int, \
00243 ROW_COUNTER int, \
00244 SERIALNO char(8), \
00245 PARTNO char(8), \
00246 HEAT char(10), \
00247 NOMINALMASSLBS int, \
00248 SCALEMASSLBS int, \
00249 primary key (SEQNO,ROW_COUNTER) \
00250 )";
00251
00252 return const_tabledescr;
00253 }
00254
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