fix problem that sent z stage to 0

fix problem that sent z stage to 0

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@6967 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -1,706 +1,706 @@
-; FILE:         acq_engine.clj
-; PROJECT:      Micro-Manager
-; SUBSYSTEM:    mmstudio acquisition engine
-; ----------------------------------------------------------------------------
-; AUTHOR:       Arthur Edelstein, arthuredelstein@gmail.com, Dec 14, 2010
-;               Adapted from the acq eng by Nenad Amodaj and Nico Stuurman
-; COPYRIGHT:    University of California, San Francisco, 2006-2011
-; LICENSE:      This file is distributed under the BSD license.
-;               License text is included with the source distribution.
-;               This file is distributed in the hope that it will be useful,
-;               but WITHOUT ANY WARRANTY; without even the implied warranty
-;               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-;               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-;               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-;               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
-
-(ns org.micromanager.acq-engine
-  (:use [org.micromanager.mm :only [when-lets map-config get-config get-positions load-mm
-                                    get-default-devices core log log-cmd mmc gui with-core-setting
-                                    do-when if-args get-system-config-cached select-values-match?
-                                    get-property get-camera-roi parse-core-metadata]]
-        [org.micromanager.sequence-generator :only [generate-acq-sequence]])
-  (:import [org.micromanager AcqControlDlg]
-           [org.micromanager.api AcquisitionEngine TaggedImageAnalyzer]
-           [org.micromanager.acquisition AcquisitionWrapperEngine LiveAcqDisplay TaggedImageQueue
-                                         ProcessorStack SequenceSettings MMImageCache
-                                         TaggedImageStorageRam VirtualAcquisitionDisplay]
-           [org.micromanager.navigation MultiStagePosition StagePosition]
-           [mmcorej TaggedImage Configuration Metadata]
-           [java.util.prefs Preferences]
-           [java.net InetAddress]
-           [java.util.concurrent TimeUnit CountDownLatch]
-           [org.micromanager.utils ChannelSpec GentleLinkedBlockingQueue MDUtils
-                                   ReportingUtils]
-           [org.json JSONObject JSONArray]
-           [java.util Date UUID]
-           [java.text SimpleDateFormat]
-           [javax.swing SwingUtilities]
-           [ij ImagePlus])
-   (:gen-class
-     :name org.micromanager.AcqEngine
-     :implements [org.micromanager.api.Pipeline]
-     :init init
-     :state state))
-
-;; constants
-
-(def run-devices-parallel false)
-
-;; general utils
-
-(defn data-object-to-map [obj]
-  (into {}
-    (for [f (.getFields (type obj))
-          :when (zero? (bit-and
-                         (.getModifiers f) java.lang.reflect.Modifier/STATIC))]
-      [(keyword (.getName f)) (.get f obj)])))
-
-(defmacro apply* [& args]
-  `(~@(butlast args) ~@(eval (last args))))
-
-(defn rekey
-  ([m kold knew]
-    (-> m (dissoc kold) (assoc knew (get m kold))))
-  ([m kold knew & ks]
-    (reduce #(apply rekey %1 %2)
-      m (partition 2 (conj ks knew kold)))))
-
-(defn select-and-rekey [m & ks]
-    (apply rekey (select-keys m (apply concat (partition 1 2 ks))) ks))
-
-(defn clock-ms []
-  (quot (System/nanoTime) 1000000))
-
-;; mm utils
-
-(def iso8601modified (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss Z"))
-
-(defn get-current-time-str []
-  (. iso8601modified format (Date.)))
-
-(defn get-pixel-type []
-  (str ({1 "GRAY", 4 "RGB"} (int (core getNumberOfComponents))) (* 8 (core getBytesPerPixel))))
-
-(defn ChannelSpec-to-map [^ChannelSpec chan]
-  (-> chan
-    (data-object-to-map)
-    (select-and-rekey
-      :config_                 :name
-      :exposure_               :exposure
-      :zOffset_                :z-offset
-      :doZStack_               :use-z-stack
-      :skipFactorFrame_        :skip-frames
-      :useChannel_             :use-channel
-      :color_                  :color
-    )
-    (assoc :properties (get-config (core getChannelGroup) (.config_ chan)))))
-
-(defn MultiStagePosition-to-map [^MultiStagePosition msp]
-  (if msp
-    {:label (.getLabel msp)
-     :axes
-        (into {}
-          (for [i (range (.size msp))]
-            (let [stage-pos (.get msp i)]
-              [(.stageName stage-pos)
-                (condp = (.numAxes stage-pos)
-                  1 [(.x stage-pos)]
-                  2 [(.x stage-pos) (.y stage-pos)])])))}))
-
-(defn get-msp [idx]
-  (when idx
-    (let [p-list (. gui getPositionList)]
-      (if (pos? (. p-list getNumberOfPositions))
-        (. p-list (getPosition idx))))))
-
-(defn get-z-position [idx z-stage]
-  (if-let [msp (get-msp idx)]
-    (if-let [stage-pos (. msp get z-stage)]
-      (. stage-pos x))))
-
-(defn set-z-position [idx z-stage z]
-  (if-let [msp (get-msp idx)]
-    (if-let [stage-pos (. msp (get z-stage))]
-      (set! (. stage-pos x) z))))
-
-;; globals
-
-(def state (atom {:running false :stop false}))
-
-(defn state-assoc! [& args]
-  (apply swap! state assoc args))
-
-(def attached-runnables (atom (vec nil)))
-
-;; metadata
-
-(defn json-to-data [json]
-  (condp #(isa? (type %2) %1) json
-    JSONObject
-      (let [keys (iterator-seq (.keys json))]
-        (into {}
-          (for [key keys]
-            (let [val (if (.isNull json key) nil (.get json key))]
-              [key (json-to-data val)]))))
-    JSONArray
-      (vec
-        (for [i (range (.length json))]
-          (json-to-data (.get json i))))
-    json))
-
-(defn compute-time-from-core [tags]
-  ; (log "core tags: " tags)
-  (when (@state :burst-init-time)
-    (when-let [t (tags "ElapsedTime-ms")]
-      (+ (Double/parseDouble t)
-         (@state :burst-init-time)))))
-
-(defn elapsed-time [state]
-  (if (state :start-time) (- (clock-ms) (state :start-time)) 0))
-
-(defn annotate-image [img event state]
-  ;(println event)
-  {:pix (:pix img)
-   :tags (merge
-      (map-config (core getSystemStateCache))
-      {
-       "AxisPositions" (when-let [axes (get-in event [:position :axes])] (JSONObject. axes))
-       "Binning" (state :binning)
-       "BitDepth" (state :bit-depth)
-       "Channel" (get-in event [:channel :name])
-       "ChannelIndex" (:channel-index event)
-       "ElapsedTime-ms" (elapsed-time state)
-       "Exposure-ms" (:exposure event)
-       "Frame" (:frame-index event)
-       "Height" (state :init-height)
-       "NextFrame" (:next-frame-index event)
-       "PixelSizeUm" (state :pixel-size-um)
-       "PixelType" (state :pixel-type)
-       "PositionIndex" (:position-index event)
-       "PositionName" (if-let [pos (:position event)] (if-args #(.getLabel %) (get-msp pos)))
-       "Slice" (:slice-index event)
-       "SlicePosition" (:slice event)
-       "Source" (state :source)
-       "Time" (get-current-time-str)
-       "UUID" (UUID/randomUUID)
-       "Width"  (state :init-width)
-       "ZPositionUm" (state :last-z-position)
-      }
-       (:tags img))})
-
-(defn make-TaggedImage [annotated-img]
-  (TaggedImage. (:pix annotated-img) (JSONObject. (:tags annotated-img))))
-
-;; acq-engine
-
-(defn await-resume []
-  (while (and (:pause @state) (not (:stop @state))) (Thread/sleep 5)))
-
-(defn interruptible-sleep [time-ms]
-  (let [sleepy (CountDownLatch. 1)]
-    (state-assoc! :sleepy sleepy :next-wake-time (+ (clock-ms) time-ms))
-    (.await sleepy time-ms TimeUnit/MILLISECONDS)))
-
-(defn acq-sleep [interval-ms]
-  (when (and (@state :init-continuous-focus)
-             (not (core isContinuousFocusEnabled)))
-    (core enableContinuousFocus true))
-  (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)]
-      (state-assoc! :last-wake-time wake-time))))
-
-(declare device-agents)
-
-(defn wait-for-device [dev]
-  (when (and dev (pos? (.length dev)))
-    (core waitForDevice dev)))
-
-(defn create-device-agents []
-  (def device-agents
-    (let [devs (seq (core getLoadedDevices))]
-      (zipmap devs (repeatedly (count devs) #(agent nil))))))
-
-(defn get-z-stage-position [stage]
-  (when-not (empty? stage) (core getPosition stage) 0))
-
-(defn set-z-stage-position [stage pos]
-  (when (core isContinuousFocusEnabled)
-    (core enableContinuousFocus false))
-  (when-not (empty? stage) (core setPosition stage pos)))
-
-(defn set-stage-position
-  ([stage-dev z]
-    (when (not= z (:last-z-position @state))
-      (set-z-stage-position stage-dev z)
-      (state-assoc! :last-z-position z)))
-  ([stage-dev x y]
-    (when (and x y
-               (not= [x y] (:last-xy-position @state)))
-      (core setXYPosition stage-dev x y)
-      (state-assoc! :last-xy-position [x y]))))
-
-(defn set-property
-  ([prop] (core setProperty (prop 0) (prop 1) (prop 2))))
-
-(defn send-device-action [dev action]
-  (send-off (device-agents dev) (fn [_] (action))))
-
-(defn create-presnap-actions [event]
-  (concat
-    (for [[axis pos] (:axes (MultiStagePosition-to-map (get-msp (:position event)))) :when pos]
-      [axis #(apply set-stage-position axis pos)])
-    (for [prop (get-in event [:channel :properties])]
-      [(prop 0) #(core setProperty (prop 0) (prop 1) (prop 2))])
-    (when-let [exposure (:exposure event)]
-      (list [(core getCameraDevice) #(core setExposure exposure)]))))
-
-(defn run-actions [action-map]
-  (if run-devices-parallel
-    (do
-      (doseq [[dev action] action-map]
-        (send-device-action dev action))
-      (doseq [dev (keys action-map)]
-        (send-device-action dev #(core waitForDevice dev)))
-      (doall (map (partial await-for 10000) (vals device-agents))))
-    (do
-      (doseq [[dev action] action-map]
-        (action) (wait-for-device dev)))))
-
-(defn run-autofocus []
-  (.. gui getAutofocusManager getDevice fullFocus)
-  (log "running autofocus " (.. gui getAutofocusManager getDevice getDeviceName))
-  (state-assoc! :reference-z-position (core getPosition (core getFocusDevice))))
-
-(defn snap-image [open-before close-after]
-  (with-core-setting [getAutoShutter setAutoShutter false]
-    (if open-before
-      (core setShutterOpen true)
-      (wait-for-device (core getShutterDevice)))
-    (core snapImage)
-    (if close-after
-      (core setShutterOpen false))
-      (wait-for-device (core getShutterDevice))))
-
-(defn init-burst [length]
-  (core setAutoShutter (@state :init-auto-shutter))
-  (swap! state assoc :burst-init-time (elapsed-time @state))
-  (core startSequenceAcquisition length 0 true))
-
-(defn expose [event]
-  (do (condp = (:task event)
-    :snap (snap-image true (:close-shutter event))
-    :init-burst (init-burst (:burst-length event))
-    nil)))
-
-(defn collect-burst-image []
-  (while (and (core isSequenceRunning) (zero? (core getRemainingImageCount)))
-    (Thread/sleep 5))
-  (let [md (Metadata.)
-        pix (core popNextImageMD md)
-        tags (parse-core-metadata md)
-        t (compute-time-from-core tags)
-        tags (if (and t (pos? t))
-               (assoc tags "ElapsedTime-ms" t)
-               (dissoc tags "ElapsedTime-ms"))]
-   ; (println "cam-t: " t ", collect-t: " (elapsed-time @state)
-   ;      ", remaining-images: " (core getRemainingImageCount))
-    {:pix pix :tags (dissoc tags "StartTime-ms")}))
-
-(defn collect-snap-image []
-  {:pix (core getImage) :tags nil})
-
-(defn collect-image [event out-queue]
-  (let [image (condp = (:task event)
-                :snap (collect-snap-image)
-                :init-burst (collect-burst-image)
-                :collect-burst (collect-burst-image))]
-    (if (. mmc isBufferOverflowed)
-      (do (swap! state assoc :stop true)
-          (ReportingUtils/showError "Circular buffer overflowed."))
-      (do (log "collect-image: "
-               (select-keys event [:position-index :frame-index
-                                   :slice-index :channel-index]))
-          (.put out-queue
-                (make-TaggedImage (annotate-image image event @state)))))))
-
-(defn compute-z-position [event]
-  (if-let [z-drive (:z-drive event)]
-    (+ (or (get-in event [:channel :z-offset]) 0)
-       (or (:slice event) 0)
-       (if (and (:slice event) (not (:relative-z event)))
-         0
-         (or (get-z-position (:position event) z-drive)
-             (@state :reference-z-position))))))
-
-(defn make-event-fns [event out-queue]
-  (let [task (:task event)]
-    (cond
-      (= task :collect-burst)
-        (list #(collect-image event out-queue))
-      (or (= task :snap) (= task :init-burst))
-        (list
-          #(log event)
-          (fn [] (doall (map #(.run %) (event :runnables))))
-          #(when-let [wait-time-ms (event :wait-time-ms)]
-            (acq-sleep wait-time-ms))
-          #(run-actions (create-presnap-actions event))
-          #(await-for 10000 (device-agents (core getCameraDevice)))
-          #(when (:autofocus event)
-            (set-z-position (:position event) (:z-drive event) (run-autofocus)))
-          #(when-let [z-drive (:z-drive event)]
-            (let [z (compute-z-position event)]
-              (when (not= z (@state :last-z-position))
-                (do (set-stage-position z-drive z)
-                    (wait-for-device z-drive)))))
-          #(do (expose event)
-               (collect-image event out-queue))))))
-
-(defn execute [event-fns]
-  (doseq [event-fn event-fns :while (not (:stop @state))]
-    (try (event-fn) (catch Throwable e (ReportingUtils/logError e)))
-    (await-resume)))
-
-(defn return-config []
-  (dorun (map set-property
-    (clojure.set/difference
-      (set (@state :init-system-state))
-      (set (get-system-config-cached))))))
-
-(defn cleanup []
-  (log "cleanup")
-  (do-when #(.update %) (:display @state))
-  (state-assoc! :finished true, :running false, :display nil)
-  (when (core isSequenceRunning)
-    (core stopSequenceAcquisition))
-  (core setAutoShutter (@state :init-auto-shutter))
-  (core setExposure (@state :init-exposure))
-  (when (not= (@state :last-z-position) (@state :init-z-position))
-    (set-z-stage-position (core getFocusDevice) (@state :init-z-position)))
-  (when (and (@state :init-continuous-focus)
-             (not (core isContinuousFocusEnabled)))
-    (core enableContinuousFocus true))
-  (return-config))
-
-(defn prepare-state [this]
-  (let [z (get-z-stage-position (core getFocusDevice))]
-    (swap! (.state this) assoc
-      :pause false
-      :stop false
-      :running true
-      :finished false
-      :last-wake-time (clock-ms)
-      :last-z-position nil
-      :last-xy-position nil
-      :reference-z-position z
-      :start-time (clock-ms)
-      :init-auto-shutter (core getAutoShutter)
-      :init-exposure (core getExposure)
-      :init-z-position z
-      :init-system-state (get-system-config-cached)
-      :init-continuous-focus (core isContinuousFocusEnabled)
-      :init-width (core getImageWidth)
-      :init-height (core getImageHeight)
-      :binning (core getProperty (core getCameraDevice) "Binning")
-      :bit-depth (core getImageBitDepth)
-      :pixel-size-um (core getPixelSizeUm)
-      :source (core getCameraDevice)
-      :pixel-type (get-pixel-type)
-      )))
-
-(defn run-acquisition [this settings out-queue]
-  (def acq-settings settings)
-  (prepare-state this)
-  (binding [state (.state this)]
-    (def last-state state)
-    (let [acq-seq (generate-acq-sequence settings @attached-runnables)]
-       (def acq-sequence acq-seq)
-       (execute (mapcat #(make-event-fns % out-queue) acq-seq))
-       (.put out-queue TaggedImageQueue/POISON)
-       (cleanup))))
-
-(defn convert-settings [^SequenceSettings settings]
-  (-> settings
-    (data-object-to-map)
-    (rekey
-      :slicesFirst             :slices-first
-      :timeFirst               :time-first
-      :keepShutterOpenSlices   :keep-shutter-open-slices
-      :keepShutterOpenChannels :keep-shutter-open-channels
-      :useAutofocus            :use-autofocus
-      :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 (range (.. settings positions size))
-           :default-exposure (core getExposure))))
-
-
-(defn get-IJ-type [depth]
-  (get {1 ImagePlus/GRAY8 2 ImagePlus/GRAY16 4 ImagePlus/COLOR_RGB 8 64} depth))
-
-(defn get-z-step-um [slices]
-  (if (and slices (< 1 (count slices)))
-    (- (second slices) (first slices))
-    0))
-
-(defn get-channel-components [channel]
-  (let [default-cam (get-property "Core" "Camera")
-        chan-cam
-          (or
-            (first
-              (filter #(= (take 2 %) '("Core" "Camera"))
-                (:properties channel)))
-            default-cam)]
-    (set-property chan-cam)
-    (let [n (int (core getNumberOfComponents))]
-      (set-property default-cam)
-      (get {1 1 , 4 3} n))))
-
-(defn make-summary-metadata [settings]
-  (let [depth (int (core getBytesPerPixel))
-        channels (settings :channels)]
-     (JSONObject. {
-      "BitDepth" (core getImageBitDepth)
-      "Channels" (count (settings :channels))
-      "ChNames" (JSONArray. (map :name channels))
-      "ChColors" (JSONArray. (map #(.getRGB (:color %)) channels))
-      "ChContrastMax" (JSONArray. (repeat (count channels) Integer/MIN_VALUE))
-      "ChContrastMin" (JSONArray. (repeat (count channels) Integer/MAX_VALUE))
-      "Comment" (settings :comment)
-      "ComputerName" (.. InetAddress getLocalHost getHostName)
-      "Depth" (core getBytesPerPixel)
-      "Directory" (if (settings :save) (settings :root) "")
-      "Frames" (count (settings :frames))
-      "GridColumn" 0
-      "GridRow" 0
-      "Height" (core getImageHeight)
-      "Interval_ms" (settings :interval-ms)
-      "IJType" (get-IJ-type depth)
-      "KeepShutterOpenChannels" (settings :keep-shutter-open-channels)
-      "KeepShutterOpenSlices" (settings :keep-shutter-open-slices)
-      "MicroManagerVersion" (.getVersion gui)
-      "MetadataVersion" 10
-      "PixelAspect" 1.0
-      "PixelSize_um" (core getPixelSizeUm)
-      "PixelType" (get-pixel-type)
-      "Positions" (count (settings :positions))
-      "Prefix" (if (settings :save) (settings :prefix) "")
-      "ROI" (JSONArray. (get-camera-roi))
-      "Slices" (count (settings :slices))
-      "SlicesFirst" (settings :slices-first)
-      "Source" "Micro-Manager"
-      "TimeFirst" (settings :time-first)
-      "UserName" (System/getProperty "user.name")
-      "UUID" (UUID/randomUUID)
-      "Width" (core getImageWidth)
-      "z-step_um" (get-z-step-um (settings :slices))
-     })))
-
-;; acquire button
-
-(def current-album (atom nil))
-
-(def snap-window (atom nil))
-
-(defn compatible-image? [display annotated-image]
-  (select-values-match?
-    (json-to-data (.. display getImageCache getSummaryMetadata))
-    (:tags annotated-image)
-    ["Width" "Height" "PixelType"]))
-
-(defn create-image-window [first-image]
-  (let [summary {:interval-ms 0.0, :use-autofocus false, :autofocus-skip 0,
-                 :relative-slices true, :keep-shutter-open-slices false, :comment "",
-                 :prefix "Untitled", :root "",
-                 :time-first false, :positions (), :channels (), :slices-first true,
-                 :slices nil, :numFrames 0, :keep-shutter-open-channels false,
-                 :zReference 0.0, :frames (), :save false}
-		summary-metadata (make-summary-metadata summary)
-		cache (doto (MMImageCache. (TaggedImageStorageRam. summary-metadata))
-						(.setSummaryMetadata summary-metadata))]
-		(doto (VirtualAcquisitionDisplay. cache nil))))
-
-(defn create-basic-event []
-  {:position-index 0, :position nil,
-   :frame-index 0, :slice 0.0, :channel-index 0, :slice-index 0, :frame 0
-   :channel {:name (core getCurrentConfig (core getChannelGroup))},
-   :exposure (core getExposure), :relative-z true,
-   :z-drive (core getFocusDevice), :wait-time-ms 0})
-
-(defn create-basic-state []
-  {:init-width (core getImageWidth)
-   :init-height (core getImageHeight)
-   :pixel-type (get-pixel-type)
-   :binning (core getProperty (core getCameraDevice) "Binning")})
-
-(defn acquire-tagged-image []
-  (core snapImage)
-    (annotate-image (collect-snap-image) (create-basic-event) (create-basic-state)))
-
-(defn show-image [display tagged-img]
-  (let [myTaggedImage (make-TaggedImage tagged-img)
-        cache (.getImageCache display)]
-    (.putImage cache myTaggedImage)
-     (.showImage display myTaggedImage)
-     (when-not false ;; (.isVisible display)
-       (.show display))))
-
-(defn add-to-album []
-  (let [tagged-image (acquire-tagged-image)]
-    (when-not (and @current-album
-                   (compatible-image? @current-album tagged-image)
-	           (not (.windowClosed @current-album)))
-      (reset! current-album (create-image-window tagged-image)))
-    (let [count (.getNumPositions @current-album)
-	  my-tagged-image
-	    (update-in tagged-image [:tags] merge
-	      {"PositionIndex" count "PositionName" (str "Snap" count)})]
-      (show-image @current-album my-tagged-image))))
-
-(defn reset-snap-window [tagged-image]
-  (when-not (and @snap-window
-                   (compatible-image? @snap-window tagged-image)
-                   (not (.windowClosed @snap-window)))
-    (when @snap-window (.close @snap-window))
-    (reset! snap-window (create-image-window tagged-image))))
-
-(defn do-snap []
-  (let [tagged-image (acquire-tagged-image)]
-    (reset-snap-window tagged-image)
-    (show-image @snap-window tagged-image)))
-
-(def live-mode-running (ref false))
-
-
-(defn enable-live-mode [^Boolean on]
-      (if on
-        (let [event (create-basic-event)
-              state (create-basic-state)]
-          (dosync (ref-set live-mode-running true))
-          (core startContinuousSequenceAcquisition 0)
-          (.start (Thread.
-                    #(do (while @live-mode-running
-                           (let [img (annotate-image (core getLastImage) event state)]
-                              (reset-snap-window img)
-                              (show-image @snap-window img)))
-                         (core stopSequenceAcquisition)))))
-        (dosync (ref-set live-mode-running false))))
-
-;; java interop
-
-(defn -init []
-  [[] (atom {:running false :stop false})])
-
-(defn -run [this acq-settings acq-eng]
-  (def last-acq this)
-  (def eng acq-eng)
-  (load-mm)
-  (create-device-agents)
-  (swap! (.state this) assoc :stop false :pause false :finished false)
-  (let [out-queue (GentleLinkedBlockingQueue.)
-        settings (convert-settings acq-settings)
-        acq-thread (Thread. #(run-acquisition this settings out-queue))
-        processors (ProcessorStack. out-queue (.getTaggedImageProcessors acq-eng))
-        out-queue-2 (.begin processors)
-        display (LiveAcqDisplay. mmc out-queue-2 (make-summary-metadata settings)
-                  (:save settings) acq-eng)]
-    (def outq out-queue)
-    ;(.addImageProcessor acq-eng
-      ;(proxy [TaggedImageAnalyzer] []
-        ;(analyze [img] (log "pretending to analyze"))))
-    (when-not (:stop @(.state this))
-      (if (. gui getLiveMode)
-        (. gui enableLiveMode false))
-      (.start acq-thread)
-      (swap! (.state this) assoc :display display)
-      (.start display))))
-
-(defn -acquireSingle [this]
-  (load-mm)
-  (add-to-album))
-
-(defn -doSnap [this]
-  (load-mm)
-  (do-snap))
-
-(defn -isLiveRunning [this]
-  @live-mode-running)
-
-(defn -enableLiveMode [this ^Boolean on]
-  (load-mm)
-  (enable-live-mode on))
-
-(defn -pause [this]
-  (log "pause requested!")
-  (swap! (.state this) assoc :pause true))
-
-(defn -resume [this]
-  (log "resume requested!")
-  (swap! (.state this) assoc :pause false))
-
-(defn -stop [this]
-  (log "stop requested!")
-  (let [state (.state this)]
-    (swap! state assoc :stop true)
-    (do-when #(.countDown %) (:sleepy @state))
-    (log @state)))
-
-(defn -isRunning [this]
-  (:running @(.state this)))
-
-(defn -isFinished [this]
-  (or (get @(.state this) :finished) false))
-
-(defn -isPaused [this]
-  (:pause @(.state this)))
-
-(defn -stopHasBeenRequested [this]
-  (:stop @(.state this)))
-
-(defn -nextWakeTime [this]
-  (or (:next-wake-time @(.state this)) -1))
-
-;; attaching runnables
-
-(defn -attachRunnable [this f p c s runnable]
-  (let [template (into {}
-          (for [[k v]
-                {:frame-index f :position-index p
-                 :channel-index c :slice-index s}
-                 :when (not (neg? v))]
-            [k v]))]
-    (swap! attached-runnables conj [template runnable])))
-
-(defn -clearRunnables [this]
-  (reset! attached-runnables (vec nil)))
-
-;; testing
-
-(defn create-acq-eng []
-  (doto
-    (proxy [AcquisitionWrapperEngine] []
-      (runPipeline [^SequenceSettings settings]
-        ;(def orig-settings settings)
-        (println "ss positions: " (.size (.positions settings)))
-        (println "position-count: " (.getNumberOfPositions (.getPositionList gui)))
-        (-run settings this)
-    (.setCore mmc (.getAutofocusManager gui))
-    (.setParentGUI gui)
-    (.setPositionList (.getPositionList gui))))))
-
-(defn test-dialog [eng]
-  (.show (AcqControlDlg. eng (Preferences/userNodeForPackage (.getClass gui)) gui)))
-
-(defn run-test []
-  (test-dialog (create-acq-eng)))
-
-
+; FILE:         acq_engine.clj
+; PROJECT:      Micro-Manager
+; SUBSYSTEM:    mmstudio acquisition engine
+; ----------------------------------------------------------------------------
+; AUTHOR:       Arthur Edelstein, arthuredelstein@gmail.com, Dec 14, 2010
+;               Adapted from the acq eng by Nenad Amodaj and Nico Stuurman
+; COPYRIGHT:    University of California, San Francisco, 2006-2011
+; LICENSE:      This file is distributed under the BSD license.
+;               License text is included with the source distribution.
+;               This file is distributed in the hope that it will be useful,
+;               but WITHOUT ANY WARRANTY; without even the implied warranty
+;               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+;               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+;               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+;               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.
+
+(ns org.micromanager.acq-engine
+  (:use [org.micromanager.mm :only [when-lets map-config get-config get-positions load-mm
+                                    get-default-devices core log log-cmd mmc gui with-core-setting
+                                    do-when if-args get-system-config-cached select-values-match?
+                                    get-property get-camera-roi parse-core-metadata]]
+        [org.micromanager.sequence-generator :only [generate-acq-sequence]])
+  (:import [org.micromanager AcqControlDlg]
+           [org.micromanager.api AcquisitionEngine TaggedImageAnalyzer]
+           [org.micromanager.acquisition AcquisitionWrapperEngine LiveAcqDisplay TaggedImageQueue
+                                         ProcessorStack SequenceSettings MMImageCache
+                                         TaggedImageStorageRam VirtualAcquisitionDisplay]
+           [org.micromanager.navigation MultiStagePosition StagePosition]
+           [mmcorej TaggedImage Configuration Metadata]
+           [java.util.prefs Preferences]
+           [java.net InetAddress]
+           [java.util.concurrent TimeUnit CountDownLatch]
+           [org.micromanager.utils ChannelSpec GentleLinkedBlockingQueue MDUtils
+                                   ReportingUtils]
+           [org.json JSONObject JSONArray]
+           [java.util Date UUID]
+           [java.text SimpleDateFormat]
+           [javax.swing SwingUtilities]
+           [ij ImagePlus])
+   (:gen-class
+     :name org.micromanager.AcqEngine
+     :implements [org.micromanager.api.Pipeline]
+     :init init
+     :state state))
+
+;; constants
+
+(def run-devices-parallel false)
+
+;; general utils
+
+(defn data-object-to-map [obj]
+  (into {}
+    (for [f (.getFields (type obj))
+          :when (zero? (bit-and
+                         (.getModifiers f) java.lang.reflect.Modifier/STATIC))]
+      [(keyword (.getName f)) (.get f obj)])))
+
+(defmacro apply* [& args]
+  `(~@(butlast args) ~@(eval (last args))))
+
+(defn rekey
+  ([m kold knew]
+    (-> m (dissoc kold) (assoc knew (get m kold))))
+  ([m kold knew & ks]
+    (reduce #(apply rekey %1 %2)
+      m (partition 2 (conj ks knew kold)))))
+
+(defn select-and-rekey [m & ks]
+    (apply rekey (select-keys m (apply concat (partition 1 2 ks))) ks))
+
+(defn clock-ms []
+  (quot (System/nanoTime) 1000000))
+
+;; mm utils
+
+(def iso8601modified (SimpleDateFormat. "yyyy-MM-dd HH:mm:ss Z"))
+
+(defn get-current-time-str []
+  (. iso8601modified format (Date.)))
+
+(defn get-pixel-type []
+  (str ({1 "GRAY", 4 "RGB"} (int (core getNumberOfComponents))) (* 8 (core getBytesPerPixel))))
+
+(defn ChannelSpec-to-map [^ChannelSpec chan]
+  (-> chan
+    (data-object-to-map)
+    (select-and-rekey
+      :config_                 :name
+      :exposure_               :exposure
+      :zOffset_                :z-offset
+      :doZStack_               :use-z-stack
+      :skipFactorFrame_        :skip-frames
+      :useChannel_             :use-channel
+      :color_                  :color
+    )
+    (assoc :properties (get-config (core getChannelGroup) (.config_ chan)))))
+
+(defn MultiStagePosition-to-map [^MultiStagePosition msp]
+  (if msp
+    {:label (.getLabel msp)
+     :axes
+        (into {}
+          (for [i (range (.size msp))]
+            (let [stage-pos (.get msp i)]
+              [(.stageName stage-pos)
+                (condp = (.numAxes stage-pos)
+                  1 [(.x stage-pos)]
+                  2 [(.x stage-pos) (.y stage-pos)])])))}))
+
+(defn get-msp [idx]
+  (when idx
+    (let [p-list (. gui getPositionList)]
+      (if (pos? (. p-list getNumberOfPositions))
+        (. p-list (getPosition idx))))))
+
+(defn get-z-position [idx z-stage]
+  (if-let [msp (get-msp idx)]
+    (if-let [stage-pos (. msp get z-stage)]
+      (. stage-pos x))))
+
+(defn set-z-position [idx z-stage z]
+  (if-let [msp (get-msp idx)]
+    (if-let [stage-pos (. msp (get z-stage))]
+      (set! (. stage-pos x) z))))
+
+;; globals
+
+(def state (atom {:running false :stop false}))
+
+(defn state-assoc! [& args]
+  (apply swap! state assoc args))
+
+(def attached-runnables (atom (vec nil)))
+
+;; metadata
+
+(defn json-to-data [json]
+  (condp #(isa? (type %2) %1) json
+    JSONObject
+      (let [keys (iterator-seq (.keys json))]
+        (into {}
+          (for [key keys]
+            (let [val (if (.isNull json key) nil (.get json key))]
+              [key (json-to-data val)]))))
+    JSONArray
+      (vec
+        (for [i (range (.length json))]
+          (json-to-data (.get json i))))
+    json))
+
+(defn compute-time-from-core [tags]
+  ; (log "core tags: " tags)
+  (when (@state :burst-init-time)
+    (when-let [t (tags "ElapsedTime-ms")]
+      (+ (Double/parseDouble t)
+         (@state :burst-init-time)))))
+
+(defn elapsed-time [state]
+  (if (state :start-time) (- (clock-ms) (state :start-time)) 0))
+
+(defn annotate-image [img event state]
+  ;(println event)
+  {:pix (:pix img)
+   :tags (merge
+      (map-config (core getSystemStateCache))
+      {
+       "AxisPositions" (when-let [axes (get-in event [:position :axes])] (JSONObject. axes))
+       "Binning" (state :binning)
+       "BitDepth" (state :bit-depth)
+       "Channel" (get-in event [:channel :name])
+       "ChannelIndex" (:channel-index event)
+       "ElapsedTime-ms" (elapsed-time state)
+       "Exposure-ms" (:exposure event)
+       "Frame" (:frame-index event)
+       "Height" (state :init-height)
+       "NextFrame" (:next-frame-index event)
+       "PixelSizeUm" (state :pixel-size-um)
+       "PixelType" (state :pixel-type)
+       "PositionIndex" (:position-index event)
+       "PositionName" (if-let [pos (:position event)] (if-args #(.getLabel %) (get-msp pos)))
+       "Slice" (:slice-index event)
+       "SlicePosition" (:slice event)
+       "Source" (state :source)
+       "Time" (get-current-time-str)
+       "UUID" (UUID/randomUUID)
+       "Width"  (state :init-width)
+       "ZPositionUm" (state :last-z-position)
+      }
+       (:tags img))})
+
+(defn make-TaggedImage [annotated-img]
+  (TaggedImage. (:pix annotated-img) (JSONObject. (:tags annotated-img))))
+
+;; acq-engine
+
+(defn await-resume []
+  (while (and (:pause @state) (not (:stop @state))) (Thread/sleep 5)))
+
+(defn interruptible-sleep [time-ms]
+  (let [sleepy (CountDownLatch. 1)]
+    (state-assoc! :sleepy sleepy :next-wake-time (+ (clock-ms) time-ms))
+    (.await sleepy time-ms TimeUnit/MILLISECONDS)))
+
+(defn acq-sleep [interval-ms]
+  (when (and (@state :init-continuous-focus)
+             (not (core isContinuousFocusEnabled)))
+    (core enableContinuousFocus true))
+  (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)]
+      (state-assoc! :last-wake-time wake-time))))
+
+(declare device-agents)
+
+(defn wait-for-device [dev]
+  (when (and dev (pos? (.length dev)))
+    (core waitForDevice dev)))
+
+(defn create-device-agents []
+  (def device-agents
+    (let [devs (seq (core getLoadedDevices))]
+      (zipmap devs (repeatedly (count devs) #(agent nil))))))
+
+(defn get-z-stage-position [stage]
+  (when-not (empty? stage) (core getPosition stage) 0))
+
+(defn set-z-stage-position [stage pos]
+  (when (core isContinuousFocusEnabled)
+    (core enableContinuousFocus false))
+  (when-not (empty? stage) (core setPosition stage pos)))
+
+(defn set-stage-position
+  ([stage-dev z]
+    (when (not= z (:last-z-position @state))
+      (set-z-stage-position stage-dev z)
+      (state-assoc! :last-z-position z)))
+  ([stage-dev x y]
+    (when (and x y
+               (not= [x y] (:last-xy-position @state)))
+      (core setXYPosition stage-dev x y)
+      (state-assoc! :last-xy-position [x y]))))
+
+(defn set-property
+  ([prop] (core setProperty (prop 0) (prop 1) (prop 2))))
+
+(defn send-device-action [dev action]
+  (send-off (device-agents dev) (fn [_] (action))))
+
+(defn create-presnap-actions [event]
+  (concat
+    (for [[axis pos] (:axes (MultiStagePosition-to-map (get-msp (:position event)))) :when pos]
+      [axis #(apply set-stage-position axis pos)])
+    (for [prop (get-in event [:channel :properties])]
+      [(prop 0) #(core setProperty (prop 0) (prop 1) (prop 2))])
+    (when-let [exposure (:exposure event)]
+      (list [(core getCameraDevice) #(core setExposure exposure)]))))
+
+(defn run-actions [action-map]
+  (if run-devices-parallel
+    (do
+      (doseq [[dev action] action-map]
+        (send-device-action dev action))
+      (doseq [dev (keys action-map)]
+        (send-device-action dev #(core waitForDevice dev)))
+      (doall (map (partial await-for 10000) (vals device-agents))))
+    (do
+      (doseq [[dev action] action-map]
+        (action) (wait-for-device dev)))))
+
+(defn run-autofocus []
+  (.. gui getAutofocusManager getDevice fullFocus)
+  (log "running autofocus " (.. gui getAutofocusManager getDevice getDeviceName))
+  (state-assoc! :reference-z-position (core getPosition (core getFocusDevice))))
+
+(defn snap-image [open-before close-after]
+  (with-core-setting [getAutoShutter setAutoShutter false]
+    (if open-before
+      (core setShutterOpen true)
+      (wait-for-device (core getShutterDevice)))
+    (core snapImage)
+    (if close-after
+      (core setShutterOpen false))
+      (wait-for-device (core getShutterDevice))))
+
+(defn init-burst [length]
+  (core setAutoShutter (@state :init-auto-shutter))
+  (swap! state assoc :burst-init-time (elapsed-time @state))
+  (core startSequenceAcquisition length 0 true))
+
+(defn expose [event]
+  (do (condp = (:task event)
+    :snap (snap-image true (:close-shutter event))
+    :init-burst (init-burst (:burst-length event))
+    nil)))
+
+(defn collect-burst-image []
+  (while (and (core isSequenceRunning) (zero? (core getRemainingImageCount)))
+    (Thread/sleep 5))
+  (let [md (Metadata.)
+        pix (core popNextImageMD md)
+        tags (parse-core-metadata md)
+        t (compute-time-from-core tags)
+        tags (if (and t (pos? t))
+               (assoc tags "ElapsedTime-ms" t)
+               (dissoc tags "ElapsedTime-ms"))]
+   ; (println "cam-t: " t ", collect-t: " (elapsed-time @state)
+   ;      ", remaining-images: " (core getRemainingImageCount))
+    {:pix pix :tags (dissoc tags "StartTime-ms")}))
+
+(defn collect-snap-image []
+  {:pix (core getImage) :tags nil})
+
+(defn collect-image [event out-queue]
+  (let [image (condp = (:task event)
+                :snap (collect-snap-image)
+                :init-burst (collect-burst-image)
+                :collect-burst (collect-burst-image))]
+    (if (. mmc isBufferOverflowed)
+      (do (swap! state assoc :stop true)
+          (ReportingUtils/showError "Circular buffer overflowed."))
+      (do (log "collect-image: "
+               (select-keys event [:position-index :frame-index
+                                   :slice-index :channel-index]))
+          (.put out-queue
+                (make-TaggedImage (annotate-image image event @state)))))))
+
+(defn compute-z-position [event]
+  (if-let [z-drive (:z-drive event)]
+    (+ (or (get-in event [:channel :z-offset]) 0)
+       (or (:slice event) 0)
+       (if (and (:slice event) (not (:relative-z event)))
+         0
+         (or (get-z-position (:position event) z-drive)
+             (@state :reference-z-position))))))
+
+(defn make-event-fns [event out-queue]
+  (let [task (:task event)]
+    (cond
+      (= task :collect-burst)
+        (list #(collect-image event out-queue))
+      (or (= task :snap) (= task :init-burst))
+        (list
+          #(log event)
+          (fn [] (doall (map #(.run %) (event :runnables))))
+          #(when-let [wait-time-ms (event :wait-time-ms)]
+            (acq-sleep wait-time-ms))
+          #(run-actions (create-presnap-actions event))
+          #(await-for 10000 (device-agents (core getCameraDevice)))
+          #(when (:autofocus event)
+            (set-z-position (:position event) (:z-drive event) (run-autofocus)))
+          #(when-let [z-drive (:z-drive event)]
+            (let [z (compute-z-position event)]
+              (when (not= z (@state :last-z-position))
+                (do (set-stage-position z-drive z)
+                    (wait-for-device z-drive)))))
+          #(do (expose event)
+               (collect-image event out-queue))))))
+
+(defn execute [event-fns]
+  (doseq [event-fn event-fns :while (not (:stop @state))]
+    (try (event-fn) (catch Throwable e (ReportingUtils/logError e)))
+    (await-resume)))
+
+(defn return-config []
+  (dorun (map set-property
+    (clojure.set/difference
+      (set (@state :init-system-state))
+      (set (get-system-config-cached))))))
+
+(defn cleanup []
+  (log "cleanup")
+  (do-when #(.update %) (:display @state))
+  (state-assoc! :finished true, :running false, :display nil)
+  (when (core isSequenceRunning)
+    (core stopSequenceAcquisition))
+  (core setAutoShutter (@state :init-auto-shutter))
+  (core setExposure (@state :init-exposure))
+  (when (not= (@state :last-z-position) (@state :init-z-position))
+    (set-z-stage-position (core getFocusDevice) (@state :init-z-position)))
+  (when (and (@state :init-continuous-focus)
+             (not (core isContinuousFocusEnabled)))
+    (core enableContinuousFocus true))
+  (return-config))
+
+(defn prepare-state [this]
+  (let [z (get-z-stage-position (core getFocusDevice))]
+    (swap! (.state this) assoc
+      :pause false
+      :stop false
+      :running true
+      :finished false
+      :last-wake-time (clock-ms)
+      :last-z-position z
+      :last-xy-position nil
+      :reference-z-position z
+      :start-time (clock-ms)
+      :init-auto-shutter (core getAutoShutter)
+      :init-exposure (core getExposure)
+      :init-z-position z
+      :init-system-state (get-system-config-cached)
+      :init-continuous-focus (core isContinuousFocusEnabled)
+      :init-width (core getImageWidth)
+      :init-height (core getImageHeight)
+      :binning (core getProperty (core getCameraDevice) "Binning")
+      :bit-depth (core getImageBitDepth)
+      :pixel-size-um (core getPixelSizeUm)
+      :source (core getCameraDevice)
+      :pixel-type (get-pixel-type)
+      )))
+
+(defn run-acquisition [this settings out-queue]
+  (def acq-settings settings)
+  (prepare-state this)
+  (binding [state (.state this)]
+    (def last-state state)
+    (let [acq-seq (generate-acq-sequence settings @attached-runnables)]
+       (def acq-sequence acq-seq)
+       (execute (mapcat #(make-event-fns % out-queue) acq-seq))
+       (.put out-queue TaggedImageQueue/POISON)
+       (cleanup))))
+
+(defn convert-settings [^SequenceSettings settings]
+  (-> settings
+    (data-object-to-map)
+    (rekey
+      :slicesFirst             :slices-first
+      :timeFirst               :time-first
+      :keepShutterOpenSlices   :keep-shutter-open-slices
+      :keepShutterOpenChannels :keep-shutter-open-channels
+      :useAutofocus            :use-autofocus
+      :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 (range (.. settings positions size))
+           :default-exposure (core getExposure))))
+
+
+(defn get-IJ-type [depth]
+  (get {1 ImagePlus/GRAY8 2 ImagePlus/GRAY16 4 ImagePlus/COLOR_RGB 8 64} depth))
+
+(defn get-z-step-um [slices]
+  (if (and slices (< 1 (count slices)))
+    (- (second slices) (first slices))
+    0))
+
+(defn get-channel-components [channel]
+  (let [default-cam (get-property "Core" "Camera")
+        chan-cam
+          (or
+            (first
+              (filter #(= (take 2 %) '("Core" "Camera"))
+                (:properties channel)))
+            default-cam)]
+    (set-property chan-cam)
+    (let [n (int (core getNumberOfComponents))]
+      (set-property default-cam)
+      (get {1 1 , 4 3} n))))
+
+(defn make-summary-metadata [settings]
+  (let [depth (int (core getBytesPerPixel))
+        channels (settings :channels)]
+     (JSONObject. {
+      "BitDepth" (core getImageBitDepth)
+      "Channels" (count (settings :channels))
+      "ChNames" (JSONArray. (map :name channels))
+      "ChColors" (JSONArray. (map #(.getRGB (:color %)) channels))
+      "ChContrastMax" (JSONArray. (repeat (count channels) Integer/MIN_VALUE))
+      "ChContrastMin" (JSONArray. (repeat (count channels) Integer/MAX_VALUE))
+      "Comment" (settings :comment)
+      "ComputerName" (.. InetAddress getLocalHost getHostName)
+      "Depth" (core getBytesPerPixel)
+      "Directory" (if (settings :save) (settings :root) "")
+      "Frames" (count (settings :frames))
+      "GridColumn" 0
+      "GridRow" 0
+      "Height" (core getImageHeight)
+      "Interval_ms" (settings :interval-ms)
+      "IJType" (get-IJ-type depth)
+      "KeepShutterOpenChannels" (settings :keep-shutter-open-channels)
+      "KeepShutterOpenSlices" (settings :keep-shutter-open-slices)
+      "MicroManagerVersion" (.getVersion gui)
+      "MetadataVersion" 10
+      "PixelAspect" 1.0
+      "PixelSize_um" (core getPixelSizeUm)
+      "PixelType" (get-pixel-type)
+      "Positions" (count (settings :positions))
+      "Prefix" (if (settings :save) (settings :prefix) "")
+      "ROI" (JSONArray. (get-camera-roi))
+      "Slices" (count (settings :slices))
+      "SlicesFirst" (settings :slices-first)
+      "Source" "Micro-Manager"
+      "TimeFirst" (settings :time-first)
+      "UserName" (System/getProperty "user.name")
+      "UUID" (UUID/randomUUID)
+      "Width" (core getImageWidth)
+      "z-step_um" (get-z-step-um (settings :slices))
+     })))
+
+;; acquire button
+
+(def current-album (atom nil))
+
+(def snap-window (atom nil))
+
+(defn compatible-image? [display annotated-image]
+  (select-values-match?
+    (json-to-data (.. display getImageCache getSummaryMetadata))
+    (:tags annotated-image)
+    ["Width" "Height" "PixelType"]))
+
+(defn create-image-window [first-image]
+  (let [summary {:interval-ms 0.0, :use-autofocus false, :autofocus-skip 0,
+                 :relative-slices true, :keep-shutter-open-slices false, :comment "",
+                 :prefix "Untitled", :root "",
+                 :time-first false, :positions (), :channels (), :slices-first true,
+                 :slices nil, :numFrames 0, :keep-shutter-open-channels false,
+                 :zReference 0.0, :frames (), :save false}
+		summary-metadata (make-summary-metadata summary)
+		cache (doto (MMImageCache. (TaggedImageStorageRam. summary-metadata))
+						(.setSummaryMetadata summary-metadata))]
+		(doto (VirtualAcquisitionDisplay. cache nil))))
+
+(defn create-basic-event []
+  {:position-index 0, :position nil,
+   :frame-index 0, :slice 0.0, :channel-index 0, :slice-index 0, :frame 0
+   :channel {:name (core getCurrentConfig (core getChannelGroup))},
+   :exposure (core getExposure), :relative-z true,
+   :z-drive (core getFocusDevice), :wait-time-ms 0})
+
+(defn create-basic-state []
+  {:init-width (core getImageWidth)
+   :init-height (core getImageHeight)
+   :pixel-type (get-pixel-type)
+   :binning (core getProperty (core getCameraDevice) "Binning")})
+
+(defn acquire-tagged-image []
+  (core snapImage)
+    (annotate-image (collect-snap-image) (create-basic-event) (create-basic-state)))
+
+(defn show-image [display tagged-img]
+  (let [myTaggedImage (make-TaggedImage tagged-img)
+        cache (.getImageCache display)]
+    (.putImage cache myTaggedImage)
+     (.showImage display myTaggedImage)
+     (when-not false ;; (.isVisible display)
+       (.show display))))
+
+(defn add-to-album []
+  (let [tagged-image (acquire-tagged-image)]
+    (when-not (and @current-album
+                   (compatible-image? @current-album tagged-image)
+	           (not (.windowClosed @current-album)))
+      (reset! current-album (create-image-window tagged-image)))
+    (let [count (.getNumPositions @current-album)
+	  my-tagged-image
+	    (update-in tagged-image [:tags] merge
+	      {"PositionIndex" count "PositionName" (str "Snap" count)})]
+      (show-image @current-album my-tagged-image))))
+
+(defn reset-snap-window [tagged-image]
+  (when-not (and @snap-window
+                   (compatible-image? @snap-window tagged-image)
+                   (not (.windowClosed @snap-window)))
+    (when @snap-window (.close @snap-window))
+    (reset! snap-window (create-image-window tagged-image))))
+
+(defn do-snap []
+  (let [tagged-image (acquire-tagged-image)]
+    (reset-snap-window tagged-image)
+    (show-image @snap-window tagged-image)))
+
+(def live-mode-running (ref false))
+
+
+(defn enable-live-mode [^Boolean on]
+      (if on
+        (let [event (create-basic-event)
+              state (create-basic-state)]
+          (dosync (ref-set live-mode-running true))
+          (core startContinuousSequenceAcquisition 0)
+          (.start (Thread.
+                    #(do (while @live-mode-running
+                           (let [img (annotate-image (core getLastImage) event state)]
+                              (reset-snap-window img)
+                              (show-image @snap-window img)))
+                         (core stopSequenceAcquisition)))))
+        (dosync (ref-set live-mode-running false))))
+
+;; java interop
+
+(defn -init []
+  [[] (atom {:running false :stop false})])
+
+(defn -run [this acq-settings acq-eng]
+  (def last-acq this)
+  (def eng acq-eng)
+  (load-mm)
+  (create-device-agents)
+  (swap! (.state this) assoc :stop false :pause false :finished false)
+  (let [out-queue (GentleLinkedBlockingQueue.)
+        settings (convert-settings acq-settings)
+        acq-thread (Thread. #(run-acquisition this settings out-queue))
+        processors (ProcessorStack. out-queue (.getTaggedImageProcessors acq-eng))
+        out-queue-2 (.begin processors)
+        display (LiveAcqDisplay. mmc out-queue-2 (make-summary-metadata settings)
+                  (:save settings) acq-eng)]
+    (def outq out-queue)
+    ;(.addImageProcessor acq-eng
+      ;(proxy [TaggedImageAnalyzer] []
+        ;(analyze [img] (log "pretending to analyze"))))
+    (when-not (:stop @(.state this))
+      (if (. gui getLiveMode)
+        (. gui enableLiveMode false))
+      (.start acq-thread)
+      (swap! (.state this) assoc :display display)
+      (.start display))))
+
+(defn -acquireSingle [this]
+  (load-mm)
+  (add-to-album))
+
+(defn -doSnap [this]
+  (load-mm)
+  (do-snap))
+
+(defn -isLiveRunning [this]
+  @live-mode-running)
+
+(defn -enableLiveMode [this ^Boolean on]
+  (load-mm)
+  (enable-live-mode on))
+
+(defn -pause [this]
+  (log "pause requested!")
+  (swap! (.state this) assoc :pause true))
+
+(defn -resume [this]
+  (log "resume requested!")
+  (swap! (.state this) assoc :pause false))
+
+(defn -stop [this]
+  (log "stop requested!")
+  (let [state (.state this)]
+    (swap! state assoc :stop true)
+    (do-when #(.countDown %) (:sleepy @state))
+    (log @state)))
+
+(defn -isRunning [this]
+  (:running @(.state this)))
+
+(defn -isFinished [this]
+  (or (get @(.state this) :finished) false))
+
+(defn -isPaused [this]
+  (:pause @(.state this)))
+
+(defn -stopHasBeenRequested [this]
+  (:stop @(.state this)))
+
+(defn -nextWakeTime [this]
+  (or (:next-wake-time @(.state this)) -1))
+
+;; attaching runnables
+
+(defn -attachRunnable [this f p c s runnable]
+  (let [template (into {}
+          (for [[k v]
+                {:frame-index f :position-index p
+                 :channel-index c :slice-index s}
+                 :when (not (neg? v))]
+            [k v]))]
+    (swap! attached-runnables conj [template runnable])))
+
+(defn -clearRunnables [this]
+  (reset! attached-runnables (vec nil)))
+
+;; testing
+
+(defn create-acq-eng []
+  (doto
+    (proxy [AcquisitionWrapperEngine] []
+      (runPipeline [^SequenceSettings settings]
+        ;(def orig-settings settings)
+        (println "ss positions: " (.size (.positions settings)))
+        (println "position-count: " (.getNumberOfPositions (.getPositionList gui)))
+        (-run settings this)
+    (.setCore mmc (.getAutofocusManager gui))
+    (.setParentGUI gui)
+    (.setPositionList (.getPositionList gui))))))
+
+(defn test-dialog [eng]
+  (.show (AcqControlDlg. eng (Preferences/userNodeForPackage (.getClass gui)) gui)))
+
+(defn run-test []
+  (test-dialog (create-acq-eng)))
+
+


multicamera mda second attempt

multicamera mda second attempt

git-svn-id: 03a8048b5ee8463be5048a3801110fb50f378627@8081 d0ab736e-dc22-4aeb-8dc9-08def0aa14fd

--- acqEngine/src/org/micromanager/acq_engine.clj
+++ acqEngine/src/org/micromanager/acq_engine.clj
@@ -374,7 +374,8 @@

 (defn collect [event out-queue]
   (condp = (:task event)
-                :snap (collect-snap-image event out-queue)
+                :snap (doseq [sub-event (make-multicamera-events event)]
+                        (collect-snap-image sub-event out-queue))
                 :burst (collect-burst-images event out-queue)))

 (defn z-in-msp [msp z-drive]
@@ -441,6 +442,7 @@
       )))

 (defn cleanup []
+  (try
   (log "cleanup")
  ; (do-when #(.update %) (:display @state))
   (state-assoc! :finished true :display nil)
@@ -453,7 +455,8 @@
   (when (and (@state :init-continuous-focus)
              (not (core isContinuousFocusEnabled)))
     (core enableContinuousFocus true))
-  (return-config))
+  (return-config)
+    (catch Throwable t (ReportingUtils/showError t "Acquisition cleanup failed."))))

 ;; running events

@@ -560,8 +563,9 @@
 (defn make-summary-metadata [settings]
   (let [depth (core getBytesPerPixel)
         channels (settings :channels)
-        num-camera-channels (long (core getNumberOfCameraChannels))
-        super-channels (flatten (for [channel channels] (repeat num-camera-channels channel)))]
+        num-camera-channels (core getNumberOfCameraChannels)
+        simple-channels (if-not (empty? channels) channels [{:name "Default" :color java.awt.Color/WHITE}])
+        super-channels (flatten (for [channel simple-channels] (repeat num-camera-channels channel)))]
      (JSONObject. {
       "BitDepth" (core getImageBitDepth)
       "Channels" (count super-channels)


Remove `websocket?` fn that was masking protocol fn

--- src/org/httpkit/server.clj
+++ src/org/httpkit/server.clj
@@ -90,8 +90,6 @@
     (DatatypeConverter/printBase64Binary
      (.digest md (.getBytes (str key websocket-13-guid))))))

-(defn websocket? [request] (:websocket? request))
-
 ;;; experiment, will remove if find not need
 (defn set-global-hook [send-hook receive-hook]
   (AsyncChannel/setGlobalHook send-hook receive-hook))


Format docstrings

Format docstrings

--- src/overtone/algo/trig.clj
+++ src/overtone/algo/trig.clj
@@ -4,7 +4,8 @@
   overtone.algo.trig)

 (defn cosr
-  "Scaled, shifted (i.e. mul-add) cosine fn with the frequency specified in terms of the idx (typically representing the beat).
+  "Scaled, shifted (i.e. mul-add) cosine fn with the frequency specified in
+  terms of the idx (typically representing the beat).

   Returns a value at idx along a scaled cosine fn with specified centre and
   range. The frequency is defined to be period idxs. Similar to Impromptu's
@@ -19,7 +20,8 @@
   (+ centre (* range (Math/cos (* 2 Math/PI idx (/ 1 period))))))

 (defn sinr
-  "Scaled, shifted (i.e. mul-add) sine fn with the frequency specified in terms of the idx (typically representing the beat).
+  "Scaled, shifted (i.e. mul-add) sine fn with the frequency specified in
+  terms of the idx (typically representing the beat).

   Returns a value at idx along a scaled sine fn with specified centre and
   range. The frequency is defined to be period idxs. Similar to Impromptu's
@@ -34,7 +36,8 @@
   (+ centre (* range (Math/sin (* 2 Math/PI idx (/ 1 period))))))

 (defn tanr
-  "Scaled, shifted (i.e. mul-add) tan fn with the frequency specified in terms of the idx (typically representing the beat).
+  "Scaled, shifted (i.e. mul-add) tan fn with the frequency specified in
+  terms of the idx (typically representing the beat).

   Returns a value at idx along a scaled tan fn with specified centre and
   range. The frequency is defined to be period idxs. Similar to Impromptu's


ensure quick-kick inst frees itself

ensure quick-kick inst frees itself

--- src/overtone/inst/drum.clj
+++ src/overtone/inst/drum.clj
@@ -93,7 +93,7 @@
    amp {:default 0.8 :min 0.01 :max 1 :step 0.01}]
   (let [freq-env (env-gen:kr (perc fattack fdecay))
         wave (sin-osc (+ (* 0.5 freq) (* 14 freq freq-env)))
-        env  (x-line:kr 1 0 decay)
+        env  (x-line:kr 1 0 decay :action FREE)
         src (* env wave)
         dist (clip2 (* 2 (tanh (* 3 (distort (* 1.5 src))))) 0.8)
         eq (b-peak-eq dist 57.41 1 44)]


ensure buffer is active for standard buffer fns

--- src/overtone/sc/buffer.clj
+++ src/overtone/sc/buffer.clj
@@ -204,6 +204,7 @@
   reading of buffer data with the internal server, see buffer-data."
   ([buf] (buffer-read buf 0 (:size buf)))
   ([buf start len]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (assert (= :live @(:status buf)))
      (let [buf-id  (:id buf)
@@ -236,6 +237,7 @@
   writing the data (defaults to 0)."
   ([buf data] (buffer-write! buf 0 data))
   ([buf start-idx data]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (when (> (count data) MAX-OSC-SAMPLES)
        (throw (Exception. (str "Error - the data you attempted to write to the buffer was too large to be sent via UDP."))))
@@ -254,6 +256,7 @@
   very slow."
   ([buf data] (buffer-write-relay! buf 0 data))
   ([buf start-idx data]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (loop [data-left data
             idx       0]
@@ -269,6 +272,7 @@
   on the server. Defaults to filling in the full buffer unless start and
   len vals are specified. Asynchronous."
   ([buf val]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (buffer-fill! buf 0 (:size buf) val))
   ([buf start len val]
@@ -281,6 +285,7 @@
   the server. Index defaults to 0 if not specified."
   ([buf val] (buffer-set! buf 0 val))
   ([buf index val]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (snd "/b_set" (:id buf) index (double val))
      buf))
@@ -289,6 +294,7 @@
   "Read a single value from a buffer. Index defaults to 0 if not specified."
   ([buf] (buffer-get buf 0))
   ([buf index]
+     (ensure-buffer-active! buf)
      (assert (buffer? buf))
      (let [buf-id (:id buf)
            prom   (recv "/b_set" (fn [msg]
@@ -319,6 +325,7 @@
    (buffer-save buf \"~/Desktop/foo.wav\" :header \"aiff\" :samples \"int32\"
                                           :start-frame 100)"
   [buf path & args]
+  (ensure-buffer-active! buf)
   (assert (buffer? buf))

   (let [path (resolve-tilde-path path)


Play with size and sleep time

Play with size and sleep time

--- src/petulant_life/main.clj
+++ src/petulant_life/main.clj
@@ -44,12 +44,12 @@
   (loop [board #{[2 0] [2 1] [2 2] [1 2] [0 1]}]
    (when-not (Display/isCloseRequested)
      (GL11/glClear GL11/GL_COLOR_BUFFER_BIT)
-     (r/draw-rectangles (life->screen 50 10 board)
+     (r/draw-rectangles (life->screen 5 2 board)
                         shader
                         [0 1 0 1])

      (Display/update)
-     (Thread/sleep 300)
+     (Thread/sleep 100)
      (recur (stepper board)))))

 (defmacro with-cleanup [close-fn & body]
@@ -63,4 +63,4 @@
   (with-cleanup destroy
     (create)
     (run (s/load-shader-program "resources/gol")
-      l/torus-step)))
+      l/rect-step)))


trying path

trying path


More funstructs

More funstructs

--- src/clj/funstructor/funstruct-base.clj
+++ src/clj/funstructor/funstruct-base.clj
@@ -6,7 +6,18 @@
    "(defn abs [x] (if (pos? x) x (- x)))"

    :even?
-   ""})
+   "(defn even? [x] (zero? (mod x 2)))"
+
+   :odd?
+   "(defn odd? [x] (= 1 (mod x 2)))"
+
+   :sum-of-squares
+   "(defn sum-of-squares [coll] (reduce + (map square coll)))"
+
+   :factorial
+   "(defn factorial [num] (reduce * (range 1 (inc num))))"
+
+   })

 (def id-regex "[a-zA-Z\\?\\!\\+\\-\\*\\/][a-zA-Z\\?\\!\\+\\-\\*\\/0-9]*")

@@ -36,3 +47,15 @@
       (re-seq s)
       (#(map token->terminal %))
       (vec)))
+
+(defn get-two-random-funstructs []
+  (let [[f1 f2] (take 2 (shuffle (keys funstructs)))
+        s1 (get funstructs f1) s2 (get funstructs f2)]
+    [{:name f1 :raw s1 :funstruct (s->funstruct s1)}
+     {:name f2 :raw s2 :funstruct (s->funstruct s2)}]))
+
+(defn print-terminal-count []
+  (doseq [k (keys funstructs)]
+    (let [raw (get funstructs k)
+          funs (s->funstruct raw)]
+      (println k ":" (count funs)))))


Add database query functions

Add database query functions

--- src/zoo_live/model/event.clj
+++ src/zoo_live/model/event.clj
@@ -1,4 +1,42 @@
-(ns zoo-live.model.event)
+(ns zoo-live.model.event
+  (require [korma.db :as kdb]
+           [koram.core :refer :all]
+           [clojure.string :as str]))

-(defn query
-  [])
+(defn uri-to-db-map
+  [uri]
+  (let [uri (java.net.URI. uri)
+        [username password] (str/split (.getUserInfo uri) #":")]
+    {:db (apply str (drop 1 (.getPath uri)))
+     :user username
+     :password password
+     :host (.getHost uri)
+     :port (.getPort uri)}))
+
+(defn ent
+  "Creates Korma Entity from event type and project"
+  [{:keys [postgres]} type project]
+  (let [postgres (kdb/postgres
+                   (if (string? postgres) (uri-to-db-map postgres) postgres))]
+    (-> (create-entity (keyword (str "events_" type "_" project)))
+        (database postgres)
+        (transform ids-to-uri))))
+
+(defn- date-between
+  [w from to]
+  (assoc w :created_at [between from to]))
+
+(defn- params-to-where
+  [w [k v]]
+  (cond
+    (and (contains? w :created_at) (= k :from)) (date-between w v (:created_at w))
+    (and (contains? w :created_at) (= k :to)) (date-between w v (:created_at w))
+    (= k :from) (assoc w :created_at [> v])
+    (= k :to) (assoc w :create [< v])
+    true (assoc w k v)))
+
+(defn query-from-params
+  [ent params]
+  (let [where-clause (reduce params-to-where {} params)] )
+  (select ent
+          (where where-clause)))


fix devcards docstring

fix devcards docstring

--- src/devcards/om_css/devcards/bugs.cljs
+++ src/devcards/om_css/devcards/bugs.cljs
@@ -83,7 +83,7 @@

 (defcard omcss-7-card
-  "Test that referencing global class names works"
+  "Test that assigning classes to child components works"
   (omcss-7component-2))

 (deftest omcss-7-test


Generified intervals.

Generified intervals.

--- src/edu/berkeley/ai/util/intervals.clj
+++ src/edu/berkeley/ai/util/intervals.clj
@@ -1,15 +1,40 @@
 (ns edu.berkeley.ai.util.intervals
-  (:use edu.berkeley.ai.util)
-  )
+  (:use edu.berkeley.ai.util
+	[clojure.contrib.types :only (deftype)]
+        [clojure.contrib.generic :only (root-type)])
+  (:require [clojure.contrib.generic.arithmetic :as ga]
+            [clojure.contrib.generic.comparison :as gc]
+            [clojure.contrib.generic.math-functions :as gm]))
+

 (defstruct interval :left :left-open :right :right-open)

-(defn make-interval [left left-open right right-open]
-  (struct interval left left-open right right-open))
+(deftype ::interval make-interval
+  (fn [l lo r ro] (struct interval l lo r ro))
+  (fn [i] (vals i)))

-(def *real-line* (struct interval Double/NEGATIVE_INFINITY true Double/POSITIVE_INFINITY true))
+(derive ::interval root-type)
+
+
+;(defn make-interval [left left-open right right-open]
+;  (with-meta (struct interval left left-open right right-open)
+;     {:type ::interval}))
+
+(def *real-line* (make-interval Double/NEGATIVE_INFINITY true Double/POSITIVE_INFINITY true))

 (defn make-point-interval [x] (make-interval x false x false))
+
+(defn parse-interval
+  "Take a number, or [lb ub] expression where lb and ub can be nil, and produce
+   an appropriate closed interval."
+  [x]
+  (cond (number? x) (make-point-interval x)
+	(nil? x) *real-line*
+	(coll? x) (do (assert (<= (count x) 2))
+		      (let [[l u] x]
+			(make-interval (or l Double/NEGATIVE_INFINITY) (if l false true)
+				       (or u Double/POSITIVE_INFINITY) (if u false true))))
+	:else (throw (Exception. "I don't know how to make an interval out of " x))))

 (defn interval-empty? [interval]
   (or (< (:right interval) (:left interval))
@@ -43,7 +68,7 @@
 (defn intersect-intervals [i1 i2]
   (let [l1 (:left i1) r1 (:right i1) lo1 (:left-open i1) ro1 (:right-open i1)
 	l2 (:left i2) r2 (:right i2) lo2 (:left-open i2) ro2 (:right-open i2)]
-    (struct interval
+    (make-interval
 	    (max l1 l2)
 	    (cond (> l1 l2) lo1 (< l1 l2) lo2 :else (or lo1 lo2))
 	    (min r1 r2)
@@ -61,6 +86,9 @@
 		 (- (:right i1) (:left i2))
 		 (or (:right-open i1) (:left-open i2))))

+(defn negate-interval [i]
+  (make-interval (- (:right i)) (:right-open i) (- (:left i)) (:left-open i)))
+
 (defn multiply-intervals [i1 i2]
   (loop [l (+ 0 Double/POSITIVE_INFINITY) lo false r (+ 0 Double/NEGATIVE_INFINITY) ro false
 	 vs     (seq (for [[e1 o1] [[(:left i1) (:left-open i1)] [(:right i1) (:right-open i1)]]
@@ -76,6 +104,21 @@
 	   (next vs)))
       (make-interval l lo r ro))))

+(defn scale-interval [i c]
+  (let [l (:left i) r (:right i)]
+    (if (>= c 0) (assoc i :left (* c l) :right (* c r))
+	(make-interval (* r c) (:right-open i) (* l c) (:left-open i)))))
+
+(defn abs-interval [i]
+  (if (>= (:left i) 0) i
+      (let [l (abs (:left i)) lo (:left-open i) r (:right i) ro (:right-open i)]
+	(cond (= l r)
+	        (make-interval 0 false l (and lo ro))
+	      (> l r)
+	        (make-interval 0 false l lo)
+	      (< l r)
+	        (make-interval 0 false r ro)))))
+
 (defn bisect-interval [i]
   (assert-is (not (interval-point interval)))
   (let [{:keys [left right left-open right-open]} i
@@ -84,8 +127,34 @@
      (make-interval mid true       right right-open)]))

+;;; Generic stuff
+
+(defmethod ga/+ [::interval ::interval] [x y]
+  (add-intervals x y))
+
+(defmethod ga/+ [::interval root-type] [x y]
+  (add-intervals x (make-point-interval y)))
+
+(defmethod ga/+ [root-type ::interval] [x y]
+  (add-intervals y (make-point-interval x)))

+(defmethod ga/- ::interval [x]
+  (negate-interval x))
+
+
+(defmethod ga/* [::interval ::interval] [x y]
+  (multiply-intervals x y))
+
+(defmethod ga/* [::interval root-type] [x y]
+  (scale-interval x y))
+
+(defmethod ga/* [root-type ::interval] [x y]
+  (scale-interval y x))
+
+
+(defmethod gm/abs ::interval [i]
+  (abs-interval i))


Threshold images first for speed improvement

--- src/tax_extractor/core.clj
+++ src/tax_extractor/core.clj
@@ -1,4 +1,5 @@
 (ns tax-extractor.core
+  (:require [clojure.java.shell :refer [sh]])
   (:import [net.sourceforge.tess4j Tesseract]
            [org.ghost4j.document PDFDocument]
            [org.ghost4j.renderer SimpleRenderer]
@@ -51,7 +52,6 @@
   (.parse (NumberFormat/getNumberInstance java.util.Locale/US) s))

 (def number-chars "0123456789,.")
-
 (def name-chars "")

 (defn parse-comp [comp-str]
@@ -74,6 +74,8 @@
         :reportable-external-comp (parse-comp (doocr (reportable-external-comp y-off)))
         :other-comp (parse-comp (doocr (other-comp y-off)))))))

+(defn threshold [filename]
+  (sh "convert" filename "-threshold" "75%" filename))

 (defn read-pdf [pdf]
   (let [doc (doto (PDFDocument.)
@@ -85,6 +87,8 @@
         file-two (File. "two.png")]
     (ImageIO/write page-one "png" file-one)
     (ImageIO/write page-two "png" file-two)
+    (threshold "one.png")
+    (threshold "two.png")
     (loop [idx 0
            records []]
       (if-let [record (try


remove the ill-considered upsert-minimal-changes

--- src/er_cassandra/model/alia/upsert.clj
+++ src/er_cassandra/model/alia/upsert.clj
@@ -407,59 +407,6 @@
        (re-matches #"\p{Alpha}[_\p{Alnum}]+")
        boolean))

-(s/defn ^:deprecated upsert-minimal-changes
-  "after callbacks have been run, upsert a minimal change"
-  [session :- ModelSession
-   entity :- Entity
-   old-record :- t/MaybeRecordSchema
-   record :- t/RecordSchema
-   opts :- fns/UpsertOptsSchema]
-  (let [;; remove any columns which would do nothing but
-        ;; create tombstones or other garbage
-        min-change (t.change/minimal-change
-                    entity
-                    old-record
-                    record)]
-
-    (if min-change
-      (ddo [:let [;; keep the removed columns to add back to the response
-                  ;; record, since they are valid columns and the
-                  ;; general contract is that the response record
-                  ;; will resemble the request record excepting
-                  ;; necessary changes (such as removal of failed key acquisitions)
-                  removed-cols (filter
-                                (->> min-change keys set complement)
-                                (keys record))
-                  removed-record (select-keys record removed-cols)]
-
-            [updated-record-with-keys
-             acquire-failures] (unique-key/upsert-primary-record-and-update-unique-keys
-                                session
-                                entity
-                                old-record
-                                min-change
-                                opts)
-
-            _ (monad/when updated-record-with-keys
-                (change-secondaries-and-lookups session
-                                                entity
-                                                old-record
-                                                min-change
-                                                opts))
-
-            ;; add columns which weren't needed for the upsert back in to the response
-            :let [updated-record-with-keys (merge updated-record-with-keys
-                                                  removed-record)]]
-
-        (return
-         (pair updated-record-with-keys
-               acquire-failures)))
-
-      ;; no upsert required
-      (return deferred-context
-              (pair record nil)))))
-
-
 (s/defn upsert-changes*
   "upsert a single instance given the previous value of the instance. if the
    previous value is nil then it's an insert. if the new value is nil then
@@ -534,14 +481,6 @@
                                             old-record-ser
                                             updated-record-with-keys-ser
                                             opts))
-
-        ;; [updated-record-with-keys-ser
-        ;;  acquire-failures] (upsert-minimal-changes
-        ;;                     session
-        ;;                     entity
-        ;;                     old-record-ser
-        ;;                     record-ser
-        ;;                     opts)

         ;; construct the response and deserialise
         response-record-raw (merge nil-removed


datepicker-dropdown should deref-or-value model

`datepicker` supports a `:model` arg which is either a
`goog.date.UtcDateTime` or an atom containing one. `datepicker-dropdown`
claims the same, but calls `anchor-button`: this commit modifies
`anchor-button` so that `datepicker-dropdown` is true to its word.

--- src/re_com/datepicker.cljs
+++ src/re_com/datepicker.cljs
@@ -232,8 +232,8 @@
     :class     "noselect"
     :min-width "10em"
     :children  [[:label {:class "form-control dropdown-button"}
-                 (if (instance? js/goog.date.Date @model)
-                   (unparse (if (seq format) (formatter format) date-format) @model)
+                 (if (instance? js/goog.date.Date (deref-or-value model))
+                   (unparse (if (seq format) (formatter format) date-format) (deref-or-value model))
                    "")]
                 [:span.dropdown-button.activator.input-group-addon
                  {:style {:padding "3px 0 0 0"}}


Accounts for non LINEFEED linebreaks (old OS/X, Windows)

--- src/typewriter/project.clj
+++ src/typewriter/project.clj
@@ -39,17 +39,23 @@
   (str (fs/name file) ".html"))

+(defn- has-meta-data?
+  "True if a text contains a meta-data in YAML."
+  [text]
+  (re-find #"^---(?:\r|\n)" text))
+
+
 (defn- parse-meta-data
   "Parses metadata from a text."
   [text]
-  (let [[_ meta contents] (re-matches #"(?s)---\n(.*?)\n---\n(.*)" text)]
+  (let [[_ meta contents] (re-matches #"(?s)---(?:\r|\n)+(.*?)(?:\r|\n)+---(?:\r|\n)+(.*)" text)]
     [(yaml/parse-string meta) contents]))

 (defn- parse-file
   "Parses meta-data and contents from a document file."
   [text]
-  (if (.startsWith text "---\n")  (parse-meta-data text)
+  (if (has-meta-data? text)  (parse-meta-data text)
       [nil text]))


Korjattu refresh-url

Korjattu refresh-url

--- clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
+++ clj-elasticsearch/src/clj_elasticsearch/elastic_connect.clj
@@ -55,7 +55,7 @@

 (defn refresh-index
       [index]
-      (http/post (elastic-url index "/_refresh") {:content-type :json}))
+      (http/post (elastic-url index "_refresh") {:content-type :json}))

 (defn delete-index ; TODO -connection timeouts
       [index]


Version 6.20.0

Version 6.20.0

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(def ps-version "6.20.0-SNAPSHOT")
+(def ps-version "6.20.0")

 (defn deploy-info
   [url]


Version 0.6.2-SNAPSHOT

Version 0.6.2-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject pandect "0.6.1"
+(defproject pandect "0.6.2-SNAPSHOT"
   :description "Message Digest and Checksum Library for Clojure"
   :url "https://github.com/xsc/pandect"
   :license {:name "MIT License"


Bumped helmsman version.

Bumped helmsman version.

--- project.clj
+++ project.clj
@@ -6,7 +6,7 @@

   :dependencies [[org.clojure/clojure "1.6.0"]
                  [enlive "1.1.5"]
-                 [org.vlacs/helmsman "0.1.10"]]
+                 [org.vlacs/helmsman "0.2.4"]]

   :pedantic? :warn


Remove release plugin

Remove release plugin

--- project.clj
+++ project.clj
@@ -14,12 +14,6 @@
           ; Don't use the latest version: https://github.com/marick/lein-midje/issues/47
           :plugins [[lein-midje "3.1.1"]]}

-    :prod {:plugins [[lein-release "1.0.6" :exclusions [org.clojure/clojure]]]
-           :global-vars {*warn-on-reflection* true}
-           :scm {:name "git"
-                 :url "https://github.com/vbauer/lein-jshint"}
-           :lein-release {:deploy-via :clojars
-                          :scm :git}}
   }

   :pedantic? :abort


Upgrade the logback dependencies so we can send mails on errors

--- project.clj
+++ project.clj
@@ -7,7 +7,7 @@
                  [buddy/buddy-core "1.10.413"]
                  [buddy/buddy-hashers "1.8.158"]
                  [buddy/buddy-sign "3.4.333"]
-                 [ch.qos.logback/logback-classic "1.4.0"]
+                 [ch.qos.logback/logback-classic "1.4.3"]
                  [clj-commons/iapetos "0.1.13" :exclusions [io.prometheus/simpleclient]]
                  [cljs-ajax "0.8.4"]
                  [clojure.java-time "0.3.3"]
@@ -60,7 +60,10 @@
                  [com.novemberain/pantomime "2.11.0" :exclusions [com.google.guava/guava]]
                  [clj-http "3.12.3"]
                  [org.clojure/data.csv "1.0.1"]
-                 [org.clojars.pntblnk/clj-ldap "0.0.17"]]
+                 [org.clojars.pntblnk/clj-ldap "0.0.17"]
+                 ;; the next two deps are needed for the logback SMTPAppender (so we can send log entries by mail)
+                 [com.sun.mail/jakarta.mail "2.0.1"]
+                 [com.sun.activation/jakarta.activation "2.0.1"]]

   :min-lein-version "2.0.0"


release 0.1.0

release 0.1.0

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject devcards-om-next "0.1.0-SNAPSHOT"
+(defproject devcards-om-next "0.1.0"
   :description "Om Next helpers for Devcards"
   :url "http://github.com/anmonteiro/devcards-om-next"
   :dependencies [[org.clojure/clojure "1.8.0"]


(maint) Bump trapperkeeper-webserver-jetty9 to 1.5.7

Bumping trapperkeeper-webserver-jetty9 to 1.5.7 as a recommended bugfix
is included; updating associated dependencies, including trapperkeeper
1.4.0. Note that, this time, we're not bumping clojure to 1.7.0.

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(def tk-version "1.3.0")
+(def tk-version "1.4.0")
 (def ks-version "1.3.0")

 (defproject puppetlabs/pcp-broker "0.7.1-SNAPSHOT"
@@ -24,13 +24,13 @@
                  ;; Transitive dependency for:
                  ;;   ch.qos.logback/logback-classic via puppetlabs/trapperkeeper
                  ;;   net.logstash.logback/logstash-logback-encoder via puppetlabs/structured-logging
-                 [ch.qos.logback/logback-core "1.1.2"]
+                 [ch.qos.logback/logback-core "1.1.3"]

                  ;; Transitive dependency for puppetlabs/trapperkeeper-authorization, and a direct dependency
                  [clj-time "0.10.0"]

                  ;; Transitive dependency for puppetlabs/trapperkeeper and puppetlabs/trapperkeeper-authorization
-                 [puppetlabs/typesafe-config "0.1.4"]
+                 [puppetlabs/typesafe-config "0.1.5"]

                  ;; Transitive dependency for:
                  ;;   puppetlabs/trapperkeeper
@@ -41,7 +41,8 @@
                  [puppetlabs/trapperkeeper ~tk-version]
                  [puppetlabs/trapperkeeper-authorization "0.1.5"]
                  [puppetlabs/trapperkeeper-metrics "0.1.1"]
-                 [puppetlabs/trapperkeeper-webserver-jetty9 "1.5.2"]
+                 ;; Exclude clojure dep for now as that will force a ripple up to clojure 1.7.0
+                 [puppetlabs/trapperkeeper-webserver-jetty9 "1.5.7" :exclusions [org.clojure/clojure]]
                  [puppetlabs/trapperkeeper-status "0.2.1"]

                  ;; Exclude clojure dep for now as that will force a ripple up to clojure 1.7.0


Remove whitespace on project.clj

Remove whitespace on project.clj

--- project.clj
+++ project.clj
@@ -48,7 +48,6 @@
                         :compiler {:output-to "target/tests.js"
                                    :optimizations :simple
                                    :pretty-print true}}]}
-
   :profiles {:dev {:dependencies [[speclj "3.1.0"]
                                   [com.keminglabs/cljx "0.5.0" :exclusions [org.clojure/clojure]]
                                   [org.clojure/tools.namespace "0.2.7"]]


change groupid to net.mikera

change groupid to net.mikera

--- project.clj
+++ project.clj
@@ -1,10 +1,11 @@
-(defproject trellis "0.0.1-SNAPSHOT"
+(defproject net.mikera/trellis "0.0.1-SNAPSHOT"
   :description "Trellis Web Framework"
   :url "http://example.com/FIXME"

   :dependencies [[org.clojure/clojure "1.6.0"]
                  [org.clojure/tools.reader "0.8.8"]
                  [org.clojure/tools.nrepl "0.2.5"]
+
                  ;; CLJ
                  [ring/ring-core "1.3.1"]
                  [org.clojure/data.xml "0.0.8"]


bump version

bump version

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject clojure.joda-time "0.5.0"
+(defproject clojure.joda-time "0.6.0-SNAPSHOT"
   :description "Idiomatic Clojure wrapper for Joda-Time"
   :url "http://github.com/dm3/clojure.joda-time"
   :license {:name "MIT License"


Update to 0.0.2-SNAPSHOT

Update to 0.0.2-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject day8.re-frame/abra "0.0.1"
+(defproject day8.re-frame/abra "0.0.2-SNAPSHOT"
   :description "Tracing and developer tools for re-frame apps"
   :url         "https://github.com/Day8/re-frame-trace"
   :license     {:name "MIT"}


Set version to 0.9.0-SNAPSHOT

Set version to 0.9.0-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject funcool/catacumba "0.8.1"
+(defproject funcool/catacumba "0.9.0-SNAPSHOT"
   :description "Asynchronous Web Toolkit for Clojure."
   :url "http://github.com/funcool/catacumba"
   :license {:name "BSD (2-Clause)"


(SERVER-2828) Bump ezbake version for ubuntu 2004

--- project.clj
+++ project.clj
@@ -162,7 +162,7 @@
                                                [puppetlabs/jruby-utils]
                                                [puppetlabs/puppetserver ~ps-version]
                                                [puppetlabs/trapperkeeper-webserver-jetty9]]
-                      :plugins [[puppetlabs/lein-ezbake "2.1.4"]]
+                      :plugins [[puppetlabs/lein-ezbake "2.2.0"]]
                       :name "puppetserver"}
              :uberjar {:dependencies [[org.bouncycastle/bcpkix-jdk15on]
                                       [puppetlabs/trapperkeeper-webserver-jetty9]]


Add sensible codocs opts

Add sensible codocs opts

--- project.clj
+++ project.clj
@@ -39,5 +39,11 @@
                                        :releases {:checksum :fail :update :always}}}
   :warn-on-reflection true
   :pedantic :warn
-  :codox {:sources ["src"]
+  :codox {:src-dir-uri "https://github.com/clojurewerkz/cassaforte/blob/master"
+          :sources ["src"]
+          :src-linenum-anchor-prefix "L"
+          :exclude [clojurewerkz.cassaforte.conversion
+                    clojurewerkz.cassaforte.ns-utils
+                    clojurewerkz.cassaforte.metrics
+                    clojurewerkz.cassaforte.debug-utils]
           :output-dir "doc/api"})


Update dependencies

Update dependencies

--- project.clj
+++ project.clj
@@ -9,9 +9,9 @@
                  [org.postgresql/postgresql "42.2.5"]
                  [org.clojure/java.jdbc "0.7.8"]
                  [honeysql "0.9.4"]
-                 [clj-time "0.14.4"]
+                 [clj-time "0.15.0"]
                  [cheshire "5.8.1"]
-                 [selmer "1.12.1"]
+                 [selmer "1.12.2"]
                  [clj-http "3.9.1"]
                  [org.clojure/tools.logging "0.4.1"]
                  [org.slf4j/slf4j-log4j12 "1.7.25"]
@@ -19,7 +19,7 @@
                  [buddy/buddy-hashers "1.3.0"]
                  [buddy/buddy-auth "2.1.0"]
                  [org.clojars.pntblnk/clj-ldap "0.0.16"]
-                 [org.influxdb/influxdb-java "2.13"]]
+                 [org.influxdb/influxdb-java "2.14"]]
   :main env-logger.handler
   :aot [env-logger.handler
         clojure.tools.logging.impl]


(PDB-4165) Duplicate dependency pins in :ezbake profile

It looks like the use of ^:replace :dependencies in the ezbake profile
causes all pins in the normal :dependencies section to be ignored.  So
for now, just repeat the pins for the recent CVEs in the :ezbake
profile, which does cause them to show up here:

  lein with-profiles ezbake deps :tree

In addition, stop pinning hikaricp and clojure/jdbc so that we won't
fall afoul of :pedantic, *and* so that we'll actually be testing the
versions that we ship (verified by spot-checking the relevant
META-INF/maven/ pom.xml versions in the 5.1.5 debian/stretch jar).

--- project.clj
+++ project.clj
@@ -1,5 +1,6 @@
 (def pdb-version "5.1.6-SNAPSHOT")
 (def clj-parent-version "1.4.3")
+(def tk-jetty9-ver "2.2.0")

 (defn true-in-env? [x]
   (#{"true" "yes" "1"} (System/getenv x)))
@@ -58,10 +59,10 @@

 (def pdb-dev-deps
   (concat
+   `[[puppetlabs/trapperkeeper-webserver-jetty9 ~tk-jetty9-ver :classifier "test"]]
    '[[ring-mock]
      [puppetlabs/trapperkeeper :classifier "test"]
      [puppetlabs/kitchensink :classifier "test"]
-     [puppetlabs/trapperkeeper-webserver-jetty9 "2.2.0" :classifier "test"]
      [org.flatland/ordered "1.5.3"]
      [org.clojure/test.check "0.9.0"]
      [com.gfredericks/test.chuck "0.2.7" :exclusions
@@ -74,6 +75,18 @@
      [puppetlabs/trapperkeeper-authorization nil]
      [puppetlabs/trapperkeeper-filesystem-watcher nil]]
    puppetserver-test-deps))
+
+;; Until we resolve the issue with :dependencies ^:replace in the
+;; ezbake profile below ignoring all the pins in :dependencies, repeat
+;; them in both places via this list.  For now, only include the pins
+;; that we added after we recognized the problem (when fixing CVEs),
+;; so we don't change unrelated deps that have been deployed for a
+;; long time.
+(def pdb-dep-pins
+  `[;; Use jetty 9.4.11.v20180605 to fix CVE-2017-7656 (PDB-4160)
+    [puppetlabs/trapperkeeper-webserver-jetty9 ~tk-jetty9-ver]
+    ;; Fix CVE-2018-5968 (PDB-4161)
+    [com.fasterxml.jackson.core/jackson-databind "2.9.7"]])

 ;; Don't use lein :clean-targets so that we don't have to repeat
 ;; ourselves, given that we need to remove some protected files, and
@@ -127,74 +140,71 @@
   ;; requires lein 2.2.0+.
   :pedantic? :abort

-  :dependencies [;; Clojure org
-                 [org.clojure/clojure "1.8.0"]
-                 [org.clojure/core.async]
-                 [org.clojure/core.match "0.3.0-alpha4" :exclusions [org.clojure/tools.analyzer.jvm]]
-                 [org.clojure/core.memoize "0.5.9"]
-                 [org.clojure/java.jdbc "0.6.1"]
-                 [org.clojure/tools.macro]
-                 [org.clojure/math.combinatorics "0.1.1"]
-                 [org.clojure/math.numeric-tower "0.0.4"]
-                 [org.clojure/tools.logging]
-
-                 ;; Puppet specific
-                 [puppetlabs/comidi]
-                 [puppetlabs/dujour-version-check]
-                 [puppetlabs/http-client]
-                 [puppetlabs/i18n]
-                 [puppetlabs/kitchensink]
-                 [puppetlabs/stockpile "0.0.4"]
-                 [puppetlabs/tools.namespace "0.2.4.1"]
-                 [puppetlabs/trapperkeeper]
-                 [puppetlabs/trapperkeeper-webserver-jetty9 "2.2.0"]
-                 [puppetlabs/trapperkeeper-metrics :exclusions [ring/ring-defaults org.slf4j/slf4j-api]]
-                 [puppetlabs/trapperkeeper-status]
-
-                 ;; Various
-                 [cheshire]
-                 [clj-stacktrace]
-                 [clj-time]
-                 [com.rpl/specter "0.5.7"]
-                 [com.taoensso/nippy "2.10.0" :exclusions [org.clojure/tools.reader]]
-                 [digest "1.4.3"]
-                 [fast-zip-visit "1.0.2"]
-                 [instaparse "1.4.1"]
-                 [me.raynes/fs]
-                 [metrics-clojure "2.6.1" :exclusions [org.clojure/clojure org.slf4j/slf4j-api]]
-                 [prismatic/schema "1.1.2"]
-                 [robert/hooke "1.3.0"]
-                 [slingshot]
-                 [trptcolin/versioneer]
-
-                 ;; Filesystem utilities
-                 [org.apache.commons/commons-lang3 "3.4"]
-                 ;; Version information
-                 ;; Job scheduling
-                 [overtone/at-at "1.2.0"]
-
-                 ;; Database connectivity
-                 [com.zaxxer/HikariCP "2.4.3" :exclusions [org.slf4j/slf4j-api]]
-                 [honeysql "0.6.3"]
-                 [org.postgresql/postgresql "9.4.1208.jre7"]
-
-                 ;; MQ connectivity
-                 [org.apache.activemq/activemq-broker "5.13.2" :exclusions [org.slf4j/slf4j-api]]
-                 [org.apache.activemq/activemq-kahadb-store "5.13.2" :exclusions [org.slf4j/slf4j-api]]
-                 [org.apache.activemq/activemq-pool "5.13.2" :exclusions [org.slf4j/slf4j-api]]
-                 ;; bridge to allow some spring/activemq stuff to log over slf4j
-                 [org.slf4j/jcl-over-slf4j "1.7.14" :exclusions [org.slf4j/slf4j-api]]
-
-                 ;; WebAPI support libraries.
-                 [bidi "2.0.12" :exclusions [org.clojure/clojurescript]]
-                 [clj-http "2.0.1" :exclusions [org.apache.httpcomponents/httpcore org.apache.httpcomponents/httpclient]]
-                 [com.novemberain/pantomime "2.1.0"]
-                 [compojure]
-                 [org.apache.commons/commons-compress "1.10"]
-                 [ring/ring-core :exclusions [javax.servlet/servlet-api org.clojure/tools.reader]]
-
-                 ;; Pin version for PDB-3809
-                 [com.fasterxml.jackson.core/jackson-databind "2.9.7"]]
+  :dependencies ~(concat
+                  pdb-dep-pins
+                  '[[org.clojure/clojure "1.8.0"]
+                    [org.clojure/core.async]
+                    [org.clojure/core.match "0.3.0-alpha4" :exclusions [org.clojure/tools.analyzer.jvm]]
+                    [org.clojure/core.memoize "0.5.9"]
+                    [org.clojure/java.jdbc]
+                    [org.clojure/tools.macro]
+                    [org.clojure/math.combinatorics "0.1.1"]
+                    [org.clojure/math.numeric-tower "0.0.4"]
+                    [org.clojure/tools.logging]
+
+                    ;; Puppet specific
+                    [puppetlabs/comidi]
+                    [puppetlabs/dujour-version-check]
+                    [puppetlabs/http-client]
+                    [puppetlabs/i18n]
+                    [puppetlabs/kitchensink]
+                    [puppetlabs/stockpile "0.0.4"]
+                    [puppetlabs/tools.namespace "0.2.4.1"]
+                    [puppetlabs/trapperkeeper]
+                    [puppetlabs/trapperkeeper-metrics :exclusions [ring/ring-defaults org.slf4j/slf4j-api]]
+                    [puppetlabs/trapperkeeper-status]
+
+                    ;; Various
+                    [cheshire]
+                    [clj-stacktrace]
+                    [clj-time]
+                    [com.rpl/specter "0.5.7"]
+                    [com.taoensso/nippy "2.10.0" :exclusions [org.clojure/tools.reader]]
+                    [digest "1.4.3"]
+                    [fast-zip-visit "1.0.2"]
+                    [instaparse "1.4.1"]
+                    [me.raynes/fs]
+                    [metrics-clojure "2.6.1" :exclusions [org.clojure/clojure org.slf4j/slf4j-api]]
+                    [prismatic/schema "1.1.2"]
+                    [robert/hooke "1.3.0"]
+                    [slingshot]
+                    [trptcolin/versioneer]
+
+                    ;; Filesystem utilities
+                    [org.apache.commons/commons-lang3 "3.4"]
+                    ;; Version information
+                    ;; Job scheduling
+                    [overtone/at-at "1.2.0"]
+
+                    ;; Database connectivity
+                    [com.zaxxer/HikariCP]
+                    [honeysql "0.6.3"]
+                    [org.postgresql/postgresql "9.4.1208.jre7"]
+
+                    ;; MQ connectivity
+                    [org.apache.activemq/activemq-broker "5.13.2" :exclusions [org.slf4j/slf4j-api]]
+                    [org.apache.activemq/activemq-kahadb-store "5.13.2" :exclusions [org.slf4j/slf4j-api]]
+                    [org.apache.activemq/activemq-pool "5.13.2" :exclusions [org.slf4j/slf4j-api]]
+                    ;; bridge to allow some spring/activemq stuff to log over slf4j
+                    [org.slf4j/jcl-over-slf4j "1.7.14" :exclusions [org.slf4j/slf4j-api]]
+
+                    ;; WebAPI support libraries.
+                    [bidi "2.0.12" :exclusions [org.clojure/clojurescript]]
+                    [clj-http "2.0.1" :exclusions [org.apache.httpcomponents/httpcore org.apache.httpcomponents/httpclient]]
+                    [com.novemberain/pantomime "2.1.0"]
+                    [compojure]
+                    [org.apache.commons/commons-compress "1.10"]
+                    [ring/ring-core :exclusions [javax.servlet/servlet-api org.clojure/tools.reader]]])

   :jvm-opts ~(if need-permgen?
               ["-XX:MaxPermSize=200M"]
@@ -236,28 +246,30 @@
                    :injections [(do
                                   (require 'schema.core)
                                   (schema.core/set-fn-validation! true))]}
-             :ezbake {:dependencies ^:replace [;; NOTE: we need to explicitly pass in `nil` values
-                                               ;; for the version numbers here in order to correctly
-                                               ;; inherit the versions from our parent project.
-                                               ;; This is because of a bug in lein 2.7.1 that
-                                               ;; prevents the deps from being processed properly
-                                               ;; with `:managed-dependencies` when you specify
-                                               ;; dependencies in a profile.  See:
-                                               ;; https://github.com/technomancy/leiningen/issues/2216
-                                               ;; Hopefully we can remove those `nil`s (if we care)
-                                               ;; and this comment when lein 2.7.2 is available.
-
-                                               ;; we need to explicitly pull in our parent project's
-                                               ;; clojure version here, because without it, lein
-                                               ;; brings in its own version, and older versions of
-                                               ;; lein depend on clojure 1.6.
-                                               [org.clojure/clojure nil]
-
-                                               ;; This circular dependency is required because of a bug in
-                                               ;; ezbake (EZ-35); without it, bootstrap.cfg will not be included
-                                               ;; in the final package.
-                                               [puppetlabs/puppetdb ~pdb-version]
-                                               [org.clojure/tools.nrepl nil]]
+             :ezbake {:dependencies ^:replace ~(concat
+                                                pdb-dep-pins
+                                                `[;; NOTE: we need to explicitly pass in `nil` values
+                                                  ;; for the version numbers here in order to correctly
+                                                  ;; inherit the versions from our parent project.
+                                                  ;; This is because of a bug in lein 2.7.1 that
+                                                  ;; prevents the deps from being processed properly
+                                                  ;; with `:managed-dependencies` when you specify
+                                                  ;; dependencies in a profile.  See:
+                                                  ;; https://github.com/technomancy/leiningen/issues/2216
+                                                  ;; Hopefully we can remove those `nil`s (if we care)
+                                                  ;; and this comment when lein 2.7.2 is available.
+
+                                                  ;; we need to explicitly pull in our parent project's
+                                                  ;; clojure version here, because without it, lein
+                                                  ;; brings in its own version, and older versions of
+                                                  ;; lein depend on clojure 1.6.
+                                                  [org.clojure/clojure nil]
+
+                                                  ;; This circular dependency is required because of a bug in
+                                                  ;; ezbake (EZ-35); without it, bootstrap.cfg will not be included
+                                                  ;; in the final package.
+                                                  [puppetlabs/puppetdb ~pdb-version]
+                                                  [org.clojure/tools.nrepl nil]])
                       :name "puppetdb"
                       :plugins [[puppetlabs/lein-ezbake "1.8.5"]]}
              :testutils {:source-paths ^:replace ["test"]}


Version 0.19.2

Version 0.19.2

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject nhl-score-api "0.19.1"
+(defproject nhl-score-api "0.19.2"
   :description "A JSON API that returns the scores and goals from the latest finished NHL games."
   :license {:name "MIT"
             :url "https://opensource.org/licenses/MIT"}


upgraded snapshot version to release

upgraded snapshot version to release

--- project.clj
+++ project.clj
@@ -8,7 +8,7 @@
   :min-lein-version "2.0.0"

   :dependencies [[org.clojure/clojure "1.6.0"]
-                 [io.sarnowski/swagger1st "0.4.0-SNAPSHOT"]
+                 [io.sarnowski/swagger1st "0.4.0"]
                  [com.stuartsierra/component "0.2.3"]
                  [ring "1.3.2"]
                  [environ "1.0.0"]


Version 0.4.17-alpha4-SNAPSHOT

Version 0.4.17-alpha4-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject yetibot.core "0.4.17-alpha3"
+(defproject yetibot.core "0.4.17-alpha4-SNAPSHOT"
   :description "Core yetibot utilities, extracted for shared use among yetibot
                 and its various plugins"
   :url "https://github.com/yetibot/yetibot.core"


lein-release plugin: preparing 0.3.8 release

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject prismatic/om-tools "0.3.8-SNAPSHOT"
+(defproject prismatic/om-tools "0.3.8"
   :description "Tools for building Om applications"
   :url "http://github.com/prismatic/om-tools"
   :license {:name "Eclipse Public License - v 1.0"


Typo in ring-devel version.

Typo in ring-devel version.

--- project.clj
+++ project.clj
@@ -43,7 +43,7 @@
     :dependencies
     [[quil "2.2.6"]
      [org.clojure/tools.namespace "0.2.10"]
-     [ring/ring-devel "1.3.3"]]}
+     [ring/ring-devel "1.3.2"]]}

    :uberjar
    {:aot :all


Upgrade lein-shadow to 0.2.2

Upgrade lein-shadow to 0.2.2

--- project.clj
+++ project.clj
@@ -12,7 +12,7 @@
                  [re-frame                  "1.1.1" :scope "provided"]]

   :plugins      [[day8/lein-git-inject "0.0.14"]
-                 [lein-shadow          "0.2.0"]]
+                 [lein-shadow          "0.2.2"]]

   :middleware   [leiningen.git-inject/middleware]


Version 0.4.7-SNAPSHOT

Version 0.4.7-SNAPSHOT

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject etaoin "0.4.6"
+(defproject etaoin "0.4.7-SNAPSHOT"

   :description "Pure Clojure Webdriver protocol implementation."


fix for jetty CVE-2015-2080

fix for jetty CVE-2015-2080

--- project.clj
+++ project.clj
@@ -15,7 +15,7 @@
                  [clj-yaml                      "0.4.0"]
                  [clj-http                      "1.0.1"
                   :exclusions [commons-codec]]
-                 [cc.qbits/jet                  "0.5.0-alpha3"]
+                 [cc.qbits/jet                  "0.5.5"]
                  [cc.qbits/alia                 "2.2.2"]
                  [net.jpountz.lz4/lz4           "1.2.0"]
                  [org.xerial.snappy/snappy-java "1.1.1.3"]


Update dependencies

Update dependencies

--- project.clj
+++ project.clj
@@ -21,13 +21,13 @@
                  [compojure "1.1.8" :exclusions [javax.servlet/servlet-api]]
                  [dire "0.5.2"]
                  [environ "0.5.0"]
-                 [io.clj/logging "0.7.1"]
+                 [io.clj/logging "0.8.1"]
                  [metrics-clojure "1.1.0"]
                  [metrics-clojure-ring "1.1.0"]
                  [nokia/instrumented-ring-jetty-adapter "0.1.9"]
                  [nokia/ring-utils "1.2.4"]
                  [org.clojure/clojure "1.6.0"]
-                 [org.clojure/tools.logging "0.2.6"]
+                 [org.clojure/tools.logging "0.3.0"]
                  [org.eclipse.jetty/jetty-server "8.1.15.v20140411"]
                  [org.slf4j/jcl-over-slf4j "1.7.7"]
                  [org.slf4j/jul-to-slf4j "1.7.7"]


Remove jnr-posix after removing the chdir

--- project.clj
+++ project.clj
@@ -86,11 +86,6 @@
                  [org.jclouds.driver/jclouds-jsch "1.2.1"]
                  [org.jclouds.provider/aws-ec2 "1.2.1"]

-                 ;; Requires github.com/pbiggar/jnr-posix
-                 [com.github.jnr/jnr-posix "2.1-5ad6cc85878cbaa4c698640a73578d8236119456"]
-                 [com.github.jnr/jnr-ffi "0.6.0"]
-                 [com.github.jnr/jnr-constants "0.8.2"]
-
                  ;; Pallet Crates
                  [org.cloudhoist/automated-admin-user "0.6.0"]
                  [org.cloudhoist/git "0.5.0"]


increment patch number

increment patch number

--- project.clj
+++ project.clj
@@ -1,4 +1,4 @@
-(defproject enslin/lein-template "0.3.0"
+(defproject enslin/lein-template "0.3.1"
   :description "Desktop app template, for Leiningen, using web technology."
   :url "https://github.com/david-rc-dayton/enslin-template"
   :license {:name "The MIT License (MIT)"