-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactuator.erl
34 lines (29 loc) · 1.01 KB
/
actuator.erl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-module(actuator).
-compile(export_all).
-include("records.hrl").
gen(ExoSelfPId, Node) ->
spawn(Node, ?MODULE, loop, [ExoSelfPId]).
loop(ExoSelfPId) ->
receive
{ExoSelfPId, {Id, CortexPId, ActuatorName, FaninPIds}} ->
loop(Id, CortexPId, ActuatorName, {FaninPIds, FaninPIds}, [])
end.
loop(Id, CortexPId, ActuatorName, {[FromPId | FaninPIds], MFaninPIds}, Acc) ->
receive
{FromPId, forward, Input} ->
loop(Id, CortexPId, ActuatorName, {FaninPIds, MFaninPIds}, lists:append(Input, Acc));
{CortexPId, terminate} ->
ok
end;
loop(Id, CortexPId, ActuatorName, {[], MFaninPIds}, Acc) ->
actuator:ActuatorName(lists:reverse(Acc)),
CortexPId ! {self(), sync},
loop(Id, CortexPId, ActuatorName, {MFaninPIds, MFaninPIds}, []).
pts(Result) ->
io:format("actuators:pts(Result): ~p~n", [Result]).
xor_SendOutput(Output,Scape)->
Scape ! {self(),action,Output},
receive
{Scape,Fitness,HaltFlag}->
{Fitness,HaltFlag}
end.