Changeset 14262
- Timestamp:
- Jul 16, 2007, 6:54:55 PM (19 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 3 edited
-
warptool.c (modified) (9 diffs)
-
warptool.h (modified) (1 diff)
-
warptoolConfig.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/warptool.c
r14105 r14262 31 31 #include "warptool.h" 32 32 33 static bool definerunMode(pxConfig *config); 33 static psS64 definerunMode(pxConfig *config); 34 static bool runoneMode(pxConfig *config); 34 35 static bool updaterunMode(pxConfig *config); 35 36 static bool addinputexpMode(pxConfig *config); … … 45 46 46 47 static bool parseAndInsertSkyCellMap(pxConfig *config, const char *mapfile); 47 static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state);48 static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state); 48 49 static bool isValidMode(pxConfig *config, const char *mode); 49 50 bool warpCompletedRuns(pxConfig *config); … … 68 69 switch (config->mode) { 69 70 MODECASE(WARPTOOL_MODE_DEFINERUN, definerunMode); 71 MODECASE(WARPTOOL_MODE_RUNONE, runoneMode); 70 72 MODECASE(WARPTOOL_MODE_UPDATERUN, updaterunMode); 71 73 MODECASE(WARPTOOL_MODE_ADDINPUTEXP, addinputexpMode); … … 101 103 102 104 103 static booldefinerunMode(pxConfig *config)105 static psS64 definerunMode(pxConfig *config) 104 106 { 105 107 PS_ASSERT_PTR_NON_NULL(config, false); … … 167 169 168 170 // get the assigned warp_id 169 warpRun->warp_id = psDBLastInsertID(config->dbh); 171 psS64 warp_id = psDBLastInsertID(config->dbh); 172 warpRun->warp_id = warp_id; 170 173 171 174 bool simple = false; … … 188 191 psFree(warpRun); 189 192 190 return true; 191 } 192 193 return warp_id; 194 } 195 196 static bool runoneMode(pxConfig *config) 197 { 198 PS_ASSERT_PTR_NON_NULL(config, false); 199 200 if (!psDBTransaction(config->dbh)) { 201 psError(PS_ERR_UNKNOWN, false, "database error"); 202 return false; 203 } 204 205 psS64 warp_id = definerunMode(config); 206 if (!warp_id) { 207 // rollback 208 if (!psDBRollback(config->dbh)) { 209 psError(PS_ERR_UNKNOWN, false, "database error"); 210 } 211 psError(PS_ERR_UNKNOWN, false, "failed to define warpRun"); 212 return false; 213 } 214 215 psString warp_id_str = psDBIntToString(warp_id); 216 if (!psMetadataAddStr(config->args, PS_LIST_TAIL, "-warp_id", 0, NULL, warp_id_str)) { 217 // rollback 218 if (!psDBRollback(config->dbh)) { 219 psError(PS_ERR_UNKNOWN, false, "database error"); 220 } 221 psError(PS_ERR_UNKNOWN, false, "failed to add item warp_id"); 222 psFree(warp_id_str); 223 return false; 224 } 225 psFree(warp_id_str); 226 227 if (!addinputexpMode(config)) { 228 // rollback 229 if (!psDBRollback(config->dbh)) { 230 psError(PS_ERR_UNKNOWN, false, "database error"); 231 } 232 psError(PS_ERR_UNKNOWN, false, "failed to add cam_id to warpRun"); 233 return false; 234 } 235 if (!setwarpRunState(config, warp_id, "run")) { 236 // rollback 237 if (!psDBRollback(config->dbh)) { 238 psError(PS_ERR_UNKNOWN, false, "database error"); 239 } 240 psError(PS_ERR_UNKNOWN, false, "failed to set warpRun.state to run"); 241 return false; 242 } 243 244 // point of no return 245 if (!psDBCommit(config->dbh)) { 246 psError(PS_ERR_UNKNOWN, false, "database error"); 247 return false; 248 } 249 250 return true; 251 } 193 252 194 253 static bool updaterunMode(pxConfig *config) … … 219 278 if (state) { 220 279 // set detRun.state to state 221 return setwarpRunState(config, warp_id, state);280 return setwarpRunState(config, (psS64)atoll(warp_id), state); 222 281 } 223 282 … … 1161 1220 1162 1221 1163 static bool setwarpRunState(pxConfig *config, const char *warp_id, const char *state) 1164 { 1165 PS_ASSERT_PTR_NON_NULL(warp_id, false); 1222 static bool setwarpRunState(pxConfig *config, psS64 warp_id, const char *state) 1223 { 1166 1224 PS_ASSERT_PTR_NON_NULL(state, false); 1167 1225 … … 1178 1236 } 1179 1237 1180 char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = '%s'";1238 char *query = "UPDATE warpRun SET state = '%s' WHERE warp_id = %" PRId64; 1181 1239 if (!p_psDBRunQuery(config->dbh, query, state, warp_id)) { 1182 1240 psError(PS_ERR_UNKNOWN, false, 1183 "failed to change state for warp_id % s", warp_id);1241 "failed to change state for warp_id %" PRId64, warp_id); 1184 1242 return false; 1185 1243 } -
trunk/ippTools/src/warptool.h
r14102 r14262 26 26 WARPTOOL_MODE_NONE = 0x0, 27 27 WARPTOOL_MODE_DEFINERUN, 28 WARPTOOL_MODE_RUNONE, 28 29 WARPTOOL_MODE_UPDATERUN, 29 30 WARPTOOL_MODE_ADDINPUTEXP, -
trunk/ippTools/src/warptoolConfig.c
r14102 r14262 60 60 "use the simple output format", false); 61 61 62 // -runone 63 psMetadata *runoneArgs = psMetadataAlloc(); 64 psMetadataAddStr(runoneArgs, PS_LIST_TAIL, "-mode", 0, 65 "define mode (required)", NULL); 66 psMetadataAddStr(runoneArgs, PS_LIST_TAIL, "-workdir", 0, 67 "define workdir (required)", NULL); 68 psMetadataAddStr(runoneArgs, PS_LIST_TAIL, "-registered", 0, 69 "time detrend run was registered", now); 70 psMetadataAddStr(runoneArgs, PS_LIST_TAIL, "-cam_id", 0, 71 "define camtool ID (required)", NULL); 72 psMetadataAddBool(runoneArgs, PS_LIST_TAIL, "-magiced", 0, 73 "has this exposure been magiced", false); 74 psMetadataAddBool(runoneArgs, PS_LIST_TAIL, "-simple", 0, 75 "use the simple output format", false); 76 62 77 // -updaterun 63 78 psMetadata *updaterunArgs = psMetadataAlloc(); … … 195 210 196 211 PXTOOL_ADD_MODE("-definerun", "", WARPTOOL_MODE_DEFINERUN, definerunArgs); 212 PXTOOL_ADD_MODE("-runone", "", WARPTOOL_MODE_RUNONE, runoneArgs); 197 213 PXTOOL_ADD_MODE("-updaterun", "", WARPTOOL_MODE_UPDATERUN, updaterunArgs); 198 214 PXTOOL_ADD_MODE("-addinputexp", "", WARPTOOL_MODE_ADDINPUTEXP, addinputexpArgs);
Note:
See TracChangeset
for help on using the changeset viewer.
