work in progress: register and lookup environ cells
This commit is contained in:
parent
1ff299bee1
commit
c15897aa93
7 changed files with 20 additions and 10 deletions
|
|
@ -12,7 +12,7 @@ defmodule Scopes.CSys.Application do
|
||||||
IO.puts("Hello CSys")
|
IO.puts("Hello CSys")
|
||||||
Logger.info(Util.show [type, args])
|
Logger.info(Util.show [type, args])
|
||||||
children = [
|
children = [
|
||||||
Scopes.Core.Environ,
|
{Scopes.Core.Environ, init: []},
|
||||||
Scopes.CSys.Server.Endpoint
|
Scopes.CSys.Server.Endpoint
|
||||||
]
|
]
|
||||||
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]
|
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ defmodule Scopes.Core.Environ do
|
||||||
@cell_registry __MODULE__.Cells
|
@cell_registry __MODULE__.Cells
|
||||||
|
|
||||||
alias Scopes.Core
|
alias Scopes.Core
|
||||||
|
alias Scopes.Core.Actor
|
||||||
alias Scopes.Core.Shape
|
alias Scopes.Core.Shape
|
||||||
|
|
||||||
defmodule State do
|
defmodule State do
|
||||||
|
|
@ -13,8 +14,13 @@ defmodule Scopes.Core.Environ do
|
||||||
start: {__MODULE__, :start_link, opts}}
|
start: {__MODULE__, :start_link, opts}}
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_link() do
|
def start_link(opts \\ []) do
|
||||||
|
#IO.inspect(opts)
|
||||||
Registry.start_link(keys: :unique, name: @cell_registry)
|
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
|
end
|
||||||
|
|
||||||
def cells(), do: @cell_registry
|
def cells(), do: @cell_registry
|
||||||
|
|
@ -22,9 +28,10 @@ defmodule Scopes.Core.Environ do
|
||||||
def setup({state, proc}, init_seq, proc_env \\ &proc_env/2) do
|
def setup({state, proc}, init_seq, proc_env \\ &proc_env/2) do
|
||||||
env_scope = {%State{init_seq: init_seq}, proc_env, [], self()}
|
env_scope = {%State{init_seq: init_seq}, proc_env, [], self()}
|
||||||
env = Core.neuron(env_scope)
|
env = Core.neuron(env_scope)
|
||||||
|
Actor.register(env, cells(), {:env, :c00})
|
||||||
msg = Shape.create([:csys, :zero], data: %{addr: [:csys, :c00, "0-0"]})
|
msg = Shape.create([:csys, :zero], data: %{addr: [:csys, :c00, "0-0"]})
|
||||||
proc = {state, proc, [], env}
|
scope = {state, proc, [], env}
|
||||||
Core.create(msg, proc)
|
Core.create(msg, scope)
|
||||||
env
|
env
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Scopes.CoreActorTest do
|
defmodule Scopes.CoreActorTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
alias Scopes.Core.Actor
|
alias Scopes.Core.Actor
|
||||||
|
|
||||||
describe "actors:" do
|
describe "actors:" do
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,12 @@ defmodule Scopes.CoreTest do
|
||||||
|
|
||||||
describe "core-basic:" do
|
describe "core-basic:" do
|
||||||
test "minimal-b1" do
|
test "minimal-b1" do
|
||||||
Environ.start_link()
|
Environ.start_link(
|
||||||
env = Environ.setup(Program.prepare_basic(), Program.init_seq_b1())
|
zero_spec: Program.prepare_basic(),
|
||||||
|
init_seq: Program.init_seq_b1())
|
||||||
|
#env = Environ.setup(Program.prepare_basic(), Program.init_seq_b1())
|
||||||
Process.sleep(50)
|
Process.sleep(50)
|
||||||
|
[{env, _val}] = Registry.lookup(Environ.cells(), {:env, :c00})
|
||||||
Environ.forward_value(env, [:csys, :c00, "0-0"], 0)
|
Environ.forward_value(env, [:csys, :c00, "0-0"], 0)
|
||||||
assert 0 = receive_data().value
|
assert 0 = receive_data().value
|
||||||
Environ.forward_value(env, [:csys, :s01, "1-0"], 1)
|
Environ.forward_value(env, [:csys, :s01, "1-0"], 1)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Scopes.CoreShapeTest do
|
defmodule Scopes.CoreShapeTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
|
|
||||||
alias Scopes.Core.Shape
|
alias Scopes.Core.Shape
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Scopes.DemoTest do
|
defmodule Scopes.DemoTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
alias Scopes.Demo.Hello
|
alias Scopes.Demo.Hello
|
||||||
doctest Hello
|
doctest Hello
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Scopes.UtilTest do
|
defmodule Scopes.UtilTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
|
|
||||||
alias Scopes.Util
|
alias Scopes.Util
|
||||||
require Util
|
require Util
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue