diff --git a/lib/csys/csys.ex b/lib/csys/csys.ex index d6ed946..d59c9b4 100644 --- a/lib/csys/csys.ex +++ b/lib/csys/csys.ex @@ -19,7 +19,8 @@ defmodule Scopes.CSys do # helper functions defp process(msg, scope) do - proc(scope).(msg, scope) + Process.put(:scope, scope) + proc(scope).(msg) end def state(scope), do: elem(scope, 0) diff --git a/lib/csys/program.ex b/lib/csys/program.ex index c8d3138..b7a715d 100644 --- a/lib/csys/program.ex +++ b/lib/csys/program.ex @@ -9,28 +9,34 @@ defmodule Scopes.CSys.Program do # programs def basic_prog() do - %{initial: &std_proc/2, - active: &std_proc/2, - retired: &std_proc/2 + %{initial: &std_proc/1, + active: &std_proc/1, + retired: &std_proc/1 } end # processors - def std_proc({:parent}, scope) do - new = create_parent(env(scope)) - notify({:created, new}, scope) + #def std_proc({:parent}, scope) do + def std_proc(msg) do + scope = Process.get(:scope) + case msg do + {:parent} -> + new = create_parent(scope) + notify({:created, new}, scope) + _ -> forward(msg, scope) || notify(msg, scope) + end end #def std_proc({:activate}, {state, _proc, syns, env) do - def std_proc({:next}, {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 - def std_proc(msg, scope) do + def xx_std_proc(msg, scope) do forward(msg, scope) || notify(msg, scope) end @@ -46,8 +52,9 @@ defmodule Scopes.CSys.Program do # step functions - def create_parent(env) do + def create_parent({_state, procs, _syns, env}) do syn = synapse(self(), &Function.identity/1, 0) - neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env}) + #neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env}) + neuron({[], procs, [syn], env}) end end