csys: clean-up, renamings, message format: list as message head

This commit is contained in:
Helmut Merz 2026-05-06 19:47:46 +02:00
parent f000cd2526
commit 2fa57ee8fb
2 changed files with 9 additions and 17 deletions

View file

@ -9,32 +9,24 @@ defmodule Scopes.CSys.Program do
# programs
def basic_prog() do
%{default: &std_proc/2
#initial: &std_proc/1,
#active: &std_proc/1,
#retired: &std_proc/1
%{default: &basic_active/2,
initial: &basic_active/2,
active: &basic_active/2,
retired: &basic_active/2
}
end
# processors
def std_proc(msg, scope) do
def basic_active(msg, scope) do
#scope = Process.get(:scope)
case msg do
{:create, :parent} -> create_parent(scope)
{:create, :child} -> create_child(scope)
[:csys, :create, :parent | _rest] -> create_parent(scope)
[:csys, :create, :child | _rest] -> create_child(scope)
_ -> forward(msg, scope) || notify(msg, scope)
end
end
#def std_proc({:activate}, {state, _proc, syns, env) do
def xx_std_proc({:next}, {state, _proc, syns, env}) do
#proc = Environ.get_next_stage(env, :basic, :initial)
#proc = Environ.get_stage_for(env, :basic, :activate)
proc = Environ.get_stage(env, :basic, :active)
update_neuron({state, proc, syns, env})
end
# processor steps
def notify(msg, scope) do

View file

@ -15,9 +15,9 @@ defmodule Scopes.CSysTest do
zero = CSys.neuron({[], proc, [], env})
Actor.send(zero, "Hello Zero!")
assert_receive "Hello Zero!"
Actor.send(zero, {:create, :parent})
Actor.send(zero, [:csys, :create, :parent])
assert_receive {:created, new1}
Actor.send(new1, {:create, :child})
Actor.send(new1, [:csys, :create, :child])
assert_receive {:created, _new2}
Actor.send(new1, "Hello New1!")
assert_receive "Hello New1!"