work in progress: register and lookup environ cells

This commit is contained in:
Helmut Merz 2026-06-17 19:06:27 +02:00
parent 1ff299bee1
commit c15897aa93
7 changed files with 20 additions and 10 deletions

View file

@ -12,7 +12,7 @@ defmodule Scopes.CSys.Application do
IO.puts("Hello CSys")
Logger.info(Util.show [type, args])
children = [
Scopes.Core.Environ,
{Scopes.Core.Environ, init: []},
Scopes.CSys.Server.Endpoint
]
opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor]

View file

@ -2,6 +2,7 @@ defmodule Scopes.Core.Environ do
@cell_registry __MODULE__.Cells
alias Scopes.Core
alias Scopes.Core.Actor
alias Scopes.Core.Shape
defmodule State do
@ -13,8 +14,13 @@ defmodule Scopes.Core.Environ do
start: {__MODULE__, :start_link, opts}}
end
def start_link() do
def start_link(opts \\ []) do
#IO.inspect(opts)
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
@ -22,9 +28,10 @@ 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"]})
proc = {state, proc, [], env}
Core.create(msg, proc)
scope = {state, proc, [], env}
Core.create(msg, scope)
env
end

View file

@ -1,5 +1,5 @@
defmodule Scopes.CoreActorTest do
use ExUnit.Case, async: true
use ExUnit.Case, async: false
alias Scopes.Core.Actor
describe "actors:" do

View file

@ -17,9 +17,12 @@ defmodule Scopes.CoreTest do
describe "core-basic:" do
test "minimal-b1" do
Environ.start_link()
env = Environ.setup(Program.prepare_basic(), Program.init_seq_b1())
Environ.start_link(
zero_spec: Program.prepare_basic(),
init_seq: Program.init_seq_b1())
#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)

View file

@ -1,5 +1,5 @@
defmodule Scopes.CoreShapeTest do
use ExUnit.Case, async: true
use ExUnit.Case, async: false
alias Scopes.Core.Shape

View file

@ -1,5 +1,5 @@
defmodule Scopes.DemoTest do
use ExUnit.Case, async: true
use ExUnit.Case, async: false
alias Scopes.Demo.Hello
doctest Hello

View file

@ -1,5 +1,5 @@
defmodule Scopes.UtilTest do
use ExUnit.Case, async: true
use ExUnit.Case, async: false
alias Scopes.Util
require Util