From bc10ef71969d8ee58ec5d36576eb56b07ecb7ac3 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Wed, 30 Nov 2011 18:49:23 +0100 Subject: [PATCH] enhance saving of settings to deal with RadOfDeg and DegOfRad macros --- sw/ground_segment/cockpit/saveSettings.ml | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sw/ground_segment/cockpit/saveSettings.ml b/sw/ground_segment/cockpit/saveSettings.ml index 65efc72b25..4dc8052237 100644 --- a/sw/ground_segment/cockpit/saveSettings.ml +++ b/sw/ground_segment/cockpit/saveSettings.ml @@ -135,18 +135,28 @@ let fill_data = fun (model:GTree.tree_store) settings airframe_xml -> let param = attrib "param" in let (airframe_value, unit) = EditAirframe.get airframe_xml param in let scale = - try - let unit_setting = attrib "unit" - and unit_airframe = - match unit with Some u -> u | None -> raise Exit in - scale_of_units unit_setting unit_airframe - with - _ -> 1. in + try + let unit_setting = attrib "unit" + and unit_airframe = + match unit with Some u -> u | None -> raise Exit in + scale_of_units unit_setting unit_airframe + with + _ -> 1. in + let val_list = Str.split (Str.regexp "[ ()]+") airframe_value in + let (scale_macros, str_val) = List.partition (fun x -> Str.string_match (Str.regexp "RadOfDeg\\|DegOfRad") x 0) val_list in + let extra_scale = + try + match (List.hd scale_macros) with + "RadOfDeg" -> Latlong.pi /. 180. + | "DegOfRad" -> 180. /. Latlong.pi + | _ -> 1. + with + _ -> 1. in let scaled_value = - try - float_of_string airframe_value *. scale - with - Failure "float_of_string" -> raise (EditAirframe.No_param param) + try + float_of_string (List.hd str_val) *. scale *. extra_scale + with + Failure "float_of_string" -> raise (EditAirframe.No_param param) in let row = model#append () in