diff --git a/lib/csys/program.ex b/lib/csys/program.ex index 64d2ea5..e2e2432 100644 --- a/lib/csys/program.ex +++ b/lib/csys/program.ex @@ -61,10 +61,11 @@ defmodule Scopes.CSys.Program do basic(msg, scope) end - def basic(msg, scope) do + def basic(msg, scope) do # + proc_ops case Shape.head(msg) do - [:csys, :set | _rest] -> set(msg, scope) [:csys, :data | _rest] -> process_data(msg, scope) + #[:csys, :trigger | _rest] -> process_trigger(msg, scope) + [:csys, :set | _rest] -> set(msg, scope) [:csys, :connect | _rest] -> CSys.connect(msg, scope) [:csys, :create, :succ | _rest] -> create_succ(msg, scope) [:csys, :create, :pred | _rest] -> create_pred(msg, scope) @@ -76,6 +77,15 @@ defmodule Scopes.CSys.Program do # message handlers // proc steps + def process_value(_msg, _scope, _ops) do + #proc ops: + #map_op, (identity) + #reduce_op, (+) + #trigger_cond, (>) + #modifier_op, (identity) + #output_op (forward_or_notify) + end + def process_data(msg, scope) do data = Shape.data(msg) state = CSys.state(scope) @@ -84,7 +94,7 @@ defmodule Scopes.CSys.Program do if value_n >= state.threshold do msg = Shape.create(Shape.head(msg), data: %{data | value: value_n}) CSys.forward(msg, scope) || CSys.notify(msg, scope) - state_n = %{state | value: state.bias} + state_n = if state.bias, do: %{state | value: state.bias}, else: state CSys.update(put_elem(scope, 0, state_n)) else state_n = %{state | value: value_n}