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

gnuplot-rif enhancements

parent d173d10b
No related branches found
No related tags found
No related merge requests found
OASISFormat: 0.4 OASISFormat: 0.4
Name: lutils Name: lutils
Version: 1.15 Version: 1.16
Authors: Erwan Jahier Authors: Erwan Jahier
Maintainers: erwan.jahier@imag.fr Maintainers: erwan.jahier@imag.fr
License: GPL-3 License: GPL-3
......
\newcommand{\version}{1.15} \newcommand{\version}{1.16}
\newcommand{\sha}{52d447c} \newcommand{\sha}{d173d10}
\newcommand{\versionname}{none} \newcommand{\versionname}{none}
\newcommand{\versiondate}{04-10-17} \newcommand{\versiondate}{24-11-17}
# OASIS_START # OASIS_START
# DO NOT EDIT (digest: e0feb154a7aab6533276454ea556bfc0) # DO NOT EDIT (digest: aed6f0fef5953ed458ecf15da3ba7c01)
version = "1.15" version = "1.16"
description = "shared by Verimag/synchronous tools (lustre, lutin, rdbg)." description = "shared by Verimag/synchronous tools (lustre, lutin, rdbg)."
requires = "unix str camlp4 num" requires = "unix str camlp4 num"
archive(byte) = "lutils.cma" archive(byte) = "lutils.cma"
......
(* Time-stamp: <modified the 12/06/2017 (at 16:44) by Erwan Jahier> *) (* Time-stamp: <modified the 10/10/2017 (at 00:13) by Erwan Jahier> *)
(*----------------------------------------------------------------------- (*-----------------------------------------------------------------------
** This file may only be copied under the terms of the GNU Library General ** This file may only be copied under the terms of the GNU Library General
** Public License ** Public License
...@@ -52,7 +52,7 @@ let (readfile: string -> string) = ...@@ -52,7 +52,7 @@ let (readfile: string -> string) =
(********************************************************************************) (********************************************************************************)
(* Well, using reg expr would have been simpler actually... *) (* Well, using reg expr would have been simpler actually... *)
let lexer = make_lexer ["#"; "columns"; ":"; "|"; ")";"("] let lexer = make_lexer ["#"; "outputs"; "inputs"; "columns"; ":"; "|"; ")";"("]
type tok = token Stream.t type tok = token Stream.t
let verbose = ref false let verbose = ref false
...@@ -84,7 +84,7 @@ let ftok2str stream = ...@@ -84,7 +84,7 @@ let ftok2str stream =
(********************************************************************************) (********************************************************************************)
(* get var type in the rif file *) (* get var type in the rif file *)
(* name, type, position (starting from 0) *) (* name, type, position (starting from 0) *)
type vtypes_tbl = (string * (string * int)) list type vtypes_tbl = (string * (string * int * bool)) list
let (get_var_types : string -> vtypes_tbl) = let (get_var_types : string -> vtypes_tbl) =
fun rif_file -> fun rif_file ->
...@@ -92,6 +92,7 @@ let (get_var_types : string -> vtypes_tbl) = ...@@ -92,6 +92,7 @@ let (get_var_types : string -> vtypes_tbl) =
let tbl = ref [] in let tbl = ref [] in
let s_ref = ref (lexer (Stream.of_string rif_file)) in (* recovering stupid errors *) let s_ref = ref (lexer (Stream.of_string rif_file)) in (* recovering stupid errors *)
let pos_ref = ref 0 in let pos_ref = ref 0 in
let is_input = ref true in
let rec aux pos s = (* aux looks for the first "string" *) let rec aux pos s = (* aux looks for the first "string" *)
s_ref := s; s_ref := s;
pos_ref := pos; pos_ref := pos;
...@@ -103,6 +104,8 @@ let (get_var_types : string -> vtypes_tbl) = ...@@ -103,6 +104,8 @@ let (get_var_types : string -> vtypes_tbl) =
| [< 'Ident(_) >] -> aux pos s | [< 'Ident(_) >] -> aux pos s
| [< 'Int(_) >] -> aux pos s | [< 'Int(_) >] -> aux pos s
| [< 'Float(_) >] -> aux pos s | [< 'Float(_) >] -> aux pos s
| [< 'Kwd("inputs") >] -> is_input:=true;aux pos s
| [< 'Kwd("outputs") >] -> is_input:=false;aux pos s
| [< 'Kwd(_) >] -> aux pos s | [< 'Kwd(_) >] -> aux pos s
| [< 'Char(_) >] -> aux pos s | [< 'Char(_) >] -> aux pos s
...@@ -118,9 +121,9 @@ let (get_var_types : string -> vtypes_tbl) = ...@@ -118,9 +121,9 @@ let (get_var_types : string -> vtypes_tbl) =
| [< 'Char(_) >] -> aux pos s | [< 'Char(_) >] -> aux pos s
and aux3 pos id s = (* aux3 looks for the next ident *) and aux3 pos id s = (* aux3 looks for the next ident *)
let _ = debug_msg ("aux3: "^(string_of_int (Stream.count s))^" pos="^ let _ = debug_msg ("aux3: "^(string_of_int (Stream.count s))^" pos="^
(string_of_int pos)^" ; token='"^ (ftok2str s) ^"'\n") in (string_of_int pos)^" ; token='"^(ftok2str s)^"'\n") in
match s with parser match s with parser
| [< 'Ident(t)>] -> tbl:=(id, (t, pos))::!tbl; aux (pos+1) s | [< 'Ident(t)>] -> tbl:=(id, (t, pos, !is_input))::!tbl; aux (pos+1) s
| [< 'Kwd(_) >] -> aux pos s | [< 'Kwd(_) >] -> aux pos s
| [< 'Int(_) >] -> aux pos s | [< 'Int(_) >] -> aux pos s
| [< 'Float(_) >] -> aux pos s | [< 'Float(_) >] -> aux pos s
...@@ -132,7 +135,7 @@ let (get_var_types : string -> vtypes_tbl) = ...@@ -132,7 +135,7 @@ let (get_var_types : string -> vtypes_tbl) =
| Stream.Error _ -> | Stream.Error _ ->
if !verbose then ( if !verbose then (
output_string stderr ("ignore (harmless?) stream errors at pos "^ output_string stderr ("ignore (harmless?) stream errors at pos "^
(string_of_int (Stream.count s))^" in gnuplot-rif.\n"); (string_of_int (Stream.count s))^" in gnuplot-rif.\n");
flush stderr); flush stderr);
aux_ignore_error !pos_ref !s_ref aux_ignore_error !pos_ref !s_ref
in in
...@@ -228,9 +231,9 @@ let terminal_kind_to_string tk file = ...@@ -228,9 +231,9 @@ let terminal_kind_to_string tk file =
| Eps -> "set term post color solid eps\nset output \"" ^ base_fn ^ ".eps\"\n" | Eps -> "set term post color solid eps\nset output \"" ^ base_fn ^ ".eps\"\n"
| Latex -> "set term solid latex\nset output \"" ^ base_fn ^ ".tex\"\n" | Latex -> "set term solid latex\nset output \"" ^ base_fn ^ ".tex\"\n"
| X11 -> "set terminal x11" | X11 -> "set terminal x11"
| Qt -> "set terminal qt" | Qt -> "set terminal qt size 1600,400"
| Default -> "" | Default -> ""
| Wxt -> "set terminal wxt persist font \"Arial,12\" " | Wxt -> "set terminal wxt persist font \"Arial,12\" size 1600,400 "
| NoDisplay -> " " | NoDisplay -> " "
let terminal = ref Default let terminal = ref Default
...@@ -241,11 +244,13 @@ let gen_gnuplot_file vars to_hide ttbl file tk = ...@@ -241,11 +244,13 @@ let gen_gnuplot_file vars to_hide ttbl file tk =
(* let flip = ref true in *) (* let flip = ref true in *)
let bool_var_nb = ref 0 in let bool_var_nb = ref 0 in
let put_one_var (var:string) (i:int) = let put_one_var (var:string) (i:int) =
let is_num = try (fst (List.assoc var ttbl)) <> "bool" with _ -> let is_num,is_input =
let var_tbl_str = String.concat ", " (List.map (fun (n,_) -> n) ttbl) in try let t,_,ii= (List.assoc var ttbl) in (t <> "bool"),ii with _ ->
output_string stderr ("Warning: cannot find "^ var ^ " in "^var_tbl_str^"\n"); let var_tbl_str = String.concat ", " (List.map (fun (n,_) -> n) ttbl) in
output_string stderr
("Warning: cannot find "^var^" in "^var_tbl_str^"\n");
flush stderr; flush stderr;
false false,false (* fake values *)
in in
put ("\"< read-rif.sh "^ !rif_file^ " "); put ("\"< read-rif.sh "^ !rif_file^ " ");
if !dynamic then put (" | tail -n "^ (string_of_int !window_size)) else if !dynamic then put (" | tail -n "^ (string_of_int !window_size)) else
...@@ -261,19 +266,19 @@ let gen_gnuplot_file vars to_hide ttbl file tk = ...@@ -261,19 +266,19 @@ let gen_gnuplot_file vars to_hide ttbl file tk =
("(getminmax($"^(string_of_int i)^")) title \"" ^ var ^ "\" with linespoints") ("(getminmax($"^(string_of_int i)^")) title \"" ^ var ^ "\" with linespoints")
else else
("(scale_bool($"^(string_of_int i)^","^ ("(scale_bool($"^(string_of_int i)^","^
(incr bool_var_nb;string_of_int (!bool_var_nb-1))^")) lc rgb \"black\" notitle") (incr bool_var_nb;string_of_int (!bool_var_nb-1))^")) lc rgb \""^(if is_input then "blue" else "red")^"\" notitle")
) )
) )
in in
let bool_nb = let bool_nb =
List.fold_left List.fold_left
(fun cpt (id, (t,_)) -> if t = "bool" && not (to_hide id) then cpt+1 else cpt) (fun cpt (id, (t,_,ii)) -> if t = "bool" && not (to_hide id) then cpt+1 else cpt)
0 0
ttbl ttbl
in in
let num_nb = let num_nb =
List.fold_left List.fold_left
(fun cpt (id, (t,_)) -> if t <> "bool" && not (to_hide id) then cpt+1 else cpt) (fun cpt (id, (t,_,ii)) -> if t <> "bool" && not (to_hide id) then cpt+1 else cpt)
0 0
ttbl ttbl
in in
...@@ -288,7 +293,7 @@ set grid back"; ...@@ -288,7 +293,7 @@ set grid back";
put (" put ("
set mouse set mouse
" ^ " ^
(if num_nb = 0 then "0" else "set key outside title \"Numeric variables\" box 3")^ (if num_nb = 0 then "" else "set key outside title \"Numeric variables\" box 3")^
" "
set xlabel \"steps\" set xlabel \"steps\"
...@@ -306,7 +311,7 @@ delta=1 ...@@ -306,7 +311,7 @@ delta=1
update_delta(x) = (range=max-min,range_10=ceil(range/10),(delta2=((range)/(bool_nb+2)), (delta2<1?1:delta=delta2))) update_delta(x) = (range=max-min,range_10=ceil(range/10),(delta2=((range)/(bool_nb+2)), (delta2<1?1:delta=delta2)))
getminmax(x)= ((x<min ? min=x : x>max ? (max=x) : x),update_delta(x),x) getminmax(x)= ((x<min ? min=x : x>max ? (max=x) : x),update_delta(x),x)
scale_bool(x,i) = min + 1.7*i*delta + (x*delta) scale_bool(x,i) = min + 1.7*i*delta + (x*delta)
label_pos(i)=i*delta*1.7+delta/2 label_pos(i)=min + i*delta*1.7+delta*0.5
"^(if !dynamic then ("set xtics " ^ (string_of_int (!window_size / 10))) else "^(if !dynamic then ("set xtics " ^ (string_of_int (!window_size / 10))) else
match !min_step,!max_step with match !min_step,!max_step with
...@@ -336,13 +341,13 @@ label_pos(i)=i*delta*1.7+delta/2 ...@@ -336,13 +341,13 @@ label_pos(i)=i*delta*1.7+delta/2
put "\n\nunset label\n"; put "\n\nunset label\n";
bool_var_nb:=0; bool_var_nb:=0;
List.iter List.iter
(fun (id, (t,pos)) -> (fun (id, (t,pos,ii)) ->
if (to_hide id) then debug_msg ("Hidding " ^ id ^ "\n"); if (to_hide id) then debug_msg ("Hidding " ^ id ^ "\n");
if t = "bool" then ( if t = "bool" then (
if (to_hide id) then () else ( if (to_hide id) then () else (
put ("set label \""^ id ^ "\" at 0, (label_pos("^ put ("set label \""^ id ^ "\" at 3, (label_pos("^
(incr bool_var_nb;string_of_int (!bool_var_nb-1)) (incr bool_var_nb;string_of_int (!bool_var_nb-1))
^"))\n") ^")) front left \n")
) )
) ; ) ;
) )
...@@ -354,7 +359,7 @@ set ytics range_10 ...@@ -354,7 +359,7 @@ set ytics range_10
flush stderr; flush stderr;
if (not (List.mem tk [Wxt; Default; Qt; X11 ;NoDisplay])) then put "set size 1.3,1\n"; if (not (List.mem tk [Wxt; Default; Qt; X11 ;NoDisplay])) then put "set size 1.3,1\n";
put "unset output\nreplot\n"; put "unset output\nreplot\n";
if (List.mem tk [Qt; X11; Default]) then put "pause mouse close\n"; if (List.mem tk [Qt; X11; Default; NoDisplay]) then put "pause mouse close\n";
close_out oc; close_out oc;
file file
......
(* Time-stamp: <modified the 08/09/2016 (at 09:49) by Erwan Jahier> *) (* Time-stamp: <modified the 09/10/2017 (at 22:50) by Erwan Jahier> *)
(*----------------------------------------------------------------------- (*-----------------------------------------------------------------------
** This file may only be copied under the terms of the GNU Library General ** This file may only be copied under the terms of the GNU Library General
** Public License ** Public License
...@@ -122,6 +122,6 @@ let main () = ...@@ -122,6 +122,6 @@ let main () =
rloop() rloop()
) )
in in
rloop () if !terminal = NoDisplay then () else rloop ()
let _ = main () let _ = main ()
let str="1.15" let str="1.16"
let sha="52d447c" let sha="d173d10"
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