Changeset 31030
- Timestamp:
- Mar 23, 2011, 4:27:17 PM (15 years ago)
- Location:
- trunk/ippToPsps/src
- Files:
-
- 2 added
- 15 edited
-
Batch.c (modified) (8 diffs)
-
Batch.h (modified) (5 diffs)
-
DetectionBatch.c (modified) (12 diffs)
-
DetectionBatch.h (modified) (1 diff)
-
Fits.c (modified) (18 diffs)
-
Fits.h (modified) (3 diffs)
-
FitsGenerator.c (modified) (23 diffs)
-
FitsGenerator.h (modified) (3 diffs)
-
InitBatch.c (modified) (4 diffs)
-
InitBatch.h (modified) (1 diff)
-
InitData.c (modified) (6 diffs)
-
InitData.h (modified) (3 diffs)
-
Logger.c (added)
-
Logger.h (added)
-
Makefile.am (modified) (3 diffs)
-
StackBatch.c (modified) (7 diffs)
-
StackBatch.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/Batch.c
r31025 r31030 63 63 if (this->exitCode != PS_EXIT_SUCCESS) { 64 64 65 psError(PS_ERR_UNKNOWN, false, "Failed, so deleting fits file");65 this->logger->print(this->logger, MSG_ERROR, "Batch: Failed, so deleting fits file\n"); 66 66 this->fitsOut->delete(this->fitsOut); 67 67 } … … 105 105 if (file == NULL) { 106 106 107 psError(PS_ERR_UNKNOWN, false, "Unable to open file at %s", this->fitsInPath);107 this->logger->print(this->logger, MSG_ERROR, "Batch: Unable to open file at %s\n", this->fitsInPath); 108 108 return false; 109 109 } … … 113 113 while (fgets(line, 1000, file) != NULL) this->numOfInputFiles++; 114 114 115 printf ("Number of input files %d\n", this->numOfInputFiles);115 this->logger->print(this->logger, MSG_INFO, "Batch: %d input files found\n", this->numOfInputFiles); 116 116 117 117 if (this->numOfInputFiles < 1) return false; … … 156 156 if (!this->pmconfig) { 157 157 158 psError(PS_ERR_UNKNOWN, false, "Unable to read configuration.");158 this->logger->print(this->logger, MSG_ERROR, "Batch: Unable to read configuration\n"); 159 159 this->exitCode = PS_EXIT_CONFIG_ERROR; 160 160 return false; … … 220 220 221 221 // create an InitData object and get survey ID 222 this->initData = new_InitData(configsBaseDir );222 this->initData = new_InitData(configsBaseDir, this->logger); 223 223 if (strlen(this->surveyType) > 0 && 224 224 !this->initData->getSurveyId(this->initData, this->surveyType, &this->surveyID)) { … … 230 230 // create a FitsGenerator object 231 231 strcat(configsBaseDir, configsDir); 232 this->fitsGenerator = new_FitsGenerator( configsBaseDir);232 this->fitsGenerator = new_FitsGenerator(this->logger, configsBaseDir); 233 233 234 234 // create full FITS out path … … 236 236 237 237 // create an output FITS file 238 this->fitsOut = new_Fits(fitsOutPath );238 this->fitsOut = new_Fits(fitsOutPath, this->logger); 239 239 if (this->fitsOut->getFilePtr(this->fitsOut) == NULL) return false; 240 240 … … 306 306 Constructor. Takes a Batch object and initialises it. 307 307 */ 308 bool new_Batch(Batch *this) { 309 308 bool new_Batch(Logger* logger, Batch *this) { 309 310 this->logger = logger; 310 311 this->surveyID = -1; 311 312 this->resultsXmlDoc = NULL; -
trunk/ippToPsps/src/Batch.h
r31025 r31030 1 /** @file ippToPsps.h1 /** @file Batch.h 2 2 * 3 3 * @brief Batch … … 6 6 * 7 7 * @author IfA 8 * Copyright 20 09Institute for Astronomy, University of Hawaii8 * Copyright 2011 Institute for Astronomy, University of Hawaii 9 9 */ 10 10 … … 21 21 #include "Fits.h" 22 22 #include "InitData.h" 23 #include "Logger.h" 23 24 24 25 /** … … 49 50 int exitCode; // ps exit code 50 51 bool testMode; // test mode boolean 52 Logger* logger; // Logger object 51 53 52 54 // methods … … 66 68 67 69 // public functions 68 bool new_Batch( Batch *this);70 bool new_Batch(Logger* logger, Batch *this); 69 71 70 72 void ippToPsps_VersionPrint(void); -
trunk/ippToPsps/src/DetectionBatch.c
r31025 r31030 47 47 48 48 // open input FITS file 49 Fits* fitsIn = existing_Fits(this->base.inputFiles[0] );49 Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger); 50 50 if (fitsIn->getFilePtr(fitsIn) == NULL) return PS_EXIT_SYS_ERROR; 51 51 … … 157 157 } 158 158 159 this->base.logger->print(this->base.logger, MSG_INFO, 160 "+-----------+---------+----------+----------------+--------------+--------------+\n"); 161 this->base.logger->print(this->base.logger, MSG_INFO, 162 "| Extension | Rows in | Rows out | Duplicate IDs | Invalid Flux | Bogus det ID |\n"); 163 159 164 // loop round chips 160 165 for (int x=startX; x<stopX; x++) { … … 190 195 skylist = dvoSkyListByExternID(this->base.dvoConfig, sourceId, imageId, &image); 191 196 if (skylist == NULL) { 192 psError(PS_ERR_IO, false,197 this->base.logger->print(this->base.logger, MSG_ERROR, 193 198 "DVO: can't find SkyList for sourceId='%d' imageId='%d' (CCD = XY%s): skipping this chip\n", 194 199 sourceId, imageId, ccdNumber); … … 205 210 if (numDvoDetections > this->MAXDETECT ) { 206 211 207 psError(PS_ERR_IO, false, "Number of detections (%d) exceeds max limit (%ld)\n",212 this->base.logger->print(this->base.logger, MSG_ERROR,"Number of detections (%d) exceeds max limit (%ld)\n", 208 213 numDvoDetections, this->MAXDETECT); 209 214 error = true; … … 370 375 } 371 376 372 psLogMsg("ippToPsps", PS_LOG_INFO, 373 "+-----------+---------+----------+----------------+--------------+--------------+\n" 374 "| Extension | Rows in | Rows out | Duplicate IDs | Invalid Flux | Bogus det ID |\n" 377 this->base.logger->print(this->base.logger, MSG_INFO, 375 378 "| %s | %5ld | %5d | %5d | %5d | %5d |\n", 376 379 extensionName, nChipDetectionsIn, nChipDetectionsOut, numOfDuplicates, numInvalidFlux, numOfInvalidIppIDet); … … 385 388 } 386 389 387 psLogMsg("ippToPsps", PS_LOG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut); 390 this->base.logger->print(this->base.logger, MSG_INFO, 391 "+-----------+---------+----------+----------------+--------------+--------------+\n"); 392 393 this->base.logger->print(this->base.logger, MSG_INFO, "Total detections for this exposure = %ld\n", totalDetectionsOut); 388 394 389 395 // free-up memory … … 419 425 writeResults(this, minObjID, maxObjID, totalDetectionsOut); 420 426 421 psLogMsg("ippToPsps", PS_LOG_INFO, "Data written for a total of %d chips/OTAs", nOta);427 this->base.logger->print(this->base.logger, MSG_INFO, "Data written for a total of %d chips/OTAs", nOta); 422 428 423 429 if (error || nOta < 1) this->base.exitCode = PS_EXIT_DATA_ERROR; … … 481 487 !haveExpName) { 482 488 483 printf("\n* ERROR with supplied arguments:");489 this->base.logger->print(this->base.logger, MSG_ERROR, "Problem with supplied arguments\n"); 484 490 this->print(this); 485 491 this->base.exitCode = PS_EXIT_CONFIG_ERROR; … … 493 499 Constructor. Returns a new DetectionBatch object. 494 500 */ 495 DetectionBatch* new_DetectionBatch(int *argc, char **argv) { 496 501 DetectionBatch* new_DetectionBatch(Logger* logger, int *argc, char **argv) { 502 503 logger->print(logger, MSG_DEBUG, "DetectionBatch: Constructor\n"); 497 504 DetectionBatch *this = (DetectionBatch*)calloc(1, sizeof(DetectionBatch)); 498 505 499 506 // call base-class constructor 500 if (!new_Batch(&this->base)) { 501 502 psError(PS_ERR_IO, false, "Unable to create Batch base-class object"); 503 return this; 504 } 507 new_Batch(logger, &this->base); 505 508 506 509 this->MAXDETECT = 200000; … … 525 528 psTimerStart("detectionbatch"); 526 529 527 ippToPsps_VersionPrint();530 // ippToPsps_VersionPrint(); 528 531 529 532 int exitCode; 530 533 531 DetectionBatch* detectionBatch = new_DetectionBatch(&argc, argv); 534 Logger* logger = new_Logger(NULL); 535 536 DetectionBatch* detectionBatch = new_DetectionBatch(logger, &argc, argv); 532 537 detectionBatch->base.run(detectionBatch); 533 538 exitCode = detectionBatch->base.exitCode; … … 537 542 double secs = psTimerMark("detectionbatch"); 538 543 539 psLogMsg("detectionbatch", 3, "detectionbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",544 logger->print(logger, MSG_INFO, "detectionbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n", 540 545 (exitCode == PS_EXIT_SUCCESS) ? "" : "un", 541 546 exitCode, … … 546 551 psTimerStop(); 547 552 psLibFinalize(); 553 logger->destroy(logger); 548 554 549 555 return exitCode; -
trunk/ippToPsps/src/DetectionBatch.h
r30190 r31030 31 31 } DetectionBatch; 32 32 33 DetectionBatch *new_DetectionBatch( int *argc, char **argv);33 DetectionBatch *new_DetectionBatch(Logger* logger, int *argc, char **argv); 34 34 35 35 # endif // IPPTOPSPS_DETECTIONBATCH_H -
trunk/ippToPsps/src/Fits.c
r31016 r31030 26 26 if (!strncmp(typename, "TSTRING", 7)) return TSTRING; 27 27 28 psError(PS_ERR_IO, false, "*Fits: Don't understand data type '%s'", typename);28 // this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand data type '%s'", typename); 29 29 30 30 return 0; … … 36 36 static void destroy(Fits* this) { 37 37 38 this->logger->print(this->logger, MSG_DEBUG, "Fits: Destructor\n"); 39 38 40 int status = 0; 39 41 if (fits_close_file(this->file, &status)) { 40 42 41 psError(PS_ERR_IO, false, "* Fits: Unable to close FITS file");43 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to close FITS file '%s'\n", this->path); 42 44 fits_report_error(stderr, status); 43 45 } 44 46 else 45 psLogMsg("ippToPsps", PS_LOG_INFO, "* Fits: Closed '%s'", this->path); 47 this->logger->print(this->logger, MSG_INFO, "Fits: Closed FITS file '%s'\n", this->path); 48 49 free(this); 46 50 } 47 51 … … 56 60 if (status) { 57 61 58 psError(PS_ERR_IO, false, "* Fits: Could not get value for header key '%s'\n", name);62 this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get value for header key '%s' from file at '%s'\n", name, this->path); 59 63 return false; 60 64 } … … 82 86 if (status) { 83 87 84 psError(PS_ERR_IO, false, "* Fits: Failed to read vector column %d row %ld", col, row);88 this->logger->print(this->logger, MSG_ERROR, "Fits: Failed to read vector column %d row %ld\n", col, row); 85 89 return false; 86 90 } … … 98 102 if (status) { 99 103 100 psError(PS_ERR_IO, false, "*Fits: Could not get column number for '%s'\n", name);104 this->logger->print(this->logger, MSG_ERROR, "Fits: Could not get column number for '%s'\n", name); 101 105 return false; 102 106 } … … 119 123 if (status) { 120 124 121 psError(PS_ERR_IO, false, "* Fits: Unable to read col '%s'", name);125 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read col '%s'\n", name); 122 126 return false; 123 127 } … … 127 131 if (status) { 128 132 129 psError(PS_ERR_IO, false, "* Fits: Unable to read type info for '%s'", name);133 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read type info for '%s'\n", name); 130 134 return false; 131 135 } … … 143 147 if (fits_movnam_hdu(this->file, type, name, 0, &status)) { 144 148 145 psError(PS_ERR_IO, false, "* Fits: Can't move to table extension named '%s'\n", name); 149 this->logger->print(this->logger, MSG_ERROR, "Fits: Can't move to table extension named '%s'\n", name); 150 return false; 146 151 } 147 152 … … 173 178 if (fits_get_num_rows(this->file, count, &status)) { 174 179 175 psError(PS_ERR_IO, false, "*Fits: Count not count rows in this table\n");180 this->logger->print(this->logger, MSG_ERROR, "Fits: Count not count rows in this table\n"); 176 181 return false; 177 182 } … … 196 201 if (remove(this->path) == -1) { 197 202 198 psError(PS_ERR_UNKNOWN, false, "* Fits: Unable to delete '%s'", this->path); 199 return false; 200 } 203 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete '%s'\n", this->path); 204 return false; 205 } 206 207 this->logger->print(this->logger, MSG_INFO, "Fits: Deleted FITS file at '%s'\n", this->path); 201 208 202 209 return true; … … 228 235 if (status) { 229 236 230 psError(PS_ERR_IO, false, "* Fits: Unable to delet rows using rowlist\n");237 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to delete rows using rowlist\n"); 231 238 return false; 232 239 } … … 283 290 else { 284 291 285 psError(PS_ERR_IO, false, "* Fits: Don't support datatype '%d' yet\n", datatype);286 return false; 287 } 288 289 if (status) { 290 291 psError(PS_ERR_IO, false, "*Fits: Unable to read column data from column %d\n", colnum);292 this->logger->print(this->logger, MSG_ERROR, "Fits: Don't understand datatype '%d'\n", datatype); 293 return false; 294 } 295 296 if (status) { 297 298 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to read column data from column %d\n", colnum); 292 299 return false; 293 300 … … 331 338 if (status) { 332 339 333 psError(PS_ERR_IO, false, "*Fits: Unable to write column data for column %d\n", colnum);340 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to write column data for column %d\n", colnum); 334 341 return false; 335 342 … … 355 362 if (status) { 356 363 357 psError(PS_ERR_IO,"* Fits: Unable to create table: '%s'", name);364 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create table: '%s'\n", name); 358 365 return false; 359 366 } … … 366 373 Initilization common to all constructors 367 374 */ 368 static void init(Fits* this) { 375 static Fits* init(const char* path, Logger* logger) { 376 377 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 378 379 // fields 380 strcpy(this->path, path); 381 this->logger = logger; 369 382 370 383 // method pointers … … 390 403 assert(this); 391 404 405 return this; 392 406 } 393 407 … … 398 412 399 413 */ 400 Fits* existing_Fits(char* path) { 401 402 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 403 404 int status = 0; 405 strcpy(this->path, path); 406 407 if (fits_open_file(&this->file, this->path, READONLY, &status)) { 408 409 psError(PS_ERR_IO, false, "* Fits: Unable to open FITS file here %s\n", path); 414 Fits* existing_Fits(const char* path, Logger* logger) { 415 416 Fits* this = init(path, logger); 417 this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for existing file at '%s'\n", path); 418 419 int status = 0; 420 if (fits_open_file(&this->file, path, READONLY, &status)) { 421 422 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to open FITS file here %s\n", path); 410 423 this->file = NULL; 411 424 } 412 425 413 init(this);414 426 415 427 return this; … … 421 433 Returns a new Fits object representing a new FITS file. 422 434 */ 423 Fits* new_Fits(char* path) { 424 425 Fits* this = (Fits*)calloc(1, sizeof(Fits)); 426 427 int status = 0; 428 strcpy(this->path, path); 429 430 if (fits_create_file(&this->file, this->path, &status)) { 431 432 psError(PS_ERR_IO, false, "* Fits: Unable to create file here '%s'", path); 435 Fits* new_Fits(const char* path, Logger* logger) { 436 437 Fits* this = init(path, logger); 438 this->logger->print(this->logger, MSG_DEBUG, "Fits: Constructor for new file at '%s'\n", path); 439 440 int status = 0; 441 if (fits_create_file(&this->file, path, &status)) { 442 443 this->logger->print(this->logger, MSG_ERROR, "Fits: Unable to create FITS file here '%s'\n", path); 433 444 this->file = NULL; 434 445 } 435 446 436 init(this);437 438 447 return this; 439 448 } -
trunk/ippToPsps/src/Fits.h
r31025 r31030 14 14 #include <psmodules.h> 15 15 16 #include "Logger.h" 17 16 18 /** 17 19 … … 24 26 fitsfile* file; // cfitsio file pointer 25 27 char path[1000]; // FITS path 28 Logger* logger; // logger object 26 29 27 30 // accessor methods … … 53 56 54 57 // constructors 55 Fits* existing_Fits(c har* path);56 Fits* new_Fits(c har* path);58 Fits* existing_Fits(const char* path, Logger* logger); 59 Fits* new_Fits(const char* path, Logger* logger); 57 60 58 61 // non-class methods -
trunk/ippToPsps/src/FitsGenerator.c
r31025 r31030 17 17 Finds a column within this table 18 18 */ 19 static Column* findColumn( Table* table, const char* name) {19 static Column* findColumn(FitsGenerator* this, Table* table, const char* name) { 20 20 21 21 Column* column = NULL; … … 29 29 } 30 30 31 if (!column) psError(PS_ERR_IO, false, "Could not find column '%s' in table '%s'", name, table->name);31 if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name); 32 32 33 33 return column; … … 49 49 } 50 50 51 if (!table) psError(PS_ERR_IO, false, "Could not find table '%s'", name);51 if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name); 52 52 53 53 return table; … … 214 214 opens an XML file and returns the document 215 215 */ 216 static xmlDoc* openXmlFile( const char* path) {216 static xmlDoc* openXmlFile(FitsGenerator* this, const char* path) { 217 217 218 218 xmlDoc* doc = xmlReadFile(path, NULL, 0); 219 if (doc == NULL) psError(PS_ERR_IO, false, "Unable to open XML file at %s", path);219 if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path); 220 220 return doc; 221 221 } … … 235 235 Populates the provided table with data from XML 236 236 */ 237 static bool populateTable( Table* table, xmlNode* rootElement, Fits *fitsOut) {237 static bool populateTable(FitsGenerator* this, Table* table, xmlNode* rootElement, Fits *fitsOut) { 238 238 239 239 char tempStr[100]; … … 253 253 if(!tableNode) { 254 254 255 psError(PS_ERR_IO,"Could not find table: %s", table->name);255 this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name); 256 256 return false; 257 257 } … … 320 320 321 321 } 322 if (status) psError(PS_ERR_IO, false, "Unable to write value of %s to column %s in table %s",322 if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n", 323 323 tempStr, table->columns[i].pspsName, table->name); 324 324 } … … 339 339 Loads a table description from XML 340 340 */ 341 static bool loadTableDescription( Table* table, xmlNode* tableNode) {341 static bool loadTableDescription(FitsGenerator* this, Table* table, xmlNode* tableNode) { 342 342 343 343 bool ret = true; … … 391 391 if (columnNum < 1) { 392 392 393 psError(PS_ERR_IO, false, "Found no columns for table '%s'", tableName);393 this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName); 394 394 ret = false; 395 395 } 396 396 397 397 if (columnNum != table->numOfColumns) 398 psError(PS_ERR_IO, false, "Mismatch between number of columns expected (%d) and those found (%d)", table->numOfColumns, columnNum);398 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum); 399 399 400 400 return ret; … … 411 411 psStringAppend(&path, "%s/tables.xml", this->configsPath); 412 412 413 xmlDoc* doc = openXmlFile( path);413 xmlDoc* doc = openXmlFile(this, path); 414 414 415 415 if (doc == NULL) { … … 424 424 if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) { 425 425 426 psError(PS_ERR_IO, false, "Root node of XML is not 'tableDescriptions', as it should be");426 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n"); 427 427 return false; 428 428 } … … 445 445 table = this->tables+tableNum; 446 446 447 if (!loadTableDescription(t able, node)) ret = false;447 if (!loadTableDescription(this, table, node)) ret = false; 448 448 else tableNum++; 449 449 } … … 452 452 453 453 if (tableNum != this->numOfTables) 454 psError(PS_ERR_IO, false, "Mismatch between number of tables expected (%d) and those found (%d)", this->numOfTables, tableNum);454 this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum); 455 455 456 456 closeXmlFile(doc); … … 486 486 // column type 487 487 getAttribute(node, "pspsName", buffer); 488 column = findColumn(t able, buffer);488 column = findColumn(this, table, buffer); 489 489 490 490 if (!column) continue; … … 518 518 psStringAppend(&path, "%s/map.xml", this->configsPath); 519 519 520 xmlDoc* doc = openXmlFile( path);520 xmlDoc* doc = openXmlFile(this, path); 521 521 522 522 if (doc == NULL) { … … 529 529 530 530 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 531 psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");531 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 532 532 return false; 533 533 } … … 560 560 psStringAppend(&path, "%s/data.xml", this->configsPath); 561 561 562 xmlDoc* doc = openXmlFile( path);562 xmlDoc* doc = openXmlFile(this, path); 563 563 564 564 if (doc == NULL) { … … 571 571 572 572 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 573 psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");573 this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n"); 574 574 return false; 575 575 } 576 576 577 577 for (uint32_t i=0; i<this->numOfTables; i++) { 578 if (!populateTable(this ->tables+i, rootElement, fitsOut)) {578 if (!populateTable(this, this->tables+i, rootElement, fitsOut)) { 579 579 ret = false; 580 580 } … … 590 590 */ 591 591 static bool populateTableFromFits( 592 FitsGenerator* this, 592 593 Table* table, 593 594 Fits *fitsIn, … … 678 679 679 680 default: 680 psError(PS_ERR_IO, false, "Don't know IPP type (%d) for mapping from '%d' '%s' to '%s'", table->columns[i].ippType,681 this->logger->print(this->logger, MSG_ERROR, "Don't know IPP type (%d) for mapping from '%d' '%s' to '%s'\n", table->columns[i].ippType, 681 682 table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName); 682 683 break; … … 711 712 712 713 if(!createTable(table, fitsOut, nRows)) return false; 713 return populateTableFromFits(t able, fitsIn, fitsOut, nRows, fromHeader);714 return populateTableFromFits(this, table, fitsIn, fitsOut, nRows, fromHeader); 714 715 } 715 716 … … 733 734 Constructor. 734 735 */ 735 FitsGenerator* new_FitsGenerator( const char* path) {736 FitsGenerator* new_FitsGenerator(Logger* logger, const char* path) { 736 737 737 738 FitsGenerator* this = (FitsGenerator*)calloc(1, sizeof(FitsGenerator)); … … 739 740 this->configsPath = NULL; 740 741 psStringAppend(&this->configsPath, path); 742 this->logger = logger; 741 743 742 744 // method pointers -
trunk/ippToPsps/src/FitsGenerator.h
r31025 r31030 13 13 14 14 #include <psmodules.h> 15 16 #include "Logger.h" 15 17 16 18 // column class … … 53 55 Table* tables; 54 56 int numOfTables; 57 Logger* logger; 55 58 56 59 // methods … … 64 67 65 68 // constructor 66 FitsGenerator* new_FitsGenerator( const char* path);69 FitsGenerator* new_FitsGenerator(Logger* logger, const char* path); 67 70 68 71 #endif // IPPTOPSPS_FITSGENERATOR_H -
trunk/ippToPsps/src/InitBatch.c
r31025 r31030 57 57 Constructor 58 58 */ 59 InitBatch* new_InitBatch( int *argc, char **argv) {59 InitBatch* new_InitBatch(Logger* logger, int *argc, char **argv) { 60 60 61 logger->print(logger, MSG_DEBUG, "InitBatch: Constructor\n"); 61 62 InitBatch *this = (InitBatch*)calloc(1, sizeof(InitBatch)); 62 63 63 64 // call base-class constructor 64 if (!new_Batch(&this->base)) { 65 66 psError(PS_ERR_IO, false, "Unable to create Batch base-class object"); 67 return this; 68 } 65 new_Batch(logger, &this->base); 69 66 70 67 // method pointers … … 85 82 psTimerStart("initbatch"); 86 83 87 ippToPsps_VersionPrint();84 // ippToPsps_VersionPrint(); 88 85 89 86 int exitCode; 90 87 91 InitBatch* initBatch = new_InitBatch(&argc, argv); 88 Logger* logger = new_Logger(NULL); 89 90 InitBatch* initBatch = new_InitBatch(logger, &argc, argv); 92 91 initBatch->base.run(initBatch); 93 92 exitCode = initBatch->base.exitCode; … … 97 96 double secs = psTimerMark("initbatch"); 98 97 99 psLogMsg("initbatch", 3, "initbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",98 logger->print(logger, MSG_INFO, "initbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n", 100 99 (exitCode == PS_EXIT_SUCCESS) ? "" : "un", 101 100 exitCode, … … 106 105 psTimerStop(); 107 106 psLibFinalize(); 107 logger->destroy(logger); 108 108 109 109 return exitCode; -
trunk/ippToPsps/src/InitBatch.h
r31011 r31030 31 31 32 32 // constructor 33 InitBatch *new_InitBatch( int *argc, char **argv);33 InitBatch *new_InitBatch(Logger *logger, int *argc, char **argv); 34 34 35 35 # endif // IPPTOPSPS_INITBATCH_H -
trunk/ippToPsps/src/InitData.c
r31015 r31030 28 28 */ 29 29 static bool getRowAttribute( 30 InitData* this, 30 31 xmlNode* tableNode, 31 32 const char* keyName, … … 58 59 } 59 60 60 psError(PS_ERR_UNKNOWN, 61 false, 62 "* InitData: Could not find value for '%s' for '%s' with value '%s'", 61 this->logger->print(this->logger, MSG_ERROR, 62 "InitData: Could not find value for '%s' for '%s' with value '%s'\n", 63 63 attName, keyName, keyValue); 64 64 … … 83 83 84 84 if (strcmp((const char*)rootElement->name, "tabledata")!=0) { 85 psError(PS_ERR_IO, false, "* InitData: Root node of XML is not 'tabledata', as it should be"); 85 this->logger->print(this->logger, MSG_ERROR, 86 "InitData: Root node of XML is not 'tabledata', as it should be\n"); 86 87 return false; 87 88 } … … 98 99 if (strcmp(tempStr, tableName)!=0) continue; 99 100 100 ret = getRowAttribute( node, keyName, keyValue, attName, attValue);101 ret = getRowAttribute(this, node, keyName, keyValue, attName, attValue); 101 102 break; 102 103 } … … 155 156 } 156 157 157 psLogMsg("ippToPsps", PS_LOG_INFO, "* InitData: destructor");158 this->logger->print(this->logger, MSG_DEBUG, "InitData: destructor\n"); 158 159 159 160 free(this); … … 163 164 Constructor. 164 165 */ 165 InitData* new_InitData(const char* path ) {166 InitData* new_InitData(const char* path, Logger* logger) { 166 167 167 psLogMsg("ippToPsps", PS_LOG_INFO, "* InitData: constructor"); 168 168 169 169 170 InitData* this = (InitData*)calloc(1, sizeof(InitData)); 171 this->logger = logger; 172 173 this->logger->print(this->logger, MSG_DEBUG, "InitData: Constructor\n"); 170 174 171 175 sprintf(this->path, "%s/init/data.xml", path); 172 176 173 177 this->doc = xmlReadFile(this->path, NULL, 0); 174 if (this->doc == NULL) psError(PS_ERR_IO, false, "* InitData: Unable to open XML file at %s", this->path); 178 this->logger->print(this->logger, MSG_ERROR, 179 "InitData: Unable to open XML file at %s\n", this->path); 175 180 176 181 // method pointers -
trunk/ippToPsps/src/InitData.h
r31015 r31030 17 17 #include <psmodules.h> 18 18 19 #include "Logger.h" 20 19 21 /** 20 22 … … 27 29 char path[1000]; 28 30 xmlDoc* doc; 31 Logger* logger; 29 32 30 33 // methods … … 38 41 39 42 // constructor 40 InitData* new_InitData(const char* path );43 InitData* new_InitData(const char* path, Logger* logger); 41 44 42 45 #endif // IPPTOPSPS_INITDATA_H -
trunk/ippToPsps/src/Makefile.am
r31025 r31030 33 33 Fits.c \ 34 34 InitData.c \ 35 Logger.c \ 35 36 FitsGenerator.c 36 37 … … 44 45 Fits.c \ 45 46 InitData.c \ 47 Logger.c \ 46 48 FitsGenerator.c 47 49 … … 55 57 Fits.c \ 56 58 InitData.c \ 59 Logger.c \ 57 60 FitsGenerator.c 58 61 -
trunk/ippToPsps/src/StackBatch.c
r31025 r31030 62 62 long unmatched = 0, totalDetections = 0, numOfDuplicates = 0, numInvalidFlux = 0, numDetectionsOut = 0; 63 63 64 this->base.logger->print(this->base.logger, MSG_INFO, 65 "+---------------+---------+----------+------------------+---------------+--------------+\n"); 66 this->base.logger->print(this->base.logger, MSG_INFO, 67 "| Extension | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n"); 68 64 69 for (long s=0; s<nDet; s++) { 65 70 … … 102 107 103 108 } 104 psLogMsg("ippToPsps", PS_LOG_INFO, 105 "+---------------+---------+----------+------------------+---------------+--------------+\n" 106 "| Extension | Rows in | Rows out | Missing from DVO | Duplicate IDs | Invalid Flux |\n" 109 110 this->base.logger->print(this->base.logger, MSG_INFO, 107 111 "| %12s | %5ld | %5ld | %5ld | %5ld | %5ld |\n", 108 112 extensionName, nDet, numDetectionsOut, unmatched, numOfDuplicates, numInvalidFlux); 113 this->base.logger->print(this->base.logger, MSG_INFO, 114 "+---------------+---------+----------+------------------+---------------+--------------+\n"); 109 115 110 116 … … 315 321 316 322 // open input FITS file 317 Fits* fitsIn = existing_Fits(this->base.inputFiles[0] );323 Fits* fitsIn = existing_Fits(this->base.inputFiles[0], this->base.logger); 318 324 if (fitsIn->getFilePtr(fitsIn) == NULL) return PS_EXIT_SYS_ERROR; 319 325 … … 425 431 Constructor 426 432 */ 427 StackBatch* new_StackBatch(int *argc, char **argv) { 428 433 StackBatch* new_StackBatch(Logger* logger, int *argc, char **argv) { 434 435 logger->print(logger, MSG_DEBUG, "StackBatch: Constructor\n"); 429 436 StackBatch *this = (StackBatch*)calloc(1, sizeof(StackBatch)); 430 437 431 438 // call base-class constructor 432 if (!new_Batch(&this->base)) { 433 434 psError(PS_ERR_IO, false, "Unable to create Batch base-class object"); 435 return this; 436 } 439 new_Batch(logger, &this->base); 437 440 438 441 this->MAXDETECT = 150000; … … 455 458 psTimerStart("stackbatch"); 456 459 457 ippToPsps_VersionPrint();460 // ippToPsps_VersionPrint(); 458 461 459 462 int exitCode; 460 463 461 StackBatch* stackBatch = new_StackBatch(&argc, argv); 464 Logger* logger = new_Logger(NULL); 465 466 StackBatch* stackBatch = new_StackBatch(logger, &argc, argv); 462 467 stackBatch->base.run(stackBatch); 463 468 exitCode = stackBatch->base.exitCode; … … 467 472 double secs = psTimerMark("stackbatch"); 468 473 469 psLogMsg("stackbatch", 3, "stackbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n",474 logger->print(logger, MSG_INFO, "stackbatch completed %ssuccessfully, with exit code %d, in %.1f %s\n", 470 475 (exitCode == PS_EXIT_SUCCESS) ? "" : "un", 471 476 exitCode, … … 476 481 psTimerStop(); 477 482 psLibFinalize(); 483 logger->destroy(logger); 478 484 479 485 return exitCode; -
trunk/ippToPsps/src/StackBatch.h
r30147 r31030 30 30 } StackBatch; 31 31 32 StackBatch *new_StackBatch( int *argc, char **argv);32 StackBatch *new_StackBatch(Logger* logger, int *argc, char **argv); 33 33 34 34 # endif // IPPTOPSPS_STACKBATCH_H
Note:
See TracChangeset
for help on using the changeset viewer.
