Changeset 15570
- Timestamp:
- Nov 9, 2007, 4:03:20 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
caltool.c (modified) (2 diffs)
-
caltoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/caltool.c
r15564 r15570 197 197 static bool addrunMode(pxConfig *config) 198 198 { 199 PS_ASSERT_PTR_NON_NULL(config, NULL); 199 PS_ASSERT_PTR_NON_NULL(config, false); 200 201 // required options 202 bool status = false; 203 psString cal_id = psMetadataLookupStr(&status, config->args, "-cal_id"); 204 if (!status) { 205 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -cal_id"); 206 return false; 207 } 208 if (!cal_id) { 209 psError(PS_ERR_UNKNOWN, true, "-cal_id is required"); 210 return false; 211 } 212 213 psString region = psMetadataLookupStr(&status, config->args, "-region"); 214 if (!status) { 215 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -region"); 216 return false; 217 } 218 if (!region) { 219 psError(PS_ERR_UNKNOWN, true, "-region is required"); 220 return false; 221 } 222 223 psString last_step = psMetadataLookupStr(&status, config->args, "-last_step"); 224 if (!status) { 225 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -last_step"); 226 return false; 227 } 228 if (!last_step) { 229 psError(PS_ERR_UNKNOWN, true, "-last_step is required"); 230 return false; 231 } 232 233 psString state = psMetadataLookupStr(&status, config->args, "-state"); 234 if (!status) { 235 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -state"); 236 return false; 237 } 238 if (!state) { 239 psError(PS_ERR_UNKNOWN, true, "-state is required"); 240 return false; 241 } 242 243 if (!calRunInsert(config->dbh, 244 (psS64)atoll(cal_id), 245 region, 246 last_step, 247 state 248 )) { 249 psError(PS_ERR_UNKNOWN, false, "database error"); 250 return false; 251 252 } 200 253 201 254 return false; … … 205 258 static bool runsMode(pxConfig *config) 206 259 { 207 PS_ASSERT_PTR_NON_NULL(config, NULL); 208 209 return false; 210 } 260 PS_ASSERT_PTR_NON_NULL(config, false); 261 262 bool status = false; 263 psU64 limit = psMetadataLookupU64(&status, config->args, "-limit"); 264 if (!status) { 265 psError(PXTOOLS_ERR_PROG, false, "failed to lookup value for -limit"); 266 return false; 267 } 268 269 psString query = psStringCopy("SELECT * FROM calRun"); 270 271 if (config->where) { 272 psString whereClause = psDBGenerateWhereSQL(config->where, NULL); 273 psStringAppend(&query, " %s", whereClause); 274 psFree(whereClause); 275 } 276 277 // treat limit == 0 as "no limit" 278 if (limit) { 279 psString limitString = psDBGenerateLimitSQL(limit); 280 psStringAppend(&query, " %s", limitString); 281 psFree(limitString); 282 } 283 284 if (!p_psDBRunQuery(config->dbh, query)) { 285 psError(PS_ERR_UNKNOWN, false, "database error"); 286 psFree(query); 287 return false; 288 } 289 psFree(query); 290 291 psArray *output = p_psDBFetchResult(config->dbh); 292 if (!output) { 293 psErrorCode err = psErrorCodeLast(); 294 switch (err) { 295 case PS_ERR_DB_CLIENT: 296 psError(PXTOOLS_ERR_SYS, false, "database error"); 297 case PS_ERR_DB_SERVER: 298 psError(PXTOOLS_ERR_PROG, false, "database error"); 299 default: 300 psError(PXTOOLS_ERR_PROG, false, "unknown error"); 301 } 302 303 return false; 304 } 305 if (!psArrayLength(output)) { 306 psTrace("caltool", PS_LOG_INFO, "no rows found"); 307 psFree(output); 308 return true; 309 } 310 311 bool simple = false; 312 { 313 bool status = false; 314 simple = psMetadataLookupBool(&status, config->args, "-simple"); 315 if (!status) { 316 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 317 return false; 318 } 319 } 320 321 if (psArrayLength(output)) { 322 if (!convertIdToStr(output)) { 323 psError(PS_ERR_UNKNOWN, false, "failed to convert id fields into a strings"); 324 psFree(output); 325 return false; 326 } 327 328 // negative simple so the default is true 329 if (!ippdbPrintMetadatas(stdout, output, "calRun", !simple)) { 330 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 331 psFree(output); 332 return false; 333 } 334 } 335 336 psFree(output); 337 338 return true; 339 } -
trunk/ippTools/src/caltoolConfig.c
r15545 r15570 50 50 psMetadata *adddbArgs = psMetadataAlloc(); 51 51 psMetadataAddStr(adddbArgs, PS_LIST_TAIL, "-dvodb", 0, 52 "define DVO db ", NULL);52 "define DVO db (required)", NULL); 53 53 54 54 // -dbs … … 62 62 psMetadata *addrunArgs = psMetadataAlloc(); 63 63 psMetadataAddStr(addrunArgs, PS_LIST_TAIL, "-cal_id", 0, 64 "define calibration DB ID", NULL); 65 psMetadataAddF64(addrunArgs, PS_LIST_TAIL, "-user_1", 0, 66 "define user statistic (1)", NAN); 67 psMetadataAddF64(addrunArgs, PS_LIST_TAIL, "-user_2", 0, 68 "define user statistic (2)", NAN); 69 psMetadataAddF64(addrunArgs, PS_LIST_TAIL, "-user_3", 0, 70 "define user statistic (3)", NAN); 71 psMetadataAddF64(addrunArgs, PS_LIST_TAIL, "-user_4", 0, 72 "define user statistic (4)", NAN); 73 psMetadataAddF64(addrunArgs, PS_LIST_TAIL, "-user_5", 0, 74 "define user statistic (5)", NAN); 75 psMetadataAddS16(addrunArgs, PS_LIST_TAIL, "-code", 0, 76 "set fault code", 0); 64 "define calibration DB ID (required)", NULL); 65 psMetadataAddStr(addrunArgs, PS_LIST_TAIL, "-region", 0, 66 "define region (required)", NULL); 67 psMetadataAddStr(addrunArgs, PS_LIST_TAIL, "-last_step", 0, 68 "define last step (required)", NULL); 69 psMetadataAddStr(addrunArgs, PS_LIST_TAIL, "-state", 0, 70 "define state (required)", NULL); 77 71 78 72 // -runs
Note:
See TracChangeset
for help on using the changeset viewer.
