     (when-let [exposure (:exposure event)]
       (list [(core getCameraDevice) #(core setExposure exposure)]))))
 
-(defmacro successful? [& body]
-  `(try (do ~@body true)
-     (catch Exception e#
-            (do (ReportingUtils/logError e#) false))))
-
-
-(defn device-best-effort [dev fun]
-  (let [attempt #(do (wait-for-device dev) (fun))]
-    (when-not
-      (or
-        (successful? (attempt)) ; first attempt
-        (successful? (attempt)) ; second attempt
-        (successful? (reload-device dev) (attempt))) ; third attempt after reloading
-      (ReportingUtils/showError (str "Device failure: " dev ".\nAborting acquisition."))
-      (swap! state assoc :stop true))))
-
 (defn run-actions [action-map]
   (if run-devices-parallel
     (do


;; acq-engine

(defn get-z-stage-position [stage]
  (if-not (empty? stage) (core getPosition stage) 0))



(defn snap-image [open-before close-after]
  (with-core-setting [getAutoShutter setAutoShutter false]
    (let [shutter (core getShutterDevice)]
      (device-best-effort shutter
        (when open-before
          (core setShutterOpen true)
          (wait-for-device (core getShutterDevice))))
      (device-best-effort (core getCameraDevice)
        (core snapImage))
      (device-best-effort shutter
        (when close-after
          (core setShutterOpen false))
          (wait-for-device (core getShutterDevice))))))

(defn init-burst [length]
  (core setAutoShutter (@state :init-auto-shutter))
