add enumerated values to message field descriptions

This commit is contained in:
Pascal Brisset
2009-10-20 11:04:00 +00:00
parent 77e4b33172
commit 155dac4e26
2 changed files with 10 additions and 3 deletions
+7 -2
View File
@@ -40,7 +40,8 @@ type value =
type field = {
_type : _type;
fformat : format;
alt_unit_coef : string
alt_unit_coef : string;
enum : string list
}
type link_mode = Forwarded | Broadcasted
@@ -153,12 +154,16 @@ let payload_size_of_message = fun message ->
message.fields
2 (** + message id + aircraft id *)
let pipe_regexp = Str.regexp "|"
let field_of_xml = fun xml ->
let t = ExtXml.attrib xml "type" in
let t = if is_array_type t then ArrayType (type_of_array_type t) else Scalar t in
let f = try Xml.attrib xml "format" with _ -> default_format t in
let auc = try Xml.attrib xml "alt_unit_coef" with _ -> "" in
(String.lowercase (ExtXml.attrib xml "name"), { _type = t; fformat = f; alt_unit_coef = auc })
let values = try Str.split pipe_regexp (Xml.attrib xml "values") with _ -> [] in
( String.lowercase (ExtXml.attrib xml "name"),
{ _type = t; fformat = f; alt_unit_coef = auc; enum=values })
let string_of_values = fun vs ->
String.concat " " (List.map (fun (a,v) -> sprintf "%s=%s" a (string_of_value v)) vs)
+3 -1
View File
@@ -39,7 +39,8 @@ type value =
type field = {
_type : _type;
fformat : format;
alt_unit_coef : string (* May be empty *)
alt_unit_coef : string; (* May be empty *)
enum : string list (* 'values' attribute *)
}
type link_mode = Forwarded | Broadcasted
type message = {
@@ -116,6 +117,7 @@ module type MESSAGES = sig
val messages : (message_id, message) Hashtbl.t
val message_of_id : message_id -> message
val message_of_name : string -> message_id * message
val values_of_payload : Serial.payload -> message_id * ac_id * values
(** [values_of_bin payload] Parses a raw payload, returns the
message id, the A/C id and the list of (field_name, value) *)