|
From: Jérémie D. <Ba...@us...> - 2010-05-10 12:43:51
|
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 39d1cabf96ca1b345c167b091859f2e93f70be2f (commit)
via c4b37f2e96d1d82a3c6581ae87ea981016b67db2 (commit)
from f4da06fd90fd328cc6300caf2471f94a1cf63af5 (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 39d1cabf96ca1b345c167b091859f2e93f70be2f
Author: Jérémie Dimino <je...@di...>
Date: Mon May 10 14:40:48 2010 +0200
reorganize devices/services names
commit c4b37f2e96d1d82a3c6581ae87ea981016b67db2
Author: Jérémie Dimino <je...@di...>
Date: Mon May 10 14:06:06 2010 +0200
refactoring
-----------------------------------------------------------------------
Changes:
diff --git a/info/control/clients/check.ml b/info/control/clients/check.ml
index 6a5f87b..4a59a31 100644
--- a/info/control/clients/check.ml
+++ b/info/control/clients/check.ml
@@ -27,7 +27,7 @@ lwt () =
(fun () ->
lwt () = Krobot.Gate.enable krobot in
lwt () = printl "opening the gate" in
- lwt () = Krobot.Gate.release krobot in
+ lwt () = Krobot.Gate.open_ krobot in
lwt () = Lwt_unix.sleep 0.5 in
lwt () = printl "closing the gate" in
lwt () = Krobot.Gate.close krobot in
diff --git a/info/control/clients/controller.ml b/info/control/clients/controller.ml
index 5e7d435..dc4cda0 100644
--- a/info/control/clients/controller.ml
+++ b/info/control/clients/controller.ml
@@ -162,19 +162,19 @@ let draw krobot =
let name_color = lwhite in
let driver = List.mem "Driver" (React.S.value services) in
- lwt devices =
+ lwt services_status =
if driver then
- OBus_property.get (Krobot.devices_status krobot)
+ OBus_property.get (Krobot.services_status krobot)
else
return {
- Krobot.dev_compass = false;
- Krobot.dev_range_finders = false;
- Krobot.dev_logic_sensors = false;
- Krobot.dev_motor = false;
- Krobot.dev_ax12 = false;
- Krobot.dev_lcd = false;
- Krobot.dev_infrared = false;
- Krobot.dev_power = false;
+ Krobot.srv_compass = false;
+ Krobot.srv_range_finders = false;
+ Krobot.srv_logic_sensors = false;
+ Krobot.srv_motor = false;
+ Krobot.srv_ax12 = false;
+ Krobot.srv_lcd = false;
+ Krobot.srv_infrared = false;
+ Krobot.srv_power = false;
}
in
@@ -222,7 +222,7 @@ let draw krobot =
let zone = Zone.inner screen in
lwt () =
- if driver && devices.Krobot.dev_range_finders then begin
+ if driver && services_status.Krobot.srv_range_finders then begin
lwt range_finders = OBus_property.get (Krobot.Range_finders.measures krobot) in
for i = 0 to 7 do
Draw.textc zone 0 i [textf "%d : " i; text (Text.repeat (range_finders.(i) * 14 / 3146) "=")]
@@ -237,7 +237,7 @@ let draw krobot =
in
lwt () =
- if driver && devices.Krobot.dev_logic_sensors then begin
+ if driver && services_status.Krobot.srv_logic_sensors then begin
lwt logic_sensors = OBus_property.get (Krobot.Logic_sensors.states krobot) in
for i = 0 to 7 do
let j = i * 2 in
@@ -290,7 +290,7 @@ let draw krobot =
in
let x = x + 12 in
lwt () =
- if driver && devices.Krobot.dev_compass then begin
+ if driver && services_status.Krobot.srv_compass then begin
lwt compass = OBus_property.get (Krobot.Compass.measure krobot) in
Draw.textf zone x 2 "compass = %d" compass;
return ()
@@ -307,7 +307,7 @@ let draw krobot =
[text mode; text "OK"]
in
lwt () =
- if driver && devices.Krobot.dev_motor then begin
+ if driver && services_status.Krobot.srv_motor then begin
lwt forward = OBus_property.get (Krobot.Motors.inhibit_forward_until krobot)
and backward = OBus_property.get (Krobot.Motors.inhibit_backward_until krobot) in
Draw.textc zone x 3 (text_of_motor_state "move forward: " forward);
@@ -321,7 +321,7 @@ let draw krobot =
end
in
lwt () =
- if driver && devices.Krobot.dev_infrared then begin
+ if driver && services_status.Krobot.srv_infrared then begin
lwt i1, i2 = OBus_property.get (Krobot.Infrared.states krobot) in
Draw.textc zone x 5 [textf "infrared 1: %d" i1];
Draw.textc zone x 6 [textf "infrared 2: %d" i2];
@@ -334,7 +334,7 @@ let draw krobot =
end
in
lwt () =
- if driver && devices.Krobot.dev_power then begin
+ if driver && services_status.Krobot.srv_power then begin
lwt current = OBus_property.get (Krobot.Power.current krobot) in
Draw.textc zone x 7 [textf "current: %d mA" current];
return ()
@@ -524,7 +524,7 @@ lwt () =
notify_property (Krobot.Card.state krobot `Sensor);
notify_property (Krobot.Card.state krobot `Motor);
notify_property (Krobot.Card.state krobot `Monitoring);
- notify_property (Krobot.devices_status krobot);
+ notify_property (Krobot.services_status krobot);
notify_property (Krobot.Infrared.states krobot);
notify_property (Krobot.Power.current krobot);
]
diff --git a/info/control/clients/script.ml b/info/control/clients/script.ml
index d78724a..e244b80 100644
--- a/info/control/clients/script.ml
+++ b/info/control/clients/script.ml
@@ -520,9 +520,9 @@ let () =
register ~path:["gate"] "close" f0
(fun logger krobot ->
Krobot.Gate.close krobot);
- register ~path:["gate"] "release" f0
+ register ~path:["gate"] "open" f0
(fun logger krobot ->
- Krobot.Gate.release krobot);
+ Krobot.Gate.open_ krobot);
register ~path:["gate"] "hold-closed" f0
(fun logger krobot ->
Krobot.Gate.hold_closed krobot);
diff --git a/info/control/driver/driver.ml b/info/control/driver/driver.ml
index a2bf6d9..c1631f1 100644
--- a/info/control/driver/driver.ml
+++ b/info/control/driver/driver.ml
@@ -54,23 +54,33 @@ let get_card card =
"the %s card is currently unavailable"
card.card_name
-(* List of services, by cards *)
+(* +-----------------------------------------------------------------+
+ | Services and devices |
+ +-----------------------------------------------------------------+ *)
+
let services = [
+ card_interface, ["Claws"; "Compass"; "Grip"; "LCD"; "Gate"; "Infrared"];
+ card_monitoring, ["Power"];
+ card_sensor, ["LogicSensors"; "RangeFinders"];
+ card_motor, ["Motors"];
+]
+
+let devices = [
card_interface, ["Servo"; "Compass"; "AX12"; "LCD"; "Gate"; "Infrared"];
card_monitoring, ["Power"];
card_sensor, ["LogicSensors"; "RangeFinders"];
card_motor, ["Motors"];
]
-let devices_status, set_devices_status =
+let services_status, set_services_status =
React.S.create ~eq:(String_map.equal (=))
(List.fold_left
(fun map service -> String_map.add service false map)
String_map.empty
(List.concat (List.map snd services)))
-let set_device_status device status =
- set_devices_status (String_map.add device status (React.S.value devices_status))
+let set_service_status service status =
+ set_services_status (String_map.add service status (React.S.value services_status))
(* +-----------------------------------------------------------------+
| USB card polling |
@@ -111,8 +121,7 @@ struct
let obus =
OBus_object.make
- ~interfaces:[Export_unsafe.interface Name.name card]
- ["fr"; "krobot"; "Devices"; Name.name]
+ ["fr"; "krobot"; "Services"; Name.name]
let () =
OBus_object.attach obus ()
@@ -121,9 +130,9 @@ struct
Lwt_signal.always_notify
(function
| Some _ ->
- set_device_status Name.name true
+ set_service_status Name.name true
| None ->
- set_device_status Name.name false)
+ set_service_status Name.name false)
card.card_card
end
@@ -135,7 +144,7 @@ module Power =
struct
include Service(struct let name = "Power" end)
- open Krobot_interfaces.Fr_krobot_Device_Power
+ open Krobot_interfaces.Fr_krobot_Service_Power
let set_buzzer_state state =
USBCard.call Commands.Power.set_buzzer_state (get_card card) state
@@ -166,7 +175,7 @@ module Compass =
struct
include Service(struct let name = "Compass" end)
- open Krobot_interfaces.Fr_krobot_Device_Compass
+ open Krobot_interfaces.Fr_krobot_Service_Compass
let value = poll ~update_delay:1.0 card 0 (fun card -> snd =|< USBCard.call Commands.Compass.get card ())
@@ -186,7 +195,7 @@ module LCD =
struct
include Service(struct let name = "LCD" end)
- open Krobot_interfaces.Fr_krobot_Device_LCD
+ open Krobot_interfaces.Fr_krobot_Service_LCD
let set_lcd lines =
if List.length lines > 4 || List.exists (fun line -> String.length line > 20) lines then
@@ -211,7 +220,7 @@ struct
OBus_object.add_interfaces obus
[make ~notify_mode
{
- m_SetLCD = (
+ m_Set = (
fun ctx () lines ->
lwt () = set_lcd lines in
OBus_method.return ctx ()
@@ -230,14 +239,14 @@ struct
end
(* +-----------------------------------------------------------------+
- | Servo |
+ | Claws |
+-----------------------------------------------------------------+ *)
-module Servo =
+module Claws =
struct
- include Service(struct let name = "Servo" end)
+ include Service(struct let name = "Claws" end)
- open Krobot_interfaces.Fr_krobot_Device_Servo
+ open Krobot_interfaces.Fr_krobot_Service_Claws
let claws_enable () =
USBCard.call Commands.Servo.set_config (get_card card) (0b10100, 0)
@@ -257,27 +266,27 @@ struct
let () =
OBus_object.add_interfaces obus
[make ~notify_mode {
- m_ClawsEnable = (
+ m_Enable = (
fun ctx obj () ->
lwt result = claws_enable obj in
OBus_method.return ctx result
);
- m_ClawsDisable = (
+ m_Disable = (
fun ctx obj () ->
lwt result = claws_disable obj in
OBus_method.return ctx result
);
- m_ClawsOpen = (
+ m_Open = (
fun ctx obj () ->
lwt result = claws_open obj in
OBus_method.return ctx result
);
- m_ClawsClose = (
+ m_Close = (
fun ctx obj () ->
lwt result = claws_close obj in
OBus_method.return ctx result
);
- m_ClawsTake = (
+ m_Take = (
fun ctx obj () ->
lwt result = claws_take obj in
OBus_method.return ctx result
@@ -286,52 +295,60 @@ struct
end
(* +-----------------------------------------------------------------+
- | AX12 |
+ | AX12 helpers |
+-----------------------------------------------------------------+ *)
-module AX12 =
+type ax12_action = {
+ aa_id : int;
+ aa_position : int;
+ aa_velocity : int;
+}
+
+let set_ax12 = function
+ | [] ->
+ return ()
+ | [action] ->
+ USBCard.call Commands.AX12.goto
+ (get_card card_interface)
+ (action.aa_id,
+ action.aa_position,
+ action.aa_velocity,
+ `Now)
+ | actions ->
+ lwt () =
+ Lwt_list.iter_p
+ (fun action ->
+ USBCard.call Commands.AX12.goto
+ (get_card card_interface)
+ (action.aa_id,
+ action.aa_position,
+ action.aa_velocity,
+ `Action))
+ actions
+ in
+ USBCard.call Commands.AX12.action (get_card card_interface) 0xfe
+
+(* +-----------------------------------------------------------------+
+ | Grip |
+ +-----------------------------------------------------------------+ *)
+
+module Grip =
struct
- include Service(struct let name = "AX12" end)
+ include Service(struct let name = "Grip" end)
- open Krobot_interfaces.Fr_krobot_Device_AX12
+ open Krobot_interfaces.Fr_krobot_Service_Grip
(* +---------------------------------------------------------------+
| High-level commands |
+---------------------------------------------------------------+ *)
- type ax12_action = {
- aa_id : int;
- aa_position : int;
- aa_velocity : int;
- }
-
- let set_ax12 actions =
- lwt () =
- Lwt_list.iter_p
- (fun action ->
- USBCard.call Commands.AX12.goto
- (get_card card)
- (action.aa_id,
- action.aa_position,
- action.aa_velocity,
- `Action))
- actions
- in
- USBCard.call Commands.AX12.action (get_card card) 0xfe
-
let grip_up () =
- set_ax12 [(*{ aa_id = 1;
- aa_position = 190;
- aa_velocity = 50 };*)
- { aa_id = 2;
+ set_ax12 [{ aa_id = 2;
aa_position = 180;
aa_velocity = 50 }]
let grip_down () =
- set_ax12 [(*{ aa_id = 1;
- aa_position = 490;
- aa_velocity = 50 };*)
- { aa_id = 2;
+ set_ax12 [{ aa_id = 2;
aa_position = 510;
aa_velocity = 50 };
{ aa_id = 3;
@@ -361,27 +378,27 @@ struct
OBus_object.add_interfaces obus
[make ~notify_mode
{
- m_GripUp = (
+ m_Up = (
fun ctx obj () ->
lwt result = grip_up obj in
OBus_method.return ctx result
);
- m_GripDown = (
+ m_Down = (
fun ctx obj () ->
lwt result = grip_down obj in
OBus_method.return ctx result
);
- m_GripOpen = (
+ m_Open = (
fun ctx obj () ->
lwt result = grip_open obj in
OBus_method.return ctx result
);
- m_GripClose = (
+ m_Close = (
fun ctx obj () ->
lwt result = grip_close obj in
OBus_method.return ctx result
);
- m_GripRelease = (
+ m_Release = (
fun ctx obj () ->
lwt result = grip_release obj in
OBus_method.return ctx result
@@ -397,7 +414,7 @@ module Infrared =
struct
include Service(struct let name = "Infrared" end)
- open Krobot_interfaces.Fr_krobot_Device_Infrared
+ open Krobot_interfaces.Fr_krobot_Service_Infrared
let states =
poll card (0, 0)
@@ -406,13 +423,19 @@ struct
return (ar.(0), ar.(1)))
let go_left () =
- USBCard.call Commands.AX12.goto (get_card card_interface) (1, 750, 200, `Now)
+ set_ax12 [{ aa_id = 1;
+ aa_position = 750;
+ aa_velocity = 200 }]
let go_right () =
- USBCard.call Commands.AX12.goto (get_card card_interface) (1, 250, 200, `Now)
+ set_ax12 [{ aa_id = 1;
+ aa_position = 250;
+ aa_velocity = 200 }]
let go_center () =
- USBCard.call Commands.AX12.goto (get_card card_interface) (1, 550, 200, `Now)
+ set_ax12 [{ aa_id = 1;
+ aa_position = 514;
+ aa_velocity = 200 }]
let () =
OBus_object.add_interfaces obus
@@ -445,7 +468,7 @@ module Logic_sensors =
struct
include Service(struct let name = "LogicSensors" end)
- open Krobot_interfaces.Fr_krobot_Device_LogicSensors
+ open Krobot_interfaces.Fr_krobot_Service_LogicSensors
let value = poll card (Array.make 16 false) (fun card -> USBCard.call Commands.Logic_sensors.get_state card ())
@@ -465,7 +488,7 @@ module Range_finders =
struct
include Service(struct let name = "RangeFinders" end)
- open Krobot_interfaces.Fr_krobot_Device_RangeFinders
+ open Krobot_interfaces.Fr_krobot_Service_RangeFinders
let get_calibration id =
USBCard.call Commands.Range_finders.get_calibration (get_card card) id
@@ -523,7 +546,7 @@ module Gate =
struct
include Service(struct let name = "Gate" end)
- open Krobot_interfaces.Fr_krobot_Device_Gate
+ open Krobot_interfaces.Fr_krobot_Service_Gate
let enable () =
USBCard.call Commands.Gate.enable (get_card card) (`Both)
@@ -562,7 +585,7 @@ struct
lwt result = close obj in
OBus_method.return ctx result
);
- m_Release = (
+ m_Open = (
fun ctx obj () ->
lwt result = release obj in
OBus_method.return ctx result
@@ -588,7 +611,7 @@ module Motors =
struct
include Service(struct let name = "Motors" end)
- open Krobot_interfaces.Fr_krobot_Device_Motors
+ open Krobot_interfaces.Fr_krobot_Service_Motors
type trajectory = {
trajectory : [ `Forward | `Backward | `Left | `Right | `Goto ];
@@ -995,20 +1018,20 @@ struct
Lwt.wakeup done_wakener ();
return ()
- let devices_status =
+ let services_status =
React.S.map
(fun map ->
String_map.fold
(fun device status acc -> (device, status) :: acc)
map [])
- devices_status
+ services_status
let () =
OBus_object.attach obus ();
OBus_object.add_interfaces obus
[make ~notify_mode
{
- p_DevicesStatus = (fun () -> devices_status);
+ p_ServicesStatus = (fun () -> services_status);
m_Shutdown = (
fun ctx () () ->
lwt () = shutdown ctx () in
@@ -1243,9 +1266,9 @@ lwt () =
return ())
in
- OBus_object.export bus Servo.obus;
+ OBus_object.export bus Claws.obus;
OBus_object.export bus Compass.obus;
- OBus_object.export bus AX12.obus;
+ OBus_object.export bus Grip.obus;
OBus_object.export bus LCD.obus;
OBus_object.export bus Power.obus;
OBus_object.export bus Logic_sensors.obus;
@@ -1261,6 +1284,22 @@ lwt () =
OBus_object.export bus Manager.obus;
+ (* Unsafe interfaces *)
+
+ List.iter
+ (fun (card, devices) ->
+ List.iter
+ (fun device ->
+ let obus =
+ OBus_object.make
+ ~interfaces:[Export_unsafe.interface device card]
+ ["fr"; "krobot"; "Devices"; device]
+ in
+ OBus_object.attach obus ();
+ OBus_object.export bus obus)
+ devices)
+ devices;
+
lwt () = Lwt_log.notice ~section "ready, waiting for requests" in
lwt () = done_waiter in
OBus_connection.close bus
diff --git a/info/control/driver/export_unsafe.ml b/info/control/driver/export_unsafe.ml
index b5b6a12..f37fbb9 100644
--- a/info/control/driver/export_unsafe.ml
+++ b/info/control/driver/export_unsafe.ml
@@ -53,4 +53,4 @@ let interface name card =
let interface_commands = List.assoc name commands in
match name with
| "Card" -> make_interface card "fr.krobot.Card.Unsafe" interface_commands
- | dev -> make_interface card ("fr.krobot.Device." ^ name ^ ".Unsafe") interface_commands
+ | dev -> make_interface card ("fr.krobot.Device." ^ name) interface_commands
diff --git a/info/control/lib-krobot/krobot.ml b/info/control/lib-krobot/krobot.ml
index 851a0ce..9ab5915 100644
--- a/info/control/lib-krobot/krobot.ml
+++ b/info/control/lib-krobot/krobot.ml
@@ -32,35 +32,38 @@ let card krobot card =
| `Motor -> "Motor"
| `Monitoring -> "Monitoring" )]
+let service krobot name =
+ OBus_proxy.make krobot ["fr"; "krobot"; "Services"; name]
+
let device krobot name =
OBus_proxy.make krobot ["fr"; "krobot"; "Devices"; name]
-type devices_status = {
- dev_compass : bool;
- dev_range_finders : bool;
- dev_logic_sensors : bool;
- dev_motor : bool;
- dev_ax12 : bool;
- dev_lcd : bool;
- dev_infrared : bool;
- dev_power : bool;
+type services_status = {
+ srv_compass : bool;
+ srv_range_finders : bool;
+ srv_logic_sensors : bool;
+ srv_motor : bool;
+ srv_ax12 : bool;
+ srv_lcd : bool;
+ srv_infrared : bool;
+ srv_power : bool;
}
-let devices_status krobot =
+let services_status krobot =
OBus_property.map_r
(fun l -> {
- dev_compass = List.assoc "Compass" l;
- dev_range_finders = List.assoc "RangeFinders" l;
- dev_logic_sensors = List.assoc "LogicSensors" l;
- dev_motor = List.assoc "Motors" l;
- dev_ax12 = List.assoc "AX12" l;
- dev_lcd = List.assoc "LCD" l;
- dev_infrared = List.assoc "Infrared" l;
- dev_power = List.assoc "Power" l;
+ srv_compass = List.assoc "Compass" l;
+ srv_range_finders = List.assoc "RangeFinders" l;
+ srv_logic_sensors = List.assoc "LogicSensors" l;
+ srv_motor = List.assoc "Motors" l;
+ srv_ax12 = List.assoc "Grip" l;
+ srv_lcd = List.assoc "LCD" l;
+ srv_infrared = List.assoc "Infrared" l;
+ srv_power = List.assoc "Power" l;
})
(OBus_property.make
~notify_mode
- Krobot_interfaces.Fr_krobot_Manager.p_DevicesStatus
+ Krobot_interfaces.Fr_krobot_Manager.p_ServicesStatus
(OBus_proxy.make krobot ["fr"; "krobot"; "Manager"]))
(* +-----------------------------------------------------------------+
@@ -69,21 +72,21 @@ let devices_status krobot =
module Infrared =
struct
- open Krobot_interfaces.Fr_krobot_Device_Infrared
+ open Krobot_interfaces.Fr_krobot_Service_Infrared
let states krobot =
OBus_property.map_r
(fun (i1, i2) -> (Int32.to_int i1, Int32.to_int i2))
- (OBus_property.make ~notify_mode p_States (device krobot "Infrared"))
+ (OBus_property.make ~notify_mode p_States (service krobot "Infrared"))
let go_left krobot =
- OBus_method.call m_GoLeft (device krobot "Infrared") ()
+ OBus_method.call m_GoLeft (service krobot "Infrared") ()
let go_right krobot =
- OBus_method.call m_GoRight (device krobot "Infrared") ()
+ OBus_method.call m_GoRight (service krobot "Infrared") ()
let go_center krobot =
- OBus_method.call m_GoCenter (device krobot "Infrared") ()
+ OBus_method.call m_GoCenter (service krobot "Infrared") ()
end
(* +-----------------------------------------------------------------+
@@ -92,13 +95,13 @@ end
module Power =
struct
- open Krobot_interfaces.Fr_krobot_Device_Power
+ open Krobot_interfaces.Fr_krobot_Service_Power
let set_buzzer_state krobot state =
- OBus_method.call m_SetBuzzerState (device krobot "Power") state
+ OBus_method.call m_SetBuzzerState (service krobot "Power") state
let current krobot =
- OBus_property.map_r Int32.to_int (OBus_property.make ~notify_mode p_Current (device krobot "Power"))
+ OBus_property.map_r Int32.to_int (OBus_property.make ~notify_mode p_Current (service krobot "Power"))
end
(* +-----------------------------------------------------------------+
@@ -107,25 +110,25 @@ end
module Gate =
struct
- open Krobot_interfaces.Fr_krobot_Device_Gate
+ open Krobot_interfaces.Fr_krobot_Service_Gate
let enable krobot =
- OBus_method.call m_Enable (device krobot "Gate") ()
+ OBus_method.call m_Enable (service krobot "Gate") ()
let disable krobot =
- OBus_method.call m_Disable (device krobot "Gate") ()
+ OBus_method.call m_Disable (service krobot "Gate") ()
let close krobot =
- OBus_method.call m_Close (device krobot "Gate") ()
+ OBus_method.call m_Close (service krobot "Gate") ()
- let release krobot =
- OBus_method.call m_Release (device krobot "Gate") ()
+ let open_ krobot =
+ OBus_method.call m_Open (service krobot "Gate") ()
let hold_closed krobot =
- OBus_method.call m_HoldClosed (device krobot "Gate") ()
+ OBus_method.call m_HoldClosed (service krobot "Gate") ()
let stop krobot =
- OBus_method.call m_Stop (device krobot "Gate") ()
+ OBus_method.call m_Stop (service krobot "Gate") ()
end
(* +-----------------------------------------------------------------+
@@ -134,10 +137,10 @@ end
module Compass =
struct
- open Krobot_interfaces.Fr_krobot_Device_Compass
+ open Krobot_interfaces.Fr_krobot_Service_Compass
let measure krobot =
- OBus_property.map_r Int32.to_int (OBus_property.make p_Value ~notify_mode (device krobot "Compass"))
+ OBus_property.map_r Int32.to_int (OBus_property.make p_Value ~notify_mode (service krobot "Compass"))
end
(* +-----------------------------------------------------------------+
@@ -146,12 +149,12 @@ end
module Logic_sensors =
struct
- open Krobot_interfaces.Fr_krobot_Device_LogicSensors
+ open Krobot_interfaces.Fr_krobot_Service_LogicSensors
let states krobot =
OBus_property.map_r
Array.of_list
- (OBus_property.make p_Value ~notify_mode (device krobot "LogicSensors"))
+ (OBus_property.make p_Value ~notify_mode (service krobot "LogicSensors"))
end
(* +-----------------------------------------------------------------+
@@ -160,16 +163,16 @@ end
module LCD =
struct
- open Krobot_interfaces.Fr_krobot_Device_LCD
+ open Krobot_interfaces.Fr_krobot_Service_LCD
let set krobot lines =
- OBus_method.call m_SetLCD (device krobot "LCD") lines
+ OBus_method.call m_Set (service krobot "LCD") lines
let backlight_on krobot =
- OBus_method.call m_BacklightOn (device krobot "LCD") ()
+ OBus_method.call m_BacklightOn (service krobot "LCD") ()
let backlight_off krobot =
- OBus_method.call m_BacklightOff (device krobot "LCD") ()
+ OBus_method.call m_BacklightOff (service krobot "LCD") ()
end
(* +-----------------------------------------------------------------+
@@ -178,25 +181,25 @@ end
module Range_finders =
struct
- open Krobot_interfaces.Fr_krobot_Device_RangeFinders
+ open Krobot_interfaces.Fr_krobot_Service_RangeFinders
let measures krobot =
OBus_property.map_r
(fun l -> Array.of_list (List.map Int32.to_int l))
- (OBus_property.make p_Value ~notify_mode (device krobot "RangeFinders"))
+ (OBus_property.make p_Value ~notify_mode (service krobot "RangeFinders"))
let get_calibration krobot id =
- lwt l = OBus_method.call m_GetCalibration (device krobot "RangeFinders") (Int32.of_int id) in
+ lwt l = OBus_method.call m_GetCalibration (service krobot "RangeFinders") (Int32.of_int id) in
return (Array.of_list (List.map Int32.to_int l))
let calibration_start krobot id skip_meas =
- OBus_method.call m_CalibrationStart (device krobot "RangeFinders") (Int32.of_int id, skip_meas)
+ OBus_method.call m_CalibrationStart (service krobot "RangeFinders") (Int32.of_int id, skip_meas)
let calibration_stop krobot =
- OBus_method.call m_CalibrationStop (device krobot "RangeFinders") ()
+ OBus_method.call m_CalibrationStop (service krobot "RangeFinders") ()
let calibration_continue krobot =
- OBus_method.call m_CalibrationContinue (device krobot "RangeFinders") ()
+ OBus_method.call m_CalibrationContinue (service krobot "RangeFinders") ()
end
(* +-----------------------------------------------------------------+
@@ -205,22 +208,22 @@ end
module Grip =
struct
- open Krobot_interfaces.Fr_krobot_Device_AX12
+ open Krobot_interfaces.Fr_krobot_Service_Grip
let up krobot =
- OBus_method.call m_GripUp (device krobot "AX12") ()
+ OBus_method.call m_Up (service krobot "Grip") ()
let down krobot =
- OBus_method.call m_GripDown (device krobot "AX12") ()
+ OBus_method.call m_Down (service krobot "Grip") ()
let open_ krobot =
- OBus_method.call m_GripOpen (device krobot "AX12") ()
+ OBus_method.call m_Open (service krobot "Grip") ()
let close krobot =
- OBus_method.call m_GripClose (device krobot "AX12") ()
+ OBus_method.call m_Close (service krobot "Grip") ()
let release krobot =
- OBus_method.call m_GripRelease (device krobot "AX12") ()
+ OBus_method.call m_Release (service krobot "Grip") ()
end
(* +-----------------------------------------------------------------+
@@ -229,22 +232,22 @@ end
module Claws =
struct
- open Krobot_interfaces.Fr_krobot_Device_Servo
+ open Krobot_interfaces.Fr_krobot_Service_Claws
let enable krobot =
- OBus_method.call m_ClawsEnable (device krobot "Servo") ()
+ OBus_method.call m_Enable (service krobot "Servo") ()
let disable krobot =
- OBus_method.call m_ClawsDisable (device krobot "Servo") ()
+ OBus_method.call m_Disable (service krobot "Servo") ()
let open_ krobot =
- OBus_method.call m_ClawsOpen (device krobot "Servo") ()
+ OBus_method.call m_Open (service krobot "Servo") ()
let close krobot =
- OBus_method.call m_ClawsClose (device krobot "Servo") ()
+ OBus_method.call m_Close (service krobot "Servo") ()
let take krobot =
- OBus_method.call m_ClawsTake (device krobot "Servo") ()
+ OBus_method.call m_Take (service krobot "Servo") ()
end
(* +-----------------------------------------------------------------+
@@ -253,24 +256,24 @@ end
module Motors =
struct
- open Krobot_interfaces.Fr_krobot_Device_Motors
+ open Krobot_interfaces.Fr_krobot_Service_Motors
let turn krobot ~angle ~velocity ~acceleration =
- OBus_method.call m_Turn (device krobot "Motors")
+ OBus_method.call m_Turn (service krobot "Motors")
(Int32.of_int angle,
Int32.of_int velocity,
Int32.of_int acceleration)
>|= move_result_of_int32
let move krobot ~distance ~velocity ~acceleration =
- OBus_method.call m_Move (device krobot "Motors")
+ OBus_method.call m_Move (service krobot "Motors")
(Int32.of_int distance,
Int32.of_int velocity,
Int32.of_int acceleration)
>|= move_result_of_int32
let goto krobot ~x ~y ~velocity ~acceleration ~mode ~bypass_distance =
- OBus_method.call m_Goto (device krobot "Motors")
+ OBus_method.call m_Goto (service krobot "Motors")
(Int32.of_int x,
Int32.of_int y,
Int32.of_int velocity,
@@ -280,22 +283,22 @@ struct
>|= move_result_of_int32
let stop krobot ~mode =
- OBus_method.call m_StopMotors (device krobot "Motors") (int32_of_stop_mode mode)
+ OBus_method.call m_StopMotors (service krobot "Motors") (int32_of_stop_mode mode)
let set_velocities krobot ~velocities:(vl, vr) ~accelerations:(al, ar) ~duration =
- OBus_method.call m_SetVelocities (device krobot "Motors")
+ OBus_method.call m_SetVelocities (service krobot "Motors")
(Int32.of_int vl, Int32.of_int al,
Int32.of_int vr, Int32.of_int ar,
duration)
let inhibit_forward_until krobot =
- OBus_property.make p_InhibitForwardUntil ~notify_mode (device krobot "Motors")
+ OBus_property.make p_InhibitForwardUntil ~notify_mode (service krobot "Motors")
let inhibit_backward_until krobot =
- OBus_property.make p_InhibitBackwardUntil ~notify_mode (device krobot "Motors")
+ OBus_property.make p_InhibitBackwardUntil ~notify_mode (service krobot "Motors")
let state krobot =
- OBus_property.make p_State ~notify_mode (device krobot "Motors")
+ OBus_property.make p_State ~notify_mode (service krobot "Motors")
end
(* +-----------------------------------------------------------------+
@@ -341,7 +344,7 @@ let unsafe_call command krobot args =
_unsafe_call
command
(device krobot command.Commands.section)
- ("fr.krobot.Device." ^ command.Commands.section ^ ".Unsafe")
+ ("fr.krobot.Device." ^ command.Commands.section)
args
(* +-----------------------------------------------------------------+
@@ -392,7 +395,7 @@ struct
"fr.krobot.Card.Unsafe"
args
| _ ->
- failwith "use Krobot.unsafe_call for calls on a device"
+ failwith "use Krobot.unsafe_call for calls on a service"
end
(* +-----------------------------------------------------------------+
diff --git a/info/control/lib-krobot/krobot.mli b/info/control/lib-krobot/krobot.mli
index f34db67..160973e 100644
--- a/info/control/lib-krobot/krobot.mli
+++ b/info/control/lib-krobot/krobot.mli
@@ -24,20 +24,20 @@ val bus : unit -> OBus_bus.t Lwt.t
- otherwise it uses the local krobot bus
*)
-(** {6 Devices} *)
-
-type devices_status = {
- dev_compass : bool;
- dev_range_finders : bool;
- dev_logic_sensors : bool;
- dev_motor : bool;
- dev_ax12 : bool;
- dev_lcd : bool;
- dev_infrared : bool;
- dev_power : bool;
+(** {6 Services} *)
+
+type services_status = {
+ srv_compass : bool;
+ srv_range_finders : bool;
+ srv_logic_sensors : bool;
+ srv_motor : bool;
+ srv_ax12 : bool;
+ srv_lcd : bool;
+ srv_infrared : bool;
+ srv_power : bool;
}
-val devices_status : t -> devices_status OBus_property.r
+val services_status : t -> services_status OBus_property.r
(** List of services with their status *)
module Infrared : sig
@@ -69,7 +69,7 @@ module Gate : sig
val close : t -> unit Lwt.t
(** Close the gate *)
- val release : t -> unit Lwt.t
+ val open_ : t -> unit Lwt.t
(** Open the gate *)
val hold_closed : t -> unit Lwt.t
diff --git a/info/control/protocol/krobot.obus b/info/control/protocol/krobot.obus
index 9720c1e..4405cd9 100644
--- a/info/control/protocol/krobot.obus
+++ b/info/control/protocol/krobot.obus
@@ -15,13 +15,13 @@
interface have changed.
*)
-interface "fr.krobot.Device.Power" {
+interface "fr.krobot.Service.Power" {
method SetBuzzerState : (state : boolean) -> ()
property.r Current : int32
}
-interface "fr.krobot.Device.Infrared" {
+interface "fr.krobot.Service.Infrared" {
property.r States : (int32 * int32) structure
method GoLeft : () -> ()
@@ -29,7 +29,7 @@ interface "fr.krobot.Device.Infrared" {
method GoCenter : () -> ()
}
-interface "fr.krobot.Device.Gate" {
+interface "fr.krobot.Service.Gate" {
method Enable : () -> ()
(** Enable the motor of the gate *)
@@ -39,7 +39,7 @@ interface "fr.krobot.Device.Gate" {
method Close : () -> ()
(** Close the gate *)
- method Release : () -> ()
+ method Open : () -> ()
(** Open the gate *)
method HoldClosed : () -> ()
@@ -49,15 +49,15 @@ interface "fr.krobot.Device.Gate" {
(** Stop holding the gate *)
}
-interface "fr.krobot.Device.Compass" {
+interface "fr.krobot.Service.Compass" {
property.r Value : int32
(** Current value of the compass *)
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.LCD" {
- method SetLCD : (lines : string array) -> ()
+interface "fr.krobot.Service.LCD" {
+ method Set : (lines : string array) -> ()
(** Write all the given lines on the LCD *)
method BacklightOn : () -> ()
@@ -66,40 +66,40 @@ interface "fr.krobot.Device.LCD" {
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.Servo" {
- method ClawsEnable : () -> ()
+interface "fr.krobot.Service.Claws" {
+ method Enable : () -> ()
(** Enable the claws. They are initially disabled. When disabled,
commands are ignored. *)
- method ClawsDisable : () -> ()
+ method Disable : () -> ()
- method ClawsOpen : () -> ()
+ method Open : () -> ()
(** Completely open the claws. *)
- method ClawsClose : () -> ()
+ method Close : () -> ()
(** Completely close the claws *)
- method ClawsTake : () -> ()
+ method Take : () -> ()
(** Put the claws in a position allowing to capture a ball *)
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.AX12" {
- method GripUp : () -> ()
- method GripDown : () -> ()
- method GripOpen : () -> ()
- method GripClose : () -> ()
- method GripRelease : () -> ()
+interface "fr.krobot.Service.Grip" {
+ method Up : () -> ()
+ method Down : () -> ()
+ method Open : () -> ()
+ method Close : () -> ()
+ method Release : () -> ()
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.LogicSensors" {
+interface "fr.krobot.Service.LogicSensors" {
property.r Value : boolean array
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.RangeFinders" {
+interface "fr.krobot.Service.RangeFinders" {
property.r Value : int32 array
method GetCalibration : (id : int32) -> (result : int32 array)
method CalibrationStart : (id : int32, skip_measure : boolean) -> ()
@@ -109,7 +109,7 @@ interface "fr.krobot.Device.RangeFinders" {
signal PropertiesChanged : (properties : (string, variant) dict)
}
-interface "fr.krobot.Device.Motors" {
+interface "fr.krobot.Service.Motors" {
property.r State : string
method Turn : (angle : int32, velocity : int32, acceleration : int32) -> (result : int32)
method Move : (distance : int32, velocity : int32, acceleration : int32) -> (result : int32)
@@ -142,8 +142,8 @@ interface "fr.krobot.Device.Motors" {
}
interface "fr.krobot.Manager" {
- property.r DevicesStatus : (string, boolean) dict
- (** Mapping from device name to their current state *)
+ property.r ServicesStatus : (string, boolean) dict
+ (** Mapping from service name to their current state *)
method Shutdown : () -> ()
(** Shutdown the driver *)
hooks/post-receive
--
krobot
|