csys/environ, basically working: connect eff cells to contact cells if present

This commit is contained in:
Helmut Merz 2026-08-07 10:36:06 +02:00
parent 8d153001fd
commit cd30c9226e
2 changed files with 17 additions and 11 deletions

View file

@ -116,6 +116,7 @@
(handle-action msg scope :default (no-op) :actions actions) (handle-action msg scope :default (no-op) :actions actions)
(when nmsg (when nmsg
(setf (nth 1 (shape:head nmsg)) :effect) (setf (nth 1 (shape:head nmsg)) :effect)
(forward nmsg (syns nscope))
(notify nmsg nscope)) (notify nmsg nscope))
(update nscope))))) (update nscope)))))
@ -188,6 +189,9 @@
;;;; public shortcuts ;;;; 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) (defun send-create (cell &rest args &key (domain :csys)
(cat :c00) loc connect op &allow-other-keys) (cat :c00) loc connect op &allow-other-keys)
(let ((args+ (if loc (let ((args+ (if loc

View file

@ -17,8 +17,7 @@
(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 meta-env &key eff-contacts) ; (csys:printer) (defun create (proc meta-env &key eff-contacts) ; meta-env example: (csys:printer)
;; + create contact cells (<- &key eff-contacts)
(let* ((prg (csys:make-program proc)) (let* ((prg (csys:make-program proc))
(scope (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))) (env (csys:neuron scope)))
@ -38,16 +37,18 @@
((loc :reader loc :initarg :loc))) ((loc :reader loc :initarg :loc)))
(defun create-contact-cells (eff-contacts env cells) (defun create-contact-cells (eff-contacts env cells)
(util:loop-plist eff-contacts cat loc do (util:loop-plist eff-contacts cat locs do
(let ((ct (csys:neuron (dolist (loc locs)
(csys:scope (csys:make-program #'proc-contact) env (let ((ct (csys:neuron
:cls 'contact-scope (csys:scope (csys:make-program #'proc-contact) env
:categ (list :env cat) :loc loc)))) :cls 'contact-scope
(register-cell cells (list :env cat loc) ct)))) :categ (list :env cat) :loc loc))))
;(util:lgi cells cat loc)
(register-cell cells (list :env cat loc) ct)))))
(defun proc-contact (msg scope) (defun proc-contact (msg scope)
(setf (nth 3 (shape:head msg)) (loc scope)) (setf (nth 3 (shape:head msg)) (loc scope))
(actor:send (env scope) msg)) (actor:send (csys:environ scope) msg))
;;;; action handlers ;;;; action handlers
@ -65,8 +66,9 @@
(new (getf data :new))) (new (getf data :new)))
(when addr (when addr
(register-cell (cells scope) addr new)) (register-cell (cells scope) addr new))
;; check: if corresponding env (contact) cell present? e.g. (:env :e00 "1-0") (let* ((ct-addr (cons :env (cdr addr)))
;; => connect (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) ;(csys:send-message new (list (message:domain msg) :next) :data data)
(actor:send new (actor:send new
(message:create (list (message:domain msg) :next) :data data)) (message:create (list (message:domain msg) :next) :data data))