Changeset 31015
- Timestamp:
- Mar 23, 2011, 9:33:05 AM (15 years ago)
- Location:
- trunk/ippToPsps/src
- Files:
-
- 2 added
- 7 edited
-
Batch.c (modified) (6 diffs)
-
Batch.h (modified) (2 diffs)
-
Config.c (modified) (6 diffs)
-
Config.h (modified) (1 diff)
-
DetectionBatch.c (modified) (1 diff)
-
InitData.c (added)
-
InitData.h (added)
-
Makefile.am (modified) (3 diffs)
-
StackBatch.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/src/Batch.c
r31011 r31015 87 87 if (this->dvoConfig != NULL) dvoConfigFree(this->dvoConfig); 88 88 89 // destroy objects 89 90 this->config->destroy(this->config); 91 this->initData->destroy(this->initData); 90 92 91 93 pmConfigDone(); … … 210 212 } 211 213 212 213 214 // check we have some input paths 214 215 if (haveFitsInPath && !readInputFilePaths(this)) { 215 216 … … 218 219 } 219 220 220 // create a config object 221 // create an InitData object and get survey ID 222 this->initData = new_InitData(configsBaseDir); 223 if (strlen(this->surveyType) > 0 && 224 !this->initData->getSurveyId(this->initData, this->surveyType, &this->surveyID)) { 225 226 this->exitCode = PS_EXIT_CONFIG_ERROR; 227 return false; 228 } 229 230 // create a Config object 221 231 strcat(configsBaseDir, configsDir); 222 232 this->config = new_Config(configsBaseDir); … … 227 237 } 228 238 229 // get survey ID using config object230 if (strlen(this->surveyType) > 0 && !this->config->getSurveyId(this->config, this->surveyType, &this->surveyID)) {231 232 this->exitCode = PS_EXIT_CONFIG_ERROR;233 return false;234 }235 239 // create full FITS out path 236 sprintf (fitsOutPath, "%s/%s", fitsOutPath, fitsOutFile);240 sprintf(fitsOutPath, "%s/%s", fitsOutPath, fitsOutFile); 237 241 238 242 // create an output FITS file … … 321 325 // set up function pointers 322 326 this->parseArguments = parseArguments; 323 //this->init = init;324 327 this->print = print; 325 this->destroy = destroy;326 327 328 this->gotResultsPath = gotResultsPath; 328 329 this->gotFitsInPath = gotFitsInPath; … … 330 331 this->gotConfig = gotConfig; 331 332 this->gotSurveyType = gotSurveyType; 333 this->destroy = destroy; 332 334 333 335 assert(this); -
trunk/ippToPsps/src/Batch.h
r31011 r31015 12 12 #define IPPTOPSPS_BATCH_H 13 13 14 #include <psmodules.h>15 #include <dvo_util.h>16 #include "Config.h"17 14 #include <libxml/parser.h> 18 15 #include <libxml/tree.h> 19 16 17 #include <psmodules.h> 18 #include <dvo_util.h> 19 20 #include "Config.h" 20 21 #include "Fits.h" 22 #include "InitData.h" 21 23 22 24 /** … … 42 44 pmConfig* pmconfig; // pmConfig 43 45 dvoConfig* dvoConfig; // dvo database 44 Config* config; // config structure 46 Config* config; // Config object 47 InitData* initData; // InitData object 45 48 char todaysDate[20]; // today's date 46 49 int exitCode; // ps exit code -
trunk/ippToPsps/src/Config.c
r31011 r31015 15 15 16 16 /** 17 Gets PS type from string 17 Gets PS type from string TODO FITS types? should be in Fits class 18 18 */ 19 19 static int ippToPsps_GetDataType(char *typename) { … … 199 199 default: 200 200 break; 201 202 201 } 203 202 } … … 230 229 } 231 230 232 /**233 Searches through this table and finds attribute value for a provided key234 */235 static bool getRowAttribute(Config* this, xmlNode* tableNode,236 const char* keyName, const char* keyValue,237 const char* attName, char* attValue) {238 239 xmlNode* node = NULL;240 241 char buffer[100];242 243 // loop round all available rows for this table244 for (node = tableNode->children; node; node = node->next) {245 if (node->type == XML_ELEMENT_NODE) {246 //psLogMsg("ippToPsps", PS_LOG_INFO, "Node name '%s'", (const char*)node->name );247 248 if (strcmp((const char*)node->name, "row")==0) {249 //psLogMsg("ippToPsps", PS_LOG_INFO, " Looking for key '%s'", keyName );250 251 if (!getAttribute(node, keyName, buffer)) continue;252 //psLogMsg("ippToPsps", PS_LOG_INFO, "Found key '%s' value '%s'", keyName, buffer );253 254 if (strcmp(buffer, keyValue) != 0) continue;255 getAttribute(node, attName, attValue);256 //printf("FOUND %s %s %s %s \n", keyName, buffer, attName, attValue );257 return true;258 259 }260 }261 }262 263 psLogMsg("ippToPsps", PS_LOG_INFO, "Could not find value for '%s' for '%s' with value '%s'", attName, keyName, keyValue );264 return false;265 }266 267 231 /* 268 232 opens an XML file and returns the document … … 283 247 xmlCleanupParser(); 284 248 285 return true;286 }287 288 /**289 Gets a value from the 'init' data290 */291 static bool getInitValue(292 Config* this,293 const char* tableName,294 const char* keyName, const char* keyValue,295 const char* attName, char* attValue) {296 297 bool ret = true;298 299 psString path = NULL;300 psStringAppend(&path, "%s/../init/data.xml", this->configsPath); // TODO nasty301 302 xmlDoc* doc = openXmlFile(path);303 304 if (doc == NULL) {305 psFree(path);306 return false;307 }308 psFree(path);309 310 xmlNode* rootElement = xmlDocGetRootElement(doc);311 312 if (strcmp((const char*)rootElement->name, "tabledata")!=0) {313 psError(PS_ERR_IO, false, "Root node of XML is not 'tabledata', as it should be");314 return false;315 }316 317 xmlNode* node = NULL;318 char tempStr[100];319 320 // loop round all available tables321 for (node = rootElement->children; node; node = node->next) {322 if (node->type == XML_ELEMENT_NODE) {323 324 if (strcmp((const char*)node->name, "table")!=0) continue;325 if (!getAttribute(node, "name", tempStr)) continue;326 if (strcmp(tempStr, tableName)!=0) continue;327 328 ret = getRowAttribute(this, node, keyName, keyValue, attName, attValue);329 break;330 }331 332 }333 334 closeXmlFile(doc);335 336 return ret;337 }338 339 /*340 Gets survey ID from survey name341 */342 static bool getSurveyId(Config* this, const char* surveyType, int8_t* surveyId) {343 344 char buffer[10];345 if (!getInitValue(this, "Survey", "name", surveyType, "surveyID", buffer)) {346 347 *surveyId = -1;348 return false;349 }350 351 *surveyId = atoi(buffer);352 return true;353 }354 355 /*356 Gets filter ID from filter type357 */358 static bool getFilterId(Config* this, const char* filterType, int8_t* filterId) {359 360 char tmp[2];361 strncpy(tmp,filterType,1);362 tmp[1] = '\0';363 char buffer[10];364 if (!getInitValue(this, "Filter", "filterType", tmp, "filterID", buffer)) {365 366 *filterId = -1;367 return false;368 }369 370 *filterId = atoi(buffer);371 249 return true; 372 250 } … … 859 737 static void destroy(Config* this) { 860 738 861 if (this != NULL ) { 862 863 // TODO check logic here 864 for (int i=0;i<this->numOfTables;i++) 865 free(this->tables[i].columns); 866 867 free(this->tables); 868 psFree(this->configsPath); 869 free(this); 870 } 739 if (this == NULL) return; 740 741 // TODO check logic here 742 for (int i=0;i<this->numOfTables;i++) 743 free(this->tables[i].columns); 744 745 free(this->tables); 746 psFree(this->configsPath); 747 free(this); 871 748 } 872 749 … … 882 759 883 760 // method pointers 884 this->getFilterId = getFilterId;885 this->getSurveyId = getSurveyId;886 761 this->createAndPopulateTable = createAndPopulateTable; 887 762 this->populateFromFile = populateFromFile; -
trunk/ippToPsps/src/Config.h
r31011 r31015 51 51 52 52 // methods 53 bool (*getFilterId)();54 bool (*getSurveyId)();55 53 bool (*createAndPopulateTable)(); 56 54 bool (*populateFromFile)(); -
trunk/ippToPsps/src/DetectionBatch.c
r31011 r31015 63 63 // FrameMeta values 64 64 int8_t filterID = -1; 65 if (!this->base. config->getFilterId(this->base.config, filterType, &filterID)) {65 if (!this->base.initData->getFilterId(this->base.initData, filterType, &filterID)) { 66 66 67 67 this->base.exitCode = PS_EXIT_DATA_ERROR; -
trunk/ippToPsps/src/Makefile.am
r31010 r31015 32 32 Version.c \ 33 33 Fits.c \ 34 InitData.c \ 34 35 Config.c 35 36 … … 42 43 Version.c \ 43 44 Fits.c \ 45 InitData.c \ 44 46 Config.c 45 47 … … 52 54 Version.c \ 53 55 Fits.c \ 56 InitData.c \ 54 57 Config.c 55 58 -
trunk/ippToPsps/src/StackBatch.c
r31011 r31015 323 323 324 324 int8_t filterID = -1; 325 if (!this->base. config->getFilterId(this->base.config, filterType, &filterID)) {325 if (!this->base.initData->getFilterId(this->base.initData, filterType, &filterID)) { 326 326 327 327 // this->base.exitCode = PS_EXIT_DATA_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.
