From bc6205b3cefb5a0228f7e9a8abf29049237fdf27 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 10 Aug 2026 15:45:16 +0200 Subject: [PATCH] csys/program basic-2 basically working --- csys/program/basic.lisp | 11 +++++++---- scratch.lisp | 4 ++-- test/test-csys.lisp | 11 +++++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/csys/program/basic.lisp b/csys/program/basic.lisp index c1d683f..a824d95 100644 --- a/csys/program/basic.lisp +++ b/csys/program/basic.lisp @@ -5,6 +5,7 @@ (:local-nicknames (:actor :scopes/core/actor) (:csys :scopes/csys) (:environ :scopes/csys/environ) + (:message :scopes/core/message) (:util :scopes/util)) (:export #:prog-b0 #:config-b1 #:config-b2)) @@ -69,9 +70,9 @@ (defun prog-b2 () (let ((val-action (csys:value-add :bias 2))) (csys:make-program - (list '(:c02 :initial) (csys-std-proc :value val-action :next (b2-next-zero)) + (list '(:c02 :initial) (csys:std-proc :value val-action :next (b2-next-zero)) '(:c02 :basic) (csys:std-proc :value val-action :next (b2-next-one)) - '(:e01 :default) (csys:eff-proc) + '(:e02 :default) (csys:eff-proc) ':default (csys:std-proc))))) (defun b2-next-zero () @@ -81,8 +82,7 @@ (csys:send-create self :cat :c02 :loc "0-1" :value 2 :stage :basic) (csys:send-create self :cat :s02 :loc "1-0" :connect :pred) (csys:send-create self :cat :e02 :loc "2-0" :connect :succ) - (environ:send-connect env :to self :target '(:csys :c02 "0-1") - :op (csys:multiply -1)) + ;(environ:send-connect env :to self :target '(:csys :c02 "0-1") :op (csys:multiply -1)) ;; switch :active nil))) @@ -94,6 +94,9 @@ (csys:send-create self :cat :e02 :loc "2-1" :connect :succ) (environ:send-connect env :to self :target '(:csys :c02 "0-0") :op (csys:multiply -1)) + (actor:send env + (message:create '(:csys :connect :c02 "0-0") + :data (list :target '(:csys :c02 "0-1") :op (csys:multiply -1)))) ;; switch :active nil))) diff --git a/scratch.lisp b/scratch.lisp index 3a96078..1c1b0a9 100644 --- a/scratch.lisp +++ b/scratch.lisp @@ -12,9 +12,9 @@ (add-package-local-nickname :environ :scopes/csys/environ) (scopes/util/async:init) -(setf environ:*env* (environ:simple-setup (basic:config-basic-1))) +(setf environ:*env* (environ:simple-setup (basic:config-b2))) -;(environ:send-value '(:s00 "0-1") 2) +;(environ:send-value '(:s02 "1-0") 2) ;;;; iterator experiments - obsolete? diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 0077be5..25250de 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -32,6 +32,7 @@ (config:add :test-receiver :setup #'tc:setup) (config:add-action '(:csys :effect :e00) (value-in '(1 2))) (config:add-action '(:csys :effect :e01) (value-in '(1 2 3 4))) + (config:add-action '(:csys :effect :e02) (value-in '(1 2 3 4))) ;(config:add-action '(:csys :effect) #'tc:check-message) (config:add-action '(:csys) (constantly nil))) @@ -50,6 +51,7 @@ (unwind-protect (test-basic-0) (test-basic-1) + (test-basic-2) (sleep 0.1) (tc:check-expected) (t:show-result)))) @@ -83,3 +85,12 @@ (environ:send-value '(:s01 "0-1") 2) (sleep 0.1) (core:shutdown))) + +(deftest test-basic-2 () + (let ((environ:*env* (setup-test (basic:config-b2)))) + (sleep 0.2) + (environ:send-value '(:s02 "1-0") 1) + (environ:send-value '(:s02 "1-1") 1) ;; 2 => loop + (sleep 0.1) + (core:shutdown))) +