Example #1
0
        static List<BreakPoint> parse(DataElement Parent, int dimensions, string s)
        {
            int lc = 0;
            List<string> iv1_bp = new List<string>();
            List<string> iv2_bp = new List<string>();
            List<BreakPoint> bpl = new List<BreakPoint>();
            foreach (var line in s.Replace("\r", "\n").Replace("\n\n", "\n").Split('\n'))
            {
                var iv1_pos = 0;
                if (!String.IsNullOrEmpty(line))
                {
                    var elems = get_elements(line);
                    if (dimensions == 2 && lc == 0)
                    {
                        lc++;
                        iv1_bp = elems.ToList();
                        continue;
                    }
                    System.Console.WriteLine("{0}: {1}", lc, String.Join(",", elems));
                    var iv2 = double.Parse(elems[0]);
                    foreach (var ee in elems.Skip(1))
                    {
                        if (dimensions == 2)
                            bpl.Add(new BreakPoint(Parent, Double.Parse(iv1_bp[iv1_pos++]), iv2, Double.Parse(ee)));
                        else
                            bpl.Add(new BreakPoint(Parent, iv2, Double.Parse(ee)));
                    }

                    lc++;
                }
            }
            return bpl;
        }
Example #2
0
 public BreakPoint(DataElement parent, double iv1, double v)
 {
     Parent = parent;
     data = new Double[1];
     data[0] = iv1;
     this.iv1 = iv1;
     Value = v;
 }
Example #3
0
 public BreakPoint(DataElement parent, double iv1, double iv2, double iv3, double v)
 {
     Parent = parent;
     data = new Double[3];
     data[0] = iv1;
     data[1] = iv2;
     data[2] = iv3;
     this.iv1 = iv1;
     this.iv2 = iv2;
     this.iv3 = iv3;
     Value = v;
 }
Example #4
0
        private void OutputExtraIndependentVariables(Aerodata aero, HtmlTextWriter writer, DataElement aero_element)
        {
            foreach (var xx in aero_element.Factors)
            {
                var name = aero.Lookup(xx);
                var v = aero.LookupValue(name);
                if (v.HasValue)
                {
                    // use the lookup value to find out if it is numeric; but lookup will add an xml comment for constants
                    // so output with the original name, rather than v
                    writer.Write("          <value>{0}</value>\n", name);
                }
                else
                {
                    if (!name.Contains("/") && !Char.IsDigit(name[0]))
                        name = "aero/coefficients/" + name;

                    writer.Write("          <property>{0}</property>\n", name);
                }
            }
        }
Example #5
0
        private void WriteFunctionDataToWriter(Aerodata aero, HtmlTextWriter writer, DataElement aero_element, DataElement aerodat_item)
        {
            if (aero.Is3d(aero_element))
            {

                writer.Write("    <function name=\"{0}\">\n", aerodat_item.GetVariable());
                writer.Write("    <description>{0}</description>\n", aerodat_item.Title);
                if (aero_element.Components.Any())
                {
                    writer.Write("    <sum>\n");
                    foreach (var c in aero_element.Components)
                        writer.Write("    <property>{0}</property>\n", c);
                }

                writer.Write("    <product>\n");
                OutputExtraIndependentVariables(aero, writer, aero_element);
                writer.Write("          <table>\n");
                writer.Write("            <independentVar lookup=\"row\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[0]));
                writer.Write("            <independentVar lookup=\"column\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[1]));
                writer.Write("            <independentVar lookup=\"table\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[2]));
                var table_data_element = aero_element.data.GroupBy(xx => xx.iv3).Select(xx => new { Key = xx.Key, Values = xx });
                foreach (var table in table_data_element)
                {
                    writer.Write("              <tableData breakPoint=\"{0}\">", table.Key);
                    var leading = "                 ";
                    var aero_data_element = table.Values.GroupBy(xx => xx.iv1).Select(xx => new { Key = xx.Key, Values = xx });

                    writer.Write("\n" + leading);
                    writer.Write("{0,6}", " ");
                    foreach (var iv2 in aero_data_element.First().Values)
                    {
                        writer.Write(FormatIntValue(iv2.iv2, 10));
                    }


                    foreach (var iv1 in aero_data_element)
                    {
                        writer.Write("\n" + leading);
                        writer.Write(FormatIntValue(iv1.Key, 6));

                        foreach (var vv in iv1.Values)
                        {
                            writer.Write(FormatValue(vv.Value, 10));
                        }
                    }
                    writer.Write("\n              </tableData>\n");
                }
                writer.Write("          </table>\n");
                writer.Write("       </product>\n");
                if (aero_element.Components.Any())
                {
                    writer.Write("    </sum>\n");
                }
                writer.Write("    </function>\n");

                //                      writer.Write("<pre>\n");

            }
            else if (aero.Is2d(aero_element))
            {
                //                          writer.Write("<h2>{0}</h2>", aero_element);
                //                          writer.Write("<pre>\n");

                writer.Write("    <function name=\"{0}\">\n", aerodat_item.GetVariable());
                writer.Write("    <description>{0}</description>\n", aerodat_item.Title);
                if (aero_element.Components.Any())
                {
                    writer.Write("    <sum>\n");
                    foreach (var c in aero_element.Components)
                        writer.Write("    <property>{0}</property>\n", c);
                }
                writer.Write("    <product>\n");
                OutputExtraIndependentVariables(aero, writer, aero_element);
                writer.Write("          <table>\n");
                writer.Write("            <independentVar lookup=\"row\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[0]));
                writer.Write("            <independentVar lookup=\"column\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[1]));
                writer.Write("            <tableData>");
                var leading = "                 ";
                var aero_data_element = aero_element.data.GroupBy(xx => xx.iv1).Select(xx => new { Key = xx.Key, Values = xx });

                writer.Write("\n" + leading);
                writer.Write("       ");
                foreach (var iv2 in aero_data_element.First().Values)
                {
                    writer.Write(" {0,10}\t", iv2.iv2);
                }


                foreach (var iv1 in aero_data_element)
                {
                    writer.Write("\n{0}{1}", leading, FormatIntValue(iv1.Key, 6));
                    foreach (var vv in iv1.Values)
                    {
                        writer.Write(FormatValue(vv.Value, 10));
                    }
                }
                writer.Write("\n            </tableData>\n");
                writer.Write("          </table>\n");
                writer.Write("       </product>\n");
                if (aero_element.Components.Any())
                {
                    writer.Write("    </sum>\n");
                }
                writer.Write("    </function>\n");

                //                      writer.Write("<pre>\n");
            }
            else if (aero_element.IndependentVars.Count == 1)
            {

                var aero_data_element = aero_element.data.Select(xx => new { Key = xx.iv1, Value = xx.Value });
                if (aero_data_element != null)
                    if (aero_data_element != null)
                    {
                        //                        writer.Write("<h2>{0}</h2>", aero_element);
                        //                        writer.Write("<pre>\n");

                        writer.Write("    <function name=\"{0}\">\n", aerodat_item.GetVariable());
                        writer.Write("    <description>{0}</description>\n", aero_element.Title);
                        if (aero_element.Components.Any())
                        {
                            writer.Write("    <sum>\n");
                            foreach (var c in aero_element.Components)
                                writer.Write("    <property>{0}</property>\n", c);
                        }
                        writer.Write("    <product>\n");
                        OutputExtraIndependentVariables(aero, writer, aero_element);
                        writer.Write("          <table>\n");
                        writer.Write("            <independentVar lookup=\"row\">{0}</independentVar>\n", aero.Lookup(aero_element.IndependentVars[0]));
                        writer.Write("            <tableData>\n");
                        var leading = "                 ";
                        foreach (var q in aero_data_element)
                        {
                            writer.Write("{0}{1}\t{2}\n", leading, FormatIntValue(q.Key, 6), FormatValue(q.Value, 10));
                        }
                        writer.Write("            </tableData>\n");
                        writer.Write("          </table>\n");
                        writer.Write("       </product>\n");
                        if (aero_element.Components.Any())
                        {
                            writer.Write("    </sum>\n");
                        }
                        writer.Write("    </function>\n");
                        //                        writer.Write("<pre>\n");
                    }
            }
            else
            {
                writer.Write("    <!-- cannot handle {0} -->", aero_element.Variable);
            }

            if (!aero.IsUsed(aero_element))
                writer.Write("    -->\n");
        }
Example #6
0
 public DataElement Add(string title, string element, string iv1, string iv2 = null, string iv3 = null)
 {
     var ne = new DataElement(iv1, iv2, iv3)
     {
         Title = title,
         Variable = element,
     };
     Data[element] = ne;
     return ne;
 }
Example #7
0
 public bool Is3d(DataElement aero_element)
 {
     return aero_element.IndependentVars.Count == 3;
 }
Example #8
0
 public bool IsUsed(DataElement aero_element)
 {
     return aero_element.data.Any();
 }
Example #9
0
 public void Compute(string axis, DataElement[] dataElement)
 {
     if (!ComputeElems.ContainsKey(axis))
         ComputeElems[axis] = new List<DataElement>();
     foreach (var el in dataElement)
     {
         ComputeElems[axis].Add(el);
         el.Axis = axis;
     }
     // Add list of elements to axis
 }