csys/environ: creation of eff contact cells upon env creation
This commit is contained in:
parent
a0e0774a77
commit
8d153001fd
3 changed files with 38 additions and 13 deletions
|
|
@ -17,10 +17,13 @@
|
||||||
(defclass scope (csys:scope)
|
(defclass scope (csys:scope)
|
||||||
((cells :reader cells :initform (make-hash-table :test #'equal))))
|
((cells :reader cells :initform (make-hash-table :test #'equal))))
|
||||||
|
|
||||||
(defun create (proc &optional (meta-env (csys:printer)))
|
(defun create (proc meta-env &key eff-contacts) ; (csys:printer)
|
||||||
;; + create contact cells (<- &key contact-cells)
|
;; + create contact cells (<- &key eff-contacts)
|
||||||
(let ((prg (csys:make-program proc)))
|
(let* ((prg (csys:make-program proc))
|
||||||
(csys:neuron (csys:scope prg meta-env :cls 'scope :categ '(:env :c00)))))
|
(scope (csys:scope prg meta-env :cls 'scope :categ '(:env :c00)))
|
||||||
|
(env (csys:neuron scope)))
|
||||||
|
(create-contact-cells eff-contacts env (cells scope))
|
||||||
|
env))
|
||||||
|
|
||||||
(defun simple-proc (msg scope)
|
(defun simple-proc (msg scope)
|
||||||
(util:mv-bind (nmsg (scope scope))
|
(util:mv-bind (nmsg (scope scope))
|
||||||
|
|
@ -29,6 +32,23 @@
|
||||||
(when nmsg
|
(when nmsg
|
||||||
(actor:send (env scope) nmsg))))
|
(actor:send (env scope) nmsg))))
|
||||||
|
|
||||||
|
;;;; eff contact cells
|
||||||
|
|
||||||
|
(defclass contact-scope (csys:scope)
|
||||||
|
((loc :reader loc :initarg :loc)))
|
||||||
|
|
||||||
|
(defun create-contact-cells (eff-contacts env cells)
|
||||||
|
(util:loop-plist eff-contacts cat loc do
|
||||||
|
(let ((ct (csys:neuron
|
||||||
|
(csys:scope (csys:make-program #'proc-contact) env
|
||||||
|
:cls 'contact-scope
|
||||||
|
:categ (list :env cat) :loc loc))))
|
||||||
|
(register-cell cells (list :env cat loc) ct))))
|
||||||
|
|
||||||
|
(defun proc-contact (msg scope)
|
||||||
|
(setf (nth 3 (shape:head msg)) (loc scope))
|
||||||
|
(actor:send (env scope) msg))
|
||||||
|
|
||||||
;;;; action handlers
|
;;;; action handlers
|
||||||
|
|
||||||
(defun actions ()
|
(defun actions ()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
(:csys :scopes/csys)
|
(:csys :scopes/csys)
|
||||||
(:environ :scopes/csys/environ)
|
(:environ :scopes/csys/environ)
|
||||||
(:util :scopes/util))
|
(:util :scopes/util))
|
||||||
(:export #:basic-0 #:basic-1))
|
(:export #:basic-0 #:config-basic-1))
|
||||||
|
|
||||||
(in-package :scopes/csys/program)
|
(in-package :scopes/csys/program)
|
||||||
|
|
||||||
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
;;;; basic-1: minimal cross-linked system
|
;;;; basic-1: minimal cross-linked system
|
||||||
|
|
||||||
|
(defun config-basic-1 ()
|
||||||
|
(list (basic-1) :zero-cat :s00
|
||||||
|
:eff-contacts '(:e00 ("1-0" "1-1"))))
|
||||||
|
|
||||||
(defun basic-1 ()
|
(defun basic-1 ()
|
||||||
(csys:make-program
|
(csys:make-program
|
||||||
(list '(:s00 :initial) (csys:std-proc :next (b1-next-zero))
|
(list '(:s00 :initial) (csys:std-proc :next (b1-next-zero))
|
||||||
|
|
|
||||||
|
|
@ -54,19 +54,20 @@
|
||||||
(tc:check-expected)
|
(tc:check-expected)
|
||||||
(t:show-result))))
|
(t:show-result))))
|
||||||
|
|
||||||
(defun setup-test (prg &key (zero-cat :c00))
|
(defun setup-test (cfg)
|
||||||
(setup-config)
|
(setup-config)
|
||||||
(core:setup-services)
|
(core:setup-services)
|
||||||
(let* ((rcvr (core:find-service :test-receiver))
|
(destructuring-bind (prg &key (zero-cat :c00) eff-contacts) cfg
|
||||||
(env (environ:create #'proc-env t:*test-suite*)))
|
(let ((rcvr (core:find-service :test-receiver))
|
||||||
(setf (tc:receiver t:*test-suite*) rcvr)
|
(env (environ:create #'proc-env t:*test-suite* :eff-contacts eff-contacts)))
|
||||||
(csys:create-zero prg env :categ (list :csys zero-cat))
|
(setf (tc:receiver t:*test-suite*) rcvr)
|
||||||
env))
|
(csys:create-zero prg env :categ (list :csys zero-cat))
|
||||||
|
env)))
|
||||||
|
|
||||||
;;;; test definitions
|
;;;; test definitions
|
||||||
|
|
||||||
(deftest test-basic-0 ()
|
(deftest test-basic-0 ()
|
||||||
(let ((env (setup-test (program:basic-0))))
|
(let ((env (setup-test (list (program:basic-0)))))
|
||||||
;(rcvr (tc:receiver t:*test-suite*))
|
;(rcvr (tc:receiver t:*test-suite*))
|
||||||
(sleep 0.1)
|
(sleep 0.1)
|
||||||
;(tc:expect rcvr (message:create '(:csys :effect :e01) :data '(:value 1)))
|
;(tc:expect rcvr (message:create '(:csys :effect :e01) :data '(:value 1)))
|
||||||
|
|
@ -76,7 +77,7 @@
|
||||||
(core:shutdown)))
|
(core:shutdown)))
|
||||||
|
|
||||||
(deftest test-basic-1 ()
|
(deftest test-basic-1 ()
|
||||||
(let ((env (setup-test (program:basic-1) :zero-cat :s00)))
|
(let ((env (setup-test (program:config-basic-1))))
|
||||||
(sleep 0.1)
|
(sleep 0.1)
|
||||||
(environ:send-value env 1 :cat :s00 :loc "0-0")
|
(environ:send-value env 1 :cat :s00 :loc "0-0")
|
||||||
(environ:send-value env 2 :cat :s00 :loc "0-1")
|
(environ:send-value env 2 :cat :s00 :loc "0-1")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue