## detrend.mkruns.pro : globals and support macros : -*- sh -*-

## XXX this script needs to be updated to use books, not queues
## XXX this script needs to be reconsidered...

## This script defines tasks which regularly initiate the detrend
## runs.  Each detrend type is given its own task, which are run once
## (or twice) per day to build the relevant detrend data

## when one of these tasks is run, it creates a new detrend run ID in
## the database, and selects the exposures for that run on the basis
## of the specified filters

# create a new detrend bias-creation run
task mkdetruns.megacam
  # command      dettool -select -time NOW -24h -type bias -camera megacam
  command      mkdetruns.megacam
  host         local

  periods      -poll 1
  periods      -exec 60
  periods      -timeout 30
  trange        18:00 19:00 -nmax 1

  # success: a new detrend run was created
  task.exit    0
    echo "new MEGACAM detrend runs"
    queueprint stdout
  end

  # default exit status
  task.exit default
    echo "unable to define a new detrend run"
  end

  # operation timed out?  is the database down?
  task.exit timeout
    # send someone email?
    echo "unable to define a new detrend run"
  end
end

# create a new detrend bias-creation run
task mkdetruns.isp
  # command      dettool -select -time NOW -24h -type bias -camera megacam
  command      mkdetruns.isp
  host         local

  periods      -poll 1
  periods      -exec 60
  periods      -timeout 30
  trange        18:00 19:00 -nmax 1

  # success: a new detrend run was created
  task.exit    0
    echo "new ISP detrend runs"
    queueprint stdout
  end

  # default exit status
  task.exit default
    echo "unable to define a new detrend run"
  end

  # operation timed out?  is the database down?
  task.exit timeout
    # send someone email?
    echo "unable to define a new detrend run"
  end
end

# create a new detrend bias-creation run
task mkdetruns.gpc
  # command      dettool -select -time NOW -24h -type bias -camera megacam
  command      mkdetruns.gpc
  host         local

  periods      -poll 1
  periods      -exec 60
  periods      -timeout 30
  trange        18:00 19:00 -nmax 1

  # success: a new detrend run was created
  task.exit    0
    echo "new GPC detrend runs"
    queueprint stdout
  end

  # default exit status
  task.exit default
    echo "unable to define a new detrend run"
  end

  # operation timed out?  is the database down?
  task.exit timeout
    # send someone email?
    echo "unable to define a new detrend run"
  end
end
