Changeset 28091 for trunk/ippTools/src/pxtools.c
- Timestamp:
- May 25, 2010, 1:38:50 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/pxtools.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pxtools.c
r28089 r28091 49 49 50 50 psString pxMergeCodeVersions(psString version1, psString version2) { 51 psString out = NULL; 52 53 bool mod1 = false; 54 bool mod2 = false; 55 56 psS32 num1; 57 psS32 num2; 58 psS32 numO; 59 60 if (!version1) { 61 psStringAppend(&out,version2); 51 psString out = NULL; 52 53 bool mod1 = false; 54 bool mod2 = false; 55 56 psS32 num1; 57 psS32 num2; 58 psS32 numO; 59 60 if (!version1) { 61 psStringAppend(&out, "%s", version2); 62 return(out); 63 } 64 if (!version2) { 65 psStringAppend(&out, "%s", version1); 66 return(out); 67 } 68 69 if (strchr(version1,'M')) { 70 psStringSubstitute(&version1,"M",""); 71 mod1 = true; 72 } 73 if (strchr(version2,'M')) { 74 psStringSubstitute(&version2,"M",""); 75 mod2 = true; 76 } 77 78 num1 = strtol(version1,NULL,10); 79 num2 = strtol(version2,NULL,10); 80 81 if (num1 >= num2) { 82 numO = num1; 83 } 84 else { 85 numO = num2; 86 } 87 88 psStringAppend(&out,"%" PRId32,numO); 89 if (mod1 || mod2) { 90 psStringAppend(&out,"M"); 91 } 62 92 return(out); 63 }64 if (!version2) {65 psStringAppend(&out,version1);66 return(out);67 }68 69 if (strchr(version1,'M')) {70 psStringSubstitute(&version1,"M","");71 mod1 = true;72 }73 if (strchr(version2,'M')) {74 psStringSubstitute(&version2,"M","");75 mod2 = true;76 }77 78 num1 = strtol(version1,NULL,10);79 num2 = strtol(version2,NULL,10);80 81 if (num1 >= num2) {82 numO = num1;83 }84 else {85 numO = num2;86 }87 88 psStringAppend(&out,"%" PRId32,numO);89 if (mod1 || mod2) {90 psStringAppend(&out,"M");91 }92 return(out);93 93 } 94 94 … … 96 96 psS64 *maskfrac_npix, psF32 *maskfrac_static, psF32 *maskfrac_dynamic, 97 97 psF32 *maskfrac_magic, psF32 *maskfrac_advisory) { 98 psString query = pxDataGet(dbQFile);98 psString query = pxDataGet(dbQFile); 99 99 /* psString text_id = NULL; */ 100 100 /* psStringAppend(&text_id," %" PRId64,stage_id); */ 101 101 /* psStringSubstitute(&query,text_id,"@STAGE_ID@"); */ 102 102 /* psFree(text_id); */ 103 if (!p_psDBRunQueryF(config->dbh, query, stage_id)) { 104 psError(PS_ERR_UNKNOWN, false, "database error"); 103 if (!p_psDBRunQueryF(config->dbh, query, stage_id)) { 104 psError(PS_ERR_UNKNOWN, false, "database error"); 105 psFree(query); 106 return(false); 107 } 105 108 psFree(query); 106 return(false); 107 } 108 psFree(query); 109 psArray *output = p_psDBFetchResult(config->dbh); 110 if (!output) { 111 psError(PS_ERR_UNKNOWN, false, "database error"); 112 return(false); 113 } 114 115 for (long i = 0; i < psArrayLength(output); i++) { 116 psMetadata *row = output->data[i]; 117 118 psS32 this_npix = psMetadataLookupS32(NULL, row, "maskfrac_npix"); 119 psF32 this_static = psMetadataLookupF32(NULL, row, "maskfrac_static"); 120 psF32 this_dynamic = psMetadataLookupF32(NULL, row, "maskfrac_dynamic"); 121 psF32 this_magic = psMetadataLookupF32(NULL, row, "maskfrac_magic"); 122 psF32 this_advisory = psMetadataLookupF32(NULL, row, "maskfrac_advisory"); 123 psString this_version = psMetadataLookupStr(NULL, row, "software_ver"); 124 125 *software_ver = pxMergeCodeVersions(*software_ver,this_version); 109 psArray *output = p_psDBFetchResult(config->dbh); 110 if (!output) { 111 psError(PS_ERR_UNKNOWN, false, "database error"); 112 return(false); 113 } 114 115 for (long i = 0; i < psArrayLength(output); i++) { 116 psMetadata *row = output->data[i]; 117 118 psS32 this_npix = psMetadataLookupS32(NULL, row, "maskfrac_npix"); 119 psF32 this_static = psMetadataLookupF32(NULL, row, "maskfrac_static"); 120 psF32 this_dynamic = psMetadataLookupF32(NULL, row, "maskfrac_dynamic"); 121 psF32 this_magic = psMetadataLookupF32(NULL, row, "maskfrac_magic"); 122 psF32 this_advisory = psMetadataLookupF32(NULL, row, "maskfrac_advisory"); 123 psString this_version = psMetadataLookupStr(NULL, row, "software_ver"); 124 125 *software_ver = pxMergeCodeVersions(*software_ver,this_version); 126 126 /* printf("%ld : %d %f %f %f %f <-> %ld %f %f %f %f\n",i,this_npix,this_static,this_dynamic,this_magic,this_advisory, */ 127 127 /* *maskfrac_npix,*maskfrac_static,*maskfrac_dynamic,*maskfrac_magic,*maskfrac_advisory); */ 128 if (this_npix > 0) {129 *maskfrac_static = ((*maskfrac_static * *maskfrac_npix) + (this_npix * this_static)) / (this_npix + *maskfrac_npix);130 *maskfrac_dynamic = ((*maskfrac_dynamic * *maskfrac_npix) + (this_npix * this_dynamic)) / (this_npix + *maskfrac_npix);131 *maskfrac_magic = ((*maskfrac_magic * *maskfrac_npix) + (this_npix * this_magic)) / (this_npix + *maskfrac_npix);132 *maskfrac_advisory = ((*maskfrac_advisory * *maskfrac_npix) + (this_npix * this_advisory)) / (this_npix + *maskfrac_npix);133 *maskfrac_npix += this_npix;134 }135 }136 psFree(output);137 return(true);128 if (this_npix > 0) { 129 *maskfrac_static = ((*maskfrac_static * *maskfrac_npix) + (this_npix * this_static)) / (this_npix + *maskfrac_npix); 130 *maskfrac_dynamic = ((*maskfrac_dynamic * *maskfrac_npix) + (this_npix * this_dynamic)) / (this_npix + *maskfrac_npix); 131 *maskfrac_magic = ((*maskfrac_magic * *maskfrac_npix) + (this_npix * this_magic)) / (this_npix + *maskfrac_npix); 132 *maskfrac_advisory = ((*maskfrac_advisory * *maskfrac_npix) + (this_npix * this_advisory)) / (this_npix + *maskfrac_npix); 133 *maskfrac_npix += this_npix; 134 } 135 } 136 psFree(output); 137 return(true); 138 138 } 139 139 140 140 bool pxSetRunSoftware(pxConfig *config, const psString tableName, const psString stage_id_name, const psS64 stage_id, 141 141 psString software_ver) { 142 char *query = "UPDATE %s SET software_ver = '%s' WHERE %s = %" PRId64;142 char *query = "UPDATE %s SET software_ver = '%s' WHERE %s = %" PRId64; 143 143 /* printf(query,tableName,software_ver,stage_id_name,stage_id); */ 144 if (!p_psDBRunQueryF(config->dbh,query,tableName,software_ver,stage_id_name,stage_id)) {145 psError(PS_ERR_UNKNOWN, false,146 "failed to set software version for %s %" PRId64,stage_id_name,stage_id);147 return(false);148 }149 150 return(true);144 if (!p_psDBRunQueryF(config->dbh,query,tableName,software_ver,stage_id_name,stage_id)) { 145 psError(PS_ERR_UNKNOWN, false, 146 "failed to set software version for %s %" PRId64,stage_id_name,stage_id); 147 return(false); 148 } 149 150 return(true); 151 151 } 152 152 … … 154 154 psS64 maskfrac_npix, psF32 maskfrac_static, psF32 maskfrac_dynamic, 155 155 psF32 maskfrac_magic, psF32 maskfrac_advisory) { 156 char *query = "UPDATE %s SET maskfrac_npix = %f, maskfrac_static = %f, maskfrac_dynamic = %f, maskfrac_magic = %f, maskfrac_advisory = %f WHERE %s = %" PRId64;157 if (!p_psDBRunQueryF(config->dbh,query,tableName,(float) maskfrac_npix,maskfrac_static,158 maskfrac_dynamic, maskfrac_magic,maskfrac_advisory,stage_id_name,stage_id)) {159 psError(PS_ERR_UNKNOWN, false,160 "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id);161 return(false);162 }163 164 165 166 return(true);156 char *query = "UPDATE %s SET maskfrac_npix = %f, maskfrac_static = %f, maskfrac_dynamic = %f, maskfrac_magic = %f, maskfrac_advisory = %f WHERE %s = %" PRId64; 157 if (!p_psDBRunQueryF(config->dbh,query,tableName,(float) maskfrac_npix,maskfrac_static, 158 maskfrac_dynamic, maskfrac_magic,maskfrac_advisory,stage_id_name,stage_id)) { 159 psError(PS_ERR_UNKNOWN, false, 160 "failed to set maskfrac stats for %s %" PRId64,stage_id_name,stage_id); 161 return(false); 162 } 163 164 165 166 return(true); 167 167 } 168 168 … … 293 293 char *comma = ","; 294 294 295 # define addColumn(_tab, _val) \296 do {\297 if (_val) {\298 psStringAppend(pQuery, "%s %s.%s = '%s'", separator, _tab, #_val, _val); \299 separator = comma;\300 }\301 } while (0)295 # define addColumn(_tab, _val) \ 296 do { \ 297 if (_val) { \ 298 psStringAppend(pQuery, "%s %s.%s = '%s'", separator, _tab, #_val, _val); \ 299 separator = comma; \ 300 } \ 301 } while (0) 302 302 303 303 addColumn(runTable, state); … … 436 436 if (import_version && strcmp(import_version, schema_version)) { 437 437 psError(PS_ERR_UNKNOWN, true, "input file schema_version: %s does not match data base: %s", 438 import_version, schema_version);438 import_version, schema_version); 439 439 return false; 440 440 } else if (!import_version) {
Note:
See TracChangeset
for help on using the changeset viewer.
