cmp.worker.select

class-key->cond-keys

(class-key->cond-keys k)

Turns a class-key into cond-keys.

class-keys

(class-keys mp-id cls)

Returns the keys where the class is cls.

cond-key->cond-map

(cond-key->cond-map k)

Builds a condition-map belonging to the key k. Replaces the compare value fetched from the exchange interface by means of the exch/read!-function.

Example:

(cond-key->cond-map "ref@definitions@1@cond@0")
;; {:mp-name "ref",
;;  :struct "definitions",
;;  :no-idx 1,
;;  :no-jdy 0,
;;  :comp-value "Pa",
;;  :meth "eq",
;;  :exch-value "Pa"}

;; where:

(st/key->val "ref@definitions@1@cond@0")
;;{:ExchangePath "A.Unit", :Methode "eq", :Value "Pa"}

;; and:

(st/key->val "ref@exchange@A")
;; {:Unit "Pa", :Value 100}

cond-match?

(cond-match? l m r)

Tests a single condition of the form defined in the definitions section.

Example:

(cond-match? 10 :gt 1)
;; true

conds-match?

(conds-match? v)

Checks if :cond-match in every map in the condition-vector v is true.

filter-match

(filter-match v)

Checks if :cond-match in every map in the condition-vector v is true.

gen-callback

(gen-callback {mp-id :mp-id, no-idx :no-idx, state-key :StateKey})

select-definition!

(select-definition! {mp-id :MpName, cls :DefinitionClass, state-key :StateKey})

Selects and runs a Definition from the Definitions section of the current mp. Builds a condition-map (analog to the state-map) in order to avoid the spreading of side effects and easy testing.

Example:

(ns cmp.worker.select)
(select-definition! {:MpName ref
                     :Action select
                     :TaskName Common-select_definition,
                     :DefinitionClass wait} )
;; match map:
{:mp-id ref,
:struct definitions
:no-idx 1,
:func cond
:seq-idx 1,
:par-idx nil,
:cond-match true}

If more than one than one of the definitions condition match the first is used:

(first (filter conds-match? match-ks))
;; ref@definitions@1@class

start-defins!

(start-defins! {mp-id :mp-id, no-idx :no-idx, state-key :StateKey, :as task})

Starts the matching definitions structure. registers a level b callback. Sets the state of the calling element to executed if the ctrl turns to ready (or error if error).