LogItemSchema CreateSchemaItem(MessageSubscription sub, MessageFormat fmt) { LogItemSchema element = new LogItemSchema() { Name = fmt.name, Id = sub.id }; foreach (var f in fmt.fields) { LogItemSchema column = new LogItemSchema() { Name = f.name, Type = f.typeName + (f.arraySize > 0 ? "[" + f.arraySize + "]" : ""), Id = sub.id }; if (f.type == FieldType.Struct) { // nested var child = CreateSchemaItem(sub, f.structType); foreach (var item in child.CopyChildren()) { column.AddChild(item); } } else if (f.arraySize > 0) { column.IsArray = true; // break out the elements of the array as separate items. for (int i = 0; i < f.arraySize; i++) { column.AddChild(new LogItemSchema() { Name = i.ToString(), Type = f.typeName, Id = sub.id }); } } element.AddChild(column); } return(element); }
private void CreateSchema() { LogItemSchema schema = new LogItemSchema() { Name = "Px4ULog", Type = "Root" }; // only need to show formats that we actually have subscriptions on. foreach (var sub in this.subscriptions.Values) { // we can have "multi_id" subscriptions on the same format. var element = CreateSchemaItem(sub, sub.format); schema.AddChild(element); } this.schema = schema; }