Changeset 25816
- Timestamp:
- Oct 8, 2009, 5:09:53 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 22 edited
-
dbconfig/add.md (modified) (3 diffs)
-
dbconfig/changes.txt (modified) (2 diffs)
-
dbconfig/flatcorr.md (modified) (1 diff)
-
ippScripts/scripts/addstar_run.pl (modified) (10 diffs)
-
ippScripts/scripts/camera_exp.pl (modified) (1 diff)
-
ippScripts/scripts/flatcorr_proc.pl (modified) (1 diff)
-
ippTasks/addstar.pro (modified) (2 diffs)
-
ippTasks/flatcorr.pro (modified) (6 diffs)
-
ippTools/share/Makefile.am (modified) (1 diff)
-
ippTools/share/addtool_find_pendingexp.sql (modified) (3 diffs)
-
ippTools/share/addtool_queue_cam_id.sql (modified) (1 diff)
-
ippTools/share/flatcorr_camerarundone.sql (added)
-
ippTools/share/flatcorr_chiprundone.sql (modified) (2 diffs)
-
ippTools/share/flatcorr_pendingprocess.sql (modified) (1 diff)
-
ippTools/share/pxadmin_create_tables.sql (modified) (4 diffs)
-
ippTools/share/pxadmin_drop_tables.sql (modified) (1 diff)
-
ippTools/src/addtool.c (modified) (16 diffs)
-
ippTools/src/addtoolConfig.c (modified) (6 diffs)
-
ippTools/src/flatcorr.c (modified) (13 diffs)
-
ippTools/src/flatcorr.h (modified) (2 diffs)
-
ippTools/src/flatcorrConfig.c (modified) (5 diffs)
-
ippTools/src/pxadd.c (modified) (4 diffs)
-
ippTools/src/pxadd.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dbconfig/add.md
r25299 r25816 1 # XXX rename these 'addstarRun', etc... (add_id -> addstar_id) 1 2 addRun METADATA 2 3 add_id S64 0 # Primary Key AUTO_INCREMENT … … 5 6 workdir STR 255 6 7 workdir_state STR 64 8 reduction STR 64 7 9 label STR 64 8 10 dvodb STR 255 9 magicked S64 011 image_only BOOL f 10 12 END 11 13 … … 13 15 add_id S64 0 # Primary Key AUTO_INCREMENT 14 16 dtime_addstar F32 0.0 15 16 n_stars S32 017 18 17 path_base STR 255 19 18 fault S16 0 # Key NOT NULL -
trunk/dbconfig/changes.txt
r25795 r25816 1300 1300 1301 1301 ALTER TABLE pstampJob ADD COLUMN options BIGINT; 1302 1303 ALTER TABLE addRun ADD COLUMN reduction VARCHAR(64) AFTER workdir_state; 1304 ALTER TABLE addRun DROP COLUMN magicked; 1305 ALTER TABLE addRun ADD COLUMN image_only tinyint after dvodb; 1306 ALTER TABLE addProcessedExp DROP COLUMN n_stars; 1307 1308 CREATE TABLE flatcorrAddstarLink ( 1309 corr_id BIGINT, 1310 cam_id BIGINT, 1311 add_id BIGINT, 1312 include TINYINT, 1313 PRIMARY KEY(corr_id, cam_id, add_id), 1314 FOREIGN KEY (corr_id) REFERENCES flatcorrRun(corr_id), 1315 FOREIGN KEY (cam_id) REFERENCES camRun(cam_id), 1316 FOREIGN KEY (add_id) REFERENCES addRun(add_id) 1317 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1318 1302 1319 ALTER TABLE pstampJob ADD COLUMN dep_id BIGINT; 1303 1320 CREATE TABLE pstampDependent ( … … 1311 1328 PRIMARY KEY(dep_id) 1312 1329 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1313 -
trunk/dbconfig/flatcorr.md
r20397 r25816 33 33 END 34 34 35 # table of exposures sent to addstar 36 flatcorrAddstarLink METADATA 37 corr_id S64 0 # Primary Key fkey(corr_id) ref flatcorrRun(corr_id) 38 cam_id S64 0 # Primary Key fkey(chip_id) ref chipRun(chip_id) 39 add_id S64 0 # Primary Key fkey(chip_id) ref chipRun(chip_id) 40 include BOOL t 41 END 42 -
trunk/ippScripts/scripts/addstar_run.pl
r25299 r25816 28 28 # Look for programs we need 29 29 my $missing_tools; 30 #my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);31 30 my $addtool = can_run('addtool') or (warn "Can't find addtool" and $missing_tools = 1); 32 #my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);33 31 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 34 #my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);35 #my $psastro = can_run('psastro') or (warn "Can't find psastro" and $missing_tools = 1);36 32 my $addstar = can_run('addstar') or (warn "Can't find addstar" and $missing_tools = 1); 37 33 if ($missing_tools) { … … 40 36 } 41 37 42 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,43 $no_op, $redirect, $save_temps , $run_state);38 my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update, 39 $no_op, $redirect, $save_temps); 44 40 GetOptions( 45 41 'exp_tag=s' => \$exp_tag, # Exposure identifier 46 42 'add_id=s' => \$add_id, # Camtool identifier 47 'recipe=s' => \$recipe, # Recipe to use48 43 'camera|c=s' => \$camera, # Camera 49 44 'dbname|d=s' => \$dbname, # Database name … … 52 47 'reduction=s' => \$reduction, # Reduction class 53 48 'dvodb|w=s' => \$dvodb, # output DVO database 54 ' run-state=s' => \$run_state, # 'new' or 'update'49 'image-only' => \$image_only, # Print to stdout 55 50 'verbose' => \$verbose, # Print to stdout 56 51 'no-update' => \$no_update, # Update the database? … … 74 69 my $logDest = $ipprc->filename("LOG.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 75 70 76 if (not defined $run_state) { $run_state = 'new'; }77 if ($run_state eq 'update') {78 $logDest .= '.update';79 }80 81 71 if ($redirect) { 82 72 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $add_id, $PS_EXIT_SYS_ERROR ); … … 89 79 $reduction = 'DEFAULT' unless defined $reduction; 90 80 81 # XXX This is now not used: do we still need it? 91 82 my $recipe_addstar = $ipprc->reduction($reduction, 'ADDSTAR'); # Recipe to use 92 83 &my_die("Unrecognised ADDSTAR recipe", $add_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_addstar; 93 84 94 #my $recipe_psastro = $ipprc->reduction($reduction, 'PSASTRO'); # Recipe to use95 #&my_die("Unrecognised PSASTRO recipe", $cam_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;96 97 85 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 98 99 my $cmdflags;100 101 # Get list of component files102 my $files; # Array of component files103 {104 my $command = "$addtool -pendingexp -add_id $add_id"; # Command to run105 $command .= " -dbname $dbname" if defined $dbname;106 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =107 run(command => $command, verbose => $verbose);108 unless ($success) {109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);110 &my_die("Unable to perform addtool: $error_code", $add_id, $error_code);111 }112 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or113 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_PROG_ERROR);114 115 # extract the metadata for the files into a hash list116 $files = parse_md_list($metadata) or117 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);118 }119 120 my $chipObjectsExist = 0;121 86 122 87 # Output products … … 126 91 my $fpaObjects = $ipprc->filename("PSASTRO.OUTPUT", $camroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 127 92 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot) or &my_die("Missing entry from camera config", $add_id, $PS_EXIT_CONFIG_ERROR); 128 129 if ($run_state eq 'update') {130 $traceDest .= '.update';131 }132 93 133 94 # convert supplied DVO database name to UNIX filename … … 141 102 142 103 unless ($no_op) { 143 if (defined $dvodbReal and ($run_state eq 'new')) { 144 ## XXX the camera analysis can either save the full set of 145 ## detections, or just the image metadata, in the dvodb 104 if (defined $dvodbReal) { 105 106 ## addstar can either save the full set of detections, or just 107 ## the image metadata, in the dvodb. this is set in the 108 ## database table addRun 146 109 147 ## get the addstar recipe for this camera and CAMERA reduction 148 my $command = "$ppConfigDump -camera $camera -recipe ADDSTAR $recipe_addstar -dump-recipe ADDSTAR -"; 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => $verbose); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to perform ppConfigDump: $error_code", $add_id, $PS_EXIT_SYS_ERROR); 154 } 155 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 156 &my_die("Unable to parse metadata config doc", $add_id, $PS_EXIT_SYS_ERROR); 157 158 ## allow the dvodb to save only images, or the full detection set 159 my $imagesOnly = metadataLookupBool($recipeData, 'IMAGES.ONLY'); 160 161 # XXX this construct requires the user to have a valid .ptolemyrc 162 # XXX which in turn points at ippconfig/dvo.site 110 # addstar requires the user to have a valid .ptolemyrc which 111 # in turn points at ippconfig/dvo.site 112 113 # get the names for the camera and the real input file 114 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 115 my $realFile = $ipprc->file_resolve($fpaObjects); 116 163 117 # require a defined output dvo database to run addstar (ie, refuse to use the .ptolemyrc default) 164 # XXX this needs to be converted to addstar_client... 165 166 my $camdir = $ipprc->dvo_cameradir(); # Camera directory for addstar 167 $command = "$addstar -D CAMERA $camdir -update"; 168 $command .= " -image" if $imagesOnly; 118 my $command = "$addstar -update"; # XXX optionally set -update? 119 $command .= " -D CAMERA $camdir"; 169 120 $command .= " -D CATDIR $dvodbReal"; 170 171 my $realFile = $ipprc->file_resolve($fpaObjects);172 121 $command .= " $realFile"; 122 $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference 123 $command .= " -image" if $image_only; 173 124 174 125 my $mjd_addstar_start = DateTime->now->mjd; # MJD of starting script 175 126 176 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 177 128 run(command => $command, verbose => $verbose); 178 129 unless ($success) { … … 184 135 } 185 136 186 187 137 # This needs to be updated when addtool is written. BROKEN 188 138 my $fpaCommand = "$addtool -add_id $add_id"; 189 if ($run_state eq 'new') { 190 $fpaCommand .= " -addprocessedexp"; 191 $fpaCommand .= " -path_base $outroot"; 192 $fpaCommand .= " $cmdflags"; 193 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 194 } else { 195 $fpaCommand .= " -updaterun -state full"; 196 } 139 $fpaCommand .= " -addprocessedexp"; 140 $fpaCommand .= " -path_base $outroot"; 141 $fpaCommand .= " -dtime_addstar $dtime_addstar"; 197 142 $fpaCommand .= " -dbname $dbname" if defined $dbname; 198 143 … … 223 168 # This needs to be updated when addtool is written. BROKEN 224 169 my $command = "$addtool -add_id $add_id"; 225 if ($run_state eq 'new') { 226 $command .= " -addprocessedexp"; 227 $command .= " -uri UNKNOWN"; 228 $command .= " -fault $exit_code"; 229 $command .= " -path_base $outroot"; 230 $command .= " -path_base $outroot" if defined $outroot; 231 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 232 } else { 233 $command .= " -updateprocessedexp"; 234 $command .= " -fault $exit_code"; 235 } 170 $command .= " -addprocessedexp"; 171 $command .= " -fault $exit_code"; 172 $command .= " -path_base $outroot" if defined $outroot; 173 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 236 174 $command .= " -dbname $dbname" if defined $dbname; 237 175 system ($command); … … 239 177 exit $exit_code; 240 178 } 241 242 179 243 180 END { -
trunk/ippScripts/scripts/camera_exp.pl
r25299 r25816 39 39 } 40 40 41 my ( $exp_tag, $cam_id, $camera, $outroot, $ recipe, $dbname, $reduction, $dvodb, $verbose, $no_update,41 my ( $exp_tag, $cam_id, $camera, $outroot, $dbname, $reduction, $dvodb, $verbose, $no_update, 42 42 $no_op, $redirect, $save_temps, $run_state); 43 43 GetOptions( 44 44 'exp_tag=s' => \$exp_tag, # Exposure identifier 45 45 'cam_id=s' => \$cam_id, # Camtool identifier 46 'recipe=s' => \$recipe, # Recipe to use47 46 'camera|c=s' => \$camera, # Camera 48 47 'dbname|d=s' => \$dbname, # Database name -
trunk/ippScripts/scripts/flatcorr_proc.pl
r23688 r25816 104 104 my ($DECs, $DECe) = split (",", $coords[1]); 105 105 106 # Run addstar -resort to ensure the db is indexed 107 { 108 my $command = "$addstar -resort"; 106 # Run addstar -resort to ensure the db is indexed 107 # XXX addstar should be able to recognize and skip indexed tables 108 { 109 my $command = "$addstar -resort"; 109 110 $command .= " -D CATDIR $dvodb"; 110 111 $command .= " -region $RAs $RAe $DECs $DECe"; -
trunk/ippTasks/addstar.pro
r25693 r25816 121 121 book getword addPendingExp $pageName exp_tag -var EXP_TAG 122 122 book getword addPendingExp $pageName add_id -var ADD_ID 123 book getword addPendingExp $pageName cam _id -var CAM_ID123 book getword addPendingExp $pageName camroot -var CAMROOT 124 124 book getword addPendingExp $pageName workdir -var WORKDIR_TEMPLATE 125 book getword addPendingExp $pageName reduction -var REDUCTION 125 126 book getword addPendingExp $pageName dvodb -var DVODB 127 book getword addPendingExp $pageName image_only -var IMAGE_ONLY 126 128 book getword addPendingExp $pageName dbname -var DBNAME 127 book getword addPendingExp $pageName reduction -var REDUCTION128 book getword addPendingExp $pageName state -var RUN_STATE129 129 130 130 # specify choice of remote host based on camera and chip (class_id) … … 144 144 ## generate outroot specific to this exposure (& chip) 145 145 sprintf outroot "%s/%s/%s.add.%s" $WORKDIR $EXP_TAG $EXP_TAG $ADD_ID 146 sprintf camroot "%s/%s/%s.cm.%s" $WORKDIR $EXP_TAG $EXP_TAG $CAM_ID147 146 148 147 stdout $LOGDIR/addstar.exp.log 149 148 stderr $LOGDIR/addstar.exp.log 150 149 151 $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA -- outroot $outroot --camroot $camroot --redirect-output --run-state $RUN_STATE150 $run = addstar_run.pl --exp_tag $EXP_TAG --add_id $ADD_ID --camera $CAMERA --dvodb $DVODB --camroot $CAMROOT --outroot $outroot --redirect-output 152 151 if ("$REDUCTION" != "NULL") 153 152 $run = $run --reduction $REDUCTION 154 153 end 155 if ("$DVODB" != "NULL") 156 $run = $run --dvodb $DVODB 157 end 154 if ("$IMAGE_ONLY" == "T") 155 $run = $run --image-only 156 end 157 158 158 add_standard_args run 159 159 -
trunk/ippTasks/flatcorr.pro
r25785 r25816 2 2 ## this file contains the tasks for running the flatcorr stage 3 3 ## these tasks use the book 'flatcorrBook' 4 5 # test for required global variables6 check.globals7 8 book init flatcorrBook9 10 macro flatcorr.reset11 book init flatcorrBook12 end13 14 macro flatcorr.status15 book listbook flatcorrBook16 end17 18 macro flatcorr.on19 task flatcorr.advancecamera20 active true21 end22 task flatcorr.load23 active true24 end25 task flatcorr.run26 active true27 end28 end29 30 macro flatcorr.off31 task flatcorr.advancecamera32 active false33 end34 task flatcorr.load35 active false36 end37 task flatcorr.run38 active false39 end40 end41 42 # these variables will cycle through the known ippdb database names43 $flatcorr_advancecamera_DB = 044 $flatcorr_pendingprocess_DB = 045 4 46 5 # a flat-field correction run is initiated (manually) with a command like: … … 57 16 # flatcorr -advancecamera 58 17 59 # we wait for the completed chip and camera analysis and search for 18 # as the camera analysis progresses, we need to occasionally migrate the 19 # completed exposures to the addstar stage by calling: 20 # flatcorr -advanceaddstar 21 22 # we wait for the completed addstar jobs and search for 60 23 # completed processing analysis with: 61 24 # flatcorr -pendingprocess … … 66 29 # and failures with: 67 30 # flatcorr -addprocess -fault N 31 32 # test for required global variables 33 check.globals 34 35 book init flatcorrBook 36 37 macro flatcorr.reset 38 book init flatcorrBook 39 end 40 41 macro flatcorr.status 42 book listbook flatcorrBook 43 end 44 45 macro flatcorr.on 46 task flatcorr.advancecamera 47 active true 48 end 49 task flatcorr.advanceaddstar 50 active true 51 end 52 task flatcorr.load 53 active true 54 end 55 task flatcorr.run 56 active true 57 end 58 end 59 60 macro flatcorr.off 61 task flatcorr.advancecamera 62 active false 63 end 64 task flatcorr.advanceaddstar 65 active false 66 end 67 task flatcorr.load 68 active false 69 end 70 task flatcorr.run 71 active false 72 end 73 end 74 75 # these variables will cycle through the known ippdb database names 76 $flatcorr_advancecamera_DB = 0 77 $flatcorr_advanceaddstar_DB = 0 78 $flatcorr_pendingprocess_DB = 0 68 79 69 80 # migrate complete flatcorr chips to the camera stage analysis … … 114 125 end 115 126 127 # migrate complete flatcorr exposures to the addstar process 128 task flatcorr.advanceaddstar 129 host local 130 131 # check the list of pending flatcorr runs 132 periods -poll 5 133 periods -exec 30 134 periods -timeout 60 135 npending 1 136 137 task.exec 138 # define the command (does not depend on previous queries) 139 if ($DB:n == 0) 140 command flatcorr -advanceaddstar 141 else 142 # save the DB name for the exit tasks 143 # note that this DB name refers to the ippdb, not the dvodb 144 option $DB:$flatcorr_advanceaddstar_DB 145 command flatcorr -advanceaddstar -dbname $DB:$flatcorr_advanceaddstar_DB 146 $flatcorr_advanceaddstar_DB ++ 147 if ($flatcorr_advanceaddstar_DB >= $DB:n) set flatcorr_advanceaddstar_DB = 0 148 end 149 end 150 151 # silently drop stdout 152 stdout NULL 153 stderr $LOGDIR/flatcorr.log 154 155 # success (no action required) 156 task.exit $EXIT_SUCCESS 157 end 158 159 # locked list 160 task.exit default 161 showcommand failure 162 end 163 164 task.exit crash 165 showcommand crash 166 end 167 168 # operation times out? 169 task.exit timeout 170 showcommand timeout 171 end 172 end 173 116 174 # create new flatcorr entries for the currently known DVO databases 117 175 # run this multiple times once an hour - on pass for each db … … 123 181 periods -exec $LOADEXEC 124 182 periods -timeout 60 125 active false126 183 npending 1 127 184 … … 180 237 periods -exec $LOADEXEC 181 238 periods -timeout 60 182 active false183 239 184 240 # silently drop stdout -
trunk/ippTools/share/Makefile.am
r25800 r25816 152 152 faketool_unmasked.sql \ 153 153 flatcorr_chiprundone.sql \ 154 flatcorr_camerarundone.sql \ 154 155 flatcorr_pendingprocess.sql \ 155 156 flatcorr_inputimfile.sql \ -
trunk/ippTools/share/addtool_find_pendingexp.sql
r25789 r25816 1 1 SELECT 2 2 addRun.*, 3 camProcessedExp.path_base as camroot, 3 4 rawExp.exp_tag, 4 5 rawExp.exp_id, … … 9 10 FROM addRun 10 11 JOIN camRun 12 USING(cam_id) 13 JOIN camProcessedExp 11 14 USING(cam_id) 12 15 JOIN chipRun … … 21 24 camRun.state = 'full' 22 25 AND ((addRun.state = 'new' AND addProcessedExp.add_id IS NULL) OR addRun.state = 'update') 26 AND addRun.dvodb IS NOT NULL 27 AND addRun.workdir IS NOT NULL 23 28 AND addMask.label IS NULL 24 29 -
trunk/ippTools/share/addtool_queue_cam_id.sql
r25299 r25816 6 6 '%s', -- workdir 7 7 '%s', -- workdir_state 8 '%s', -- reduction 8 9 '%s', -- label 9 10 '%s', -- dvodb 10 0 -- magicked11 %d -- image_only 11 12 FROM camRun 12 13 WHERE -
trunk/ippTools/share/flatcorr_chiprundone.sql
r20397 r25816 1 1 SELECT 2 2 corr_id, 3 cam_id,4 3 chipRun.* 5 4 FROM flatcorrRun … … 14 13 AND flatcorrChipLink.include = 1 15 14 AND chipRun.state = 'full' 16 AND camRun.cam_id is NULL ;15 AND camRun.cam_id is NULL -
trunk/ippTools/share/flatcorr_pendingprocess.sql
r20397 r25816 10 10 reduction, 11 11 region, 12 c hip_count,13 cam_count12 cam_count, 13 add_count 14 14 FROM 15 15 (SELECT 16 16 flatcorrRun.*, 17 flatcorrC hipLink.corr_id as chip_corr_id,18 count(flatcorrC hipLink.chip_id) as chip_count17 flatcorrCamLink.corr_id as cam_corr_id, 18 count(flatcorrCamLink.cam_id) as cam_count 19 19 FROM flatcorrRun 20 JOIN flatcorrC hipLink21 ON flatcorrChipLink.corr_id = flatcorrRun.corr_id22 WHERE flatcorrC hipLink.include = 120 JOIN flatcorrCamLink 21 USING (corr_id) 22 WHERE flatcorrCamLink.include = 1 23 23 GROUP BY 24 flatcorrC hipLink.corr_id) AS t124 flatcorrCamLink.corr_id) AS t1 25 25 LEFT JOIN 26 26 (SELECT 27 flatcorr CamLink.corr_id as cam_corr_id,28 count(flatcorr CamLink.cam_id) as cam_count29 FROM flatcorr CamLink30 JOIN camRun31 ON flatcorrCamLink.cam_id = camRun.cam_id32 WHERE camRun.state = 'full'33 AND flatcorr CamLink.include = 127 flatcorrAddstarLink.corr_id as add_corr_id, 28 count(flatcorrAddstarLink.add_id) as add_count 29 FROM flatcorrAddstarLink 30 JOIN addRun 31 USING (add_id) 32 WHERE addRun.state = 'full' 33 AND flatcorrAddstarLink.include = 1 34 34 GROUP BY 35 flatcorr CamLink.corr_id) AS t236 ON t1.c hip_corr_id = t2.cam_corr_id37 WHERE c hip_count = cam_count35 flatcorrAddstarLink.corr_id) AS t2 36 ON t1.cam_corr_id = t2.add_corr_id 37 WHERE cam_count = add_count 38 38 AND state = 'new' -
trunk/ippTools/share/pxadmin_create_tables.sql
r25795 r25816 464 464 workdir VARCHAR(255), 465 465 workdir_state VARCHAR(64), 466 reduction VARCHAR(64), 466 467 label VARCHAR(64), 467 468 dvodb VARCHAR(255), 468 magicked BIGINT,469 image_only TINYINT, 469 470 PRIMARY KEY(add_id), 470 471 KEY(add_id), … … 480 481 add_id BIGINT AUTO_INCREMENT, 481 482 dtime_addstar FLOAT, 482 n_stars INT,483 483 path_base VARCHAR(255), 484 484 fault SMALLINT NOT NULL, … … 1182 1182 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1183 1183 1184 -- these t wo tables link the flatcorrRun to the associated chip and cameraruns1184 -- these three tables link the flatcorrRun to the associated chip, camera, and addstar runs 1185 1185 CREATE TABLE flatcorrChipLink ( 1186 1186 corr_id BIGINT, … … 1201 1201 FOREIGN KEY(chip_id) REFERENCES chipRun(chip_id), 1202 1202 FOREIGN KEY(cam_id) REFERENCES camRun(cam_id) 1203 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1204 1205 CREATE TABLE flatcorrAddstarLink ( 1206 corr_id BIGINT, 1207 cam_id BIGINT, 1208 add_id BIGINT, 1209 include TINYINT, 1210 PRIMARY KEY(corr_id, cam_id, add_id), 1211 FOREIGN KEY (corr_id) REFERENCES flatcorrRun(corr_id), 1212 FOREIGN KEY (cam_id) REFERENCES camRun(cam_id), 1213 FOREIGN KEY (add_id) REFERENCES addRun(add_id) 1203 1214 ) ENGINE=innodb DEFAULT CHARSET=latin1; 1204 1215 -
trunk/ippTools/share/pxadmin_drop_tables.sql
r25795 r25816 59 59 DROP TABLE IF EXISTS flatcorrChipLink; 60 60 DROP TABLE IF EXISTS flatcorrCamLink; 61 DROP TABLE IF EXISTS flatcorrAddstarLink; 61 62 DROP TABLE IF EXISTS pstampDataStore; 62 63 DROP TABLE IF EXISTS pstampProject; -
trunk/ippTools/src/addtool.c
r25789 r25816 40 40 static bool maskedMode(pxConfig *config); 41 41 static bool unblockMode(pxConfig *config); 42 static bool pendingcleanuprunMode(pxConfig *config);43 static bool pendingcleanupexpMode(pxConfig *config);44 static bool donecleanupMode(pxConfig *config);45 static bool exportrunMode(pxConfig *config);46 static bool importrunMode(pxConfig *config);47 42 48 43 # define MODECASE(caseName, func) \ … … 74 69 MODECASE(ADDTOOL_MODE_MASKED, maskedMode); 75 70 MODECASE(ADDTOOL_MODE_UNBLOCK, unblockMode); 76 MODECASE(ADDTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode);77 MODECASE(ADDTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpMode);78 MODECASE(ADDTOOL_MODE_DONECLEANUP, donecleanupMode);79 MODECASE(ADDTOOL_MODE_EXPORTRUN, exportrunMode);80 MODECASE(ADDTOOL_MODE_IMPORTRUN, importrunMode);81 71 default: 82 72 psAbort("invalid option (this should not happen)"); … … 118 108 } 119 109 120 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 121 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 122 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 123 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 124 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 125 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 110 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", false, false); 111 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 112 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 113 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 114 PXOPT_LOOKUP_BOOL(image_only, config->args, "-image_only", false); 115 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 116 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 126 117 127 118 // find the cam_id of all the exposures that we want to queue up. … … 170 161 } 171 162 163 // loop over our list of camRun rows to check the supplied and selected dvodb and workdir values: 164 for (long i = 0; i < psArrayLength(output); i++) { 165 psMetadata *md = output->data[i]; 166 167 camRunRow *row = camRunObjectFromMetadata(md); 168 if (!row) { 169 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 170 psFree(output); 171 return false; 172 } 173 174 if (!dvodb && !row->dvodb) { 175 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined dvodb: label: %s, cam_id %" PRId64, row->label, row->cam_id); 176 psFree(output); 177 return false; 178 } 179 if (!workdir && !row->workdir) { 180 psError(PS_ERR_UNKNOWN, false, "cannot queue addstar run without a defined workdir: label: %s, cam_id %" PRId64, row->label, row->cam_id); 181 psFree(output); 182 return false; 183 } 184 185 psFree(row); 186 } 187 172 188 // start a transaction so we don't end up with an exp without any associted 173 189 // imfiles … … 183 199 // old values in place (i.e., passing the values through). 184 200 185 186 // loop over our list of addRun rows 201 // loop over our list of camRun rows 187 202 for (long i = 0; i < psArrayLength(output); i++) { 188 203 psMetadata *md = output->data[i]; … … 190 205 camRunRow *row = camRunObjectFromMetadata(md); 191 206 if (!row) { 192 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into addRun");207 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun"); 193 208 psFree(output); 194 209 return false; … … 199 214 row->cam_id, 200 215 workdir ? workdir : row->workdir, 216 reduction ? reduction : row->reduction, 201 217 label ? label : row->label, 202 "RECIPE", 203 dvodb ? dvodb : row->dvodb 204 218 dvodb ? dvodb : row->dvodb, 219 image_only 205 220 )) { 206 221 if (!psDBRollback(config->dbh)) { … … 234 249 PXOPT_COPY_S64(config->args, where, "-cam_id", "camRun.cam_id", "=="); 235 250 pxcamGetSearchArgs (config, where); // most search arguments based on camera 236 237 251 PXOPT_COPY_STR(config->args, where, "-label", "addRun.label", "=="); 238 252 PXOPT_COPY_STR(config->args, where, "-state", "addRun.state", "=="); … … 287 301 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 288 302 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 289 290 303 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 291 304 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 349 362 350 363 // optional 351 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false); 352 PXOPT_LOOKUP_S32(n_stars, config->args, "-n_stars", false, false); 353 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 354 PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false); 364 PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false); 365 PXOPT_LOOKUP_F32(dtime_addstar, config->args, "-dtime_addstar", false, false); 366 PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false); 355 367 356 368 // generate restrictions … … 401 413 pendingRow->add_id, 402 414 dtime_addstar, 403 n_stars,404 415 path_base, 405 0416 fault 406 417 ); 407 418 … … 418 429 419 430 // since there is only one exp per 'new' set addRun.state = 'full' 420 if (!pxaddRunSetState(config, row->add_id, "full" , magicked)) {431 if (!pxaddRunSetState(config, row->add_id, "full")) { 421 432 psError(PS_ERR_UNKNOWN, false, "failed to change addRun.state for add_id: %" PRId64, row->add_id); 422 433 psFree(row); … … 439 450 { 440 451 PS_ASSERT_PTR_NON_NULL(config, false); 441 442 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);443 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);444 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false);445 452 446 453 // generate restrictions … … 451 458 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "=="); 452 459 PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "=="); 460 461 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 462 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 463 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 453 464 454 465 if (!psListLength(where->list) && … … 628 639 PS_ASSERT_PTR_NON_NULL(config, false); 629 640 630 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);631 632 641 psMetadata *where = psMetadataAlloc(); 633 642 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "=="); 634 643 PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "=="); 644 PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false); 635 645 636 646 if (!pxSetFaultCode(config->dbh, "addProcessedExp", where, fault)) { … … 713 723 return true; 714 724 } 715 716 static bool pendingcleanuprunMode(pxConfig *config)717 {718 PS_ASSERT_PTR_NON_NULL(config, NULL);719 720 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);721 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);722 723 psMetadata *where = psMetadataAlloc();724 pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");725 726 psString query = pxDataGet("addtool_pendingcleanuprun.sql");727 if (!query) {728 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");729 return false;730 }731 732 if (where && psListLength(where->list)) {733 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);734 psStringAppend(&query, " AND %s", whereClause);735 psFree(whereClause);736 }737 psFree(where);738 739 // treat limit == 0 as "no limit"740 if (limit) {741 psString limitString = psDBGenerateLimitSQL(limit);742 psStringAppend(&query, " %s", limitString);743 psFree(limitString);744 }745 746 if (!p_psDBRunQuery(config->dbh, query)) {747 psError(PS_ERR_UNKNOWN, false, "database error");748 psFree(query);749 return false;750 }751 psFree(query);752 753 psArray *output = p_psDBFetchResult(config->dbh);754 if (!output) {755 psError(PS_ERR_UNKNOWN, false, "database error");756 return false;757 }758 if (!psArrayLength(output)) {759 psTrace("addtool", PS_LOG_INFO, "no rows found");760 psFree(output);761 return true;762 }763 764 // negative simple so the default is true765 if (!ippdbPrintMetadatas(stdout, output, "addPendingCleanupRun", !simple)) {766 psError(PS_ERR_UNKNOWN, false, "failed to print array");767 psFree(output);768 return false;769 }770 771 psFree(output);772 773 return true;774 }775 776 777 static bool pendingcleanupexpMode(pxConfig *config)778 {779 PS_ASSERT_PTR_NON_NULL(config, NULL);780 781 PXOPT_LOOKUP_S64(add_id, config->args, "-add_id", false, false);782 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);783 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);784 785 psMetadata *where = psMetadataAlloc();786 if (add_id) {787 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "==");788 }789 pxAddLabelSearchArgs (config, where, "-label", "label", "==");790 791 psString query = pxDataGet("addtool_pendingcleanupexp.sql");792 if (!query) {793 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");794 return false;795 }796 797 if (where && psListLength(where->list)) {798 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);799 psStringAppend(&query, " AND %s", whereClause);800 psFree(whereClause);801 }802 psFree(where);803 804 // treat limit == 0 as "no limit"805 if (limit) {806 psString limitString = psDBGenerateLimitSQL(limit);807 psStringAppend(&query, " %s", limitString);808 psFree(limitString);809 }810 811 if (!p_psDBRunQuery(config->dbh, query)) {812 psError(PS_ERR_UNKNOWN, false, "database error");813 psFree(query);814 return false;815 }816 psFree(query);817 818 psArray *output = p_psDBFetchResult(config->dbh);819 if (!output) {820 psError(PS_ERR_UNKNOWN, false, "database error");821 return false;822 }823 if (!psArrayLength(output)) {824 psTrace("chiptool", PS_LOG_INFO, "no rows found");825 psFree(output);826 return true;827 }828 829 // negative simple so the default is true830 if (!ippdbPrintMetadatas(stdout, output, "addPendingCleanupExp", !simple)) {831 psError(PS_ERR_UNKNOWN, false, "failed to print array");832 psFree(output);833 return false;834 }835 836 psFree(output);837 838 return true;839 }840 841 842 static bool donecleanupMode(pxConfig *config)843 {844 PS_ASSERT_PTR_NON_NULL(config, NULL);845 846 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);847 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);848 849 psMetadata *where = psMetadataAlloc();850 PXOPT_COPY_STR(config->args, where, "-label", "label", "==");851 852 psString query = pxDataGet("addtool_donecleanup.sql");853 if (!query) {854 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");855 return false;856 }857 858 if (where && psListLength(where->list)) {859 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);860 psStringAppend(&query, " AND %s", whereClause);861 psFree(whereClause);862 }863 psFree(where);864 865 // treat limit == 0 as "no limit"866 if (limit) {867 psString limitString = psDBGenerateLimitSQL(limit);868 psStringAppend(&query, " %s", limitString);869 psFree(limitString);870 }871 872 if (!p_psDBRunQuery(config->dbh, query)) {873 psError(PS_ERR_UNKNOWN, false, "database error");874 psFree(query);875 return false;876 }877 psFree(query);878 879 psArray *output = p_psDBFetchResult(config->dbh);880 if (!output) {881 psError(PS_ERR_UNKNOWN, false, "database error");882 return false;883 }884 if (!psArrayLength(output)) {885 psTrace("addtool", PS_LOG_INFO, "no rows found");886 psFree(output);887 return true;888 }889 890 // negative simple so the default is true891 if (!ippdbPrintMetadatas(stdout, output, "addDoneCleanup", !simple)) {892 psError(PS_ERR_UNKNOWN, false, "failed to print array");893 psFree(output);894 return false;895 }896 897 psFree(output);898 899 return true;900 }901 902 bool exportrunMode(pxConfig *config)903 {904 typedef struct ExportTable {905 char tableName[80];906 char sqlFilename[80];907 } ExportTable;908 909 int numExportTables = 2;910 911 PS_ASSERT_PTR_NON_NULL(config, NULL);912 913 PXOPT_LOOKUP_S64(det_id, config->args, "-add_id", true, false);914 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false);915 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);916 PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);917 918 FILE *f = fopen (outfile, "w");919 if (f == NULL) {920 psError(PS_ERR_UNKNOWN, false, "failed to open output file");921 return false;922 }923 924 psMetadata *where = psMetadataAlloc();925 PXOPT_COPY_S64(config->args, where, "-add_id", "add_id", "==");926 927 ExportTable tables [] = {928 {"addRun", "addtool_export_run.sql"},929 {"addProcessedExp", "addtool_export_processed_exp.sql"},930 };931 932 for (int i=0; i < numExportTables; i++) {933 psString query = pxDataGet(tables[i].sqlFilename);934 if (!query) {935 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");936 return false;937 }938 939 if (where && psListLength(where->list)) {940 psString whereClause = psDBGenerateWhereSQL(where, NULL);941 psStringAppend(&query, " %s", whereClause);942 psFree(whereClause);943 }944 945 // treat limit == 0 as "no limit"946 if (limit) {947 psString limitString = psDBGenerateLimitSQL(limit);948 psStringAppend(&query, " %s", limitString);949 psFree(limitString);950 }951 952 if (!p_psDBRunQuery(config->dbh, query)) {953 psError(PS_ERR_UNKNOWN, false, "database error");954 psFree(query);955 return false;956 }957 psFree(query);958 959 psArray *output = p_psDBFetchResult(config->dbh);960 if (!output) {961 psError(PS_ERR_UNKNOWN, false, "database error");962 return false;963 }964 if (!psArrayLength(output)) {965 psError(PS_ERR_UNKNOWN, true, "no rows found");966 psFree(output);967 return false;968 }969 970 if (clean) {971 if (!strcmp(tables[i].tableName, "addRun")) {972 if (!pxSetStateCleaned("addRun", "state", output)) {973 psFree(output);974 psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s", tables[i].tableName);975 return false;976 }977 }978 }979 980 // we must write the export table in non-simple (true) format981 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {982 psError(PS_ERR_UNKNOWN, false, "failed to print array");983 psFree(output);984 return false;985 }986 psFree(output);987 }988 989 fclose (f);990 991 return true;992 }993 994 bool importrunMode(pxConfig *config)995 {996 unsigned int nFail;997 998 PS_ASSERT_PTR_NON_NULL(config, NULL);999 1000 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false);1001 1002 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false);1003 1004 fprintf (stdout, "---- input ----\n");1005 psMetadataPrint (stderr, input, 1);1006 1007 psMetadataItem *item = psMetadataLookup (input, "addRun");1008 psAssert (item, "entry not in input?");1009 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");1010 1011 psMetadataItem *entry = psListGet (item->data.list, 0);1012 assert (entry);1013 assert (entry->type == PS_DATA_METADATA);1014 addRunRow *addRun = addRunObjectFromMetadata (entry->data.md);1015 addRunInsertObject (config->dbh, addRun);1016 1017 // fprintf (stdout, "---- add run ----\n");1018 // psMetadataPrint (stderr, entry->data.md, 1);1019 1020 item = psMetadataLookup (input, "addProcessedExp");1021 psAssert (item, "entry not in input?");1022 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");1023 1024 for (int i = 0; i < item->data.list->n; i++) {1025 psMetadataItem *entry = psListGet (item->data.list, i);1026 assert (entry);1027 assert (entry->type == PS_DATA_METADATA);1028 addProcessedExpRow *addProcessedExp = addProcessedExpObjectFromMetadata (entry->data.md);1029 addProcessedExpInsertObject (config->dbh, addProcessedExp);1030 1031 // fprintf (stdout, "---- row %d ----\n", i);1032 // psMetadataPrint (stderr, entry->data.md, 1);1033 }1034 1035 return true;1036 } -
trunk/ippTools/src/addtoolConfig.c
r25789 r25816 58 58 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction", 0, "define reduction class", NULL); 59 59 psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dvodb", 0, "define DVO db", NULL); 60 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-image_only", 0, "addstar image metadata but not detections", false); 60 61 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend", 0, "do not actually modify the database", false); 62 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 61 63 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all", 0, "allow everything to be queued without search terms", false); 62 psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);63 64 64 65 // -updaterun … … 87 88 psMetadata *addprocessedexpArgs = psMetadataAlloc(); 88 89 psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "define addtool ID (required)", 0); 90 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 89 91 psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-dtime_addstar", 0, "define elapsed time for DVO insertion (seconds)", NAN); 90 psMetadataAddS32(addprocessedexpArgs, PS_LIST_TAIL, "-n_stars", 0, "define number of stars", 0); 91 psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0, "define base output location", NULL); 92 psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-magicked", 0, "set magicked", 0); 92 psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 93 93 94 94 // -processedexp … … 101 101 102 102 psMetadataAddU64(processedexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 103 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 104 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0, "only return imfiles with a fault status set", false); 103 105 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-all", 0, "list everything without restriction", false); 104 psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);105 106 106 107 // -revertprocessedexp … … 118 119 psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by addtool ID", 0); 119 120 psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-cam_id", 0, "search by camtool ID", 0); 121 psMetadataAddS16(updateprocessedexpArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0); 120 122 121 123 // -block … … 130 132 psMetadata *unblockArgs = psMetadataAlloc(); 131 133 psMetadataAddStr(unblockArgs, PS_LIST_TAIL, "-label", 0, "name of a label to unmask (required)", NULL); 132 133 // -pendingcleanuprun134 psMetadata *pendingcleanuprunArgs = psMetadataAlloc();135 psMetadataAddStr(pendingcleanuprunArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);136 psMetadataAddBool(pendingcleanuprunArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);137 psMetadataAddU64(pendingcleanuprunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);138 139 // -pendingcleanupexp140 psMetadata *pendingcleanupexpArgs = psMetadataAlloc();141 psMetadataAddStr(pendingcleanupexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);142 psMetadataAddS64(pendingcleanupexpArgs, PS_LIST_TAIL, "-add_id", 0, "search by addstar ID", 0);143 psMetadataAddBool(pendingcleanupexpArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);144 psMetadataAddU64(pendingcleanupexpArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);145 146 // -donecleanup147 psMetadata *donecleanupArgs = psMetadataAlloc();148 psMetadataAddStr(donecleanupArgs, PS_LIST_TAIL, "-label", 0, "list blocks for specified label", NULL);149 psMetadataAddBool(donecleanupArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);150 psMetadataAddU64(donecleanupArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);151 152 // -exportrun153 psMetadata *exportrunArgs = psMetadataAlloc();154 psMetadataAddS64(exportrunArgs, PS_LIST_TAIL, "-add_id", 0, "export this addstar ID (required)", 0);155 psMetadataAddStr(exportrunArgs, PS_LIST_TAIL, "-outfile", 0, "export to this file (required)", NULL);156 psMetadataAddU64(exportrunArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0);157 psMetadataAddBool(exportrunArgs, PS_LIST_TAIL, "-clean", 0, "export tables as cleaned", false);158 159 // -importrun160 psMetadata *importrunArgs = psMetadataAlloc();161 psMetadataAddStr(importrunArgs, PS_LIST_TAIL, "-infile", 0, "import from this file (required)", NULL);162 163 134 164 135 psMetadata *argSets = psMetadataAlloc(); … … 175 146 PXOPT_ADD_MODE("-masked", "show blocked labels", ADDTOOL_MODE_MASKED, maskedArgs); 176 147 PXOPT_ADD_MODE("-unblock", "remove a label block", ADDTOOL_MODE_UNBLOCK, unblockArgs); 177 PXOPT_ADD_MODE("-pendingcleanuprun", "show runs that need to be cleaned up", ADDTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunArgs);178 PXOPT_ADD_MODE("-pendingcleanupexp", "show exps for cleanup runs", ADDTOOL_MODE_PENDINGCLEANUPEXP, pendingcleanupexpArgs);179 PXOPT_ADD_MODE("-donecleanup", "show runs that have been cleaned", ADDTOOL_MODE_DONECLEANUP, donecleanupArgs);180 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", ADDTOOL_MODE_EXPORTRUN, exportrunArgs);181 PXOPT_ADD_MODE("-importrun", "import run from metadata file", ADDTOOL_MODE_IMPORTRUN, importrunArgs);182 148 183 149 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
trunk/ippTools/src/flatcorr.c
r25784 r25816 33 33 #include "pxtools.h" 34 34 #include "pxchip.h" 35 #include "pxcam.h" 36 #include "pxadd.h" 35 37 #include "flatcorr.h" 36 38 … … 38 40 static bool definerunMode(pxConfig *config); 39 41 static bool addchipMode(pxConfig *config); 42 static bool dropchipMode(pxConfig *config); 40 43 static bool addcameraMode(pxConfig *config); 44 static bool dropcameraMode(pxConfig *config); 41 45 static bool advancecameraMode(pxConfig *config); 42 static bool dropchipMode(pxConfig *config); 43 static bool dropcameraMode(pxConfig *config); 46 static bool advanceaddstarMode(pxConfig *config); 44 47 static bool pendingprocessMode(pxConfig *config); 45 48 static bool addprocessMode(pxConfig *config); … … 47 50 static bool inputexpMode(pxConfig *config); 48 51 static bool inputimfileMode(pxConfig *config); 49 static bool exportrunMode(pxConfig *config);50 static bool importrunMode(pxConfig *config);51 52 52 53 static bool setflatcorrRunState(pxConfig *config, psS64 corr_id, const char *state); … … 73 74 MODECASE(FLATCORR_MODE_DEFINERUN, definerunMode); 74 75 MODECASE(FLATCORR_MODE_ADDCHIP, addchipMode); 76 MODECASE(FLATCORR_MODE_DROPCHIP, dropchipMode); 75 77 MODECASE(FLATCORR_MODE_ADDCAMERA, addcameraMode); 78 MODECASE(FLATCORR_MODE_DROPCAMERA, dropcameraMode); 76 79 MODECASE(FLATCORR_MODE_ADVANCECAMERA, advancecameraMode); 77 MODECASE(FLATCORR_MODE_DROPCHIP, dropchipMode); 78 MODECASE(FLATCORR_MODE_DROPCAMERA, dropcameraMode); 80 MODECASE(FLATCORR_MODE_ADVANCEADDSTAR, advanceaddstarMode); 79 81 MODECASE(FLATCORR_MODE_PENDINGPROCESS, pendingprocessMode); 80 82 MODECASE(FLATCORR_MODE_ADDPROCESS, addprocessMode); … … 82 84 MODECASE(FLATCORR_MODE_INPUTEXP, inputexpMode); 83 85 MODECASE(FLATCORR_MODE_INPUTIMFILE, inputimfileMode); 84 MODECASE(FLATCORR_MODE_EXPORTRUN, exportrunMode);85 MODECASE(FLATCORR_MODE_IMPORTRUN, importrunMode);86 86 default: 87 87 psAbort("invalid option (this should not happen)"); … … 404 404 } 405 405 406 static bool dropcameraMode(pxConfig *config) 407 { 408 PS_ASSERT_PTR_NON_NULL(config, false); 409 410 // required 411 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 412 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", true, false); 413 414 // UPDATE flatcorrCamLink set include = 0 where corr_id = %lld AND cam_id = %lld 415 psString query = pxDataGet("flatcorr_dropcamera.sql"); 416 if (!query) { 417 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 418 return false; 419 } 420 421 if (!p_psDBRunQueryF(config->dbh, query, (long long) corr_id, (long long) cam_id)) { 422 psError(PS_ERR_UNKNOWN, false, "database error"); 423 psFree(query); 424 return false; 425 } 426 427 return true; 428 } 429 406 430 // select the flatcorr chip runs that have completed and for which there is no camera entry 407 431 // queue a new camera run for them … … 413 437 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 414 438 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 439 440 psMetadata *where = psMetadataAlloc(); 441 pxAddLabelSearchArgs (config, where, "-label", "flatcorrRun.label", "=="); 415 442 416 443 psString query = pxDataGet("flatcorr_chiprundone.sql"); … … 419 446 return false; 420 447 } 448 449 if (where && psListLength(where->list)) { 450 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 451 psStringAppend(&query, " AND %s", whereClause); 452 psFree(whereClause); 453 } 454 psFree(where); 421 455 422 456 // treat limit == 0 as "no limit" … … 528 562 } 529 563 530 static bool dropcameraMode(pxConfig *config) 531 { 532 PS_ASSERT_PTR_NON_NULL(config, false); 533 534 // required 535 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 536 PXOPT_LOOKUP_S64(cam_id, config->args, "-cam_id", true, false); 537 538 // UPDATE flatcorrCamLink set include = 0 where corr_id = %lld AND cam_id = %lld 539 psString query = pxDataGet("flatcorr_dropcamera.sql"); 540 if (!query) { 541 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 542 return false; 543 } 544 545 if (!p_psDBRunQueryF(config->dbh, query, (long long) corr_id, (long long) cam_id)) { 546 psError(PS_ERR_UNKNOWN, false, "database error"); 547 psFree(query); 548 return false; 549 } 550 551 return true; 552 } 553 554 // select the flatcorr chip runs that have completed and for which there is no camera entry 555 // queue a new camera run for them 556 static bool pendingprocessMode(pxConfig *config) 564 // Select the flatcorr camera runs that have completed and for which there is no addstar 565 // entry. Queue a new addstar run for them 566 static bool advanceaddstarMode(pxConfig *config) 557 567 { 558 568 PS_ASSERT_PTR_NON_NULL(config, false); … … 560 570 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 561 571 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 572 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 562 573 563 574 psMetadata *where = psMetadataAlloc(); 564 pxAddLabelSearchArgs (config, where, "-label", " label", "==");565 566 psString query = pxDataGet("flatcorr_ pendingprocess.sql");575 pxAddLabelSearchArgs (config, where, "-label", "flatcorrRun.label", "=="); 576 577 psString query = pxDataGet("flatcorr_camerarundone.sql"); 567 578 if (!query) { 568 579 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); … … 601 612 } 602 613 614 if (pretend) { 615 // negative simple so the default is true 616 if (!ippdbPrintMetadatas(stdout, output, "flatcorr_addcamera", !simple)) { 617 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 618 psFree(output); 619 return false; 620 } 621 } 622 623 // start a transaction so we don't end up with an exp without any associted 624 // imfiles 625 if (!psDBTransaction(config->dbh)) { 626 psError(PS_ERR_UNKNOWN, false, "database error"); 627 psFree(output); 628 return false; 629 } 630 631 // loop over our list of chipRun rows 632 for (long i = 0; i < psArrayLength(output); i++) { 633 psMetadata *md = output->data[i]; 634 635 bool status; 636 psS64 corr_id = psMetadataLookupS64(&status, md, "corr_id"); 637 if (!status) { 638 if (!psDBRollback(config->dbh)) { 639 psError(PS_ERR_UNKNOWN, false, "database error"); 640 } 641 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for corr_id"); 642 psFree(output); 643 return false; 644 } 645 646 camRunRow *row = camRunObjectFromMetadata(md); 647 if (!row) { 648 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 649 psFree(output); 650 return false; 651 } 652 653 // queue the exp : force image_only to be false (flatcorr is meaningless with just image info) 654 if (!pxaddQueueByCamID( 655 config, 656 row->cam_id, 657 row->workdir, 658 row->reduction, 659 row->label, 660 row->dvodb, 661 0)) { 662 if (!psDBRollback(config->dbh)) { 663 psError(PS_ERR_UNKNOWN, false, "database error"); 664 } 665 psError(PS_ERR_UNKNOWN, false, 666 "failed to trying to queue cam_id: %" PRId64, row->cam_id); 667 psFree(row); 668 psFree(output); 669 return false; 670 } 671 672 // figure out the ID of the flatcorrRun we just created 673 psS64 add_id = psDBLastInsertID(config->dbh); 674 675 // add the addRun entry to the flatcorrAddstarLink table (include is TRUE) 676 if (!flatcorrAddstarLinkInsert(config->dbh, corr_id, row->cam_id, add_id, 1)) { 677 if (!psDBRollback(config->dbh)) { 678 psError(PS_ERR_UNKNOWN, false, "database error"); 679 } 680 psError(PS_ERR_UNKNOWN, false, "database error"); 681 return false; 682 } 683 psFree(row); 684 } 685 psFree(output); 686 687 if (!psDBCommit(config->dbh)) { 688 psError(PS_ERR_UNKNOWN, false, "database error"); 689 return false; 690 } 691 692 return false; 693 } 694 695 // select the flatcorr chip runs that have completed and for which there is no camera entry 696 // queue a new camera run for them 697 static bool pendingprocessMode(pxConfig *config) 698 { 699 PS_ASSERT_PTR_NON_NULL(config, false); 700 701 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 702 PXOPT_LOOKUP_BOOL(limit, config->args, "-limit", false); 703 704 psMetadata *where = psMetadataAlloc(); 705 pxAddLabelSearchArgs (config, where, "-label", "label", "=="); 706 707 psString query = pxDataGet("flatcorr_pendingprocess.sql"); 708 if (!query) { 709 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 710 return false; 711 } 712 713 if (where && psListLength(where->list)) { 714 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 715 psStringAppend(&query, " AND %s", whereClause); 716 psFree(whereClause); 717 } 718 psFree(where); 719 720 // treat limit == 0 as "no limit" 721 if (limit) { 722 psString limitString = psDBGenerateLimitSQL(limit); 723 psStringAppend(&query, " %s", limitString); 724 psFree(limitString); 725 } 726 727 if (!p_psDBRunQuery(config->dbh, query)) { 728 psError(PS_ERR_UNKNOWN, false, "database error"); 729 psFree(query); 730 return false; 731 } 732 733 psArray *output = p_psDBFetchResult(config->dbh); 734 if (!output) { 735 psError(PS_ERR_UNKNOWN, false, "database error"); 736 return false; 737 } 738 if (!psArrayLength(output)) { 739 psTrace("flatcorr", PS_LOG_INFO, "no rows found"); 740 psFree(output); 741 return true; 742 } 743 603 744 if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) { 604 745 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 605 746 psFree(output); 606 747 return false; 748 } 749 750 return true; 751 } 752 753 // XXX need a fault state 754 static bool addprocessMode(pxConfig *config) 755 { 756 PS_ASSERT_PTR_NON_NULL(config, false); 757 758 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 759 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false); 760 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false); 761 762 char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64; 763 764 if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) { 765 psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id); 766 return false; 767 } 768 769 return true; 770 } 771 772 static bool updaterunMode(pxConfig *config) 773 { 774 PS_ASSERT_PTR_NON_NULL(config, false); 775 776 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false); 777 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false); 778 779 if (!setflatcorrRunState(config, corr_id, state)) { 780 if (!psDBRollback(config->dbh)) { 781 psError(PS_ERR_UNKNOWN, false, "database error"); 782 } 783 psError(PS_ERR_UNKNOWN, false, "failed to set run state"); 784 return false; 607 785 } 608 786 … … 714 892 } 715 893 716 // XXX need a fault state717 static bool addprocessMode(pxConfig *config)718 {719 PS_ASSERT_PTR_NON_NULL(config, false);720 721 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);722 PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);723 PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);724 725 char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64;726 727 if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) {728 psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id);729 return false;730 }731 732 return true;733 }734 735 static bool updaterunMode(pxConfig *config)736 {737 PS_ASSERT_PTR_NON_NULL(config, false);738 739 PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);740 PXOPT_LOOKUP_STR(state, config->args, "-state", true, false);741 742 if (!setflatcorrRunState(config, corr_id, state)) {743 if (!psDBRollback(config->dbh)) {744 psError(PS_ERR_UNKNOWN, false, "database error");745 }746 psError(PS_ERR_UNKNOWN, false, "failed to set run state");747 return false;748 }749 750 return true;751 }752 753 894 static bool setflatcorrRunState(pxConfig *config, psS64 corr_id, const char *state) 754 895 { … … 774 915 return true; 775 916 } 776 777 bool exportrunMode(pxConfig *config)778 {779 typedef struct ExportTable {780 char tableName[80];781 char sqlFilename[80];782 } ExportTable;783 784 int numExportTables = 3;785 786 PS_ASSERT_PTR_NON_NULL(config, NULL);787 788 PXOPT_LOOKUP_S64(det_id, config->args, "-corr_id", true, false);789 PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true, false);790 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);791 792 FILE *f = fopen (outfile, "w");793 if (f == NULL) {794 psError(PS_ERR_UNKNOWN, false, "failed to open output file");795 return false;796 }797 798 psMetadata *where = psMetadataAlloc();799 PXOPT_COPY_S64(config->args, where, "-corr_id", "corr_id", "==");800 801 ExportTable tables [] = {802 {"flatcorrRun", "flatcorr_export_run.sql"},803 {"flatcorrCamLink", "flatcorr_export_cam_link.sql"},804 {"flatcorrChipLink", "flatcorr_export_chip_link.sql"},805 };806 807 for (int i=0; i < numExportTables; i++) {808 psString query = pxDataGet(tables[i].sqlFilename);809 if (!query) {810 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");811 return false;812 }813 814 if (where && psListLength(where->list)) {815 psString whereClause = psDBGenerateWhereSQL(where, NULL);816 psStringAppend(&query, " %s", whereClause);817 psFree(whereClause);818 }819 820 // treat limit == 0 as "no limit"821 if (limit) {822 psString limitString = psDBGenerateLimitSQL(limit);823 psStringAppend(&query, " %s", limitString);824 psFree(limitString);825 }826 827 if (!p_psDBRunQuery(config->dbh, query)) {828 psError(PS_ERR_UNKNOWN, false, "database error");829 psFree(query);830 return false;831 }832 psFree(query);833 834 psArray *output = p_psDBFetchResult(config->dbh);835 if (!output) {836 psError(PS_ERR_UNKNOWN, false, "database error");837 return false;838 }839 if (!psArrayLength(output)) {840 psTrace("regtool", PS_LOG_INFO, "no rows found");841 psFree(output);842 return true;843 }844 845 // we must write the export table in non-simple (true) format846 if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {847 psError(PS_ERR_UNKNOWN, false, "failed to print array");848 psFree(output);849 return false;850 }851 psFree(output);852 }853 854 fclose (f);855 856 return true;857 }858 859 bool importrunMode(pxConfig *config)860 {861 unsigned int nFail;862 psMetadataItem *item, *entry;863 864 int numImportTables = 3;865 866 char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"};867 868 PS_ASSERT_PTR_NON_NULL(config, NULL);869 870 PXOPT_LOOKUP_STR(infile, config->args, "-infile", true, false);871 872 psMetadata *input = psMetadataConfigRead (NULL, &nFail, infile, false);873 874 fprintf (stdout, "---- input ----\n");875 psMetadataPrint (stderr, input, 1);876 877 for (int i = 0; i < numImportTables; i++) {878 item = psMetadataLookup (input, tables[i]);879 psAssert (item, "entry not in input?");880 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");881 882 entry = psListGet (item->data.list, 0);883 assert (entry);884 assert (entry->type == PS_DATA_METADATA);885 886 switch (i) {887 case 0:888 {889 flatcorrRunRow *flatcorrRun = flatcorrRunObjectFromMetadata (entry->data.md);890 flatcorrRunInsertObject (config->dbh, flatcorrRun);891 892 // fprintf (stdout, "---- flatcorr run ----\n");893 // psMetadataPrint (stderr, entry->data.md, 1);894 break;895 }896 case 1:897 {898 flatcorrCamLinkRow *flatcorrCamLink = flatcorrCamLinkObjectFromMetadata (entry->data.md);899 flatcorrCamLinkInsertObject (config->dbh, flatcorrCamLink);900 901 // fprintf (stdout, "---- flatcorr cam link ----\n");902 // psMetadataPrint (stderr, entry->data.md, 1);903 break;904 }905 case 2:906 {907 flatcorrChipLinkRow *flatcorrChipLink = flatcorrChipLinkObjectFromMetadata (entry->data.md);908 flatcorrChipLinkInsertObject (config->dbh, flatcorrChipLink);909 910 // fprintf (stdout, "---- flatcorr chip link ----\n");911 // psMetadataPrint (stderr, entry->data.md, 1);912 break;913 }914 }915 }916 return true;917 } -
trunk/ippTools/src/flatcorr.h
r25784 r25816 28 28 FLATCORR_MODE_DEFINERUN, 29 29 FLATCORR_MODE_ADDCHIP, 30 FLATCORR_MODE_DROPCHIP, 30 31 FLATCORR_MODE_ADDCAMERA, 32 FLATCORR_MODE_DROPCAMERA, 31 33 FLATCORR_MODE_ADVANCECAMERA, 32 FLATCORR_MODE_DROPCHIP, 33 FLATCORR_MODE_DROPCAMERA, 34 FLATCORR_MODE_ADVANCEADDSTAR, 34 35 FLATCORR_MODE_PENDINGPROCESS, 35 36 FLATCORR_MODE_ADDPROCESS, … … 37 38 FLATCORR_MODE_INPUTEXP, 38 39 FLATCORR_MODE_INPUTIMFILE, 39 FLATCORR_MODE_EXPORTRUN,40 FLATCORR_MODE_IMPORTRUN41 40 } flatcorrMode; 42 41 -
trunk/ippTools/src/flatcorrConfig.c
r25784 r25816 83 83 psMetadataAddS64(addchipArgs, PS_LIST_TAIL, "-chip_id", 0, "define Chip ID (required)", 0); 84 84 85 // -dropchip 86 psMetadata *dropchipArgs = psMetadataAlloc(); 87 psMetadataAddS64(dropchipArgs, PS_LIST_TAIL, "-corr_id", 0, "define Flat Correction ID (required)", 0); 88 psMetadataAddS64(dropchipArgs, PS_LIST_TAIL, "-chip_id", 0, "define Chip ID (required)", 0); 89 85 90 // -addcamera 86 91 psMetadata *addcameraArgs = psMetadataAlloc(); … … 89 94 psMetadataAddS64(addcameraArgs, PS_LIST_TAIL, "-cam_id", 0, "define Camera ID (required)", 0); 90 95 91 // -dropc hip92 psMetadata *dropc hipArgs = psMetadataAlloc();93 psMetadataAddS64(dropc hipArgs, PS_LIST_TAIL, "-corr_id", 0,"define Flat Correction ID (required)", 0);94 psMetadataAddS64(dropc hipArgs, PS_LIST_TAIL, "-chip_id", 0, "define ChipID (required)", 0);96 // -dropcamera 97 psMetadata *dropcameraArgs = psMetadataAlloc(); 98 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-corr_id", 0, "define Flat Correction ID (required)", 0); 99 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-cam_id", 0, "define Camera ID (required)", 0); 95 100 96 101 // -advancecamera … … 99 104 psMetadataAddBool(advancecameraArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 100 105 psMetadataAddBool(advancecameraArgs, PS_LIST_TAIL, "-pretend", 0, "use the simple output format", false); 106 psMetadataAddStr(advancecameraArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 101 107 102 // -dropcamera 103 psMetadata *dropcameraArgs = psMetadataAlloc(); 104 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-corr_id", 0, "define Flat Correction ID (required)", 0); 105 psMetadataAddS64(dropcameraArgs, PS_LIST_TAIL, "-cam_id", 0, "define Camera ID (required)", 0); 108 // -advanceaddstar 109 psMetadata *advanceaddstarArgs = psMetadataAlloc(); 110 psMetadataAddU64 (advanceaddstarArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 111 psMetadataAddBool(advanceaddstarArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 112 psMetadataAddBool(advanceaddstarArgs, PS_LIST_TAIL, "-pretend", 0, "use the simple output format", false); 113 psMetadataAddStr(advanceaddstarArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by label", NULL); 106 114 107 115 // -pendingprocess … … 155 163 PXOPT_ADD_MODE("-addcamera", "add an existing camera run to a flat correction run", FLATCORR_MODE_ADDCAMERA, addcameraArgs); 156 164 PXOPT_ADD_MODE("-advancecamera", "migrate completed chips to camera stage analysis", FLATCORR_MODE_ADVANCECAMERA, advancecameraArgs); 165 PXOPT_ADD_MODE("-advanceaddstar", "migrate completed exposures to addstar processing", FLATCORR_MODE_ADVANCEADDSTAR, advanceaddstarArgs); 157 166 PXOPT_ADD_MODE("-dropchip", "drop a chip from a flat correction run", FLATCORR_MODE_DROPCHIP, dropchipArgs); 158 167 PXOPT_ADD_MODE("-dropcamera", "drop an exposure (camera stage analysis)", FLATCORR_MODE_DROPCAMERA, dropcameraArgs); … … 162 171 PXOPT_ADD_MODE("-inputexp", "list exposures for a correction run", FLATCORR_MODE_INPUTEXP, inputexpArgs); 163 172 PXOPT_ADD_MODE("-inputimfile", "list imfiles for a chip run", FLATCORR_MODE_INPUTIMFILE, inputimfileArgs); 164 PXOPT_ADD_MODE("-exportrun", "export run for import on other database", FLATCORR_MODE_EXPORTRUN, exportrunArgs);165 PXOPT_ADD_MODE("-importrun", "import run from metadata file", FLATCORR_MODE_IMPORTRUN, importrunArgs);166 173 167 174 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
trunk/ippTools/src/pxadd.c
r25789 r25816 29 29 #include "pxadd.h" 30 30 31 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state , psS64 magicked)31 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state) 32 32 { 33 33 PS_ASSERT_PTR_NON_NULL(config, false); … … 41 41 } 42 42 43 char *query = "UPDATE addRun SET state = '%s', magicked = %" PRId64 " WHERE add_id = %" PRId64; 44 if (!p_psDBRunQueryF(config->dbh, query, state, magicked, add_id)) { 45 psError(PS_ERR_UNKNOWN, false, 46 "failed to change state for add_id %" PRId64, add_id); 43 char *query = "UPDATE addRun SET state = '%s' WHERE add_id = %" PRId64; 44 if (!p_psDBRunQueryF(config->dbh, query, state, add_id)) { 45 psError(PS_ERR_UNKNOWN, false, "failed to change state for add_id %" PRId64, add_id); 47 46 return false; 48 47 } … … 123 122 } 124 123 125 // Need to think more about this to see what we want it to do. BROKEN126 124 bool pxaddQueueByCamID(pxConfig *config, 127 125 psS64 cam_id, 128 126 char *workdir, 127 char *reduction, 129 128 char *label, 130 char * recipe,131 char *dvodb)129 char *dvodb, 130 bool image_only) 132 131 { 133 132 PS_ASSERT_PTR_NON_NULL(config, false); … … 149 148 if (!p_psDBRunQueryF(config->dbh, query, 150 149 "new", // state 151 workdir ? workdir : "NULL",150 workdir ? workdir : "NULL", 152 151 "dirty", //workdir_state 153 label ? label : "NULL", 154 dvodb ? dvodb : "NULL", 155 (long long)cam_id 152 reduction? reduction : "NULL", 153 label ? label : "NULL", 154 dvodb ? dvodb : "NULL", 155 image_only, 156 (long long) cam_id 156 157 )) { 157 158 psError(PS_ERR_UNKNOWN, false, "database error"); -
trunk/ippTools/src/pxadd.h
r25789 r25816 25 25 #include "pxtools.h" 26 26 27 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state , psS64 magicked);27 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state); 28 28 bool pxaddRunSetStateByQuery(pxConfig *config, psMetadata *where, const char *state); 29 29 bool pxaddRunSetLabel(pxConfig *config, psS64 add_id, const char *label); 30 30 bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label); 31 31 32 // Likely BROKEN33 32 bool pxaddQueueByCamID(pxConfig *config, 34 psS64 cam_id,35 char *workdir,36 char *label,37 char *recipe,38 char *dvodb); 39 33 psS64 cam_id, 34 char *workdir, 35 char *reduction, 36 char *label, 37 char *dvodb, 38 bool image_only); 40 39 41 40 #endif // PXADD_H
Note:
See TracChangeset
for help on using the changeset viewer.
