From: Jérémie D. <Ba...@us...> - 2010-03-02 13:26:32
|
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 3d05cb1b4e6b5a7976548aab8e639572d47d57ab (commit) from 2e41773908b10cad366a5395fa1f35b5477a1b6a (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 3d05cb1b4e6b5a7976548aab8e639572d47d57ab Author: Jérémie Dimino <je...@di...> Date: Tue Mar 2 14:25:31 2010 +0100 Use a more suitable proxy type for cards ----------------------------------------------------------------------- Changes: diff --git a/PC_Mainboard/clients/controller.ml b/PC_Mainboard/clients/controller.ml index 3f01691..cd91d27 100644 --- a/PC_Mainboard/clients/controller.ml +++ b/PC_Mainboard/clients/controller.ml @@ -240,9 +240,9 @@ let rec draw krobot = | `Absent -> [fg lred; textf "%s card is absent" name] | `Present -> [textf "%s card is present" name] in - Draw.textc zone x 3 (text_of_state "interface" (React.S.value (Krobot.Card.state krobot `Interface))); - Draw.textc zone x 4 (text_of_state "sensor" (React.S.value (Krobot.Card.state krobot `Sensor))); - Draw.textc zone x 5 (text_of_state "motor" (React.S.value (Krobot.Card.state krobot `Motor))); + Draw.textc zone x 3 (text_of_state "interface" (React.S.value (Krobot.Card.state (krobot, `Interface)))); + Draw.textc zone x 4 (text_of_state "sensor" (React.S.value (Krobot.Card.state (krobot, `Sensor)))); + Draw.textc zone x 5 (text_of_state "motor" (React.S.value (Krobot.Card.state (krobot, `Motor)))); let date = Unix.gettimeofday () in let text_of_motor_state mode until = if date < until then @@ -415,9 +415,9 @@ lwt () = notify (Krobot.jack krobot); notify (Krobot.inhibited_forward_until krobot); notify (Krobot.inhibited_backward_until krobot); - notify (Krobot.Card.state krobot `Interface); - notify (Krobot.Card.state krobot `Sensor); - notify (Krobot.Card.state krobot `Motor); + notify (Krobot.Card.state (krobot, `Interface)); + notify (Krobot.Card.state (krobot, `Sensor)); + notify (Krobot.Card.state (krobot, `Motor)); notify services; (* Redraw immedlatly the screen when [signal] changes: *) diff --git a/PC_Mainboard/clients/info.ml b/PC_Mainboard/clients/info.ml index 99519db..7efb03a 100644 --- a/PC_Mainboard/clients/info.ml +++ b/PC_Mainboard/clients/info.ml @@ -13,10 +13,10 @@ open Lwt open Lwt_io let print_card krobot card = - match React.S.value (Krobot.Card.state krobot card) with + match React.S.value (Krobot.Card.state (krobot, card)) with | `Present -> - lwt firmware_build = Krobot.Card.get_firmware_build krobot card - and board_info = Krobot.Card.get_board_info krobot card in + lwt firmware_build = Krobot.Card.get_firmware_build (krobot, card) + and board_info = Krobot.Card.get_board_info (krobot, card) in let name = Krobot.Card.name card in lwt () = printl "==========" in lwt () = printlf "card.%s.state = present" name in diff --git a/PC_Mainboard/clients/script.ml b/PC_Mainboard/clients/script.ml index 166ce54..f57651b 100644 --- a/PC_Mainboard/clients/script.ml +++ b/PC_Mainboard/clients/script.ml @@ -234,11 +234,11 @@ let () = ("sensor", `Sensor)] in register ~path:["card"] "bootloader" (f1 card) - (fun logger -> Krobot.Card.bootloader); + (fun logger krobot card -> Krobot.Card.bootloader (krobot, card)); register ~path:["card"] "reset" (f1 card) - (fun logger -> Krobot.Card.reset); + (fun logger krobot card -> Krobot.Card.reset (krobot, card)); register ~path:["card"] "test" (f1 card) - (fun logger -> Krobot.Card.test); + (fun logger krobot card -> Krobot.Card.test (krobot, card)); (* +---------------------------------------------------------------+ | Range finders | diff --git a/PC_Mainboard/generators/gen_dbus_imports.ml b/PC_Mainboard/generators/gen_dbus_imports.ml index 2f27622..d4d5f1d 100644 --- a/PC_Mainboard/generators/gen_dbus_imports.ml +++ b/PC_Mainboard/generators/gen_dbus_imports.ml @@ -69,22 +69,19 @@ let () = print_string "\ open OBus_pervasives module Card = struct - OP_interface \"fr.krobot.Card.Unsafe\" + module Proxy = OBus_proxy.Make + (struct + type proxy = Krobot.t * Krobot.Card.card + let cast (krobot, card) = + OBus_proxy.make (Krobot.peer krobot) + [\"fr\"; \"krobot\"; \"Cards\"; (match card with + | `Interface -> \"Interface\" + | `Sensor -> \"Sensor\" + | `Motor -> \"Motor\")] + let make proxy = failwith \"not implemented\" + end) + OP_interface(Proxy) \"fr.krobot.Card.Unsafe\" "; List.iter (print " ") card; - print_string "\ - let proxy krobot (card : Krobot.Card.card) = - OBus_proxy.make (Krobot.peer krobot) - [\"fr\"; \"krobot\"; \"Cards\"; (match card with - | `Interface -> \"Interface\" - | `Sensor -> \"Sensor\" - | `Motor -> \"Motor\")] -"; - List.iter (function - | Request{ req_name = name } | Command{ cmd_name = name } -> - let name = Name.lid name in - printf " let %s krobot card = %s (proxy krobot card)\n" name name - | _ -> - ()) card; printf "end\n"; List.iter (print "") interfaces diff --git a/PC_Mainboard/generators/gen_script_commands.ml b/PC_Mainboard/generators/gen_script_commands.ml index 020bf5d..8e48838 100644 --- a/PC_Mainboard/generators/gen_script_commands.ml +++ b/PC_Mainboard/generators/gen_script_commands.ml @@ -10,12 +10,13 @@ open Printf open Interface -let print_common path caml_path name args repl = +let print_common is_card path caml_path name args repl = printf " register ~path:[%s] \"%s\" (f%d" path name (List.fold_left (fun n arg -> match arg with | Arg _ -> n + 1 - | Cst _ -> n) 0 args); + | Cst _ -> n) (if is_card then 1 else 0) args); + if is_card then printf " (__type_card \"name\")"; List.iter (function | Arg(name, { caml_type = "int" }) -> printf " (int \"%s\")" name @@ -27,15 +28,17 @@ let print_common path caml_path name args repl = ()) args; printf ")\n"; printf " (fun logger krobot"; + if is_card then printf " card"; List.iter (function | Arg(name, typ) -> printf " %s" (Name.lid name) | Cst _ -> ()) args; printf " ->\n"; - printf " lwt (%s) = Krobot_unsafe.%s%s krobot" + printf " lwt (%s) = Krobot_unsafe.%s%s" (String.concat ", " (List.map (fun (name, typ) -> Name.lid name) repl)) caml_path (Name.lid name); + if is_card then printf " (krobot, card)" else printf " krobot"; List.iter (function | Arg(name, typ) -> printf " %s" (Name.lid name) @@ -48,16 +51,16 @@ let print_common path caml_path name args repl = repl; printf " Lwt.return ());\n" -let rec print path caml_path = function +let rec print is_card path caml_path = function | Request req -> - print_common path caml_path req.req_name req.req_args + print_common is_card path caml_path req.req_name req.req_args (List.map (function | Arg(name, typ) -> (name, typ) | Cst _ -> failwith "constants not allow in replies") req.req_repl) | Command cmd -> - print_common path caml_path cmd.cmd_name cmd.cmd_args [] + print_common is_card path caml_path cmd.cmd_name cmd.cmd_args [] | Enum enum -> printf " let __type_%s name = keyword name [" (Name.lid enum.enum_name); List.iter (fun (name, code) -> @@ -80,20 +83,12 @@ let rec print path caml_path = function printf "]) ^ \"}\" in\n"; printf " let _ = print_%s in\n" (Name.lid record.rec_name) | Module(name, items) -> - List.iter (print (sprintf "%s; \"%s\"" path (String.lowercase name)) (caml_path ^ Name.uid name ^ ".")) items + List.iter (print false (sprintf "%s; \"%s\"" path (String.lowercase name)) (caml_path ^ Name.uid name ^ ".")) items let () = printf "open Script_commands\n"; printf "let register () =\n"; printf " let __type_card name = keyword name [(\"interface\", `Interface); (\"sensor\", `Sensor); (\"motor\", `Motor)] in\n"; - let card_type = typ "card" in - List.iter - (print "\"unsafe\"; \"card\"" "Card.") - (List.map - (function - | Request req -> Request{ req with req_args = Arg("card", card_type) :: req.req_args } - | Command cmd -> Command{ cmd with cmd_args = Arg("card", card_type) :: cmd.cmd_args } - | item -> item) - card); - List.iter (print "\"unsafe\"" "") interfaces; + List.iter (print true "\"unsafe\"; \"card\"" "Card.") card; + List.iter (print false "\"unsafe\"" "") interfaces; printf " ()" diff --git a/PC_Mainboard/lib_krobot/krobot.ml b/PC_Mainboard/lib_krobot/krobot.ml index 4c6279f..62a7c10 100644 --- a/PC_Mainboard/lib_krobot/krobot.ml +++ b/PC_Mainboard/lib_krobot/krobot.ml @@ -205,28 +205,27 @@ struct | `Sensor -> "sensor" | `Motor -> "motor" - let state krobot = function + let state (krobot, card) = match card with | `Interface -> krobot.interface.card_state | `Sensor -> krobot.sensor.card_state | `Motor -> krobot.motor.card_state - let proxy krobot card = - OBus_proxy.make krobot.peer - ["fr"; "krobot"; "Cards"; (match card with - | `Interface -> "Interface" - | `Sensor -> "Sensor" - | `Motor -> "Motor")] + module Proxy = OBus_proxy.Make + (struct + type proxy = t * card + let cast (krobot, card) = + OBus_proxy.make krobot.peer + ["fr"; "krobot"; "Cards"; (match card with + | `Interface -> "Interface" + | `Sensor -> "Sensor" + | `Motor -> "Motor")] + let make proxy = failwith "not implemented" + end) - OP_interface "fr.krobot.Card" + OP_interface(Proxy) "fr.krobot.Card" OP_method GetFirmwareBuild : string OP_method GetBoardInfo : string OP_method Bootloader : unit OP_method Reset : unit OP_method Test : unit - - 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) end diff --git a/PC_Mainboard/lib_krobot/krobot.mli b/PC_Mainboard/lib_krobot/krobot.mli index 0dbb1c6..4dde27c 100644 --- a/PC_Mainboard/lib_krobot/krobot.mli +++ b/PC_Mainboard/lib_krobot/krobot.mli @@ -118,14 +118,14 @@ module Card : sig val name : card -> string (** Returns the name of a card *) - val state : t -> card -> Types.card_state React.signal + val state : t * card -> Types.card_state React.signal (** Returns the status of one of the card of the krobot *) - val bootloader : t -> card -> unit Lwt.t + val bootloader : t * card -> unit Lwt.t (** Put the card into bootloader mode *) - val get_firmware_build : t -> card -> string Lwt.t - val get_board_info : t -> card -> string Lwt.t - val reset : t -> card -> unit Lwt.t - val test : t -> card -> unit Lwt.t + val get_firmware_build : t * card -> string Lwt.t + val get_board_info : t * card -> string Lwt.t + val reset : t * card -> unit Lwt.t + val test : t * card -> unit Lwt.t end hooks/post-receive -- krobot |