Exemple #1
0
        private void plotTrefftz(Aircraft ac, Run_Case rc, Chart c)
        {
            //if there is a mixup between the aircraft and run case, stop
            if (!ac.Analyze_Cases.Contains(rc))
            {
                return;
            }

            if (rc.Strip_Forces.Count > 0)
            {
                //this does it for each surface
                foreach (string s in rc.Strip_Forces.Keys)
                {
                    double[] Yle       = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl        = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl_c_cref = new double[rc.Strip_Forces[s].GetLength(0)];
                    for (int i = 0; i < Yle.Length; i++)
                    {
                        Yle[i]       = (rc.Strip_Forces[s])[i, 0];
                        cl[i]        = (rc.Strip_Forces[s])[i, 9];
                        cl_c_cref[i] = (rc.Strip_Forces[s])[i, 1];
                    }
                    PlotSpline(c, Yle, cl, main_Lines == 0 ? "cl" : "cl " + s + main_Lines.ToString(), Color.Green, main_Lines == 0, true);
                    PlotSpline(c, Yle, cl_c_cref, main_Lines == 0 ? "cl*(c/cref)" : "cl*(c/cref) " + s + main_Lines.ToString(), Color.Orange, main_Lines == 0, true);
                    main_Lines++;
                }
                c.ChartAreas[0].AxisX.Minimum = -1;
                c.ChartAreas[0].AxisX.Maximum = 1;
                c.ChartAreas[0].AxisX.Title   = "Spanwise Location";
                c.ChartAreas[0].AxisY.Title   = "Section Lift Coefficient";
            }
        }
Exemple #2
0
        public void ExecuteCase(Run_Case rc)
        {
            m_currentCase = rc;
            //now that we have set all parameters, change status and execute.
            rc.Current_Status = Run_Case.Case_Status.Working;

            Task.Factory.StartNew(() =>
            {
                while (!Ready)
                {
                    System.Threading.Thread.Sleep(50);
                }

                AVLUpdateMessage(this, new AVLEventArgs(AVLEventArgs.AVLData_Source.Case_Started, m_currentCase.Case_Index));

                RunCase(rc);
                System.Threading.Thread.Sleep(2000);

                while (!Ready)
                {
                    System.Threading.Thread.Sleep(50);
                }

                if (rc.Current_Status != Run_Case.Case_Status.Error)
                {
                    rc.Current_Status = Run_Case.Case_Status.Finished;
                }

                AVLUpdateMessage(this, new AVLEventArgs(AVLEventArgs.AVLData_Source.Case_Ended, m_currentCase.Case_Index));
                //System.Threading.Thread.Sleep(200);
            });
        }
Exemple #3
0
        private void PopulateData()
        {
            if (DispAircraft == null)
            {
                return;
            }

            this.listView1.SuspendLayout();
            this.listView1.Items.Clear();
            this.listView1.Groups.Clear();

            var group = this.listView1.Groups.Add("Status", "Status");

            for (int i = 0; i < DispAircraft.Analyze_Cases.Count; i++)
            {
                //add the item for the specific case
                Run_Case rc = DispAircraft.Analyze_Cases[i];
                this.listView1.Items.Add(new ListViewItem(new string[] { "Case " + rc.Case_Index.ToString(), "Status", "Ready" }, 2, this.listView1.Groups[0])).Tag = rc.Case_Index;
                //add the group to represent all the case parameters
                group     = this.listView1.Groups.Add("Case " + rc.Case_Index.ToString(), "Case " + rc.Case_Index.ToString());
                group.Tag = rc.Case_Index;
                //add each parameter to the ith-case group
                foreach (var kvp in rc.Parameters)
                {
                    string[] subitems = new string[3];

                    if (!string.IsNullOrEmpty(kvp.Key.GetLabel()))
                    {
                        subitems[0] = kvp.Key.GetLabel();
                    }
                    else//special situation for the control surfaces and section span/chord
                        //if we are a control surface display the actual surface's name
                    if ((int)kvp.Key >= (int)Run_Case.Independant_Vars.D1 && (int)kvp.Key <= (int)Run_Case.Independant_Vars.D10)
                    {
                        subitems[0] = DispAircraft.Initial_AVL_File.Controls[(int)kvp.Key - (int)Run_Case.Independant_Vars.D1];
                    }

                    if (!string.IsNullOrEmpty(kvp.Value.Item1.GetLabel()))
                    {
                        subitems[1] = kvp.Value.Item1.GetLabel();
                    }
                    else//special situation for the control surfaces and section span/chord
                        //if we are a control surface display the actual surface's name
                    if ((int)kvp.Value.Item1 >= (int)Run_Case.Constraint.D1 && (int)kvp.Value.Item1 <= (int)Run_Case.Constraint.D10)
                    {
                        subitems[1] = DispAircraft.Initial_AVL_File.Controls[(int)kvp.Value.Item1 - (int)Run_Case.Constraint.D1];
                    }

                    subitems[2] = kvp.Value.Item2.ToString();

                    this.listView1.Items.Add(new ListViewItem(subitems, -1, group));
                }
            }
            this.listView1.ResumeLayout();
            this.statusLabel.Text = DispAircraft.Configuration_Name.Substring(0, Math.Min(DispAircraft.Configuration_Name.Length, 35)) + " Ready: " + DispAircraft.Analyze_Cases.Count.ToString() + " Cases Total";
        }
Exemple #4
0
        public void Add_Run_Case(Run_Case rc)
        {
            this.Analyze_Cases.Add(rc);
            rc.Current_Status = Run_Case.Case_Status.Ready;

            rc.Case_Index = this.CaseIndex;
            this.CaseIndex++;

            OnUpdate(this, new AircraftUpdateEventArgs(AircraftUpdateEventArgs.Update_Type.Added_Case, rc));
        }
Exemple #5
0
        private void showRawDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (runMenuStrip.Tag == null)
            {
                return;
            }

            if (runMenuStrip.Tag.GetType() == typeof(ListViewItem))
            {
                Run_Case rc = GetRepresentedCase(runMenuStrip.Tag as ListViewItem);
                if (rc != null)
                {
                    RawDataForm rdf = new RawDataForm((runMenuStrip.Tag as ListViewItem).Group.Header, "All Raw Data", rc.Forces.FullText + "\r\n" + rc.StabDerivs.FullText + "\r\n" + rc.StripFullText);
                    rdf.Show();
                }
            }
        }
        private void acceptButton_Click(object sender, EventArgs e)
        {
            if (selected_Aircraft == null)
                return;

            //you must actually select a proper variable not type junk in
            if (primaryVarCombobox.SelectedValue == null)
                return;

            if ((int)primaryVarCombobox.SelectedValue == (int)Run_Case.Independant_Vars.Control_Surface && primaryExtraCombobox.SelectedValue == null)
                return;

            //for loop generating one new RunCase per step in the independant variable sweep
            for (double sweep = (double)indMinUpDown.Value; sweep <= (double)indMaxUpDown.Value; sweep += (double)indStepUpDown.Value)
            {
                Run_Case tempCase = new Run_Case();
                tempCase.CaseNotes = primaryVarCombobox.Text + " Sweep = " + sweep.ToString();
                //tempCase.CaseNotes = "Sweep of " + primaryVarCombobox.Text + " from " + indMinUpDown.Value.ToString() + " to " + indMaxUpDown.Value.ToString() + " by " + indStepUpDown.Value.ToString() + "\r\n";
                //tempCase.CaseNotes += "Case Value = " + sweep.ToString();
                switch ((int)primaryVarCombobox.SelectedValue)
                {
                    case (int)Run_Case.Independant_Vars.Section_Chord:
                    case (int)Run_Case.Independant_Vars.Section_Span: break;
                    case (int)Run_Case.Independant_Vars.Control_Surface:
                        {//if we are playing with a control surface, then we need to use the selected value of the extra combobox instead of the primary one
                            tempCase.SetParameters((Run_Case.Independant_Vars)primaryExtraCombobox.SelectedValue, ((Run_Case.Independant_Vars)primaryExtraCombobox.SelectedValue).GetMatchingCon(), sweep);
                        }break;
                    default: tempCase.SetParameters((Run_Case.Independant_Vars)primaryVarCombobox.SelectedValue, ((Run_Case.Independant_Vars)primaryVarCombobox.SelectedValue).GetMatchingCon(), sweep); break;
                }
                //finally add in all the addional constraints
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    var data = (Tuple<Run_Case.Independant_Vars, Run_Case.Constraint, double>)listView1.Items[i].Tag;
                    tempCase.SetParameters(data.Item1, data.Item2, data.Item3);
                }
                selected_Aircraft.Add_Run_Case(tempCase);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }
Exemple #7
0
        private void plotTrefftz(Aircraft ac, Run_Case rc, Chart c)
        {
            //if there is a mixup between the aircraft and run case, stop
            if (!ac.Analyze_Cases.Contains(rc))
                return;

            if(rc.Strip_Forces.Count > 0)
            {
                //this does it for each surface
                foreach (string s in rc.Strip_Forces.Keys)
                {
                    double[] Yle = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl = new double[rc.Strip_Forces[s].GetLength(0)];
                    double[] cl_c_cref = new double[rc.Strip_Forces[s].GetLength(0)];
                    for (int i = 0; i < Yle.Length; i++)
                    {
                        Yle[i] = (rc.Strip_Forces[s])[i, 0];
                        cl[i] = (rc.Strip_Forces[s])[i, 9];
                        cl_c_cref[i] = (rc.Strip_Forces[s])[i, 1];
                    }
                    PlotSpline(c, Yle, cl, main_Lines == 0 ? "cl" : "cl " + s + main_Lines.ToString(), Color.Green, main_Lines == 0, true);
                    PlotSpline(c, Yle, cl_c_cref, main_Lines == 0 ? "cl*(c/cref)" : "cl*(c/cref) " + s + main_Lines.ToString(), Color.Orange, main_Lines == 0, true);
                    main_Lines++;
                }
                c.ChartAreas[0].AxisX.Minimum = -1;
                c.ChartAreas[0].AxisX.Maximum = 1;
                c.ChartAreas[0].AxisX.Title = "Spanwise Location";
                c.ChartAreas[0].AxisY.Title = "Section Lift Coefficient";
            }
        }
Exemple #8
0
 private static object GetValueSingleRun(Run_Case rc, PropertyInfo info)
 {
     return GetPropertyValue(info, rc);
 }
Exemple #9
0
        private void RunCase(Run_Case rc)
        {
            if (rc.Parameters.Count == 0)
            {
                return;
            }

            foreach (var kvp in rc.Parameters)
            {
                switch (kvp.Key)
                {
                case Run_Case.Independant_Vars.Section_Span: break;

                case Run_Case.Independant_Vars.Section_Chord: break;

                case Run_Case.Independant_Vars.Control_Surface: break;

                //the C.G. edits are done through the 'M'odify menu, and only to a value
                case Run_Case.Independant_Vars.X_cg:
                case Run_Case.Independant_Vars.Y_cg:
                case Run_Case.Independant_Vars.Z_cg:
                {
                    if (kvp.Value.Item1 != Run_Case.Constraint.Value)
                    {
                        break;
                    }
                    ChangeMenu(Menu.OPER);
                    Write("M", true);
                    Write(kvp.Key.GetMenuCode() + " " + kvp.Value.Item2.ToString(), true);
                    Write(" ", true);
                }; break;

                //this is the case where we can translate the variable to the character
                //that AVL is looking for, for instance a a # to set alpha => alpha = #
                default:
                {
                    switch (kvp.Value.Item1)
                    {
                    //This is the case where 90% of the time you ment to say a a #, but the other 10% is the new
                    //factors like section chord and section lift
                    case Run_Case.Constraint.Value:
                    {
                        if (kvp.Key == Run_Case.Independant_Vars.Section_Chord || kvp.Key == Run_Case.Independant_Vars.Section_Span)
                        {
                            return;
                        }
                        else
                        {
                            ChangeMenu(Menu.OPER);
                            Write(kvp.Key.GetMenuCode() + " " + kvp.Key.GetMenuCode() + " " + kvp.Value.Item2.ToString(), true);
                        }
                    }; break;

                    //these are all the cases where we have a menu code for the constraint
                    default:
                    {
                        ChangeMenu(Menu.OPER);
                        Write(kvp.Key.GetMenuCode() + " " + kvp.Value.Item1.GetMenuCode() + " " + kvp.Value.Item2.ToString(), true);
                    }; break;
                    }
                }; break;
                }
            }
            ChangeMenu(Menu.OPER);
            Write("x", true);
            System.Threading.Thread.Sleep(50);

            //write for stability
            Write("st\n", true);

            //write for surface strip forces
            Write("FS\n", true);
            //strip shear/moment
            //Write("VM\n");

            //flush for good luck
            Write("?", true);
        }
Exemple #10
0
 public MenuCodeAttribute(string menuCode, Run_Case.Constraint matchingC)
     : this(menuCode)
 {
     MatchingCon = matchingC;
 }
Exemple #11
0
 private static object GetValueSingleRun(Run_Case rc, PropertyInfo info)
 {
     return(GetPropertyValue(info, rc));
 }
Exemple #12
0
        private List <double[]> GetRelevantData(PropertyInfo info, object data)
        {
            var values = new List <double[]>();

            if (info == null)
            {
                return(values);
            }

            if (info.PropertyType == typeof(double))
            {
                for (int i = 0; i < m_form.designs.Count; i++)
                {
                    var results  = GetValueAllRuns(m_form.designs[i], info);
                    var dresults = new double[results.Length];
                    Array.Copy(results, dresults, results.Length);
                    values.Add(dresults);
                }
            }
            else if ((info.PropertyType == typeof(double[]) && data != null && data.GetType() == typeof(int)))
            {
                for (int i = 0; i < m_form.designs.Count; i++)
                {
                    var results  = GetValueAllRuns(m_form.designs[i], info);
                    var dresults = new double[results.Length];
                    for (int j = 0; j < results.Length; j++)
                    {
                        dresults[j] = ((double[])results[j])[(int)data];
                    }
                    values.Add(dresults);
                }
            }
            else if ((info.PropertyType == typeof(double[, ]) && data != null && data.GetType() == typeof(int)))
            {
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    Run_Case rc = GetRepresentedCase(listView1.SelectedItems[i]);
                    if (rc != null)
                    {
                        var results  = (double[, ])GetValueSingleRun(rc, info);
                        var dresults = new double[results.GetLength(0)];
                        for (int j = 0; j < results.GetLength(0); j++)
                        {
                            dresults[j] = ((double)results[j, (int)data]);
                        }
                        values.Add(dresults);
                    }
                }
            }
            else if ((info.PropertyType == typeof(Dictionary <string, double[, ]>) && data != null && data.GetType() == typeof(int)))
            {
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    Run_Case rc = GetRepresentedCase(listView1.SelectedItems[i]);
                    if (rc != null)
                    {
                        var results = (Dictionary <string, double[, ]>)GetValueSingleRun(rc, info);
                        foreach (var kvp in results)
                        {
                            var dresults = new double[kvp.Value.GetLength(0)];
                            for (int j = 0; j < dresults.GetLength(0); j++)
                            {
                                dresults[j] = ((double)kvp.Value[j, (int)data]);
                            }
                            values.Add(dresults);
                        }
                    }
                }
            }
            return(values);
        }