 (defn random-error [prob]
   (when (< (rand) prob)
     (throw (Exception. "Simulated error"))))
-
-(defmacro time* [expr]
- `(do (println "Timing: " '~expr)
-      (time ~expr)))
 
 ;; globals
 

(defn run-acquisition [this settings out-queue]
  (try
    (def acq-settings settings)
    (log "Starting MD Acquisition: " settings)
    (prepare-state this)
    (binding [state (.state this)]
      (def last-state state) ; for debugging

  (let [z-drive (@state :default-z-drive)
        z0 (get-z-stage-position z-drive)]
  (try
    (log "running autofocus " (.. gui getAutofocusManager getDevice getDeviceName))
    (let [z (.. gui getAutofocusManager getDevice fullFocus)]
      (swap! state assoc-in [:last-stage-positions (@state :default-z-drive)] z))
    (catch Exception e
           (ReportingUtils/logError e "Autofocus failed.")
           (set-stage-position z-drive (+ 1.0e-6 z0))))))

(defn snap-image [open-before close-after]
  (with-core-setting [getAutoShutter setAutoShutter false]
