 (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))))
 


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

;; acq-engine

(defn acq-sleep [interval-ms]
  (let [target-time (+ (@state :last-wake-time) interval-ms)
        sleep-time (- target-time (clock-ms))]
    (log-cmd (@state :last-wake-time))
    (when (pos? sleep-time)
      (Thread/sleep sleep-time)
      (dosync (alter state assoc :last-wake-time target-time)))))

(declare device-agents)

