88 {
91
92
93
94
95
96
97
98 std::vector<Assertion::Operator *> conditions;
99 conditions.reserve(6);
100
102 FIELDTYPEold, FIELDTYPElit);
103
105 FIELDTYPEold, FIELDTYPElit);
106
108 FIELDTYPEold, FIELDTYPElit);
109
111 FIELDTYPEold, FIELDTYPElit);
112
114 FIELDTYPEold, FIELDTYPElit);
115
117 "vstart",
118 FIELDTYPElit, FIELDTYPEold);
119
120 conditions.push_back(&calibTypeOp);
121 conditions.push_back(&instOp);
122 conditions.push_back(&flavorOp);
123 conditions.push_back(&levelOp);
124 conditions.push_back(&vstartOp);
125 conditions.push_back(&completeOp);
128
130
131 try {
132 results = m_conn->
select(m_table, m_selects, m_orderBy, whereClause);
133 }
135 std::cerr << ex.
getMsg() << std::endl;
136 std::cerr.flush();
137 return false;
138 }
139
140 if (!results) {
141 std::cerr << "Error making query " << std::endl;
142 std::cerr.flush();
143 exit(1);
144 }
145
146
147 std::vector<SelectInfo> info;
148 unsigned nFound = results->
getNRows();
149
150 if (!nFound) {
151 std::cout << "No calibrations found for calib_type '" << calibtype
152 << "'" << std::endl;
153 return true;
154 }
155
157
158 unsigned iRow = 0;
159 std::vector<std::string> fields;
160 fields.reserve(3);
161
162 bool ok = true;
163 unsigned retCode = 0;
164
165
166 std::cout << std::endl
167 << "Checking for valid timestamps, vstart < vend .. "
168 << std::endl;
169 for (iRow = 0; iRow < nFound; iRow++) {
170 results->
getRow(fields, iRow);
172 try {
173 Timestamp vstart = Timestamp(fields[1]);
174 Timestamp vend = Timestamp(fields[2]);
175 info.push_back(
SelectInfo(ser, vstart, vend));
176
177 if (vend.getClibTime() < vstart.getClibTime() ) {
178 std::cerr << "vend < vstart for " << info.back();
179 ok = false;
180 retCode = 1;
181 }
182 }
184 std::cerr << "Bad vstart or vend in row " << ser << std::endl;
185 ok = false;
186 retCode = 1;
187 }
188
189 }
190 if (!ok) return retCode;
191
192
193 std::cout << std::endl << "Checking for vends monotonic.. " << std::endl;
194 for (iRow = 0; iRow < nFound - 1; iRow++) {
195 if (info[iRow].m_vend.getClibTime() > info[iRow+1].m_vend.getClibTime()) {
196 std::cerr << "Validity interval for row with serial #"
197 << info[iRow+1].m_ser
198 << " completely contained in interval for row with serial #"
199 << info[iRow].m_ser << std::endl;
200 std::cerr << info[iRow];
201 std::cerr << info[iRow+1] << std::endl;
202 ok = false;
203 retCode = 2;
204 }
205 }
206 if (!ok) return retCode;
207
208
209 std::cout << std::endl << "Checking for gaps.. " << std::endl;
210 for (iRow = 0; iRow < nFound - 1; iRow++) {
211 if (info[iRow].m_vend < info[iRow+1].m_vstart) {
212 std::cerr << "Validity interval gap between calibrations with serial #"
213 << info[iRow].m_ser << " and #" << info[iRow+1].m_ser
214 << std::endl;
215 std::cerr << info[iRow];
216 std::cerr << info[iRow+1] << std::endl;
217 ok = false;
218 retCode = 3;
219 }
220 }
221
222 std::cout << std::endl << "Checking for overlaps.. " << std::endl;
223 for (iRow = 0; iRow < nFound - 1; iRow++) {
224 if ((info[iRow].m_vend).getClibTime() >
225 (info[iRow+1].m_vstart).getClibTime() + m_overlap) {
226 std::cerr << "Unacceptable overlap between serial #" << info[iRow].m_ser
227 << " and #" << info[iRow+1].m_ser << std::endl;
228 std::cerr << info[iRow];
229 std::cerr << info[iRow+1] << std::endl;
230 ok = false;
231 if (!retCode) retCode = 4;
232 }
233 }
234 return retCode;
235
236 }
std::string getString() const
Return string representation of time, not including nanoseconds;.
static int stringToInt(const std::string &InStr)
virtual ResultHandle * select(const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0
virtual std::string getMsg()
virtual bool getRow(std::vector< std::string > &fields, unsigned int i=0, bool clear=true)=0
virtual unsigned int getNRows() const =0
Return number of rows in results.