From: Jérémie D. <Ba...@us...> - 2011-04-19 19:12:50
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via fa1824d9c5b53f71a4e6091206ab2e73ac1c1b74 (commit) from 8359d44c2c097a6a9851638a1f67524dd4d3bd2c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fa1824d9c5b53f71a4e6091206ab2e73ac1c1b74 Author: Jérémie Dimino <je...@di...> Date: Tue Apr 19 21:11:38 2011 +0200 [info] add krobot-monitor ----------------------------------------------------------------------- Changes: diff --git a/info/control2011/_oasis b/info/control2011/_oasis index e826386..3b5b668 100644 --- a/info/control2011/_oasis +++ b/info/control2011/_oasis @@ -82,6 +82,13 @@ Executable "krobot-dump" MainIs: krobot_dump.ml BuildDepends: krobot, lwt.syntax +Executable "krobot-monitor" + Path: src/tools + Install: true + CompiledObject: best + MainIs: krobot_monitor.ml + BuildDepends: krobot, lwt.syntax + Executable "krobot-dump-encoders" Path: src/tools Install: true diff --git a/info/control2011/_tags b/info/control2011/_tags index 0faf3ef..42135ad 100644 --- a/info/control2011/_tags +++ b/info/control2011/_tags @@ -2,7 +2,7 @@ <src/interfaces/*.ml>: -syntax_camlp4o # OASIS_START -# DO NOT EDIT (digest: c856ca92c511128600c4a9a2ddb551e7) +# DO NOT EDIT (digest: e0fdca06da598f490f540bfd1de2f7ad) # Library krobot "src/lib": include "src/lib/krobot.cmxs": use_krobot @@ -55,6 +55,11 @@ <src/tools/krobot_viewer.{native,byte}>: pkg_lablgtk2.glade <src/tools/krobot_viewer.{native,byte}>: pkg_cairo.lablgtk2 <src/tools/*.ml{,i}>: pkg_lablgtk2.glade +# Executable krobot-monitor +<src/tools/krobot_monitor.{native,byte}>: use_krobot +<src/tools/krobot_monitor.{native,byte}>: pkg_lwt.unix +<src/tools/krobot_monitor.{native,byte}>: pkg_lwt.syntax +<src/tools/krobot_monitor.{native,byte}>: pkg_lwt.react # Executable krobot-hil-simulator <src/tools/krobot_hil_simulator.{native,byte}>: use_krobot <src/tools/krobot_hil_simulator.{native,byte}>: pkg_lwt.unix diff --git a/info/control2011/setup.ml b/info/control2011/setup.ml index 41e82e4..a90aa6e 100644 --- a/info/control2011/setup.ml +++ b/info/control2011/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.2.0~alpha1 *) (* OASIS_START *) -(* DO NOT EDIT (digest: d57b3cf1b9ea66ae670ea790a42da492) *) +(* DO NOT EDIT (digest: e5aa81e40566663130f898cbaee3b839) *) (* Regenerated by OASIS v0.2.0 Visit http://oasis.forge.ocamlcore.org for more information and @@ -5292,6 +5292,34 @@ let setup_t = {exec_custom = false; exec_main_is = "krobot_viewer.ml"; }); Executable ({ + cs_name = "krobot-monitor"; + cs_data = PropList.Data.create (); + cs_plugin_data = []; + }, + { + bs_build = [(OASISExpr.EBool true, true)]; + bs_install = [(OASISExpr.EBool true, true)]; + bs_path = "src/tools"; + bs_compiled_object = Best; + bs_build_depends = + [ + InternalLibrary "krobot"; + FindlibPackage ("lwt.syntax", None) + ]; + bs_build_tools = [ExternalTool "ocamlbuild"]; + bs_c_sources = []; + bs_data_files = []; + bs_ccopt = [(OASISExpr.EBool true, [])]; + bs_cclib = [(OASISExpr.EBool true, [])]; + bs_dlllib = [(OASISExpr.EBool true, [])]; + bs_dllpath = [(OASISExpr.EBool true, [])]; + bs_byteopt = [(OASISExpr.EBool true, [])]; + bs_nativeopt = [(OASISExpr.EBool true, [])]; + }, + {exec_custom = false; exec_main_is = "krobot_monitor.ml"; + }); + Executable + ({ cs_name = "krobot-hil-simulator"; cs_data = PropList.Data.create (); cs_plugin_data = []; diff --git a/info/control2011/src/tools/krobot_monitor.ml b/info/control2011/src/tools/krobot_monitor.ml new file mode 100644 index 0000000..0fae3c7 --- /dev/null +++ b/info/control2011/src/tools/krobot_monitor.ml @@ -0,0 +1,52 @@ +(* + * krobot_monitor.ml + * ----------------- + * Copyright : (c) 2011, Jeremie Dimino <je...@di...> + * Licence : BSD3 + * + * This file is a part of [kro]bot. + *) + +(* Monitor all messages passing on the krobot bus. *) + +open Lwt +open Lwt_react + +let date_string time = + let tm = Unix.localtime time in + let month_string = + match tm.Unix.tm_mon with + | 0 -> "Jan" + | 1 -> "Feb" + | 2 -> "Mar" + | 3 -> "Apr" + | 4 -> "May" + | 5 -> "Jun" + | 6 -> "Jul" + | 7 -> "Aug" + | 8 -> "Sep" + | 9 -> "Oct" + | 10 -> "Nov" + | 11 -> "Dec" + | _ -> Printf.ksprintf failwith "Lwt_log.ascdate: invalid month, %d" tm.Unix.tm_mon + in + Printf.sprintf + "%s %2d %02d:%02d:%02d.%s" + month_string + tm.Unix.tm_mday + tm.Unix.tm_hour + tm.Unix.tm_min + tm.Unix.tm_sec + (String.sub (Printf.sprintf "%.4f" (fst (modf time))) 2 4) + +lwt () = + lwt bus = Krobot_bus.get () in + + E.keep + (E.map_s + (fun (timestamp, message) -> + Lwt_io.printlf "%s: %s" (date_string timestamp) (Krobot_bus.string_of_message message)) + (Krobot_bus.recv bus)); + + fst (wait ()) + hooks/post-receive -- krobot |