   
 (defn execute [event-fns]
   (doseq [event-fn event-fns :while (not (:stop @state))]
-    (while (:pause @state) (Thread/sleep 5))
-    (event-fn)))
+    (event-fn)
+    (await-resume)
+    ))
 
 (defn cleanup []
   (do-when #(.update %) (:display @state))

  [[] (atom {:running false :stop false})])

(defn -run [this settings acq-eng]
  (load-mm)
  (create-device-agents)
	(let [out-queue (GentleLinkedBlockingQueue.)


(defn acq-sleep [interval-ms]
  (let [target-time (+ (@state :last-wake-time) interval-ms)
        delta (- target-time (clock-ms))]
    (when (pos? delta)
      (interruptible-sleep delta))
    (await-resume)
    (let [now (clock-ms)
          wake-time (if (> now (+ target-time 10)) now target-time)]
      (swap! state assoc :last-wake-time wake-time))))

(declare device-agents)

