 (defn set-stage-position
   ([stage-dev z] (log "setting z position to " z)
 		 (core setPosition stage-dev z)
-		 (dosync alter state assoc :last-z-position z))
+		 (dosync (alter state assoc :last-z-position z)))
   ([stage-dev x y] (log "setting x,y position to " x "," y)
                    (when (and x y) (core setXYPosition stage-dev x y))))
 

    (event-fn)))

(defn stop-acq []
  (dosync alter state assoc-in [:interrupt-requests :stop] true))
  
(defn pause-acq []
  (dosync alter state assoc-in [:interrupt-requests :pause] true))
  
(defn run-acquisition [settings out-queue] 
  (def acq-settings settings)
  (binding
    [state (ref {:interrupt-requests {:pause false :stop false}
                 :z-corrections nil
                 :last-wake-time (clock-ms)
                 :start-time (clock-ms)


(ns org.micromanager.acq-engine
  (:use [org.micromanager.mm :only [when-lets map-config get-config get-positions 
                                    get-default-devices core log log-cmd mmc gui with-core-setting]]
        [org.micromanager.sequence-generator :only [generate-acq-sequence]])
  (:import [org.micromanager AcqControlDlg]
           [org.micromanager.api AcquisitionEngine]
