Compare commits

..

3 commits

4 changed files with 13 additions and 12 deletions

View file

@ -1,11 +1,13 @@
defmodule Scopes.CSys do
require Logger
require Scopes.Util
alias Scopes.Core.Actor
alias Scopes.Shape
alias Scopes.Util
def neuron(scope) do
#Logger.info([scope: inspect(scope)])
#Logger.info(Util.show [scope])
Actor.create(fn msg -> process(msg, scope) end)
end
@ -58,7 +60,7 @@ defmodule Scopes.CSys do
# send shortcuts
def send_message(rcvr, head, data \\ %{}) do
Logger.info rcvr: inspect(rcvr), head: inspect(head), data: inspect(data)
Logger.debug(Util.show [rcvr, head, data])
Actor.send(rcvr, Shape.create(head, data: data))
end

View file

@ -1,9 +1,11 @@
defmodule Scopes.CSys.Program do
require Logger
require Scopes.Util
alias Scopes.CSys
alias Scopes.CSys.Environ
alias Scopes.Shape
alias Scopes.Util
defmodule State do
defstruct [:value, :count, :stage, :prog]
@ -74,7 +76,7 @@ defmodule Scopes.CSys.Program do
limit = args[:limit]
data = Shape.data(msg)
state = CSys.state(scope)
Logger.info data: data, state_value: state.value, threshold: threshold, self: self()
Logger.debug(Util.show [data, state.value, threshold, self()])
value_n = state.value + data.value
if value_n >= threshold do
value_out = limit && rem(value_n - 1, limit) + limit || value_n

View file

@ -1,9 +1,8 @@
defmodule Scopes.Util do
defmacro fields_info(fields) do
names = for {f, _, _} <- fields do f end
quote do
Enum.zip(unquote(names), unquote(fields))
defmacro show(fields) do
names = for f <- fields do Macro.to_string(f) end
quote bind_quoted: [names: names, fields: fields] do
Enum.zip(names, fields) |> Map.new
end
end
end

View file

@ -6,10 +6,8 @@ defmodule Scopes.UtilTest do
describe "info:" do
test "fields" do
a = 17
b = 22
c = 42
assert [a: 17, b: 22, c: 42] = Util.fields_info([a, b, c])
{a, b, c} = {17, 22, 42}
assert %{"a" => 17, "b" => 22, "c" => 42} = Util.show([a, b, c])
end
end
end