diff --git a/lib/csys/program.ex b/lib/csys/program.ex index 2bbd803..428c1c9 100644 --- a/lib/csys/program.ex +++ b/lib/csys/program.ex @@ -10,26 +10,40 @@ defmodule Scopes.CSys.Program do def basic_prog() do default = &basic_active/2 - %{default: default, - initial: default, + stages = %{ + default: default, + initial: &basic_initial/2, active: default, retired: default } + transitions = %{ + restart: :initial, + retire: :retired, + next: [initial: :active, active: :retired] + } + {stages, transitions} end - # processors + # basic processors + + def basic_initial(msg, scope) do + basic(msg, scope, {:initial, basic_prog()}) + end - def basic_active(msg = {head, _info}, scope) do + def basic_active(msg, scope) do + basic(msg, scope, {:active, basic_prog()}) + end + + def basic(msg = {head, _info}, scope, _meta) do case head do [:csys, :create, :pred | _rest] -> create_pred(scope) [:csys, :create, :succ | _rest] -> create_succ(scope) - #[:csys, :next | _rest] -> CSys.update_neuron({state, &basic_active/2, syns, env}) - #[:csys, :next | _rest] -> next(:active, scope) + #[:csys, :next | _rest] -> next(scope, meta) _ -> forward(msg, scope) || notify(msg, scope) end end - def basic_active(msg, scope) do + def basic(msg, scope, _meta) do forward(msg, scope) || notify(msg, scope) end diff --git a/test/csys_test.exs b/test/csys_test.exs index e20c9bc..527e994 100644 --- a/test/csys_test.exs +++ b/test/csys_test.exs @@ -19,7 +19,8 @@ defmodule Scopes.CSysTest do describe "basic:" do test "minimal-neural-net" do - zero = Environ.setup(Program.basic_prog()[:initial]) + {stages, _trans} = Program.basic_prog() + zero = Environ.setup(stages[:initial]) #Actor.send(zero, "Hello Zero!") CSys.send_value(zero, "Hello Zero!") assert "Hello Zero!" = receive_data().value