static void processGraphItem(graphitem graphitem) { List <displayitem> list = new List <displayitem>(); foreach (var expression in graphitem.expressions) { var items = expression.Split(new char[] { ' ', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var item in items) { var matchs = Regex.Matches(item.Trim(), @"^([A-z0-9_]+)\.([A-z0-9_]+)[:2]*$"); if (matchs.Count > 0) { foreach (Match match in matchs) { var temp = new displayitem(); // right axis if (item.EndsWith(":2")) { temp.left = false; } temp.type = match.Groups[1].Value.ToString(); temp.field = match.Groups[2].Value.ToString(); list.Add(temp); } } else { var temp = new displayitem(); if (item.EndsWith(":2")) { temp.left = false; } temp.expression = item; temp.type = item; list.Add(temp); } } } var dispitem = new displaylist() { Name = graphitem.name, items = list.ToArray() }; graphs.Add(dispitem); }
void processGraphItem(graphitem graphitem) { List<displayitem> list = new List<displayitem>(); foreach (var expression in graphitem.expressions) { var items = expression.Split(new char[] {' ', '\t', '\n'}, StringSplitOptions.RemoveEmptyEntries); foreach (var item in items) { var matchs = Regex.Matches(item.Trim(), @"^([A-z0-9_]+)\.([A-z0-9_]+)[:2]*$"); // there is a item we dont understand/abandon it if (matchs.Count == 0) break; foreach (Match match in matchs) { var temp = new displayitem(); // right axis if (item.EndsWith(":2")) temp.left = false; temp.type = match.Groups[1].Value.ToString(); temp.field = match.Groups[2].Value.ToString(); list.Add(temp); } } } var dispitem = new displaylist() { Name = graphitem.name, items = list.ToArray() }; graphs.Add(dispitem); }
private void readmavgraphsxml() { if (readmavgraphsxml_runonce) return; readmavgraphsxml_runonce = true; List<graphitem> items = new List<graphitem>(); using (XmlReader reader = XmlReader.Create("mavgraphs.xml")) { while (reader.Read()) { if (reader.ReadToFollowing("graph")) { graphitem newGraphitem = new graphitem(); for (int a = 0; a < reader.AttributeCount; a++) { reader.MoveToAttribute(a); if (reader.Name.ToLower() == "name") { newGraphitem.name = reader.Value; } } reader.MoveToElement(); XmlReader inner = reader.ReadSubtree(); while (inner.Read()) { if (inner.IsStartElement()) { if (inner.Name.ToLower() == "expression") newGraphitem.expressions.Add(inner.ReadString().Trim()); else if (inner.Name.ToLower() == "description") newGraphitem.description = inner.ReadString().Trim(); } } processGraphItem(newGraphitem); items.Add(newGraphitem); } } } }
public static void readmavgraphsxml() { if (readmavgraphsxml_runonce) { return; } readmavgraphsxml_runonce = true; List <graphitem> items = new List <graphitem>(); log.Info("readmavgraphsxml from " + Settings.GetRunningDirectory() + Path.DirectorySeparatorChar + "graphs"); var files = Directory.GetFiles(Settings.GetRunningDirectory() + Path.DirectorySeparatorChar + "graphs", "*.xml"); foreach (var file in files) { try { using ( XmlReader reader = XmlReader.Create(file)) { while (reader.Read()) { if (reader.ReadToFollowing("graph")) { graphitem newGraphitem = new graphitem(); for (int a = 0; a < reader.AttributeCount; a++) { reader.MoveToAttribute(a); if (reader.Name.ToLower() == "name") { newGraphitem.name = reader.Value + " " + Path.GetFileNameWithoutExtension(file); } } reader.MoveToElement(); XmlReader inner = reader.ReadSubtree(); while (inner.Read()) { if (inner.IsStartElement()) { if (inner.Name.ToLower() == "expression") { newGraphitem.expressions.Add(inner.ReadString().Trim()); } else if (inner.Name.ToLower() == "description") { newGraphitem.description = inner.ReadString().Trim(); } } } processGraphItem(newGraphitem); items.Add(newGraphitem); } } } } catch (Exception ex) { log.Error(ex); } } }