
automate MULTI

# we run in the sequence BLOCK -> CHECK -> LAUNCH -> BLOCK -> CHECK
# success on CHECK -> LAUNCH
# failure on BLOCK -> CHECK

# XXX these steps all refer to "@DBNAME@"; they need to be more generic, even for the basic simtest analysis

automate METADATA
  name       STR BIAS
  check      STR "regtool -processedexp -exp_type BIAS -inst @CAMERA@ -dbname @DBNAME@"
  ncheck     S32 20
  launch     STR "dettool -definebyquery -workdir file://@CWD@/detwork -inst @CAMERA@ -det_type BIAS -select_exp_type BIAS -dbname @DBNAME@"
  block      STR "dettool -runs -active -det_type BIAS -dbname @DBNAME@"
END

automate METADATA
  name       STR DARK
  check      STR "detselect -search -inst @CAMERA@ -det_type BIAS -dbname @DBNAME@"
  launch     STR "dettool -definebyquery -workdir file://@CWD@/detwork -inst @CAMERA@ -det_type DARK -select_exp_type DARK -dbname @DBNAME@"
  block      STR "dettool -runs -active -det_type DARK -dbname @DBNAME@"
END
 
automate METADATA
  name       STR SHUTTER
  check      STR "detselect -search -inst @CAMERA@ -det_type DARK -dbname @DBNAME@"
  launch     STR "dettool -definebyquery -workdir file://@CWD@/detwork -inst @CAMERA@ -det_type SHUTTER -filter r -select_exp_type SKYFLAT -select_filter r -dbname @DBNAME@"
  block      STR "dettool -runs -active -det_type SHUTTER -dbname @DBNAME@"
END

automate METADATA
  name       STR FLAT-r
  check      STR "detselect -search -inst @CAMERA@ -det_type SHUTTER -dbname @DBNAME@"
  launch     STR "dettool -definebyquery -workdir file://@CWD@/detwork -inst @CAMERA@ -det_type FLAT -filter r -select_exp_type SKYFLAT -select_filter r -dbname @DBNAME@"
  block      STR "dettool -runs -active -det_type FLAT -filter r -dbname @DBNAME@"
END

automate METADATA
  name       STR FLAT-i
  check      STR "detselect -search -inst @CAMERA@ -det_type SHUTTER -dbname @DBNAME@"
  launch     STR "dettool -definebyquery -workdir file://@CWD@/detwork -inst @CAMERA@ -det_type FLAT -filter i -select_exp_type SKYFLAT -select_filter i -dbname @DBNAME@"
  block      STR "dettool -runs -active -det_type FLAT -filter i -dbname @DBNAME@"
END

automate METADATA
  name       STR OBJECT-i
  check      STR "detselect -dbname @DBNAME@ -search    -inst @CAMERA@ -filter i -det_type FLAT"
  launch     STR "chiptool  -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter i -label wait -set_label proc"
  block      STR NONE
END

automate METADATA
  name       STR OBJECT-r
  check      STR "detselect -dbname @DBNAME@ -search    -inst @CAMERA@ -filter r -det_type FLAT"
  launch     STR "chiptool  -dbname @DBNAME@ -updaterun -inst @CAMERA@ -filter r -label wait -set_label proc"
  block      STR NONE
END

### Stack automation???
automate METADATA
  name       STR STACK
  regular    STR "stacktool -definebyquery -label proc -workdir file://@CWD@/stack -min_new 4 -min_num 4 -min_frac 2 -select_good_frac_min 0.2 -dbname @DBNAME@"
END

