From 3aafb36bd34b0c39469009505f8a45d776519cf8 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Wed, 17 Jun 2026 10:54:14 +0200 Subject: [PATCH] starting with Environ cell registry --- apps/csys/lib/application.ex | 6 ++---- apps/csys/lib/server/endpoint.ex | 7 ------- lib/application.ex | 4 ++-- lib/core/environ.ex | 12 ++++++++++++ test/core/core_test.exs | 2 ++ 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/csys/lib/application.ex b/apps/csys/lib/application.ex index f00e008..f45fc5a 100644 --- a/apps/csys/lib/application.ex +++ b/apps/csys/lib/application.ex @@ -11,11 +11,9 @@ defmodule Scopes.CSys.Application do def start(type, args) do IO.puts("Hello CSys") Logger.info(Util.show [type, args]) - # input_neurons = Environ.create_input - IO.inspect Scopes.CSys.Server.Endpoint.child_spec(input: %{[:csys, :s01] => "dummy"}) children = [ - #Scopes.CSys.Server.Endpoint - {Scopes.CSys.Server.Endpoint, input: %{[:csys, :s01] => "dummy"}} + Scopes.Core.Environ, + Scopes.CSys.Server.Endpoint ] opts = [strategy: :one_for_one, name: Scopes.CSys.Supervisor] Supervisor.start_link(children, opts) diff --git a/apps/csys/lib/server/endpoint.ex b/apps/csys/lib/server/endpoint.ex index adbc505..60ad655 100644 --- a/apps/csys/lib/server/endpoint.ex +++ b/apps/csys/lib/server/endpoint.ex @@ -1,12 +1,6 @@ defmodule Scopes.CSys.Server.Endpoint do use Phoenix.Endpoint, otp_app: :scopes_csys - def init(arg) do - IO.inspect(arg) - IO.inspect(Process.get()) - :ignore - end - plug Plug.Static, at: "/", from: :scopes_csys, @@ -22,5 +16,4 @@ defmodule Scopes.CSys.Server.Endpoint do json_decoder: Phoenix.json_library() plug Scopes.CSys.Server.Router - #input_neurons: @input end diff --git a/lib/application.ex b/lib/application.ex index 30d02c6..bd3bceb 100644 --- a/lib/application.ex +++ b/lib/application.ex @@ -12,7 +12,7 @@ defmodule Scopes.Application do @impl true def start(type, args) do - IO.puts("Hello World") + IO.puts("Hello Scopes!") Logger.info(Util.show [type, args]) children = [ #Scopes.Web.Server.Telemetry, @@ -28,7 +28,7 @@ defmodule Scopes.Application do # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options - opts = [strategy: :one_for_one, name: ScopesApi.Supervisor] + opts = [strategy: :one_for_one, name: Scopes.Supervisor] Supervisor.start_link(children, opts) end diff --git a/lib/core/environ.ex b/lib/core/environ.ex index fde85a6..1ecc6e9 100644 --- a/lib/core/environ.ex +++ b/lib/core/environ.ex @@ -1,4 +1,5 @@ defmodule Scopes.Core.Environ do + @cell_registry __MODULE__.Cells alias Scopes.Core alias Scopes.Core.Shape @@ -7,6 +8,17 @@ defmodule Scopes.Core.Environ do defstruct [cells: %{}, init_seq: []] end + def child_spec(opts) do + %{id: __MODULE__, + start: {__MODULE__, :start_link, opts}} + end + + def start_link() do + Registry.start_link(keys: :unique, name: @cell_registry) + end + + def cells(), do: @cell_registry + 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) diff --git a/test/core/core_test.exs b/test/core/core_test.exs index f8238d1..e8a27a2 100644 --- a/test/core/core_test.exs +++ b/test/core/core_test.exs @@ -17,6 +17,7 @@ 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()) Process.sleep(50) Environ.forward_value(env, [:csys, :c00, "0-0"], 0) @@ -31,6 +32,7 @@ defmodule Scopes.CoreTest do end test "recursive-1" do + Environ.start_link() env = Environ.setup(Program.prepare_basic(), Program.init_recursive_1()) Process.sleep(50) Environ.forward_value(env, [:csys, :s01, "1-1"], 42)