diff --git a/lib/sasacore/daemon.mli b/lib/sasacore/daemon.mli index ae3471ab18320c599d14ea4a745bbc2c0ed28e19..a4f058f45105bae03ce4813b766e4016f6bf651f 100644 --- a/lib/sasacore/daemon.mli +++ b/lib/sasacore/daemon.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/05/2021 (at 13:43) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/05/2021 (at 15:25) by Erwan Jahier> *) type t = | Synchronous (* select all actions *) @@ -52,3 +52,4 @@ val f : bool -> bool -> t -> 'v Process.t list -> (** Used in gtkgui.ml *) val central: 'a list list -> 'a list +val distributed: 'a list list -> 'a list diff --git a/tools/rdbg4sasa/gtkgui.ml b/tools/rdbg4sasa/gtkgui.ml index 826dd061d696782f943b579d5c26a232376b9ab3..91fac17d5f8a84aa744c8af0722d4f08254f59bc 100644 --- a/tools/rdbg4sasa/gtkgui.ml +++ b/tools/rdbg4sasa/gtkgui.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 07/05/2021 (at 15:18) by Erwan Jahier> *) +(* Time-stamp: <modified the 07/05/2021 (at 16:20) by Erwan Jahier> *) #thread #require "lablgtk3" @@ -27,15 +27,20 @@ let rdbg_nodes_info e: (string * string * bool) list = in List.map split_var enabled -(** Liste qui dit pour chaque noeud s'il est activable. On suppose - qu'ils sont groupés. *) +(** Liste qui dit pour chaque noeud s'il est activable. On suppose + qu'ils sont groupés. + + XXX On suppose aussi qu'au plus une action par process est + enabled. Les demons dans sasa, font mieux. Mais ici, c'est + raisonnable si on ne veut pas avoir nb_actions fois plus de boutons + ! (alors que ca n'arrive jamais) *) let rdbg_nodes_enabled e = match rdbg_nodes_info e with | [] -> assert false - | (node, _, enab)::l -> + | (node, _action, enab)::l -> let last, res = List.fold_left - (fun ((p_node, p_enab), res) (node, state, enab) -> + (fun ((p_node, p_enab), res) (node, _action, enab) -> if p_node = node then (node, p_enab || enab), res else @@ -45,6 +50,7 @@ let rdbg_nodes_enabled e = l in List.rev (last::res) + type daemon_kind = Distributed | Synchronous | Central | LocCentral | ManualCentral | Manual let daemon_kind = ref ManualCentral @@ -318,27 +324,32 @@ let custom_daemon p gtext vbox step_button round_button = aux 0 [] nl in let step () = + let nodes_enabled = rdbg_nodes_enabled !e in + let nodes = List.filter (fun (_,b) -> b) nodes_enabled in + let nodes = get_higher_prioriry nodes_enabled in match !daemon_kind with | Distributed -> - p "finish me" + let nodes = List.map (fun x -> [x]) nodes in + let to_activate = Daemon.distributed nodes in + Hashtbl.clear daemongui_activate; + List.iter (fun n -> Hashtbl.replace daemongui_activate n true) to_activate; + sd (); + + p ("Distributed step : " ^ (String.concat "," to_activate)) | Synchronous -> ( - let nodes_enabled = rdbg_nodes_enabled !e in - let nodes = get_higher_prioriry nodes_enabled in - List.iter (fun (n,_) -> Hashtbl.replace daemongui_activate n (List.mem n nodes)) - nodes_enabled; + Hashtbl.clear daemongui_activate; + List.iter (fun n -> Hashtbl.replace daemongui_activate n true) nodes; sd (); - gtext#buffer#set_text ("Synchronous step : " ^ (String.concat "," nodes)) + p ("Synchronous step : " ^ (String.concat "," nodes)) ) | Central -> - let nodes_enabled = rdbg_nodes_enabled !e in - let nodes = List.filter (fun (_,b) -> b) nodes_enabled in - let nodes = get_higher_prioriry nodes_enabled in - let to_activate = Daemon.central [nodes] in + let nodes = List.map (fun x -> [x]) nodes in + let to_activate = Daemon.central nodes in Hashtbl.clear daemongui_activate; List.iter (fun n -> Hashtbl.replace daemongui_activate n true) to_activate; sd (); p ("Central step : " ^ (String.concat "," to_activate)) - + | LocCentral -> p "finish me"