Changeset 9967
- Timestamp:
- Nov 13, 2006, 4:00:40 PM (20 years ago)
- Location:
- trunk/ippTools/src
- Files:
-
- 2 edited
-
pztool.c (modified) (3 diffs)
-
pztoolConfig.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/pztool.c
r9735 r9967 32 32 static bool pendingMode(pxConfig *config); 33 33 static bool copydoneMode(pxConfig *config); 34 static bool summitExpPrint(FILE *stream, summitExpRow *summitExp); 34 35 35 static psArray *pztoolPendingExp(pxConfig *config); 36 36 static psArray *pztoolPendingImfiles(pxConfig *config); … … 78 78 PS_ASSERT_PTR_NON_NULL(config, false); 79 79 80 psArray *summit = summitExpSelectRowObjects(config->dbh, 81 config->where, MAX_ROWS); 82 if (!summit) { 83 psError(PS_ERR_UNKNOWN, false, "no summitExp rows found"); \ 84 return false; 85 } 86 87 psArray *new = newExpSelectRowObjects(config->dbh, 88 config->where, MAX_ROWS); 89 if (!new) { 90 psError(PS_ERR_UNKNOWN, false, "no newExp rows found"); \ 91 } 92 93 if (new) { 94 for (long i = 0; i < summit->n; i++) { 95 summitExpRow *summitExp = summit->data[i]; 96 for (long j = 0; j < summit->n; j++) { 97 newExpRow *newExp = new->data[j]; 98 if (strcmp(summitExp->exp_id, newExp->exp_id) == 0) { 99 psArrayRemoveData(summit, summitExp); 100 // dec the counter as the array just got shorter 101 //and we don't want to skip elemnts 102 i--; 103 break; 104 } 105 } 106 } 107 psFree(new); 108 } 109 110 for (long i = 0; i < summit->n; i++) { 111 if (!summitExpPrint(stdout, summit->data[i])) { 112 psError(PS_ERR_UNKNOWN, false,"summitExpPrint() failed"); 80 psString query = psStringCopy( 81 "SELECT" 82 " summitExp.*" 83 " FROM summitExp" 84 " LEFT JOIN newExp" 85 " USING(exp_id, camera, telescope)" 86 " WHERE" 87 " newExp.exp_id is NULL" 88 " AND newExp.camera IS NULL" 89 " AND newExp.telescope IS NULL" 90 ); 91 92 if (config->where) { 93 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "newExp"); 94 psStringAppend(&query, " AND %s", whereClause); 95 psFree(whereClause); 96 } 97 98 if (!p_psDBRunQuery(config->dbh, query)) { 99 psError(PS_ERR_UNKNOWN, false, "database error"); 100 psFree(query); 101 return false; 102 } 103 psFree(query); 104 105 psArray *output = p_psDBFetchResult(config->dbh); 106 if (!output) { 107 psError(PS_ERR_UNKNOWN, false, "database error"); 108 return false; 109 } 110 if (!psArrayLength(output)) { 111 psError(PS_ERR_UNKNOWN, false, "no newExp rows found"); 112 psFree(output); 113 return true; 114 } 115 116 bool simple = false; 117 { 118 bool status = false; 119 simple = psMetadataLookupBool(&status, config->args, "-simple"); 120 if (!status) { 121 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple"); 113 122 return false; 114 123 } 115 124 } 125 126 // negative simple so the default is true 127 if (!ippdbPrintMetadatas(stdout, output, "newExp", !simple)) { 128 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 129 psFree(output); 130 return false; 131 } 132 133 psFree(output); 116 134 117 135 return true; … … 201 219 202 220 return false; 203 }204 205 static bool summitExpPrint(FILE *stream, summitExpRow *summitExp)206 {207 PS_ASSERT_PTR_NON_NULL(stream, false);208 PS_ASSERT_PTR_NON_NULL(summitExp, false);209 210 fprintf(stream, "%s %s %s %s %s\n",211 summitExp->exp_id,212 summitExp->camera,213 summitExp->telescope,214 summitExp->exp_type,215 summitExp->uri216 );217 218 return true;219 221 } 220 222 -
trunk/ippTools/src/pztoolConfig.c
r9392 r9967 42 42 // -seen 43 43 psMetadata *seenArgs = psMetadataAlloc(); 44 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_tag", 0, 45 "define exposure ID", NULL); 46 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-inst", 0, 47 "define camera ID", NULL); 48 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-telescope", 0, 49 "define telescope ID", NULL); 50 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_type", 0, 51 "define exposure type", NULL); 44 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_tag", 0, 45 "define exposure ID", NULL); 46 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-inst", 0, 47 "define camera ID", NULL); 48 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-telescope", 0, 49 "define telescope ID", NULL); 50 psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_type", 0, 51 "define exposure type", NULL); 52 psMetadataAddBool(seenArgs, PS_LIST_TAIL, "-simple", 0, 53 "use the simple output format", false); 52 54 53 55 // -pending 54 56 psMetadata *pendingArgs = psMetadataAlloc(); 55 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_tag", 0,56 "define exposure ID", NULL);57 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-inst", 0,58 "define camera ID", NULL);59 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-telescope", 0,60 "define telescope ID", NULL);61 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_type", 0,62 "define exposure type", NULL);57 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_tag", 0, 58 "define exposure ID", NULL); 59 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-inst", 0, 60 "define camera ID", NULL); 61 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-telescope", 0, 62 "define telescope ID", NULL); 63 psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_type", 0, 64 "define exposure type", NULL); 63 65 64 66 // -copydone 65 67 psMetadata *copydoneArgs = psMetadataAlloc(); 66 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_tag", 0,67 "define exposure ID", NULL);68 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class", 0,69 "define class", NULL);70 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class_id", 0,71 "define class_id", NULL);72 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-suri", 0,73 "define storage uri", NULL);68 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_tag", 0, 69 "define exposure ID", NULL); 70 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class", 0, 71 "define class", NULL); 72 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class_id", 0, 73 "define class_id", NULL); 74 psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-suri", 0, 75 "define storage uri", NULL); 74 76 75 77 #define PXTOOL_MODE(option, modeval, argset) \ … … 80 82 if (config->mode) { \ 81 83 psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \ 84 goto FAIL; \ 82 85 } \ 83 86 config->mode = modeval; \ 84 87 config->args = psMemIncrRefCounter(argset); \ 85 88 } \ 89 if (!psMetadataAddMetadata(argSets, PS_LIST_TAIL, option, 0, NULL, argset)) {;\ 90 psError(PS_ERR_UNKNOWN, false, "failed to add argset for %s", option); \ 91 } \ 92 psFree(argset); \ 86 93 } 87 94 95 psMetadata *argSets = psMetadataAlloc(); 96 // find which mode we're running under 88 97 PXTOOL_MODE("-seen", PZTOOL_MODE_SEEN, seenArgs); 89 98 PXTOOL_MODE("-pending", PZTOOL_MODE_PENDING, pendingArgs); … … 100 109 101 110 if (argErr) { 102 printf("\nPan-STARRS Phase Z SearchTool\n");111 printf("\nPan-STARRS Detrend Tool\n"); 103 112 printf("Usage: %s <mode> [<options>]\n\n", argv[0]); 104 printf(" <mode> : -seen | -pending | -copydone\n\n");113 printf(" <mode> :\n\n"); 105 114 106 fprintf (stdout, "-seen "); 107 psArgumentHelp(seenArgs); 108 psFree(seenArgs); 115 psMetadataIterator *iter = psMetadataIteratorAlloc(argSets, 0, NULL); 116 psMetadataItem *item = NULL; 117 while ((item = psMetadataGetAndIncrement(iter))) { 118 if (!item->type == PS_DATA_METADATA) { 119 psAbort(argv[0], "all options must be specified as a metadata"); 120 } 109 121 110 fprintf (stdout, "-pending "); 111 psArgumentHelp(pendingArgs); 112 psFree(pendingArgs); 122 fprintf(stdout, "%s ", item->name); 123 psArgumentHelp(item->data.md); 124 } 125 psFree(iter); 113 126 114 fprintf (stdout, "-copydone "); 115 psArgumentHelp(copydoneArgs); 116 psFree(copydoneArgs); 117 127 psFree(argSets); 118 128 goto FAIL; 119 129 } 120 130 121 psFree(seenArgs); 122 psArgumentHelp(pendingArgs); 123 psFree(copydoneArgs); 131 psFree(argSets); 124 132 125 133 // setup search criterion
Note:
See TracChangeset
for help on using the changeset viewer.
