cmp

0.13.0


A study of an interpreter for measurement program definitions (mpd) written in clojure.

dependencies

org.clojure/clojure
1.10.1
com.taoensso/carmine
3.0.0
com.ashafa/clutch
0.4.0
clj-time
0.15.0
org.clojure/data.json
0.2.6
com.taoensso/timbre
5.0.0
clj-http
3.10.0
clojang/codox-theme
0.2.0-SNAPSHOT



(this space intentionally left almost blank)
 

Reference measurement program definition

{:_id "mpd-ref",
 :_rev "6-b4475e103286fba67eb4ad849270841d",
 :Mp
 {
  :Date [{:Type "created", :Value "2020-01-11"}],
  :Name "wait",
  :Description "Simple measurement programm definition (mpd) which serves as a reference for documentation  and testing.",
  :Standard "NN"
  ;; Endpoint for exchanging data and information.
  ;; Internal and external use is intendet. 
  :Exchange {
             ;; one level deep nested values ..
             :A {:Type "ref" :Unit "Pa", :Value 100.0 }
             ;; .. or flat values are valid
             :B "token"
             ;; 
             :Target_pressure {:Selected 1 :Unit "Pa"}
             }
  ;; -------------------------------------------------------
  ;; container section
  ;; -------------------------------------------------------
  :Container
  [
   ;; Containers are fixed sequences of things to do. 
   ;; In opposit to definitions containers have no conditions structure.
   ;; First container:
   {:Description "Container just waits parallel and sequential.",
    ;; The ctrl endpoint of the first container.
    ;; All values are ok. The values start, stop and mon will start stop and mon.
    ;; mon ... relaunch the container if all tasks are executed
    ;; void ... just some value (as good as foo or bar), causes no action.
    :Ctrl "void",
    :Title "multiple wait tasks",
    ;; Element is inteded for filtering the exchange interface:
    ;; which elements should be vissible at a gui of this
    ;; container
    :Element ["A"],
    ;; The defilition of what schould happen after what.
    ;; The "array of arrays"-structure controlls what happens 
    ;; parallel and what sequential.
    :Definition
    [;; First: start a wait task with 3000 ms waittime.
     ;; At the same time start a wait task with 3000 ms waittime.
     [{:TaskName "Common-wait", :Replace {:%waittime 3000}}
      {:TaskName "Common-wait", :Replace {:%waittime 4000}}]
     ;; After first step is executed: start 4 wait tasks 
     ;; with 3000 ms waittime, step is executed within 3000ms
     [{:TaskName "Common-wait", :Replace {:%waittime 3000}}
      {:TaskName "Common-wait", :Replace {:%waittime 3000}}
      {:TaskName "Common-wait", :Replace {:%waittime 3000}}
      {:TaskName "Common-wait", :Replace {:%waittime 3000}}]
     ;; After the second step is executed: wait 1000ms
     [{:TaskName "Common-wait", :Replace {:%waittime 1000}}]]}
   ;; second container
   {:Description "Container with one task only",
    :Ctrl "void",
    :Title "container with single task",
    :Element ["*"],
    :Definition
    [[{:TaskName "Common-wait", :Replace {:%waittime 1000}}]]}
   ;; third container
   {:Description "Show case select feature",
    :Ctrl "void",
    :Title "choose definition, run it",
    :Element ["*"],
    :Definition
    [[{:TaskName "Common-select_definition",
       :Replace {:%definitionclass "wait"}}]]}
   ;; fourth container
   {:Description "Run a mpd (first container of ref).",
    :Ctrl "void",
    :Title "run 1st container",
    :Element ["*"],
    :Definition
    [[{:TaskName "Common-run_mp",
       :Replace {:%conttitle "multiple wait tasks"
                 :%mpdef "ref" }}]]}
   {:Description "Test modbus action with prescript (get)"
    :Ctrl "void"
    :Title "modbus get test"
    :Element ["*"]
    :Definition [
                 [{:TaskName "VS_NEW_SE3-get_valve_pos",
                   :Replace {:%valve "V1"}}]
                 [{:TaskName "VS_NEW_SE3-get_valve_pos",
                   :Replace {:%valve "V2"}}]]
    }
   {:Description "Test modbus action with prescript (set)"
    :Ctrl "void"
    :Title "modbus set test"
    :Element ["*"]
    :Definition [
                 [{:TaskName "VS_NEW_SE3-set_valve_pos",
                   :Replace {:%valve "V1",
                             :%should "close"}}]
                 [{:TaskName "Common-wait"
                   :Replace {:%waittime 3000}}]
                 [{:TaskName "VS_NEW_SE3-set_valve_pos",
                   :Replace {:%valve "V1",
                             :%should "open"}}]]
    }
    {:Description "Test TCP action."
    :Ctrl "void"
    :Title "TCP test with result set."
    :Element ["*"]
    :Definition [
                 [{:TaskName "MKS_SRG_3-read_out",
                   :Replace {:%docpath "Calibration.Measurement.Values.Pressure"}}]
                 ]}
   {:Description "Test read_exchange action."
    :Ctrl "void"
    :Title "read exchange."
    :Element ["*"]
    :Definition [
                 [{:TaskName "Common-simple_read_element"
                   :Replace {:%docpath "Measurement.Values.Pressure"
                             :%exchpath "A"}}]
                 ]}
   {:Description "Test anselm request."
    :Ctrl "void"
    :Title "anselm."
    :Element ["*"]
    :Definition [
                 [{:TaskName "Common-anselm_get_dut_max"}]
                 ]}
   {:Description "Test date and time and the ability to parallel write to database docs."
    :Ctrl "void"
    :Title "date & time"
    :Element ["*"]
    :Definition [
                 [{:TaskName "Common-get_date"
                   :Replace {:%docpath "Calibration.Measurement.Date"
                             :%type "cmp-test"}}
                  {:TaskName "Common-get_time"
                   :Replace {:%docpath "Calibration.Measurement.AuxValues.Time"
                             :%type "cmp-test"}}]
                 ]}
   {:Description "Message test."
    :Ctrl "void"
    :Title "message"
    :Element ["*"]
    :Definition [
                 [{:TaskName "Common-message"
                   :Replace {:%message "cmp?"}}]
                 ]}]
  ;; -------------------------------------------------------
  ;; Definitions section
  ;; -------------------------------------------------------
  :Definitions
  [;; Several definitions with the same
   ;; class (here wait) are possible.
   ;; At Runtime: the first of all matching 
   ;; (see condition section) definition is started
   {:DefinitionClass "wait",
    :ShortDescr "waits 1 and 2s\n",
    ;; condition for the
    ;; the exec. of the first
    ;; definition for the class wait
    :Condition
    [{:ExchangePath "A.Unit", :Methode "eq", :Value "Pa"}
     {:ExchangePath "A.Value", :Methode "gt", :Value 133}],
    :Definition
    [[{:TaskName "Common-wait", :Replace {:%waittime 1000}}
      {:TaskName "Common-wait", :Replace {:%waittime 2000}}]]}
   {:DefinitionClass "wait",
    :ShortDescr "waits 3 and 4s\n",
    ;; condition for the
    ;; the exec. of the second
    ;; definition for the class wait
    :Condition
    [{:ExchangePath "A.Unit", :Methode "eq", :Value "Pa"}
     {:ExchangePath "A.Value", :Methode "lt", :Value 133}],
    ;; The definition structure under definitions section 
    ;; works the same as under container
    :Definition
    [[{:TaskName "Common-wait", :Replace {:%waittime 3000}}
      {:TaskName "Common-wait", :Replace {:%waittime 4000}}]]}
   {:DefinitionClass "wait",
    :ShortDescr "waits 4 and 5s\n",
    :Condition
    [{:ExchangePath "A.Unit", :Methode "eq", :Value "Pa"}
     {:ExchangePath "A.Value", :Methode "lt", :Value 13}],
    :Definition
    [[{:TaskName "Common-wait", :Replace {:%waittime 4000}}
      {:TaskName "Common-wait", :Replace {:%waittime 5000}}]]}],
}}