From e7b76391c234c85f84604e21e6876e307baef9fa Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 31 Jul 2026 17:50:32 +0200 Subject: [PATCH] add csys/program, move corresponding funtions from test module to program --- csys/program.lisp | 32 ++++++++++++++++++++++++++++++++ scopes-csys.asd | 4 +++- test/test-csys.lisp | 25 ++----------------------- 3 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 csys/program.lisp diff --git a/csys/program.lisp b/csys/program.lisp new file mode 100644 index 0000000..56e0533 --- /dev/null +++ b/csys/program.lisp @@ -0,0 +1,32 @@ +;;;; cl-scopes/csys/program - common and general csys program definitions + +(defpackage :scopes/csys/program + (:use :common-lisp) + (:local-nicknames (:actor :scopes/core/actor) + (:csys :scopes/csys) + (:util :scopes/util)) + (:export #:basic-0)) + +(in-package :scopes/csys/program) + +;;;; basic-0: minimal recursive system + +(defun basic-0 () + (csys:make-program + (list '(:c00 :initial) (csys:std-proc :actions (actions-zero-initial)) + '(:e01 :initial) (csys:eff-proc :actions (csys:basic-actions)) + ':default (csys:std-proc :actions (csys:basic-actions))))) + +(defun actions-zero-initial () + (util:plist-merge (csys:basic-actions) + (list :next (next-zero-initial)))) + +(defun next-zero-initial () + (lambda (msg scope) + (let ((self actor:*self*)) + (csys:send-create self :cat :e01 :connect :succ) + (csys:send-create self :cat :s01 :loc "0-1" :connect :pred) + (csys:send-connect self self :op (csys:multiply -1)) + ;; switch :active + nil))) + diff --git a/scopes-csys.asd b/scopes-csys.asd index f1172df..38cc72d 100644 --- a/scopes-csys.asd +++ b/scopes-csys.asd @@ -10,7 +10,9 @@ :description "Concurrent cybernetic communications systems." :depends-on (:scopes-core) :components ((:file "csys/csys") - (:file "csys/environ" :depends-on ("csys/csys"))) + (:file "csys/environ" :depends-on ("csys/csys")) + (:file "csys/program" :depends-on ("csys/csys" "csys/environ")) + ) :long-description "scopes/csys: Concurrent cybernetic communication systems." :in-order-to ((test-op (test-op "scopes-csys/test")))) diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 94c7b24..cc7d0da 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -11,6 +11,7 @@ (:environ :scopes/csys/environ) (:logging :scopes/logging) (:message :scopes/core/message) + (:program :scopes/csys/program) (:shape :scopes/shape) (:util :scopes/util) (:t :scopes/testing) @@ -60,32 +61,10 @@ (csys:create-zero prg env) env)) -;;;; test-specific programs / actions -;;;; (move to scopes/csys/programs) - -(defun prog-b0 () - (csys:make-program - (list '(:c00 :initial) (csys:std-proc :actions (actions-zero-initial)) - '(:e01 :initial) (csys:eff-proc :actions (csys:basic-actions)) - ':default (csys:std-proc :actions (csys:basic-actions))))) - -(defun actions-zero-initial () - (util:plist-merge (csys:basic-actions) - (list :next (next-zero-initial)))) - -(defun next-zero-initial () - (lambda (msg scope) - (let ((self actor:*self*)) - (csys:send-create self :cat :e01 :connect :succ) - (csys:send-create self :cat :s01 :loc "0-1" :connect :pred) - (csys:send-connect self self :op (csys:multiply -1)) - ;; switch :active - nil))) - ;;;; test definitions (deftest test-basic-0 () - (let ((env (setup-test (prog-b0))) + (let ((env (setup-test (program:basic-0))) (rcvr (tc:receiver t:*test-suite*))) (sleep 0.1) ;(tc:expect rcvr (message:create '(:csys :effect :e01) :data '(:value 1)))