Compare commits
No commits in common. "c15897aa9349b02684fdf6c82b4222356f569e6e" and "22bf6fdf2cf9b27df5250cf6b5d1f79e4c746478" have entirely different histories.
c15897aa93
...
22bf6fdf2c
8 changed files with 32 additions and 29 deletions
|
|
@ -12,7 +12,7 @@ defmodule Scopes.CSys.Application do
|
|||
IO.puts("Hello CSys")
|
||||
Logger.info(Util.show [type, args])
|
||||
children = [
|
||||
{Scopes.Core.Environ, init: []},
|
||||
Scopes.Core.Environ,
|
||||
Scopes.CSys.Server.Endpoint
|
||||
]
|
||||
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ defmodule Scopes.Core.Environ do
|
|||
@cell_registry __MODULE__.Cells
|
||||
|
||||
alias Scopes.Core
|
||||
alias Scopes.Core.Actor
|
||||
alias Scopes.Core.Shape
|
||||
|
||||
defmodule State do
|
||||
|
|
@ -14,13 +13,8 @@ defmodule Scopes.Core.Environ do
|
|||
start: {__MODULE__, :start_link, opts}}
|
||||
end
|
||||
|
||||
def start_link(opts \\ []) do
|
||||
#IO.inspect(opts)
|
||||
def start_link() do
|
||||
Registry.start_link(keys: :unique, name: @cell_registry)
|
||||
zero_spec = opts[:zero_spec]
|
||||
if zero_spec do
|
||||
setup(zero_spec, opts[:init_seq] || [])
|
||||
end
|
||||
end
|
||||
|
||||
def cells(), do: @cell_registry
|
||||
|
|
@ -28,10 +22,9 @@ defmodule Scopes.Core.Environ do
|
|||
def setup({state, proc}, init_seq, proc_env \\ &proc_env/2) do
|
||||
env_scope = {%State{init_seq: init_seq}, proc_env, [], self()}
|
||||
env = Core.neuron(env_scope)
|
||||
Actor.register(env, cells(), {:env, :c00})
|
||||
msg = Shape.create([:csys, :zero], data: %{addr: [:csys, :c00, "0-0"]})
|
||||
scope = {state, proc, [], env}
|
||||
Core.create(msg, scope)
|
||||
proc = {state, proc, [], env}
|
||||
Core.create(msg, proc)
|
||||
env
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ defmodule Scopes.Core.Program do
|
|||
[:csys, :data | _rest] -> process_basic(msg, scope, args)
|
||||
#[:csys, :trigger | _rest] -> process_trigger(msg, scope)
|
||||
[:csys, :connect | _rest] -> Core.connect(msg, scope)
|
||||
[:csys, :create, :succ | _rest] -> create_succ(msg, scope)
|
||||
[:csys, :create, :pred | _rest] -> create_pred(msg, scope)
|
||||
[:csys, :create | _rest] -> create(msg, scope)
|
||||
#[:csys, :next | _rest] -> next(msg, scope)
|
||||
_ -> Core.forward(msg, scope) || Core.notify(msg, scope)
|
||||
|
|
@ -90,6 +92,18 @@ defmodule Scopes.Core.Program do
|
|||
end
|
||||
end
|
||||
|
||||
def create_succ(msg, scope) do
|
||||
new = Core.create(msg, restart(scope))
|
||||
data = Shape.data(msg)
|
||||
Core.send_message(self(), ~w(csys connect)a, Map.put(data, :target, new))
|
||||
end
|
||||
|
||||
def create_pred(msg, scope) do
|
||||
new = Core.create(msg, restart(scope))
|
||||
data = Shape.data(msg)
|
||||
Core.send_message(new, ~w(csys connect)a, Map.put(data, :target, self()))
|
||||
end
|
||||
|
||||
def create(msg, scope) do
|
||||
new = Core.create(msg, restart(scope))
|
||||
data = Shape.data(msg)
|
||||
|
|
@ -126,12 +140,11 @@ defmodule Scopes.Core.Program do
|
|||
two = [:csys, :c00, "1-1"]
|
||||
three = [:csys, :s01, "1-1"]
|
||||
[
|
||||
&Environ.send_message(&1, zero, ~w(csys create)a,
|
||||
%{op: [Core.data_only(), negate()], addr: one, dir: :pred}),
|
||||
&Environ.send_message(&1, one, ~w(csys create)a,
|
||||
%{op: Core.data_only(), addr: two, dir: :succ}),
|
||||
&Environ.send_message(&1, two, ~w(csys create)a,
|
||||
%{addr: three, dir: :pred}),
|
||||
&Environ.send_message(&1, zero, ~w(csys create pred)a,
|
||||
%{op: [Core.data_only(), negate()], addr: one}),
|
||||
&Environ.send_message(&1, one, ~w(csys create succ)a,
|
||||
%{op: Core.data_only(), addr: two}),
|
||||
&Environ.send_message(&1, two, ~w(csys create pred)a, %{addr: three}),
|
||||
&Environ.connect(&1, three, zero)
|
||||
]
|
||||
end
|
||||
|
|
@ -139,9 +152,9 @@ defmodule Scopes.Core.Program do
|
|||
def init_recursive_1() do
|
||||
zero = [:csys, :c00, "0-0"]
|
||||
[
|
||||
&Environ.send_message(&1, zero, ~w(csys create)a, %{dir: :succ}),
|
||||
&Environ.send_message(&1, zero, ~w(csys create)a,
|
||||
%{addr: [:csys, :s01, "1-1"], dir: :pred}),
|
||||
&Environ.send_message(&1, zero, ~w(csys create succ)a, %{}),
|
||||
&Environ.send_message(&1, zero, ~w(csys create pred)a,
|
||||
%{addr: [:csys, :s01, "1-1"]}),
|
||||
&Environ.connect(&1, zero, zero, negate())
|
||||
]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Scopes.CoreActorTest do
|
||||
use ExUnit.Case, async: false
|
||||
use ExUnit.Case, async: true
|
||||
alias Scopes.Core.Actor
|
||||
|
||||
describe "actors:" do
|
||||
|
|
|
|||
|
|
@ -17,12 +17,9 @@ defmodule Scopes.CoreTest do
|
|||
|
||||
describe "core-basic:" do
|
||||
test "minimal-b1" do
|
||||
Environ.start_link(
|
||||
zero_spec: Program.prepare_basic(),
|
||||
init_seq: Program.init_seq_b1())
|
||||
#env = Environ.setup(Program.prepare_basic(), Program.init_seq_b1())
|
||||
Environ.start_link()
|
||||
env = Environ.setup(Program.prepare_basic(), Program.init_seq_b1())
|
||||
Process.sleep(50)
|
||||
[{env, _val}] = Registry.lookup(Environ.cells(), {:env, :c00})
|
||||
Environ.forward_value(env, [:csys, :c00, "0-0"], 0)
|
||||
assert 0 = receive_data().value
|
||||
Environ.forward_value(env, [:csys, :s01, "1-0"], 1)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Scopes.CoreShapeTest do
|
||||
use ExUnit.Case, async: false
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias Scopes.Core.Shape
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Scopes.DemoTest do
|
||||
use ExUnit.Case, async: false
|
||||
use ExUnit.Case, async: true
|
||||
alias Scopes.Demo.Hello
|
||||
doctest Hello
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Scopes.UtilTest do
|
||||
use ExUnit.Case, async: false
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
alias Scopes.Util
|
||||
require Util
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue