From: Jérémie D. <Ba...@us...> - 2010-02-23 12:09:28
|
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 c0d1d60462dfc4bf44bdc73eb14937bc048a6afc (commit) from 6abe826b5278a9447436ef4209a6db4e8804799d (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 c0d1d60462dfc4bf44bdc73eb14937bc048a6afc Author: Jérémie Dimino <je...@di...> Date: Tue Feb 23 13:08:44 2010 +0100 Generate code for common requests/commands ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/driver/driver.ml b/PC_Mainboard/driver/driver.ml index 6e1170c..2a23af1 100644 --- a/PC_Mainboard/driver/driver.ml +++ b/PC_Mainboard/driver/driver.ml @@ -243,14 +243,6 @@ struct include OBus.MakeInterface(struct let name = "fr.krobot.Device.Motors" end) (* +---------------------------------------------------------------+ - | Dispatching | - +---------------------------------------------------------------+ *) - - (* The dispatcher *) -(* let *) - - - (* +---------------------------------------------------------------+ | High-level movement | +---------------------------------------------------------------+ *) @@ -578,7 +570,7 @@ end let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = match try `Handle(USB.open_device_with ~vendor_id ~product_id) with exn -> `Error exn with | `Error exn -> - lwt () = Log.exn_f exn "failed to open %s card" name in + lwt () = Log.info_f "failed to open %s card: %s" name (Printexc.to_string exn) in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Handle handle -> lwt () = Log.info_f "%s card opened" name in @@ -601,7 +593,7 @@ let rec monitor_card ~name ~vendor_id ~product_id ~set on_up on_down = | `Closed -> return () | `Error exn -> - Log.exn_f exn "%s card crashed with" name + Log.info_f "%s card crashed: %s" name (Printexc.to_string exn) in restart_card ~name ~vendor_id ~product_id ~set on_up on_down | `Error exn -> diff --git a/PC_Mainboard/generators/gen_dbus_imports.ml b/PC_Mainboard/generators/gen_dbus_imports.ml index 6db0ef4..9fe5e5f 100644 --- a/PC_Mainboard/generators/gen_dbus_imports.ml +++ b/PC_Mainboard/generators/gen_dbus_imports.ml @@ -16,7 +16,7 @@ let rec print indent = function List.iter (function | Arg(name, typ) -> - printf "%s -> " typ.caml_type + printf "%s : %s -> " (Name.lid name) typ.caml_type | Cst _ -> ()) req.req_args; @@ -48,6 +48,19 @@ let rec print indent = function cmd.cmd_args; printf "unit\n"; + | Module("common", items) -> + printf "%smodule Common = struct\n" indent; + printf "%s let proxy krobot (card : Krobot.Card.card) =\n" indent; + printf "%s OBus_proxy.make (Krobot.peer krobot)\n" indent; + printf "%s [\"fr\"; \"krobot\"; \"Cards\"; (match card with\n" indent; + printf "%s | `Interface -> \"Interface\"\n" indent; + printf "%s | `Sensor -> \"Sensor\"\n" indent; + printf "%s | `Motor -> \"Motor\")]\n" indent; + printf "%s let op_method_call member typ krobot card =\n" indent; + printf "%s OBus_proxy.method_call (proxy krobot card) ~interface:\"fr.krobot.Card.Unsafe\" ~member typ\n" indent; + List.iter (print (indent ^ " ")) items; + printf "%send\n" indent + | Module(name, items) -> printf "%smodule %s = struct\n" indent (Name.uid name); printf "%s include MakeDevice(struct let name = \"%s\" end)\n" indent (Name.caml_case name); @@ -70,7 +83,7 @@ module MakeDevice(Name : sig val name : string end) = let get krobot = OBus_proxy.make (Krobot.peer krobot) [\"fr\"; \"krobot\"; \"Devices\"; Name.name] end) (struct - let name = \"fr.krobot.Device.\" ^ Name.name + let name = \"fr.krobot.Device.\" ^ Name.name ^ \".Unsafe\" end) "; List.iter (print "") interface diff --git a/PC_Mainboard/generators/gen_script_commands.ml b/PC_Mainboard/generators/gen_script_commands.ml index 68cbc35..42e21a4 100644 --- a/PC_Mainboard/generators/gen_script_commands.ml +++ b/PC_Mainboard/generators/gen_script_commands.ml @@ -56,6 +56,19 @@ let rec print path caml_path = function | Record _ -> () | Module(name, items) -> + let items = + if name = "common" then begin + printf "let __type_card name = keyword name [(\"interface\", `Interface); (\"sensor\", `Sensor); (\"motor\", `Motor)] in\n"; + let card = typ "card" in + List.map + (function + | Request req -> Request{ req with req_args = Arg("card", card) :: req.req_args } + | Command cmd -> Command{ cmd with cmd_args = Arg("card", card) :: cmd.cmd_args } + | item -> item) + items + end else + items + in List.iter (print (sprintf "%s; \"%s\"" path (String.lowercase name)) (caml_path ^ Name.uid name ^ ".")) items let () = diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 6657a67..7660c91 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -203,14 +203,6 @@ struct | `Sensor -> krobot.sensor.card_state | `Motor -> krobot.motor.card_state - include OBus_interface.Make(struct let name = "fr.krobot.Card" end) - - OP_method GetFirmwareBuild : string - OP_method GetBoardInfo : string - OP_method Bootloader : unit - OP_method Reset : unit - OP_method Test : unit - let proxy krobot card = OBus_proxy.make krobot.peer ["fr"; "krobot"; "Cards"; (match card with @@ -218,9 +210,12 @@ struct | `Sensor -> "Sensor" | `Motor -> "Motor")] - let get_firmware_build krobot card = get_firmware_build (proxy krobot card) - let get_board_info krobot card = get_board_info (proxy krobot card) - let bootloader krobot card = bootloader (proxy krobot card) - let reset krobot card = reset (proxy krobot card) - let test krobot card = test (proxy krobot card) + let op_method_call member typ krobot card = + OBus_proxy.method_call (proxy krobot card) ~interface:"fr.krobot.Card" ~member typ + + OP_method GetFirmwareBuild : string + OP_method GetBoardInfo : string + OP_method Bootloader : unit + OP_method Reset : unit + OP_method Test : unit end hooks/post-receive -- krobot |