#!/bin/sh

#
# the default value for -iteration (e.g., you didn't specify -iteration) is 0
# it may make sense to make it default to the latest iteration number for a
# given det run
#
# so of the sanity checking still needs to be improved/tested 
#
# also worth noting is that the validity of the iteration value isn't yet
# checked
#

# create a new detrun
det_id=`dettool -define -exp_id 1 -exp_id 2 -exp_id 3 -det_type flat`

# list detruns (active only?)
dettool -runs

# get detrun status (iteration #)

# list the input exposures in a detRun
dettool -input -det_id $det_id

# list raw imfiles
dettool -raw -det_id $det_id

# register a processed imfile
dettool -addprocessed -det_id $det_id ...

# processed imfiles should mask out raw imfiles
dettool -raw -det_id $det_id

# list processed imfiles 
dettool -processed -det_id $det_id [-iteration]

# list processed imfiles for a chip (all or none)
dettool -processed -chip -det_id $det_id [-iteration]

# list all processed imfiles (even those that have been stacked)
dettool -processed -unmask -det_id $det_id [-iteration]

# register a stacked imfile
dettool -addstacked -det_id $det_id [-iteration] -class_id ...

# stacked imfiles should mask out processed imfiles
dettool -processed -det_id $det_id [-iteration]

# list stacked imfiles
dettool -stacked -det_id $det_id [-iteration]
# list stacked imfiles only for complete frames
dettool -stackedframe -det_id $det_id [-iteration]

# register a normalized imfile
dettool -addnormalized -det_id $det_id [-iteration] ...

# normalized imfiles should mask out stacked imfiles
dettool -stacked -det_id $det_id [-iteration]
# does a single normalized imfile mask out the entire frame?
dettool -stackedframe -det_id $det_id [-iteration]

# list normalized imfiles 
dettool -normalized -det_id $det_id[ -iteration]

# register a residual result
dettool -addresid -det_id $det_id [-iteration] -exp_id ... -class_id ... -stats ...

# residuals mask out normalized imfiles
dettool -normalized -det_id $det_id [-iteration]

# list residual imfile analyses
dettool -resid -det_id $det_id [iteration] -exp_id ... -class_id ... -stats ...

# register a residual exp XXX not sanity checked against all input class_ids having a resid registered
dettool -addresidexp -det_id $det_id [iteration] -stats ... -accept

# list residual exps
dettool -residexp -det_id $det_id [iteration]  

# register a/the master
dettool -declaremasterframe -det_id $det_id [-iteration ...]

# list masters
dettool -masterframe -det_id

# list imfiles in a master frame
dettool -master -det_id $det_id [-iteration ...]

# start another iteration but use only these input exps (must be a subset of
# the original input exps)
dettool -rerun -det_id $det_id -exp_id 1 -exp_id 2 -exp_id 3 


# always print out the det_type in the output for imfiles

# -addresid -uri
# -addresidexp -uri (big/small jpeg)

# -updatedresid for -accept
# -masterframe needs 'class'
# -nukemaster

pxinject

- class is currently in db at the imfile level, not the exp level.

dettool

- list of det_ids without registered masters
- -chip option is a bad name

for normalize to resid, support script needs to run different commands on basis
of type


# need a way to quiery live det runs
# add det run state tracking (alive or dead)
# die at the end of a det run... -rerun makes it live again ??
# -processed -chip (no -det_id) returns a list of ready det_id/class_id pairs

