csys: first running neuron example with two sensors (just logging)
This commit is contained in:
parent
3ccf33393e
commit
2f5a3b1d74
2 changed files with 17 additions and 11 deletions
|
@ -10,16 +10,18 @@
|
|||
(:shape :scopes/shape)
|
||||
(:util :scopes/util)
|
||||
(:alx :alexandria))
|
||||
(:export #:printer #:send
|
||||
#:*sensors*))
|
||||
(:export #:send #:*sensors* #:neuron
|
||||
#:nprint))
|
||||
|
||||
(in-package :scopes/csys)
|
||||
|
||||
(defvar *sensors* (make-hash-table :test #'equal))
|
||||
|
||||
(defun send (msg)
|
||||
(dolist (sn (find-create-sensors msg))
|
||||
(actor:send sn msg)))
|
||||
(if (eq (shape:head-value msg :domain) :csys)
|
||||
(dolist (sn (find-create-sensors msg))
|
||||
(actor:send sn msg))
|
||||
(core:handle-message core:*root* msg)))
|
||||
|
||||
(defun find-create-sensors (msg)
|
||||
(let* ((key (cddr (shape:head msg)))
|
||||
|
@ -34,9 +36,13 @@
|
|||
(setf (gethash key *sensors*) tsks))
|
||||
(util:lgw "no action selected" msg))))))
|
||||
|
||||
;;;; example behaviors / actions
|
||||
;;;; neurons (= behavior generators)
|
||||
|
||||
(defun printer (msg)
|
||||
(util:lgi msg)
|
||||
;(format t "~&~a" msg)
|
||||
)
|
||||
(defun neuron (proc &optional state syns env)
|
||||
(lambda (msg) (funcall proc msg state syns env)))
|
||||
|
||||
;;;; predefined neuron processors
|
||||
|
||||
(defun nprint (msg state syns env)
|
||||
(util:lgi msg state)
|
||||
(actor:become (neuron #'nprint (shape:data msg) syns env)))
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
(config:root)
|
||||
|
||||
(config:add-action '(:csys :sensor :log) #'csys:printer)
|
||||
;(config:add-action '(:test) #'csys:printer)
|
||||
(config:add-action '(:csys :sensor :log)
|
||||
(csys:neuron #'csys:nprint :testing))
|
||||
|
||||
(config:add :logger :class 'logging:config
|
||||
:loglevel (config:from-env :loglevel :info)
|
||||
|
|
Loading…
Add table
Reference in a new issue