Newer
Older
(* Time-stamp: <modified the 13/03/2019 (at 10:01) by Erwan Jahier> *)
actions: Algo.action list;
init : Algo.neighbor list -> Algo.local_env;
let (make: bool -> Topology.node -> t) =
fun custom_mode n ->
let pid = n.Topology.id in
let cmxs = n.Topology.file in
let id = Filename.chop_suffix cmxs ".cmxs" in
if !Algo.verbose_level > 0 then Printf.printf "Loading %s...\n" cmxs;
(* TODO: should I prevent the same cmxs to be loaded twice? Not clear. *)
Dynlink.loadfile cmxs;
let vars = Algo.get_vars id in
let user_init_env = Algo.get_init_vars id vars in
(* let (string_to_value: string -> Algo.value) = *)
let init_env nl v =
None ->
if !Algo.verbose_level > 1 then
Printf.eprintf "No init value for '%s' found in the graph.\n" v;
user_init_env nl v
match List.assoc_opt v vars with
| Some(Algo.It)
| Some(Algo.Nt) -> I (int_of_string x)
| Some(Algo.Bt) -> B (bool_of_string x)
| Some(Algo.Ft) -> F (float_of_string x)
| Some(Algo.Et _i) -> I (int_of_string x)
| Some(Algo.St) -> S "dummy"
| None ->
failwith (Printf.sprintf "%s is not a variable of program %s" v cmxs)
)
in
let actions =
try Algo.get_actions id
with _ ->
if custom_mode then
failwith "Registering actions is mandatory in algorithms when using custom demon!"
else [""]
in
let process = {
pid = pid;
variables = vars ;
init = init_env ;
actions = actions;