               2 [(.x stage-pos) (.y stage-pos)])])))})
 
 ;; acq-engine
-
-(defn set-stage-position
-  ([stage-dev z] (. mmc setPosition stage-dev z))
-  ([stage-dev x y] (. mmc setXYPosition stage-dev x y)))
-  
-(def device-agents
-  (let [devs (seq (. mmc getLoadedDevices))]
-    (zipmap devs (repeatedly (count devs) #(agent nil)))))
-    
-(defn create-presnap-actions [event]
-  (into {} (concat
-    (for [[axis pos] (get-in event [:position :axes])]
-      [axis #(apply set-stage-position axis pos)])
-    (for [prop (get-in event [:channel :properties])]
-      [(prop 0) #(apply* .setProperty mmc prop)]))))
-
-(defn send-device-action [dev action]
-  (send-off (device-agents dev) (fn [_] (action))))
-
-(defn run-actions [action-map]
-  (doseq [[dev action] action-map]
-    (send-device-action dev action))
-  (doseq [dev (keys action-map)]
-    (send-device-action dev #(. mmc waitForDevice dev)))
-  (apply await-for 10000 (vals device-agents)))
-
-(defn snap-image [event auto-shutter]
-  (if (and auto-shutter (. mmc getShutterOpen))
-    (. mmc setShutterOpen true)
-    (. mmc waitForDevice (. mmc getShutterDevice)))
-  (. mmc snapImage)
-  (if (and auto-shutter (event :close-shutter))
-     (. mmc setShutterOpen false))
-  (. mmc getImage))
-
-(defn start-burst [n-images]
-  (. mmc startSequenceAcquisition n-images 0 false)) 
-
-(defn collect-burst-image []
-  (while (zero? (. mmc remainingImageCount))
-    (Thread/sleep 5))
-  (. mmc popNextImage))   
-  
-(defn update-channel [event]
-  (when-let [channel (event :channel)]
-    (let [channel-group (. mmc getChannelGroup)
-          config (.config channel)]
-      (. mmc setConfig channel-group config))))
-      
-(defn update-slice [event]
-  (when-let [slice (event :slice)]
-    (when-let [focusDevice (. mmc getFocusDevice)]
-      (. mmc setPosition focusDevice slice))))
-
-(defn get-stage-positions [^MultiStagePosition msp]
-  (map #(.get msp %) (range (.size msp))))
-
-(defn update-position [event]
-  (when-let [position (event :position)]
-    (for [sp (get-stage-positions position)]
-      (let [stage (.stageName sp)]
-        (condp = (.numAxes sp)
-          1 (. mmc setPosition stage (.x sp))
-          2 (. mmc setXYPosition stage (.x sp) (.y sp)))))))
-          
-(defn run-autofocus [event]
-  (when (event :use-autofocus)
-    (.. gui getAutofocusManager getDevice fullFocus)))
-          
+ 
 (defn clock-ms []
   (quot (System/nanoTime) 1000000))
 

(defn test-dialog [eng]
  (.show (AcqControlDlg. eng (Preferences/userNodeForPackage (.getClass gui)) gui)))

   

   
      :skipAutofocusCount      :autofocus-skip
      :relativeZSlice          :relative-slices
      :intervalMs              :interval-ms
      :slices                  :slices
    )
    (assoc :frames (range (.numFrames settings))
           :channels (filter :use-channel (map ChannelSpec-to-map (.channels settings)))
           :positions (map MultiStagePosition-to-map (.positions settings)))))

(defn run-acquisition-from-settings [^SequenceSettings settings]
  (println settings)
  (def orig-settings settings)
  (println (run-acquisition (convert-settings settings))))

(defn create-acq-eng []
  (doto
