00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00015 #include "Morgue/BadHardware.h"
00016 #include "MessageService/MsgService.h"
00017 #include "DatabaseInterface/DbiOutRowStream.h"
00018 #include "DatabaseInterface/DbiResultSet.h"
00019 #include "DatabaseInterface/DbiValidityRec.h"
00020 #include <iostream>
00021
00022 ClassImp(BadHardware)
00023
00024
00025
00026
00027 CVSID("$Id: BadHardware.cxx,v 1.2 2005/03/03 15:41:47 tagg Exp $\n \
00028 CVSID_DBIRESULTPTR ");
00029
00030
00031
00032
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class DbiResultPtr<BadHardware>;
00035
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class DbiWriter<BadHardware>;
00038
00039
00040
00041
00042 BadHardware::BadHardware( const string& type,
00043 Int_t id,
00044 const VldTimeStamp& start,
00045 const VldTimeStamp& stop,
00046 Int_t badness,
00047 const string& reason ) :
00048 fThingType(HardwareType::FromString(type)),
00049 fThingId(id),
00050 fStart(start.GetSec()),
00051 fStop(stop.GetSec()),
00052 fBadness(badness),
00053 fReason(reason)
00054 {
00055 LEA_CTOR;
00056 }
00057
00058 BadHardware::BadHardware( HardwareComponent component,
00059 const VldTimeStamp& start,
00060 const VldTimeStamp& stop,
00061 Int_t badness,
00062 const string& reason) :
00063 fThingType(component.GetType()),
00064 fThingId(component.GetId()),
00065 fStart(start.GetSec()),
00066 fStop(stop.GetSec()),
00067 fBadness(badness),
00068 fReason(reason)
00069 {
00070 LEA_CTOR;
00071 }
00072
00073
00074
00075
00076
00077 void BadHardware::Fill(DbiResultSet& rs,
00078 const DbiValidityRec* ) {
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 if ( rs.TableName() == "BADHARDWARE" ) {
00105
00106 rs >> fThingType >> fThingId >> fStart >> fStop >> fBadness >> fReason;
00107 }
00108 else {
00109
00110
00111 Int_t numCol = rs.NumCols();
00112
00113 for (Int_t curCol = 2; curCol <= numCol; ++curCol) {
00114 string colName = rs.CurColName();
00115 if ( colName == "TYPE" ) rs >> fThingType;
00116 else if ( colName == "ID" ) rs >> fThingId;
00117 else if ( colName == "START" ) rs >> fStart;
00118 else if ( colName == "STOP" ) rs >> fStop;
00119 else if ( colName == "BADNESS" ) rs >> fBadness;
00120 else if ( colName == "REASON" ) rs >> fReason;
00121 else {
00122 MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol
00123 << "(" << colName << ")"
00124 << "; not part of BadHardware"
00125 << endl;
00126 rs.IncrementCurCol();
00127 }
00128 }
00129 }
00130
00131
00132 }
00133
00134
00135
00136 void BadHardware::Store(DbiOutRowStream& ors,
00137 const DbiValidityRec* ) const {
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 ors << fThingType << fThingId << fStart << fStop << fBadness << fReason;
00162 }
00163
00164
00165
00166
00167 void BadHardware::Print(Option_t* ) const
00168 {
00169 std::cout << "BadHardware: " << GetComponent().AsString()
00170 << " " << GetStart().AsString("s")
00171 << " to " << GetStop().AsString("s")
00172 << " " << GetBadness() << " " << fReason << endl;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196