Index: trunk/ippTasks/magic.pro
===================================================================
--- trunk/ippTasks/magic.pro	(revision 20760)
+++ trunk/ippTasks/magic.pro	(revision 20790)
@@ -8,25 +8,25 @@
 
 ### Initialise the books containing the tasks to do
-book init magicTree
-book init magicProcess
-book init magicMask
+book init magicToTree
+book init magicToProcess
+book init magicToDS
 
 ### Database lists
-$magicTree_DB = 0
-$magicProcess_DB = 0
-$magicMask_DB = 0
+$magicToTree_DB = 0
+$magicToProcess_DB = 0
+$magicToDS_DB = 0
 
 ### Check status of tasks
 macro magic.status
-  book listbook magicTree
-  book listbook magicProcess
-  book listbook magicMask
+  book listbook magicToTree
+  book listbook magicToProcess
+  book listbook magicToDS
 end
 
 ### Reset tasks
 macro magic.reset
-  book init magicTree
-  book init magicProcess
-  book init magicMask
+  book init magicToTree
+  book init magicToProcess
+  book init magicToDS
 end
 
@@ -45,8 +45,8 @@
     active true
   end
-  task magic.mask.load
-    active true
-  end
-  task magic.mask.run
+  task magic.destreak.load
+    active true
+  end
+  task magic.destreak.run
     active true
   end
@@ -54,5 +54,5 @@
 
 ### Turn tasks off
-macro magic.on
+macro magic.off
   task magic.tree.load
     active false
@@ -67,8 +67,8 @@
     active false
   end
-  task magic.mask.load
-    active false
-  end
-  task magic.mask.run
+  task magic.destreak.load
+    active false
+  end
+  task magic.destreak.run
     active false
   end
@@ -92,8 +92,8 @@
     else
       # save the DB name for the exit tasks
-      option $DB:$magicTree_DB
-      command magictool -totree -limit 20 -dbname $DB:$magicTree_DB
-      $magicTree_DB ++
-      if ($magicTree_DB >= $DB:n) set magicTree_DB = 0
+      option $DB:$magicToTree_DB
+      command magictool -totree -limit 20 -dbname $DB:$magicToTree_DB
+      $magicToTree_DB ++
+      if ($magicToTree_DB >= $DB:n) set magicToTree_DB = 0
     end
   end
@@ -102,11 +102,11 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout magicTree -key magic_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    ipptool2book stdout magicToTree -key magic_id -uniq -setword dbname $options:0 -setword pantaskState INIT
     if ($VERBOSE > 2)
-      book listbook magicTree
+      book listbook magicToTree
     end
 
     # delete existing entries in the appropriate pantaskStates
-    process_cleanup magicTree
+    process_cleanup magicToTree
   end
 
@@ -128,21 +128,21 @@
 
   task.exec
-    book npages magicTree -var N
+    book npages magicToTree -var N
     if ($N == 0) break
     if ($NETWORK == 0) break
     
     # look for new images (pantaskState == INIT)
-    book getpage magicTree 0 -var pageName -key pantaskState INIT
+    book getpage magicToTree 0 -var pageName -key pantaskState INIT
     if ("$pageName" == "NULL") break
 
-    book setword magicTree $pageName pantaskState RUN
-    book getword magicTree $pageName magic_id -var MAGIC_ID
-    book getword magicTree $pageName exp_id -var EXP_ID
-    book getword magicTree $pageName camera -var CAMERA
-    book getword magicTree $pageName workdir -var WORKDIR_TEMPLATE
-    book getword magicTree $pageName dbname -var DBNAME
-    book getword magicTree $pageName tess_id -var TESS_DIR
-    book getword magicTree $pageName ra -var RA
-    book getword magicTree $pageName decl -var DEC
+    book setword magicToTree $pageName pantaskState RUN
+    book getword magicToTree $pageName magic_id -var MAGIC_ID
+    book getword magicToTree $pageName exp_id -var EXP_ID
+    book getword magicToTree $pageName camera -var CAMERA
+    book getword magicToTree $pageName workdir -var WORKDIR_TEMPLATE
+    book getword magicToTree $pageName dbname -var DBNAME
+    book getword magicToTree $pageName tess_id -var TESS_DIR
+    book getword magicToTree $pageName ra -var RA
+    book getword magicToTree $pageName decl -var DEC
 
 #    set.host.for.camera $CAMERA $MAGIC_ID
@@ -184,5 +184,5 @@
   # default exit status
   task.exit    default
-    process_exit magicTree $options:0 $JOB_STATUS
+    process_exit magicToTree $options:0 $JOB_STATUS
   end
 
@@ -190,5 +190,5 @@
   task.exit    timeout
     showcommand timeout
-    book setword magicTree $options:0 pantaskState TIMEOUT
+    book setword magicToTree $options:0 pantaskState TIMEOUT
   end
 end
@@ -211,8 +211,8 @@
     else
       # save the DB name for the exit tasks
-      option $DB:$magicTree_DB
-      command magictool -toprocess -limit 20 -dbname $DB:$magicProcess_DB
-      $magicProcess_DB ++
-      if ($magicProcess_DB >= $DB:n) set magicProcess_DB = 0
+      option $DB:$magicToTree_DB
+      command magictool -toprocess -limit 20 -dbname $DB:$magicToProcess_DB
+      $magicToProcess_DB ++
+      if ($magicToProcess_DB >= $DB:n) set magicToProcess_DB = 0
     end
   end
@@ -221,11 +221,11 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout magicProcess -key magic_id:node -uniq -setword dbname $options:0 -setword pantaskState INIT
+    ipptool2book stdout magicToProcess -key magic_id:node -uniq -setword dbname $options:0 -setword pantaskState INIT
     if ($VERBOSE > 2)
-      book listbook magicProcess
+      book listbook magicToProcess
     end
 
     # delete existing entries in the appropriate pantaskStates
-    process_cleanup magicProcess
+    process_cleanup magicToProcess
   end
 
@@ -247,19 +247,19 @@
 
   task.exec
-    book npages magicProcess -var N
+    book npages magicToProcess -var N
     if ($N == 0) break
     if ($NETWORK == 0) break
     
     # look for new images (pantaskState == INIT)
-    book getpage magicProcess 0 -var pageName -key pantaskState INIT
+    book getpage magicToProcess 0 -var pageName -key pantaskState INIT
     if ("$pageName" == "NULL") break
 
-    book setword magicProcess $pageName pantaskState RUN
-    book getword magicProcess $pageName magic_id -var MAGIC_ID
-    book getword magicProcess $pageName exp_id -var EXP_ID
-    book getword magicProcess $pageName node -var NODE
-    book getword magicProcess $pageName camera -var CAMERA
-    book getword magicProcess $pageName workdir -var WORKDIR_TEMPLATE
-    book getword magicProcess $pageName dbname -var DBNAME
+    book setword magicToProcess $pageName pantaskState RUN
+    book getword magicToProcess $pageName magic_id -var MAGIC_ID
+    book getword magicToProcess $pageName exp_id -var EXP_ID
+    book getword magicToProcess $pageName node -var NODE
+    book getword magicToProcess $pageName camera -var CAMERA
+    book getword magicToProcess $pageName workdir -var WORKDIR_TEMPLATE
+    book getword magicToProcess $pageName dbname -var DBNAME
 
 #    set.host.for.camera $CAMERA $MAGIC_ID
@@ -298,5 +298,5 @@
   # default exit status
   task.exit    default
-    process_exit magicProcess $options:0 $JOB_STATUS
+    process_exit magicToProcess $options:0 $JOB_STATUS
   end
 
@@ -304,9 +304,9 @@
   task.exit    timeout
     showcommand timeout
-    book setword magicProcess $options:0 pantaskState TIMEOUT
-  end
-end
-
-task	       magic.mask.load
+    book setword magicToProcess $options:0 pantaskState TIMEOUT
+  end
+end
+
+task	       magic.destreak.load
   host         local
 
@@ -316,20 +316,17 @@
   npending     1
 
-# this task is not ready to go yet
-active false
-
   stdout NULL
-  stderr $LOGDIR/magic.mask.log
+  stderr $LOGDIR/magic.destreak.log
 
   task.exec
     if ($DB:n == 0)
       option DEFAULT
-      command magictool -tomask -limit 20
+      command magicdstool -todestreak -limit 20
     else
       # save the DB name for the exit tasks
-      option $DB:$magicMask_DB
-      command magictool -tomask -limit 20 -dbname $DB:$magicMask_DB
-      $magicMask_DB ++
-      if ($magicMask_DB >= $DB:n) set magicMask_DB = 0
+      option $DB:$magicToDS_DB
+      command magicdstool -todestreak -limit 20 -dbname $DB:$magicToDS_DB
+      $magicToDS_DB ++
+      if ($magicToDS_DB >= $DB:n) set magicToDS_DB = 0
     end
   end
@@ -338,11 +335,11 @@
   task.exit    0
     # convert 'stdout' to book format
-    ipptool2book stdout magicMask -key magic_id -uniq -setword dbname $options:0 -setword pantaskState INIT
+    ipptool2book stdout magicToDS -key magic_ds_id:component -uniq -setword dbname $options:0 -setword pantaskState INIT
     if ($VERBOSE > 2)
-      book listbook magicMask
+      book listbook magicToDS
     end
 
     # delete existing entries in the appropriate pantaskStates
-    process_cleanup magicMask
+    process_cleanup magicToDS
   end
 
@@ -358,49 +355,43 @@
 end
 
-task	       magic.mask.run
+task	       magic.destreak.run
   periods      -poll $RUNPOLL
   periods      -exec $RUNEXEC
   periods      -timeout 60
 
-#this task is not ready to go yet
-active false
-
-  task.exec
-    book npages magicMask -var N
+  task.exec
+    book npages magicToDS -var N
     if ($N == 0) break
     if ($NETWORK == 0) break
     
     # look for new images (pantaskState == INIT)
-    book getpage magicMask 0 -var pageName -key pantaskState INIT
+    book getpage magicToDS 0 -var pageName -key pantaskState INIT
     if ("$pageName" == "NULL") break
 
-    book setword magicMask $pageName pantaskState RUN
-    book getword magicMask $pageName magic_id -var MAGIC_ID
-    book getword magicMask $pageName exp_id -var EXP_ID
-    book getword magicMask $pageName camera -var CAMERA
-    book getword magicMask $pageName workdir -var WORKDIR_TEMPLATE
-    book getword magicMask $pageName dbname -var DBNAME
-
-#    set.host.for.camera $CAMERA $MAGIC_ID
-#    set.workdir.by.camera $CAMERA $MAGIC_ID $WORKDIR_TEMPLATE $default_host WORKDIR
+    book setword magicToDS $pageName pantaskState RUN
+    book getword magicToDS $pageName magic_ds_id -var MAGIC_DS_ID
+    book getword magicToDS $pageName camera -var CAMERA
+    book getword magicToDS $pageName streaks_uri -var STREAKS
+    book getword magicToDS $pageName stage -var STAGE
+    book getword magicToDS $pageName stage_id -var STAGE_ID
+    book getword magicToDS $pageName component -var COMPONENT
+    book getword magicToDS $pageName uri -var URI
+    book getword magicToDS $pageName path_base -var PATH_BASE
+    book getword magicToDS $pageName cam_path_base -var CAM_PATH_BASE
+    book getword magicToDS $pageName outroot -var OUTROOT
+    book getword magicToDS $pageName recoveryroot -var RECROOT
+    book getword magicToDS $pageName re_place -var REPLACE
+    book getword magicToDS $pageName remove -var REMOVE
+    book getword magicToDS $pageName dbname -var DBNAME
+
+    sprintf logfile "%s/mgcds.%s.%s.%s.log" $OUTROOT $MAGIC_DS_ID $STAGE_ID $COMPONENT
+
     host anyhost
-    $WORKDIR = $WORKDIR_TEMPLATE
-
-    basename $TESS_DIR -var TESS_ID
-    sprintf outroot "%s/%s/%s.mgc.%s.mask" $WORKDIR $EXP_ID $EXP_ID $MAGIC_ID
-
-    ## generate output log based on filerule (convert the URI to a PATH)
-    $logfile = `ipp_filename.pl --filerule LOG.EXP --camera $CAMERA --class_id $MAGIC_ID --basename $outroot`
-    if ("$logfile" == "") 
-      echo "WARNING: logfile not defined in magic.tree.run"
-      break
-    end
-
-    stdout $logfile
-    stderr $logfile
-    dirname $logfile -var outpath
-    mkdir $outpath
-
-    $run = magic_mask.pl --magic_id $MAGIC_ID --camera $CAMERA --outroot $outroot --logfile $logfile
+
+    # TODO: do not add recoveryroot, replace, or remove if they are null or zero
+
+    $run = magic_destreak.pl --magic_ds_id $MAGIC_DS_ID --camera $CAMERA --streaks $STREAKS --stage $STAGE --stage_id $STAGE_ID --component $COMPONENT --uri $URI --path_base $PATH_BASE --cam_path_base $CAM_PATH_BASE --outroot $OUTROOT
+    # --recoveryroot $RECROOT --replace $REPLACE --remove $REMOVE 
+    # --logfile $logfile
     add_standard_args run
 
@@ -416,13 +407,19 @@
 
   # default exit status
-  task.exit    default
-    process_exit magicMask $options:0 $JOB_STATUS
+  task.exit    0
+    process_exit magicToDS $options:0 $JOB_STATUS
    end
 
+  # locked list
+  task.exit    default
+    showcommand failure
+    process_exit magicToDS $options:0 $JOB_STATUS
+  end
+
   # operation timed out?
   task.exit    timeout
     showcommand timeout
-    book setword magicMask $options:0 pantaskState TIMEOUT
-  end
-end
-
+    book setword magicToDS $options:0 pantaskState TIMEOUT
+  end
+end
+
