cmp.task

action=

(action= task)

A = partial on the task :Action.

assemble

(assemble meta-task mp-id state-key)

Assembles the task from the given meta-task in a special order:

  • merge Use
  • replace from Replace
  • replace from Defaults
  • replace from Globals

assocs the structs afterwards.

TODO: clarify :PreInput

(def proto {:TaskName "Common-wait"
                  :Replace {"%waittime" 10}})
(assemble
  (gen-meta-task proto "ref" "ref@container@0@state@0@0"))
;; {:Action  "wait",
;;  :Comment  "Ready in  10 ms",
;;  :TaskName "Common-wait",
;;  :WaitTime "10",
;;  :MpName   "ref"
;;  :StateKey "ref@container@0@state@0@0"
;;  ...
;; }

build

(build k)

Builds and returns the assembled task for the given key k related to the proto-task. Since the functions in the cmp.task namespace are (kept) independent from the tasks position, this info (:StateKey holds the position of the task) have to beassoced (done in tsk/assemble).

dev-action?

(dev-action? task)

Device actions are: * :MODBUS * :VXI11 * :TCP * :UDP * :EXECUTE

extract-use-value

(extract-use-value task m k)

gen-meta-task

(gen-meta-task x)

Gathers all information for the given proto-task (map). The proto-task should be a map containing the :TaskName keyword at least. String version makes a map out of s and calls related method.

(gen-meta-task "Common-wait")
;; 19-12-27 11:14:48 hiob DEBUG [cmp.lt-mem:21] - get task:  Common-wait  from ltm
;; {:Task
;; {:Action "wait",
;; :Comment "%waitfor  %waittime ms",
;; :TaskName "Common-wait",
;; :WaitTime "%waittime"},
;; :Use nil,
;; :Defaults
;; {"%unit" "mbar",
;; "%targetdb" "vl_db",
;; "%relayinfo" "relay_info",
;; "%docpath" "",
;; "%sourcedb" "vl_db_work",
;; "%timepath" "Time",
;; "%waitunit" "ms",
;; "%break" "no",
;; "%waitfor" "Ready in",
;; "%waittime" "1000",
;; "%dbinfo" "db_info"},
;; :Globals
;; {"%hour" "11",
;; "%minute" "14",
;; "%second" "48",
;; "%year" "2019",
;; "%month" "12",
;; "%day" "27",
;; "%time" "1577445288247"},
;; :Replace nil}
;;
;; call the map vesion as follows:

(gen-meta-task {:TaskName "Common-wait" :Replace {"%waittime" 10}})

globals

(globals)

Returns a map with replacements of general intrest.

(globals)
;; {"%hour"  "14",
;; "%minute" "07",
;; "%second" "54",
;; "%year"   "2020",
;; "%month"  "02",
;; "%day"    "02",
;; "%time"   "1580652474824"}

inner-replace-map

(inner-replace-map m task)

Applies the generated function f to the values v of the task map. fs input is v. If m has a key v the value of this key is returned. If m has no key v the v returned. This kind of replacement is used during the runtime.

merge-use-map

(merge-use-map m task)

The use keyword enables a replace mechanism. It works like this: proto-task:

Use: {Values: med_range}
;; should lead to:
task: { Value: rangeX.1}

outer-replace-map

(outer-replace-map m task)

Replaces tokens (given in the m) in the task. This kind of replacement is used during the task build up at the beginning of its life cycle.

Example:

(outer-replace-map (globals) {:TaskName "foo" :Value "%time"})
;; {:TaskName "foo", :Value "1580652820247"}
(outer-replace-map nil {:TaskName "foo" :Value "%time"})
;; {:TaskName "foo", :Value "%time"}

proto-task

(proto-task x)

Returns x if it is not a string.

str->singular-kw

(str->singular-kw s)

Takes a keyword or string and removes the tailing letter (most likely a s). Turns the result to a keyword.

(str->singular-kw :Values)
;; :Value
(str->singular-kw "Values")
;; :Value