paparazzi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paparazzi-commits] [5607] add automatic conversion of standard units if


From: Gautier Hattenberger
Subject: [paparazzi-commits] [5607] add automatic conversion of standard units if alt_unit_coef is not specified
Date: Mon, 23 Aug 2010 13:24:02 +0000

Revision: 5607
          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5607
Author:   gautier
Date:     2010-08-23 13:24:02 +0000 (Mon, 23 Aug 2010)
Log Message:
-----------
add automatic conversion of standard units if alt_unit_coef is not specified

Modified Paths:
--------------
    paparazzi3/trunk/sw/ground_segment/tmtc/messages.ml
    paparazzi3/trunk/sw/lib/ocaml/pprz.ml
    paparazzi3/trunk/sw/lib/ocaml/pprz.mli

Modified: paparazzi3/trunk/sw/ground_segment/tmtc/messages.ml
===================================================================
--- paparazzi3/trunk/sw/ground_segment/tmtc/messages.ml 2010-08-23 13:12:40 UTC 
(rev 5606)
+++ paparazzi3/trunk/sw/ground_segment/tmtc/messages.ml 2010-08-23 13:24:02 UTC 
(rev 5607)
@@ -67,7 +67,7 @@
          let literal_values = values_of_field f in
          let alt_value =
            try
-             let coeff = ExtXml.float_attrib f "alt_unit_coef"
+             let coeff = float_of_string (Pprz.alt_unit_coef_of_xml f)
              and unit = Xml.attrib f "alt_unit" in
              fun value -> sprintf "%s (%f%s)" value (coeff*.float_of_string 
value) unit
            with

Modified: paparazzi3/trunk/sw/lib/ocaml/pprz.ml
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/pprz.ml       2010-08-23 13:12:40 UTC (rev 
5606)
+++ paparazzi3/trunk/sw/lib/ocaml/pprz.ml       2010-08-23 13:24:02 UTC (rev 
5607)
@@ -25,8 +25,8 @@
  *)
 
 open Printf
+open Latlong
 
-
 type message_id = int
 type ac_id = int
 type class_name = string
@@ -326,7 +326,21 @@
       failwith (sprintf "Error: expecting array in Pprz.hex_of_int_array, 
found %s" (string_of_value value))
 
   
+let alt_unit_coef_of_xml = function xml ->
+  try Xml.attrib xml "alt_unit_coef"
+  with _ ->
+    let u = try Xml.attrib xml "unit" with _ -> "" in
+    let au = try Xml.attrib xml "alt_unit" with _ -> "" in
+    match (u, au) with
+      ("deg", "rad") | ("deg/s", "rad/s") -> string_of_float (pi /. 180.)
+    | ("rad", "deg") | ("rad/s", "deg/s") -> string_of_float (180. /. pi)
+    | ("m", "cm") | ("m/s", "cm/s") -> "100."
+    | ("cm", "m") | ("cm/s", "m/s") -> "0.01"
+    | ("decideg", "deg") -> "0.1"
+    | (_, _) -> "1."
 
+
+
 exception Unknown_msg_name of string * string
 
 module type TRANSPORT_TYPE = sig

Modified: paparazzi3/trunk/sw/lib/ocaml/pprz.mli
===================================================================
--- paparazzi3/trunk/sw/lib/ocaml/pprz.mli      2010-08-23 13:12:40 UTC (rev 
5606)
+++ paparazzi3/trunk/sw/lib/ocaml/pprz.mli      2010-08-23 13:24:02 UTC (rev 
5607)
@@ -86,6 +86,18 @@
 val hex_of_int_array : value -> string
 (** Returns the hexadecimal string of an array of integers *)
 
+val alt_unit_coef_of_xml : Xml.xml -> string
+(** Return coef for alternate unit
+    Default possible corrections:
+    deg -> rad
+    rad -> deg
+    m -> cm
+    cm -> m
+    m/s -> cm/s
+    cm/s -> m/s
+    decideg -> deg
+    *)
+
 exception Unknown_msg_name of string * string
 (** [Unknown_msg_name (name, class_name)] Raised if message [name] is not
 found in class [class_name]. *)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]