csys: program as combination of stages and transitions; common proc for different stages
This commit is contained in:
parent
a7af69381b
commit
d13962c02b
2 changed files with 23 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue