Changeset 20377 for trunk/ippTools/src/dettool_correction.c
- Timestamp:
- Oct 24, 2008, 3:02:43 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/dettool_correction.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/dettool_correction.c
r19621 r20377 26 26 PXOPT_LOOKUP_S64(ref_det_id, config->args, "-det_id", true, false); // required 27 27 PXOPT_LOOKUP_S32(ref_iter, config->args, "-iteration", true, false); // required 28 PXOPT_LOOKUP_STR(det_type, config->args, "-det_type", true, false); // required 28 29 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); // optional 30 31 // optional modifications 32 PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false); 33 PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false); 34 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 29 35 30 36 // build the needed where … … 32 38 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", ref_det_id); 33 39 psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", ref_iter); 40 41 // select the detRun that matches 34 42 psArray *runs = detRunSelectRowObjects(config->dbh, where, 1); 35 43 psFree (where); … … 46 54 return false; 47 55 } 56 57 char *use_workdir = (workdir) ? workdir : detRun->workdir; 58 char *use_reduction = (reduction) ? reduction : detRun->reduction; 59 char *use_label = (label) ? label : detRun->label; 48 60 49 61 detRunInsert(config->dbh, 50 62 0, // det_id 51 63 0, // iteration 52 det Run->det_type,64 det_type, 53 65 "correction", // mode 54 66 "run", // state 55 67 detRun->filelevel, 56 detRun->workdir,68 use_workdir, 57 69 detRun->camera, 58 70 detRun->telescope, 59 71 detRun->exp_type, 60 detRun->reduction,72 use_reduction, 61 73 detRun->filter, 62 74 detRun->airmass_min, … … 75 87 detRun->solang_min, 76 88 detRun->solang_max, 77 detRun->label,89 use_label, 78 90 detRun->det_id, // ref_det_id 79 91 detRun->iteration // ref_iter 80 92 ); 81 82 93 psFree(runs); 83 94 … … 91 102 92 103 psMetadata *where_new = psMetadataAlloc(); 93 psMetadataAddS64(where , PS_LIST_TAIL, "det_id", 0, "==", new_det_id);104 psMetadataAddS64(where_new, PS_LIST_TAIL, "det_id", 0, "==", new_det_id); 94 105 psArray *detRuns = psDBSelectRows(config->dbh, "detRun", where_new, 0); 95 106 psFree(where_new); … … 116 127 } 117 128 118 bool tocorrectexpMode(pxConfig *config) 119 { 120 PS_ASSERT_PTR_NON_NULL(config, false); 129 bool tocorrectimfileMode(pxConfig *config) 130 { 131 PS_ASSERT_PTR_NON_NULL(config, false); 132 133 psMetadata *where = psMetadataAlloc(); 134 PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "=="); 135 PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "=="); 121 136 122 137 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 123 138 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 124 139 125 psString query = pxDataGet("dettool_tocorrect exp.sql");140 psString query = pxDataGet("dettool_tocorrectimfile.sql"); 126 141 if (!query) { 127 142 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 128 143 return false; 129 144 } 145 146 if (psListLength(where->list)) { 147 // NOTE the SQL uses an intermediate table 'det1' for this query 148 psString whereClause = psDBGenerateWhereConditionSQL(where, "det1"); 149 psStringAppend(&query, " AND %s", whereClause); 150 psFree(whereClause); 151 } 152 psFree (where); 130 153 131 154 // treat limit == 0 as "no limit" … … 155 178 156 179 // negative simple so the default is true 157 if (!ippdbPrintMetadatas(stdout, output, "det Run", !simple)) {180 if (!ippdbPrintMetadatas(stdout, output, "detPendingCorrectImfile", !simple)) { 158 181 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 159 182 psFree(output); … … 166 189 } 167 190 168 bool tocorrectimfileMode(pxConfig *config) 169 { 170 PS_ASSERT_PTR_NON_NULL(config, false); 171 172 psMetadata *where = psMetadataAlloc(); 173 PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "=="); 191 bool tocorrectexpMode(pxConfig *config) 192 { 193 PS_ASSERT_PTR_NON_NULL(config, false); 174 194 175 195 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 176 196 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 177 197 178 psString query = pxDataGet("dettool_tocorrect imfile.sql");198 psString query = pxDataGet("dettool_tocorrectexp.sql"); 179 199 if (!query) { 180 200 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 181 201 return false; 182 202 } 183 184 if (psListLength(where->list)) {185 // NOTE the SQL uses an intermediate table 'det1' for this query186 psString whereClause = psDBGenerateWhereConditionSQL(where, "det1");187 psStringAppend(&query, " AND %s", whereClause);188 psFree(whereClause);189 }190 psFree (where);191 203 192 204 // treat limit == 0 as "no limit" … … 216 228 217 229 // negative simple so the default is true 218 if (!ippdbPrintMetadatas(stdout, output, "det PendingCorrectImfile", !simple)) {230 if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) { 219 231 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 220 232 psFree(output);
Note:
See TracChangeset
for help on using the changeset viewer.
