Skip to content
Snippets Groups Projects
Commit 341c4a6e authored by erwan's avatar erwan
Browse files

Clean up the algo.mli w.r.t. to possible varT and values

parent 01c51efd
No related branches found
No related tags found
No related merge requests found
(* Time-stamp: <modified the 10/03/2019 (at 22:47) by Erwan Jahier> *)
(* Time-stamp: <modified the 11/03/2019 (at 10:41) by Erwan Jahier> *)
type t = {
pid : string;
......@@ -33,6 +33,8 @@ let (make: bool -> Topology.node -> t) =
| 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)
)
......
......@@ -6,6 +6,7 @@ let (algo_varT: Algo.varT -> string) = function
| Bt -> "bool"
| Et i -> Printf.sprintf "enum(%d)" i
| Nt -> "Neighbor"
| St -> "string"
let (algo_vars : Algo.vars -> string) = fun vars ->
String.concat "," (List.map (fun (n,t) -> Printf.sprintf "%s:%s" n (algo_varT t)) vars)
......
(* Time-stamp: <modified the 10/03/2019 (at 20:46) by Erwan Jahier> *)
(* Time-stamp: <modified the 11/03/2019 (at 10:40) by Erwan Jahier> *)
(** Process programmer API *)
type varT = It | Nt | Ft | Bt | Et of int
type varT = It | Ft | Bt | Et of int | St | Nt
type action = string (* just a label *)
type value = I of int | F of float | B of bool | S of string | N of int
type value = I of int | F of float | B of bool | E of int | S of string | N of int
type local_env = string -> value
type vars = (string * varT) list
......@@ -40,11 +40,13 @@ let vart_to_rif_string = function
| It -> "int"
| Ft -> "real"
| Bt -> "bool"
| St -> "string"
| Et _i -> "int"
| Nt -> "int"
let value_to_string = function
| I i
| E i
| N i -> string_of_int i
| F f -> string_of_float f
| B true -> "t"
......@@ -88,6 +90,8 @@ let (get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_
| Some(_,Bt) -> B (Random.bool ())
| Some(_,Ft) -> F (Random.float max_float)
| Some(_,Et i) -> I (Random.int i)
| Some(_,St) -> S "dummy"
)
in
try
......
(* Time-stamp: <modified the 10/03/2019 (at 20:47) by Erwan Jahier> *)
(* Time-stamp: <modified the 11/03/2019 (at 10:38) by Erwan Jahier> *)
(** Process programmer API *)
type value = I of int | F of float | B of bool | S of string
type varT = It | Ft | Bt | Et of int | St | Nt
type vars = (string * varT) list
type value = I of int | F of float | B of bool | E of int | S of string
| N of int (* neighbor canal number *)
type local_env = string -> value
type action = string (* label *)
type varT = It | Nt | Ft | Bt | Et of int
type vars = (string * varT) list
type neighbor = {
lenv: local_env;
......@@ -15,37 +15,38 @@ type neighbor = {
}
type enable_fun = neighbor list -> local_env -> action list
type step_fun = neighbor list -> local_env -> action -> local_env
type step_fun = neighbor list -> local_env -> action -> local_env
(** Those 3 registering functions must be called! *)
type algo_id = string (* XXX comment s'en passer ??? *)
type algo_id = string
val reg_vars : algo_id -> vars -> unit
val reg_enable : algo_id -> enable_fun -> unit
val reg_step : algo_id -> step_fun -> unit
(** nb: The initialisation done in the dot file have priority over this one *)
(** raised by sasa if one of the function above is not called *)
exception Unregistred of string * string
(** This one is not mandatory. The initialisation done in the dot
file have priority over this one. *)
val reg_init_vars : algo_id -> (neighbor list -> local_env) -> unit
(** Mandatory in custom mode only. *)
val reg_actions : algo_id -> action list -> unit
(** util(s) *)
val value_to_string : value -> string
(**/**)
(** functions below are not part of the API *)
val vart_to_rif_string: varT -> string
val verbose_level: int ref
(** raised by get_* functions *)
exception Unregistred of string * string
(** the following functions are used by sasa *)
val get_vars : algo_id -> vars
val get_enable : algo_id -> enable_fun
val get_step : algo_id -> step_fun
val get_init_vars : algo_id -> (string * varT) list -> (neighbor list -> local_env)
val get_actions : algo_id -> action list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment