cmp.exchange
enclose-map
(enclose-map m p)Encloses the given map m with respect to the path p.
Example:
(enclose-map {:gg "ff"} "mm.ll")
;; gives:
;; {:mm {:ll {:gg "ff"}}}
(enclose-map {:gg "ff"} "mm")
;; gives:
;; {:mm {:gg "ff"}}
(enclose-map {:gg "ff"} nil)
;; gives:
;; {:gg "ff"}
exch-key
(exch-key mp-id s)Returns the base key for the exchange path.
(exch-key "foo" "bar.baz")
;; "foo@exchange@bar"
(exch-key "foo" "bar")
;; "foo@exchange@bar"
from!
(from! mp-id m)Builds a map by replacing the values of the input map m. The replacements are gathered from the exchange interface with the keys: <mp-id>@exchange@<input-map-value>
The example key: ref@exchange@Vraw_block1 with the example value: [1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0] should return: {:%stateblock1 [1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0]}
(from! "ref" {:%stateblock1 "Vraw_block1"})
;; =>
;; {:%stateblock1 [1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0]}
Todo
Check for non trivial <input-map-value> like {:%aaa "bbb.ccc"}
key->first-kw
(key->first-kw s)Returns the keyword or nil.
(key->second-kw "foo" )
;; nil
(key->second-kw "foo.bar" )
;; :bar
key->second-kw
(key->second-kw s)Returns the keyword or nil.
(key->second-kw "foo" )
;; nil
(key->second-kw "foo.bar" )
;; :bar
only-if-not
(only-if-not {mp-id :MpName, k :OnlyIfNot})Runs the task only-if-not the exchange path given with :MpName and :OnlyIfNot evaluates to true.
read!
(read! mp-id p)Returns e.g the compare value belonging to a mp-id and an ExchangePath k. First try is to simply request to <mp-id>@exchange@<k>. If this is nil Second try is to get the keyword kw from k if k looks like this: aaa.bbb. If kw is not nil it is used to extract the related value.
(read! "ref" "A.Unit")
;; "Pa"
;; or:
(read! "devhub" "Vraw_block1")
;; [1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0]
run-if
(run-if {mp-id :MpName, k :RunIf})Checks if the exchange path given with :MpName and :RunIf evaluates to true.
stop-if
(stop-if {mp-id :MpName, k :StopIf})Checks if the exchange path given with :MpName and :StopIf evaluates to true.
to!
(to! mp-id m p)(to! mp-id m)Writes m to the exchange interface. The first level keys of m are used for the key. The return value of the storing process (e.g. “OK”) is converted to a keyword. After storing the amounts of :OK is compared to (count m).
Example:
{:A 1
:B 2}
Stores the value 1 under the key <mp-id>@exchange@A and a 2 under <mp-id>@exchange@B.
If a path p is given the enclose-map function respects p.