Example #1
0
        /// <summary>
        /// Atthis stage it plots and writes to richtext. Should change it.
        /// </summary>
        /// <param name="pcu">value from pcu</param>
        /// <param name="powermeter">value from power meter</param>
        /// <param name="cnf">configured value by the test</param>
        /// <param name="chartarea">The chart area name where data should go</param>
        /// <param name="FS">the fulscale value used for accuracy</param>
        /// <param name="filter_mask">the mask to filter plotted values</param>
        private void plot_general(string pcu, string powermeter, string cnf, string chartarea, float persent_fail_margin, List <float> filter_mask,
                                  List <float> maskVdccnf)
        {
            List <string> valuesforreport = new List <string>()
            {
                "Wacvarconfigured", "Wacconfigured", "Wdcconfigured", "Vdcconfigured",
                "Phaseconfigured", "Temperature", "Vacpowermeter"
            };
            //clear series and add the series
            //chart3.Series.Clear();
            //Get the column float values: (cnf is configured values)
            List <float> CNF = getfloatlist(cnf);
            List <float> PM  = getfloatlist(powermeter);
            List <float> PCU = getfloatlist(pcu);
            //Get the bool fail list for specific margins (The ones are percentage 1)
            //convert double from the numericUpDown to float
            float       failpersentage   = persent_fail_margin;
            List <bool> accuracyfaillist = new List <bool>(Calculate.Pesentage_faillist(PCU, PM, failpersentage));

            //**************************Setup chart4********************************************************
            addlist_series_tochart(chart4, new List <string>()
            {
                pcu
            });
            setupseriesline(chart4.Series[pcu]);   //setup the color and the line type plot
            chart4.Series[pcu].Points.AddXY(0, 0); //Add the first dot to the line
            //******************************End chart 4 setup***********************************************
            //*****************************Setup chart 3****************************************************
            addlist_series_tochart(chart3, new List <string> {
                pcu, powermeter, cnf
            });
            //List<bool> accuracyfaillist = new List<bool>(Calculate.Faillist(PCU, PM, 1, FS, 1));
            chart3.Series[powermeter].ChartArea = chartarea;
            chart3.Series[cnf].ChartArea        = chartarea;
            setupseriescross(chart3.Series[cnf]);
            setupseriescircle(chart3.Series[powermeter]);
            //****************************End setup chart 3*************************************************
            //Add a litte heading to the richtextbob
            richTextBox1.AppendText("*****************************" + pcu + "**********************************" + "\r\n");
            for (int i = 0; i < PM.Count; i++)
            {
                //ignore the values that is below this value in textbox10 and above textBox13
                if (filter_mask[i] > float.Parse(textBox10.Text) && filter_mask[i] < float.Parse(textBox13.Text))
                {
                    //Filter according to Vcnf
                    if (maskVdccnf[i] > float.Parse(textBox5.Text) && maskVdccnf[i] < float.Parse(textBox6.Text))
                    {
                        if (accuracyfaillist[i] == false)
                        {
                            if (CSVrowManager.GetaCSVrow(i) != null)
                            {
                                //Append text to the richtext box
                                richTextBox1.AppendText(CSVrowManager.GetaCSVrow(i).Humantext(valuesforreport) + "\r\n");
                                //Add point to the chart
                                chart3.Series[powermeter].Points.AddY(PM[i]);
                                chart3.Series[cnf].Points.AddY(CNF[i]);
                                //**************************CHART4*************************
                                //Add bug plot to the line plot
                                chart4.Series[pcu].Points.AddXY(i, 0);
                                chart4.Series[pcu].Points.AddXY(i, 3);
                                chart4.Series[pcu].Points.AddXY(i, 0);
                                //**********************Accumulate bugs to Chart 4****************
                                //if the series is empty then add something
                                if (chart4.Series["Accumulate"].Points.Count == 0)
                                {
                                    chart4.Series["Accumulate"].Points.AddXY(0, 0);
                                }
                                //If the series is empty then add something
                                DataPoint datapoint = chart4.Series["Accumulate"].Points.FindByValue(i, "X", 0);//o is start index
                                if (datapoint == null)
                                {
                                    chart4.Series["Accumulate"].Points.AddXY(i, 1);
                                }
                                else
                                {
                                    datapoint.SetValueY(datapoint.YValues.Last() + 1);
                                }
                            }
                        }
                    }
                }
            }
            setbackground(chart3.Series[powermeter], chartarea);
        }
Example #2
0
        //************************************Done populating data for baseline*********************
        //************************************Start populating UUT instances with data*************
        /// <summary>
        /// Populate data for the unit under test
        /// </summary>
        /// <param name="filename"></param>
        private void populatedatatestunit(string filename)
        {
            //clear the old values
            if (wantedcolumns.Count > 0)
                wantedcolumns.Clear();
            if (realpowerdict.Count > 0)
                realpowerdict.Clear();
            if (colobjinterflist.Count > 0)
                colobjinterflist.Clear();

            if (!(File.Exists(filename)))
            {
                MessageBox.Show("The data file: !exist");
                return;
            }
            //datacolumnsbl come from xml so do not clear it
            foreach (Column c in datacolumns.namealiaslist)
            {
                //Clear the values in the columns
                c.clearvalues();
                wantedcolumns.Add(c);
            }
            // Read data from CSV file
            using (CsvFileReader reader = new CsvFileReader(filename))
            {
                CsvRow row = new CsvRow();
                rowcount = 0;
                while (reader.ReadRow(row))
                {
                    //if the row count is 0, then headers
                    if (rowcount == 0)
                    {
                        foreach (string s in row)
                        {
                            //the first row is the header
                            foreach (Column c in wantedcolumns)
                                //if the name is in the wanted columns save position
                                if (c.columnname == s)
                                    c.columnnumber = row.IndexOf(s);
                        }
                    }
                    else
                    {
                        foreach (Column c in wantedcolumns)
                        {
                            c.colvalues.Add(row[c.columnnumber]);
                        }
                    }
                    rowcount++;
                }
                Richtextedit("Datarows imported: " + Convert.ToString(rowcount));
            }

            foreach (Column c in wantedcolumns)
            {
                realpowerdict.Add(c.alias, c);
            }
            //Uses the CSVrowManager to load all the wanted data as they exist in rows
            CSVrowManager = new CSVrowManager();
            CSVrowManager.Load(wantedcolumns);

            //columnobjectlist = new List<Baselist>();
            foreach (var VAR in realpowerdict)
            {
                /// <summary>
                /// Below the instance is created and!!! the parameter is passes to it. I like it. 
                /// VAR.Value.Columnvalues is the value
                /// </summary>
                //columnobjectlist.Add((Baselist)Activator.CreateInstance(Type.GetType("PlotDVT." + VAR.Key), VAR.Value.Columnvalues));
                if(VAR.Key == "Vdcconfigured")
                {
                    colobjinterflist.Add((IBaselist)Activator.CreateInstance
                        (Type.GetType("PlotDVT.VdcconfiguredI"), VAR.Value.Columnvalues, VAR.Key));

                }
                else if (VAR.Key == "Phaseconfigured")
                {
                    colobjinterflist.Add((IBaselist)Activator.CreateInstance
                        (Type.GetType("PlotDVT.PhaseconfiguredI"), VAR.Value.Columnvalues, VAR.Key));
                }
                else
                {
                    colobjinterflist.Add((IBaselist)Activator.CreateInstance(Type.GetType("PlotDVT.ValuelistI"), VAR.Value.Columnvalues, VAR.Key));
                }
            }

            foreach (IBaselist Ibl in colobjinterflist)
            {
                if (Ibl.GetName() == "Phaseconfigured")
                {
                    //Find Vdcconfigure to get slice parameters
                    foreach (IBaselist Ibltwo in colobjinterflist)
                    {
                        if (Ibltwo.GetName() == "Vdcconfigured")
                        {
                            (Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices);
                            (Ibltwo as VdcconfiguredI).Setphaseslice((Ibl as PhaseconfiguredI).Listslices2);
                        }
                    }
                    break;    
                }
            }
            ///<summary>
            ///Below loop creates the slices of the column set up by Vdcconfigured.
            ///New with interface implementation
            ///</summary>
            //slices = Ibl.GetSlices();
            try
            {
                //Find Vdcconfigure to get slice parameters
                foreach (IBaselist Ibltwo in colobjinterflist)
                {
                    if (Ibltwo.GetName() == "Vdcconfigured")
                    {
                       // (Ibltwo as VdcconfiguredI)
                        foreach(IBaselist Ibl in colobjinterflist)
                        {
                            if (!(Ibl.GetName() == "Vdcconfigured"))
                            {
                                Ibl.Populareslices((Ibltwo as VdcconfiguredI).Slicelist);
                            }
                        }
                    }
                }
            }
            catch (InvalidCastException)
            {

            }

        }
Example #3
0
        /// <summary>
        /// This function gets called by button press
        /// Plots the Var vs real power triangle
        /// This plot is a special plot. It plot the ractive power
        /// triangles and writest to the richtextbox.
        /// </summary>
        private async void async_col_sequenceplot()
        {
            //Clear all the data points
            if (chart3.Series != null)
            {
                foreach (Series s in chart3.Series)
                {
                    clearseries(s);
                }
            }
            //Clear all the data points
            if (chart4.Series != null)
            {
                foreach (Series s in chart4.Series)
                {
                    clearseries(s);
                }
            }

            //enter a dalay for user feedback to show chart is updated
            await Task.Delay(100);

            //chart3.Titles.Clear();
            //AC plots Below are the values for chart one, Wacpm also used for filter
            List <float> Wacpm = getfloatlist("Wacpowermeter");
            //Filter mask, Get a masked value, this will be mask2!!!!!!
            List <float> maskVdccnf = getfloatlist("Vdcconfigured");
            //List<float> Wacpm = new List<float>(colobjinterflist.First(item => item.GetName() == "Wacpowermeter").GetFloats());
            List <float> Wvarpm  = getfloatlist("ACvarpowermeter");
            List <float> Waccnf  = getfloatlist("Wacconfigured");
            List <float> Wvarcnf = getfloatlist("Wacvarconfigured");
            //never plot these just use them to determine accuracy
            List <float> WACpcu     = getfloatlist("Wacpcu");
            List <float> WACimagpcu = getfloatlist("Wacimagpcu");
            //Get a bool fail list to do selective plotting
            List <bool> accuracyfaillist = new List <bool>
                                               (Calculate.Faillist(WACpcu, Wacpm, 1, float.Parse(textBox9.Text), 1));
            List <bool> accuracyfaillistvar = new List <bool>
                                                  (Calculate.Faillist(WACimagpcu, Wvarpm, 1, float.Parse(textBox9.Text), 1));
            //this is independent of plot
            List <string> valuesforreport = new List <string>()
            {
                "Wacvarconfigured", "Wacconfigured", "Wdcconfigured", "Vdcconfigured",
                "Phaseconfigured", "Temperature", "Vacpowermeter"
            };
            //clear value everytime button calls this function
            List <string> listofseries = new List <string>()
            {
                "Wacpowermeter", "Wacconfigured"
            };

            // Create a list of values to extract, alias names from xml
            //**************************Setup chart3***************************************************
            //chart3.Series.Clear();
            //AC plots Set up axis variables
            setup_chart3axes(chart3);
            addlist_series_tochart(chart3, listofseries);
            Series Waccnfseries  = chart3.Series["Wacconfigured"];
            Series Wacpowermeter = chart3.Series["Wacpowermeter"];

            //**************************Setup chart4***************************************************
            setup_chart4axes(chart4, Wvarpm.Count);
            addlist_series_tochart(chart4, new List <string>()
            {
                "Wacpowermeter", "Accumulate"
            });
            setupseriesline(chart4.Series["Wacpowermeter"]);   //setup the color and the line type plot
            setupseriescross(chart4.Series["Accumulate"]);     //setup the color and the line type plot
            chart4.Series["Wacpowermeter"].Points.AddXY(0, 0); //Add the first dot to the line
            //******************************End chart 4 setup***********************************************
            //var and watt
            setupseriesline(Wacpowermeter);
            setupseriescross(Waccnfseries);
            //**END configure series**
            //Inititalise classes for different bugs, the int is the chartarea number
            //Bugs class contains a list of text bugrows
            Wacpowerbuglist = new Bugs(0);
            Vdcvbuglist     = new Bugs(1);
            Idcvbuglist     = new Bugs(2);
            Vacbuglist      = new Bugs(3);
            List <Bugs> Bugslist = new List <Bugs>()
            {
                Wacpowerbuglist
            };

            //loop trough a series to cover every value
            for (int i = 0; i < Wacpm.Count; i++)
            {
                //This will have to stay a special plot
                if (accuracyfaillist[i] == false || accuracyfaillistvar[i] == false)
                {
                    //ignore the values that is below this value in textbox10 and above textBox13
                    if (Wacpm[i] > float.Parse(textBox10.Text) && Wacpm[i] < float.Parse(textBox13.Text))
                    {
                        //Filter according to Vcnf
                        if (maskVdccnf[i] > float.Parse(textBox5.Text) && maskVdccnf[i] < float.Parse(textBox6.Text))
                        {
                            Wacpowerbuglist.Addbug(CSVrowManager.GetaCSVrow(i));
                            //Plot the congfigured w/va powermeter values
                            Wacpowermeter.Points.AddXY(0, 0);
                            Wacpowermeter.Points.AddXY(Wacpm[i], 0);
                            Wacpowermeter.Points.AddXY(Wacpm[i], Wvarpm[i]);
                            Wacpowermeter.Points.AddXY(0, 0);
                            ////Plot the congfigured w/va configured values
                            Waccnfseries.Points.AddXY(Waccnf[i], 0);
                            Waccnfseries.Points.AddXY(Waccnf[i], Wvarcnf[i]);
                            //**************************CHART4*************************
                            //Add bug plot to the line plot
                            chart4.Series["Wacpowermeter"].Points.AddXY(i, 0);
                            chart4.Series["Wacpowermeter"].Points.AddXY(i, 3);
                            chart4.Series["Wacpowermeter"].Points.AddXY(i, 0);
                            //**********************Accumulate bugs to Chart 4*********
                            //if the series is empty then add something
                            if (chart4.Series["Accumulate"].Points.Count == 0)
                            {
                                chart4.Series["Accumulate"].Points.AddXY(0, 0);
                            }
                            DataPoint datapoint = chart4.Series["Accumulate"].Points.FindByValue(i, "X", 0);//o is start index
                            if (datapoint == null)
                            {
                                //chart4.Series["Accumulate"].Points.AddXY(i, 0);
                                chart4.Series["Accumulate"].Points.AddXY(i, 1);
                                //chart4.Series["Accumulate"].Points.AddXY(i, 0);
                            }
                            else
                            {
                                datapoint.SetValueY(datapoint.YValues.Last() + 1);
                            }
                        }
                    }
                }
            }
            //clear the richtext box
            richTextBox1.Clear();
            //hunt bugs kicks of a series of bug plots with Wacpm as the filter list
            huntbugs(Wacpm, maskVdccnf);
            //Writes to richtext box, this needs to be function
            printbugs(Bugslist);
        }