Changeset 17216 for trunk/ippTools/src/camtool.c
- Timestamp:
- Mar 28, 2008, 3:57:39 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/camtool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/camtool.c
r17171 r17216 159 159 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 160 160 161 if (!psListLength(where->list)) { 161 if (!psListLength(where->list) 162 && !psMetadataLookupBool(NULL, config->args, "-all")) { 162 163 psFree(where); 164 where = NULL; 163 165 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 164 166 return false; … … 180 182 } 181 183 182 if (where ) {184 if (where && psListLength(where->list)) { 183 185 psString whereClause = psDBGenerateWhereConditionSQL(where, ""); 184 186 psFree(where); … … 337 339 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 338 340 339 if (!psListLength(where->list)) { 341 if (!psListLength(where->list) 342 && !psMetadataLookupBool(NULL, config->args, "-all")) { 340 343 psFree(where); 344 where = NULL; 341 345 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 342 346 return false; … … 760 764 PS_ASSERT_PTR_NON_NULL(config, false); 761 765 766 PXOPT_LOOKUP_STR(cam_id, config->args, "-cam_id", false, false); 767 PXOPT_LOOKUP_STR(chip_id, config->args, "-chip_id", false, false); 768 PXOPT_LOOKUP_STR(exp_id, config->args, "-exp_id", false, false); 769 770 psMetadata *where = psMetadataAlloc(); 771 // convert cam_id into a psS64 772 if (cam_id) { 773 if (!psMetadataAddS64(where, PS_LIST_TAIL, "cam_id", 0, "==", (psS64)atoll(cam_id))) { 774 psError(PS_ERR_UNKNOWN, false, "failed to add item cam_id"); 775 psFree(where); 776 return false; 777 } 778 } 779 780 // convert chip_id into a psS64 781 if (chip_id) { 782 if (!psMetadataAddS64(where, PS_LIST_TAIL, "chip_id", 0, "==", (psS64)atoll(chip_id))) { 783 psError(PS_ERR_UNKNOWN, false, "failed to add item chip_id"); 784 psFree(where); 785 return false; 786 } 787 } 788 789 // convert exp_id into a psS64 790 if (exp_id) { 791 if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(exp_id))) { 792 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 793 psFree(where); 794 return false; 795 } 796 } 797 798 PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "=="); 799 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); 800 PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "=="); 801 PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">="); 802 PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<="); 803 PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "=="); 804 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 805 PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "=="); 806 PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "=="); 807 PXOPT_COPY_STR(config->args, where, "-filter", "filter", "=="); 808 809 PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">="); 810 PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<"); 811 PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">="); 812 PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<"); 813 PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">="); 814 PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<"); 815 PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">="); 816 PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<"); 817 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">="); 818 PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<"); 819 PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">="); 820 PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<"); 821 PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">="); 822 PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<"); 823 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">="); 824 PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<"); 825 PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">="); 826 PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<"); 827 PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">="); 828 PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<"); 829 PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">="); 830 PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<"); 831 PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">="); 832 PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<"); 833 PXOPT_COPY_STR(config->args, where, "-object", "object", "=="); 834 PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">="); 835 PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<"); 836 837 if (!psListLength(where->list) 838 && !psMetadataLookupBool(NULL, config->args, "-all")) { 839 psFree(where); 840 where = NULL; 841 psError(PXTOOLS_ERR_DATA, false, "search parameters are required"); 842 return false; 843 } 844 762 845 if (!psDBTransaction(config->dbh)) { 763 846 psError(PS_ERR_UNKNOWN, false, "database error"); 847 psFree(where); 764 848 return false; 765 849 } … … 769 853 if (!query) { 770 854 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 771 return false; 772 } 773 774 if (config->where) { 775 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "camProcessedExp"); 855 psFree(where); 856 return false; 857 } 858 859 if (where && psListLength(where->list)) { 860 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 776 861 psStringAppend(&query, " AND %s", whereClause); 777 862 psFree(whereClause); … … 785 870 psError(PS_ERR_UNKNOWN, false, "database error"); 786 871 psFree(query); 872 psFree(where); 787 873 return false; 788 874 } … … 798 884 } 799 885 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 800 return false; 801 } 802 803 if (config->where) { 804 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "camProcessedExp"); 886 psFree(where); 887 return false; 888 } 889 890 if (where && psListLength(where->list)) { 891 psString whereClause = psDBGenerateWhereConditionSQL(config->where, NULL); 805 892 psStringAppend(&query, " AND %s", whereClause); 806 893 psFree(whereClause); … … 814 901 psError(PS_ERR_UNKNOWN, false, "database error"); 815 902 psFree(query); 903 psFree(where); 816 904 return false; 817 905 } 818 906 psFree(query); 819 907 } 820 821 if (psDBAffectedRows(config->dbh) < 1) { 822 // rollback 823 if (!psDBRollback(config->dbh)) { 824 psError(PS_ERR_UNKNOWN, false, "database error"); 825 } 826 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); 827 return false; 828 } 908 psFree(where); 829 909 830 910 if (!psDBCommit(config->dbh)) {
Note:
See TracChangeset
for help on using the changeset viewer.
