IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 24, 2011, 11:03:32 AM (15 years ago)
Author:
rhenders
Message:

Changes to reflect those in Logger class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/src/FitsGenerator.c

    r31030 r31033  
    2929    }
    3030
    31     if (!column) this->logger->print(this->logger, MSG_ERROR, "Could not find column '%s' in table '%s'\n", name, table->name);
     31    if (!column) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     32            "Could not find column '%s' in table '%s'\n", name, table->name);
    3233
    3334    return column;
     
    4950    }
    5051
    51     if (!table) this->logger->print(this->logger, MSG_ERROR, "Could not find table '%s'\n", name);
     52    if (!table) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     53            "Could not find table '%s'\n", name);
    5254
    5355    return table;
     
    217219
    218220    xmlDoc* doc = xmlReadFile(path, NULL, 0);
    219     if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "Unable to open XML file at %s\n", path);
     221    if (doc == NULL) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     222            "Unable to open XML file at %s\n", path);
    220223    return doc;
    221224}
     
    253256    if(!tableNode) {
    254257
    255         this->logger->print(this->logger, MSG_ERROR, "Could not find table: %s\n", table->name);
     258        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     259                "Could not find table: %s\n", table->name);
    256260        return false;
    257261    }
     
    320324
    321325            }
    322             if (status) this->logger->print(this->logger, MSG_ERROR, "Unable to write value of %s to column %s in table %s\n",
     326            if (status) this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     327                    "Unable to write value of %s to column %s in table %s\n",
    323328                    tempStr, table->columns[i].pspsName, table->name);
    324329        }
     
    391396    if (columnNum < 1) {
    392397
    393         this->logger->print(this->logger, MSG_ERROR, "Found no columns for table '%s'\n", tableName);
     398        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     399                "Found no columns for table '%s'\n", tableName);
    394400        ret = false;
    395401    }
    396402
    397403    if (columnNum != table->numOfColumns)
    398         this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of columns expected (%d) and those found (%d)\n", table->numOfColumns, columnNum);
     404        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     405                "Mismatch between number of columns expected (%d) and those found (%d)\n",
     406                table->numOfColumns, columnNum);
    399407
    400408    return ret;
     
    424432    if (strcmp((const char*)rootElement->name, "tableDescriptions")!=0) {
    425433
    426         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tableDescriptions', as it should be\n");
     434        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     435                "Root node of XML is not 'tableDescriptions', as it should be\n");
    427436        return false;
    428437    }
     
    452461
    453462    if (tableNum != this->numOfTables)
    454         this->logger->print(this->logger, MSG_ERROR, "Mismatch between number of tables expected (%d) and those found (%d)\n", this->numOfTables, tableNum);
     463        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     464                "Mismatch between number of tables expected (%d) and those found (%d)\n",
     465                this->numOfTables, tableNum);
    455466
    456467    closeXmlFile(doc);
     
    515526    bool ret = true;
    516527
     528    char path[1000];
     529    sprintf(path, "%s/map.xml", this->configsPath);
     530
     531    struct stat sts;
     532    if ((stat(path, &sts)) == -1) {
     533        this->logger->print(this->logger, MSG_INFO, "FitsGenerator",
     534                "No map file found at '%s'\n", path);
     535        return false;
     536    }
     537
     538    xmlDoc* doc = openXmlFile(this, path);
     539
     540    if (doc == NULL) {
     541       
     542        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 
     543                "Could not create XML document from '%s'\n", path);
     544        return false;
     545    }
     546
     547    this->logger->print(this->logger, MSG_INFO, "FitsGenerator",
     548            "Using map file at '%s'\n", path);
     549    xmlNode* rootElement = xmlDocGetRootElement(doc);
     550
     551    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
     552        this->logger->print(this->logger, MSG_ERROR,"FitsGenerator", 
     553                "Root node of XML is not 'tabledata', as it should be\n");
     554        return false;
     555    }
     556
     557    xmlNode* node = NULL;
     558
     559    // loop round all available tables
     560    for (node = rootElement->children; node; node = node->next) {
     561        if (node->type == XML_ELEMENT_NODE) {
     562
     563            if (strcmp((const char*)node->name, "table")==0) {
     564
     565                if (!loadTableMappings(this, node)) ret = false;
     566            }
     567        }
     568    }
     569
     570    closeXmlFile(doc);
     571
     572    return ret;
     573}
     574
     575/**
     576  Populate the provided table with data from XML
     577  */
     578static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
     579
     580    bool ret = true;
    517581    psString path = NULL;
    518     psStringAppend(&path, "%s/map.xml", this->configsPath);
     582    psStringAppend(&path, "%s/data.xml", this->configsPath);
    519583
    520584    xmlDoc* doc = openXmlFile(this, path);
     
    529593
    530594    if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    531         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
    532         return false;
    533     }
    534 
    535     xmlNode* node = NULL;
    536 
    537     // loop round all available tables
    538     for (node = rootElement->children; node; node = node->next) {
    539         if (node->type == XML_ELEMENT_NODE) {
    540 
    541             if (strcmp((const char*)node->name, "table")==0) {
    542 
    543                 if (!loadTableMappings(this, node)) ret = false;
    544             }
    545         }
    546     }
    547 
    548     closeXmlFile(doc);
    549 
    550     return ret;
    551 }
    552 
    553 /**
    554   Populate the provided table with data from XML
    555   */
    556 static bool populateFromFile(FitsGenerator* this, Fits *fitsOut) {
    557 
    558     bool ret = true;
    559     psString path = NULL;
    560     psStringAppend(&path, "%s/data.xml", this->configsPath);
    561 
    562     xmlDoc* doc = openXmlFile(this, path);
    563 
    564     if (doc == NULL) {
    565         psFree(path);
    566         return false;
    567     }
    568     psFree(path);
    569 
    570     xmlNode* rootElement = xmlDocGetRootElement(doc);
    571 
    572     if (strcmp((const char*)rootElement->name, "tabledata")!=0) {
    573         this->logger->print(this->logger, MSG_ERROR, "Root node of XML is not 'tabledata', as it should be\n");
     595        this->logger->print(this->logger, MSG_ERROR, "FitsGenerator",
     596                "Root node of XML is not 'tabledata', as it should be\n");
    574597        return false;
    575598    }
     
    679702
    680703                default:
    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,
     704                    this->logger->print(this->logger, MSG_ERROR, "FitsGenerator", "Don't know IPP type (%d) for mapping from  '%d'  '%s' to '%s'\n", table->columns[i].ippType,
    682705                            table->columns[i].ippColNum, table->columns[i].ippName, table->columns[i].pspsName);
    683706                    break;
Note: See TracChangeset for help on using the changeset viewer.