diff --git a/csys/csys.lisp b/csys/csys.lisp index a8ea3bf..8d5328c 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -62,19 +62,26 @@ (defun update (scope) (actor:become (process scope))) +(defun create (prg env &key (categ '(:csys :c00)) name value) + (let* ((domain (car categ)) + (addr (when name (list domain (cadr categ) name))) + (scope (scope prg env :categ categ)) + (msg (message:create (list domain :create) + :data (when addr (list :addr addr))))) + (do-create msg scope))) + ;;;; message handlers, proc steps (defun process (scope) (lambda (msg) (funcall (proc scope) msg scope))) (defun std-proc (msg scope) - ;(util:lgi msg state syns env) (destructuring-bind (nmsg nscope) (handle-action msg scope :default #'remember) ; + params, actions (forward nmsg (syns nscope)) (update nscope))) -(defun create (msg scope) +(defun do-create (msg scope) (let ((new (neuron (apply #'reset-scope scope (shape:data msg))))) (notify-created msg new scope))) diff --git a/csys/environ.lisp b/csys/environ.lisp index 93bde02..09b1ed5 100644 --- a/csys/environ.lisp +++ b/csys/environ.lisp @@ -16,9 +16,9 @@ (defclass scope (csys:scope) ((cells :reader cells :initform (make-hash-table :test #'equal)))) -(defun create (proc app) - (let ((prog (csys:make-program proc))) - (csys:neuron (csys:scope prog app :cls 'scope :categ '(:env :c00))))) +(defun create (proc meta-env) + (let ((prg (csys:make-program proc))) + (csys:neuron (csys:scope prg meta-env :cls 'scope :categ '(:env :c00))))) ;;;; action handlers, public callables diff --git a/test/test-csys.lisp b/test/test-csys.lisp index da61202..c7b2c1f 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -55,14 +55,13 @@ (defun setup-test-basic-0 () (setup-config) (core:setup-services) - (setf (tc:receiver t:*test-suite*) (core:find-service :test-receiver)) - ;(csys:add-action '(:csys :sensor) #'csys:create-sensor) - (let* ((env (environ:create #'proc-env (tc:receiver t:*test-suite*))) + (let* ((app (core:find-service :test-receiver)) + (env (environ:create #'proc-env app)) (msg (message:create '(:csys :create) :data `(:addr (:csys :c00 "0-0") - :categ :c00 :environ ,env)))) - ;(csys:create) ; or: (environ:setup program:basic-0 #'proc-env) + (setf (tc:receiver t:*test-suite*) app) + ;(csys:create-zero (test-program) env) )) (deftest test-basic-0 ()