               1 [(.x stage-pos)]
               2 [(.x stage-pos) (.y stage-pos)])])))})
 
-; engine
+;; 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) #(.setProperty mmc (prop 0) (prop 1) (prop 2))]))))
+
+(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))

      :doZStack_               :use-z-stack
      :skipFactorFrame_        :skip-frames
      :useChannel_             :use-channel
    )
    (assoc :properties (get-config (. mmc getChannelGroup) (.config_ chan)))))

(defn MultiStagePosition-to-map [^MultiStagePosition msp]

  (-> settings
    (data-object-to-map)
    (assoc :frames (range (.numFrames settings))
           :channels (filter :use-channel (map ChannelSpec-to-map (.channels settings)))
           :positions (map MultiStagePosition-to-map (.positions settings)))
    (rekey
      :slicesFirst             :slices-first
