diff --git a/csys/csys.lisp b/csys/csys.lisp index 5f07445..94b13fd 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -116,6 +116,7 @@ (handle-action msg scope :default (no-op) :actions actions) (when nmsg (setf (nth 1 (shape:head nmsg)) :effect) + (forward nmsg (syns nscope)) (notify nmsg nscope)) (update nscope))))) @@ -188,6 +189,9 @@ ;;;; public shortcuts +(defun send-message (cell head data) + (actor:send cell (message:create head :data data))) + (defun send-create (cell &rest args &key (domain :csys) (cat :c00) loc connect op &allow-other-keys) (let ((args+ (if loc diff --git a/csys/environ.lisp b/csys/environ.lisp index b06c41e..3ede415 100644 --- a/csys/environ.lisp +++ b/csys/environ.lisp @@ -17,8 +17,7 @@ (defclass scope (csys:scope) ((cells :reader cells :initform (make-hash-table :test #'equal)))) -(defun create (proc meta-env &key eff-contacts) ; (csys:printer) - ;; + create contact cells (<- &key eff-contacts) +(defun create (proc meta-env &key eff-contacts) ; meta-env example: (csys:printer) (let* ((prg (csys:make-program proc)) (scope (csys:scope prg meta-env :cls 'scope :categ '(:env :c00))) (env (csys:neuron scope))) @@ -38,16 +37,18 @@ ((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)))) + (util:loop-plist eff-contacts cat locs do + (dolist (loc locs) + (let ((ct (csys:neuron + (csys:scope (csys:make-program #'proc-contact) env + :cls 'contact-scope + :categ (list :env cat) :loc loc)))) + ;(util:lgi cells cat 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)) + (actor:send (csys:environ scope) msg)) ;;;; action handlers @@ -65,8 +66,9 @@ (new (getf data :new))) (when addr (register-cell (cells scope) addr new)) - ;; check: if corresponding env (contact) cell present? e.g. (:env :e00 "1-0") - ;; => connect + (let* ((ct-addr (cons :env (cdr addr))) + (ct (find-cell (cells scope) ct-addr))) + (when ct (csys:send-connect new ct))) ;(csys:send-message new (list (message:domain msg) :next) :data data) (actor:send new (message:create (list (message:domain msg) :next) :data data))