Ejemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // resolve the address to the Access database
            string fileNameString = this.MapPath(".");

            fileNameString += "..\\..\\..\\..\\data\\chartdata.mdb";

            // initialize a connection string
            string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString;

            // define the database query
            string mySelectQuery = "SELECT Name, Sales FROM REPS;";

            // create a database connection object using the connection string
            OleDbConnection myConnection = new OleDbConnection(myConnectionString);

            // create a database command on the connection using query
            OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);

            // open the connection
            myCommand.Connection.Open();

            // create a database reader
            OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            // since the reader implements and IEnumerable, pass the reader directly into
            // the DataBindTable method with the name of the Column to be used as the XValue
            Chart1.DataBindTable(myReader, "Name");

            // close the reader and the connection
            myReader.Close();
            myConnection.Close();
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string        constr = "Data Source=192.168.50.4;Initial Catalog=SBSPMS;Persist Security Info=True;User ID=sa;Password=123456";
                string        str    = "select * from BookInfo";
                SqlConnection con    = new SqlConnection(constr);
                con.Open();
                SqlDataAdapter sda = new SqlDataAdapter(str, con);
                DataSet        ds  = new DataSet();
                sda.Fill(ds, "BookInfo");
                GridView1.DataSource = ds;
                GridView1.DataBind();
                con.Close();

                SqlConnection cn  = new SqlConnection("Data Source=192.168.50.4;Initial Catalog=SBSPMS;Persist Security Info=True;User ID=sa;Password=123456");
                SqlCommand    cmd = cn.CreateCommand();
                cmd.CommandText = "select name,sales from flower";
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                Chart1.DataBindTable(dr, "name");
                dr.Close();
                cn.Close();
            }
        }
        void initChart1()
        {
            SqlDataReader rdr = c.Hospital_Surgeries(Convert.ToInt32(DropDownList1.SelectedItem.Text), DropDownList2.SelectedItem.Text);

            if (rdr != null)
            {
                Chart1.Visible = true;
                Label1.Text    = "";
                Chart1.DataBindTable(rdr, "Name");
            }
            else
            {
                Label1.Text    = "There is No Enough Data ";
                Chart1.Visible = false;
            }
        }
        void initChart1()
        {
            SqlDataReader rdr = c.DiagnosisReport(Convert.ToInt32(DropDownList1.SelectedItem.Text));

            if (rdr != null)
            {
                Chart1.Visible = true;
                Label1.Text    = "";
                Chart1.DataBindTable(rdr, "illness");
            }
            else
            {
                Label1.Text = "There is No Enough Data ";

                Chart1.Visible = false;
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Add Code for a charting control, refer to article bookmarked in edge for details.
                SqlCommand    sqlCmd        = new SqlCommand();
                SqlConnection sqlConn       = new SqlConnection();
                Utilities     Util          = new Utilities();
                string        strConnString = Util.GetConnectionString();
                string        strSqlCmd     = "Select SMT_Data.Requestor as 'Patrtner Name', COUNT (INC) AS 'Count of Incidents' from SMT_Data GROUP BY SMT_Data.Requestor";

                sqlConn.ConnectionString = strConnString;
                sqlCmd.CommandText       = strSqlCmd;
                sqlCmd.Connection        = sqlConn;
                sqlConn.Open();
                SqlDataReader sqlReader;
                sqlReader = sqlCmd.ExecuteReader();
                Chart1.DataBindTable(sqlReader, "Patrtner Name");
                sqlReader.Close();
                sqlConn.Close();
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            // resolve the address to the XML document
            string fileNameString = this.MapPath(".");

            fileNameString += "..\\..\\..\\..\\data\\ExcelData.xls";

            // Create connection object by using the preceding connection string.
            string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
                           fileNameString + ";Extended Properties=\"Excel 8.0;HDR=YES\"";
            OleDbConnection myConnection = new OleDbConnection(sConn);

            myConnection.Open();

            // The code to follow uses a SQL SELECT command to display the data from the worksheet.
            // Create new OleDbCommand to return data from worksheet.
            OleDbCommand myCommand = new OleDbCommand("Select * From [data1$A1:E25]", myConnection);

            // create a database reader
            OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            // Populate the chart with data from the Excel file.
            Chart1.DataBindTable(myReader, "HOUR");

            // close the reader and the connection
            myReader.Close();
            myConnection.Close();

            // Set series appearance
            foreach (Series ser in Chart1.Series)
            {
                ser.ShadowOffset = 1;
                ser.BorderWidth  = 3;
                ser.ChartType    = SeriesChartType.Line;
            }
        }
Ejemplo n.º 7
0
        private void DoThings()
        {
            int Support = 2;

            if (FileUploadControl.PostedFile != null && FileUploadControl.PostedFile.FileName != "" && FileUploadControl.PostedFile.ContentLength > 0)
            {
                using (System.IO.TextReader tr = new System.IO.StreamReader(FileUploadControl.PostedFile.InputStream))
                {
                    while ((line = tr.ReadLine()) != null)
                    {
                        line.Replace("\t", "#");
                        lines.Add(tr.ReadLine());
                    }
                    ViewState["lines"] = lines;
                }
            }
            else
            {
                lines = (List <string>)ViewState["lines"];
            }
            DataTable dt = TableUserControl(lines.ToList());

            // flowLayoutPanel1.Controls.Add(DataGridview);
            DataGridview1.DataSource = dt;
            //DataGridview.AllowPaging = true;
            //DataGridview.PageSize = PageSize;
            DataGridview1.DataBind();
            // DataGridview.PageIndexChanging += new GridViewPageEventHandler(GridView1_PageIndexChanging);

            //DataGridview.PageIndexChanging += GridView1_PageIndexChanging;


            var enumerableTable = (dt as System.ComponentModel.IListSource).GetList();

            Chart1.DataBindTable(enumerableTable, "Itemset");
            //Chart1.Series["Series1"].XValueMember = "Count";
            //Chart1.Series["Series1"].YValueMembers = "Itemset";
            //Chart1.DataSource = dt;
            //Chart1.DataBind();

            //Chart ItemsetChart = new Chart();
            //ItemsetChart.Series.Add("x");
            //ItemsetChart.Series["x"].XValueMember = "Itemset";
            //ItemsetChart.Series["x"].YValueMembers = "Count";
            //ItemsetChart.DataSource = dt;
            //ItemsetChart.DataBind();

            BAL.Apriori        apriori  = new BAL.Apriori(lines.ToList());
            int                k        = 1;
            List <BAL.ItemSet> ItemSets = new List <BAL.ItemSet>();
            bool               next;

            do
            {
                next = false;
                var L = apriori.GetItemSet(k, Support, IsFirstItemList: k == 1);
                if (L.Count > 0)
                {
                    List <AssociationRule> rules = new List <AssociationRule>();
                    if (k != 1)
                    {
                        rules = apriori.GetRules(L);
                    }
                    //  TableUserControl tableL = new TableUserControl(L, rules);
                    TableUserControl(L, rules);

                    next = true;
                    k++;
                    ItemSets.Add(L);
                }
            } while (next);
        }
    private void Draw()
    {
        DataTable table, table2, table3;
        DataView  dView;

        table  = new DataTable();
        table2 = new DataTable();
        table3 = new DataTable();
        DataColumn column;
        DataRow    row;

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Częstotliwość";
        table.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Widmo amplitudowe";
        table.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Częstotliwość";
        table2.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Widmo fazowe";
        table2.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Częstotliwość";
        table3.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "Obwiednia prądu";
        table3.Columns.Add(column);

        column            = new DataColumn();
        column.DataType   = System.Type.GetType("System.Double");
        column.ColumnName = "-Obwiednia prądu";
        table3.Columns.Add(column);


        for (int i = 0; i <= fmax - fmin; i++)
        {
            row = table.NewRow();
            row["Częstotliwość"]     = Results[i, 0];
            row["Widmo amplitudowe"] = Results[i, 1];
            table.Rows.Add(row);
        }
        dView = new DataView(table);
        Chart1.Series.Clear();
        Chart1.DataBindTable(dView, "Częstotliwość");
        Chart1.Series["Widmo amplitudowe"].ChartType = SeriesChartType.Line;
        Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{#0}";
        Chart1.Height = 600;
        Chart1.Width  = 1500;
        Chart1.ChartAreas[0].BackColor = System.Drawing.Color.Azure;
        Chart1.BackColor = System.Drawing.Color.SeaShell;
        Chart1.ChartAreas[0].AxisX.LineWidth     = 3;
        Chart1.ChartAreas[0].AxisX.Title         = "f [Hz]";
        Chart1.ChartAreas[0].AxisY.Title         = "ku [dB]";
        Chart1.ChartAreas[0].AxisX.TitleFont     = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Italic);
        Chart1.ChartAreas[0].AxisX.LogarithmBase = 10;
        Chart1.ChartAreas[0].AxisX.IsLogarithmic = true;
        Chart1.ChartAreas[0].AxisY.TitleFont     = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold);
        Chart1.Titles.Add("Widmo amplitudowe");
        Chart1.Titles[0].Font               = new System.Drawing.Font("Times New Roman", 16F, System.Drawing.FontStyle.Bold);
        Chart1.Titles[0].ForeColor          = System.Drawing.Color.Black;
        Chart1.Legends[0].DockedToChartArea = Chart1.ChartAreas[0].Name;
        Chart1.Legends[0].Docking           = Docking.Right;
        Chart1.ChartAreas[0].AxisX.Minimum  = fmin;
        Chart1.ChartAreas[0].AxisX.Maximum  = fmax;

        for (int i = 0; i <= fmax - fmin; i++)
        {
            row = table2.NewRow();
            row["Częstotliwość"] = Results[i, 0];
            row["Widmo fazowe"]  = Results[i, 2];
            table2.Rows.Add(row);
        }
        dView = new DataView(table2);
        Chart2.Series.Clear();
        Chart2.DataBindTable(dView, "Częstotliwość");
        Chart2.Series["Widmo fazowe"].ChartType      = SeriesChartType.Line;
        Chart2.ChartAreas[0].AxisX.LabelStyle.Format = "{#0}";
        Chart2.Height = 600;
        Chart2.Width  = 1500;
        Chart2.ChartAreas[0].BackColor = System.Drawing.Color.Azure;
        Chart2.BackColor = System.Drawing.Color.SeaShell;
        Chart2.ChartAreas[0].AxisX.LineWidth     = 3;
        Chart2.ChartAreas[0].AxisX.Title         = "f [Hz]";
        Chart2.ChartAreas[0].AxisY.Title         = "fi [rad]";
        Chart2.ChartAreas[0].AxisX.TitleFont     = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Italic);
        Chart2.ChartAreas[0].AxisX.LogarithmBase = 10;
        Chart2.ChartAreas[0].AxisX.IsLogarithmic = true;
        Chart2.ChartAreas[0].AxisY.TitleFont     = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold);
        Chart2.Titles.Add("Widmo fazowe");
        Chart2.Titles[0].Font               = new System.Drawing.Font("Times New Roman", 16F, System.Drawing.FontStyle.Bold);
        Chart2.Titles[0].ForeColor          = System.Drawing.Color.Black;
        Chart2.Legends[0].DockedToChartArea = Chart2.ChartAreas[0].Name;
        Chart2.Legends[0].Docking           = Docking.Right;
        Chart2.ChartAreas[0].AxisX.Minimum  = fmin;
        Chart2.ChartAreas[0].AxisX.Maximum  = fmax;

        for (int i = 0; i <= fmax - fmin; i++)
        {
            row = table3.NewRow();
            row["Częstotliwość"]    = Results[i, 0];
            row["Obwiednia prądu"]  = Results[i, 3];
            row["-Obwiednia prądu"] = Results[i, 4];
            table3.Rows.Add(row);
        }
        dView = new DataView(table3);
        Chart3.Series.Clear();
        Chart3.DataBindTable(dView, "Częstotliwość");
        Chart3.Series["Obwiednia prądu"].ChartType   = SeriesChartType.Line;
        Chart3.Series["-Obwiednia prądu"].ChartType  = SeriesChartType.Line;
        Chart3.ChartAreas[0].AxisX.LabelStyle.Format = "{#0}";
        Chart3.Height = 600;
        Chart3.Width  = 1500;
        Chart3.ChartAreas[0].BackColor = System.Drawing.Color.Azure;
        //Chart3.BackImage = "~/backround2.png";
        Chart3.ChartAreas[0].AxisX.LineWidth     = 3;
        Chart3.ChartAreas[0].AxisX.Title         = "f [Hz]";
        Chart3.ChartAreas[0].AxisY.Title         = "I [A]";
        Chart3.ChartAreas[0].AxisX.TitleFont     = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Italic);
        Chart3.ChartAreas[0].AxisX.LogarithmBase = 10;
        Chart3.ChartAreas[0].AxisX.IsLogarithmic = true;
        Chart3.ChartAreas[0].AxisY.TitleFont     = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Bold);
        Chart3.Titles.Add("Obwiednia prądu zasilającego");
        Chart3.Titles[0].Font               = new System.Drawing.Font("Times New Roman", 16F, System.Drawing.FontStyle.Bold);
        Chart3.Titles[0].ForeColor          = System.Drawing.Color.Black;
        Chart3.Legends[0].DockedToChartArea = Chart2.ChartAreas[0].Name;
        Chart3.Legends[0].Docking           = Docking.Right;
        Chart3.ChartAreas[0].AxisX.Minimum  = fmin;
        Chart3.ChartAreas[0].AxisX.Maximum  = fmax;
    }
    protected void btnOblicz_Click(object sender, EventArgs e)
    {
        bool bVal1 = Int32.TryParse(txtTmin.Text, out Tmin);
        bool bVal2 = Int32.TryParse(txtTmax.Text, out Tmax);
        bool bVal4 = Double.TryParse(txtUt_m.Text, out U_mnoznik);


        //Chart1.Visible = true;
        //Chart4.Visible = true;
        //---

        modelParams = new ModelParams();

        //modelParams.TimeStart = tmin;
        //modelParams.TimeStop = tmax;
        modelParams.Uarma = Ua * U_mnoznik;
        modelParams.Uflux = Uf;

        modelParams.Raext = Ra_ext;
        modelParams.Rfext = Rf_ext;
        modelParams.Maext = Ma_ext * 0.001;   //przeliczenie jednostek do µF i mH
        modelParams.Mfext = Mf_ext * 0.001;   //przeliczenie jednostek do µF i mH



        If = modelParams.Uflux / modelParams.Rfint;
        //Ia = (modelParams.Uarma - modelParams.Gaf * If * ω) / modelParams.Raint;
        //ω = (modelParams.Uarma - modelParams.Raint * Ia) / (modelParams.Gaf * If);

        //modelParams.Jrext = Jr_ext;
        modelParams.Drext = Dr_ext;

        //Text = modelParams.Drext * ω - modelParams.Gaf * If * Ia;

        //ustawianie parametrow momentu zewnetrznego
        modelParams.Textern    = Text;
        modelParams.Textern_t1 = Text_t1;
        modelParams.Textern_t2 = Text_t2;
        //----
        flag = false;

        //size = Convert.ToInt32(Tmax / delta); //liczenie ilości próbek ; modelParams.Tstop
        //modelParams.PtsResults = size;

        size = modelParams.PtsResults;
        //------------Sprawdzenie poprawności wprowadzania danych - walidacja-------------
        if (Tmin >= Tmax || Tmin < 0 || !bVal1 || !bVal2)
        {
            validation.Visible         = true;
            labErrorMessage_Tm.Visible = true;
            labErrorMessage_Tm.Text    = "Wartości parametrów t<sub>min</sub> oraz t<sub>max</sub> zostały wprowadzone błędnie ";
            txtTmin.BackColor          = System.Drawing.Color.Red;
            txtTmax.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }

        /* Sprawdzenie poprawności napięć*/

        if (!bVal4 || Ua < 0)
        {
            validation.Visible = true;
            labErrorMessage_Voltage.Visible = true;
            labErrorMessage_Voltage.Text    = "Błędnie wprowadzona wartość napięcia twornika";
            txtUt_m.BackColor = System.Drawing.Color.Red;
            flag = true;
        }

        /*pętla*/

        if (flag == true)
        {
            return;
        }
        else
        {
            labErrorMessage.Visible = true;
            labErrorMessage.Text    = "Dane zostały wprowadzone poprawnie";
            Chart1.Visible          = true;
        }

        this.mathModel = new MathModel(modelParams, modelParams.TimeStart, modelParams.InitCondit);
        this.solver    = new Solver(modelParams, mathModel);
        //---
        solver.SolverStart(modelParams);
        double[,] wyniki = solver.Results;

        //-- pierwsza tabela danych do wykresu 1

        table1 = new DataTable();
        //--
        DataColumn column1;
        DataRow    row1;

        //--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "Torque";
        table1.Columns.Add(column1);

        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "ω";
        table1.Columns.Add(column1);

        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "ω przy Uan";
        table1.Columns.Add(column1);

        //----------------
        //int size_tmin = Convert.ToInt32(Tmin / delta);
        //labErrorMessage.Text = "jest to ilosc " + (int)size;

        double[,] array;

        for (int i = Tmin; i <= Tmax; i++)
        {
            array              = new double[Tmax + 1, 3];
            array[i, 0]        = i;
            array[i, 1]        = ((modelParams.Uarma / modelParams.Gaf * If) - (modelParams.Raint / Math.Pow(modelParams.Gaf * If, 2)) * i) * 10;
            array[i, 2]        = ((Ua / modelParams.Gaf * If) - (modelParams.Raint / Math.Pow(modelParams.Gaf * If, 2)) * i) * 10;
            row1               = table1.NewRow();
            row1["Torque"]     = array[i, 0];
            row1["ω"]          = array[i, 1];
            row1["ω przy Uan"] = array[i, 2];



            table1.Rows.Add(row1);
        }
        //--
        dView1 = new DataView(table1);
        //--
        Chart1.Series.Clear();
        Chart1.ChartAreas.Add("Wykres01");
        //--
        Chart1.DataBindTable(dView1, "Torque");
        Chart1.Width  = 900;
        Chart1.Height = 750;
        Chart1.Series["ω"].ChartType            = SeriesChartType.Line;
        Chart1.Series["ω"].BorderWidth          = 3; //grubosc wykresu
        Chart1.Series["ω przy Uan"].ChartType   = SeriesChartType.Line;
        Chart1.Series["ω przy Uan"].BorderWidth = 3; //grubosc wykresu


        //if (chkIcs.Checked)
        //{
        //    Chart1.Visible = true;
        //    Chart1.Series["Ics"].ChartType = SeriesChartType.Line;
        //    Chart1.Series["Ics"].BorderWidth = 3;//grubosc wykresu
        //}
        //Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        Chart1.ChartAreas[0].AxisX.Minimum = 0;
        //Chart1.ChartAreas[0].AxisX.Maximum = (double)table1.Rows[size]["Torque"];
        //Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        Chart1.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart1.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        Chart1.ChartAreas[0].AxisX.Title             = "Text [Nm]";
        Chart1.ChartAreas[0].AxisY.Title             = "ω [rad/s]";
        Chart1.ChartAreas[0].AxisX.TitleFont         = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        Chart1.ChartAreas[0].AxisY.TitleFont         = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
    }
Ejemplo n.º 10
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUploader.HasFile)
            {
                try
                {
                    FileUploader.SaveAs(Server.MapPath(DefaultFileName) + FileUploader.FileName);

                    Image <Bgr, Byte> originalImage = new Image <Bgr, byte>(Server.MapPath(DefaultFileName) + FileUploader.FileName);
                    int width, height, channels = 0;
                    width    = originalImage.Width;
                    height   = originalImage.Height;
                    channels = originalImage.NumberOfChannels;

                    Image <Bgr, byte>  colorImage = new Image <Bgr, byte>(originalImage.ToBitmap());
                    Image <Gray, byte> grayImage  = colorImage.Convert <Gray, Byte>();

                    float[]        GrayHist;
                    DenseHistogram Histo = new DenseHistogram(255, new RangeF(0, 255));
                    Histo.Calculate(new Image <Gray, Byte>[] { grayImage }, true, null);
                    GrayHist = new float[256];
                    Histo.MatND.ManagedArray.CopyTo(GrayHist, 0);
                    float largestHist   = GrayHist[0];
                    int   thresholdHist = 0;
                    for (int i = 0; i < 255; i++)
                    {
                        if (GrayHist[i] > largestHist)
                        {
                            largestHist   = GrayHist[i];
                            thresholdHist = i;
                        }
                    }

                    grayImage  = grayImage.ThresholdAdaptive(new Gray(255), ADAPTIVE_THRESHOLD_TYPE.CV_ADAPTIVE_THRESH_MEAN_C, THRESH.CV_THRESH_BINARY, 85, new Gray(4));
                    colorImage = colorImage.Copy();
                    int countRedCells = 0;
                    using (MemStorage storage = new MemStorage())
                    {
                        for (Contour <Point> contours = grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage); contours != null; contours = contours.HNext)
                        {
                            Contour <Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.015, storage);
                            if (currentContour.BoundingRectangle.Width > 20)
                            {
                                CvInvoke.cvDrawContours(colorImage, contours, new MCvScalar(0, 0, 255), new MCvScalar(0, 0, 255), -1, 2, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
                                colorImage.Draw(currentContour.BoundingRectangle, new Bgr(0, 255, 0), 1);
                                countRedCells++;
                            }
                        }
                    }

                    Image <Gray, byte> grayImageCopy2 = originalImage.Convert <Gray, Byte>();
                    grayImageCopy2 = grayImageCopy2.ThresholdBinary(new Gray(100), new Gray(255));
                    colorImage     = colorImage.Copy();
                    int countMalaria = 0;
                    using (MemStorage storage = new MemStorage())
                    {
                        for (Contour <Point> contours = grayImageCopy2.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, storage); contours != null; contours = contours.HNext)
                        {
                            Contour <Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.015, storage);
                            if (currentContour.BoundingRectangle.Width > 20)
                            {
                                CvInvoke.cvDrawContours(colorImage, contours, new MCvScalar(255, 0, 0), new MCvScalar(255, 0, 0), -1, 2, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
                                colorImage.Draw(currentContour.BoundingRectangle, new Bgr(0, 255, 0), 1);
                                countMalaria++;
                            }
                        }
                    }

                    colorImage.Save(Server.MapPath(DefaultFileName2) + FileUploader.FileName);

                    inputDiv.Attributes["style"]  = "display: block; margin-left: auto; margin-right: auto";
                    outputDiv.Attributes["style"] = "display: block; margin-left: auto; margin-right: auto";
                    Image1.ImageUrl = this.ResolveUrl(DefaultFileName + FileUploader.FileName);
                    Image2.ImageUrl = this.ResolveUrl(DefaultFileName2 + FileUploader.FileName);
                    Chart1.DataBindTable(GrayHist);
                    Label1.Text = "Uploaded Successfully";
                    Label2.Text = "File name: " +
                                  FileUploader.PostedFile.FileName + "<br>" + "File Size: " +
                                  FileUploader.PostedFile.ContentLength + " kb<br>" + "Content type: " + FileUploader.PostedFile.ContentType + "<br>"
                                  + "Resolution: " + width.ToString() + "x" + height.ToString() + "<br>"
                                  + "Number of channels: " + channels.ToString() + "<br>"
                                  + "Histogram (maximum value): " + largestHist + " @ " + thresholdHist;

                    LabelRed.Text     = countRedCells.ToString();
                    LabelMalaria.Text = countMalaria.ToString();
                }
                catch (Exception ex)
                {
                    Label1.Text = "ERROR: " + ex.Message.ToString();
                    Label2.Text = "";
                }
            }
            else
            {
                Label1.Text = "You have not specified a file.";
                Label2.Text = "";
            }
        }
Ejemplo n.º 11
0
    protected void btnOblicz_Click(object sender, EventArgs e)
    {
        bool bVal1  = Double.TryParse(txtTmin.Text, out tmin);
        bool bVal2  = Double.TryParse(txtTmax.Text, out tmax);
        bool bVal4  = Double.TryParse(txtUa.Text, out Ua);
        bool bVal5  = Double.TryParse(txtRa_ext.Text, out Ra_ext);
        bool bVal6  = Double.TryParse(txtRf_ext.Text, out Rf_ext);
        bool bVal7  = Double.TryParse(txtMa_ext.Text, out Ma_ext);
        bool bVal8  = Double.TryParse(txtMf_ext.Text, out Mf_ext);
        bool bVal9  = Double.TryParse(txtJr_ext.Text, out Jr_ext);
        bool bVal10 = Double.TryParse(txtDr_ext.Text, out Dr_ext);
        bool bVal11 = Double.TryParse(txtText.Text, out Text);
        bool bVal12 = Double.TryParse(txtText_t1.Text, out Text_t1);
        bool bVal13 = Double.TryParse(txtText_t2.Text, out Text_t2);

        //Chart1.Visible = true;
        //Chart4.Visible = true;
        //---

        modelParams = new ModelParams();

        //modelParams.TimeStart = tmin;
        modelParams.TimeStop = tmax;

        modelParams.Uarma = Ua;
        modelParams.Uflux = Uf;

        modelParams.Raext = Ra_ext;
        modelParams.Rfext = Rf_ext;
        modelParams.Maext = Ma_ext * 0.001;   //przeliczenie jednostek do µF i mH
        modelParams.Mfext = Mf_ext * 0.001;   //przeliczenie jednostek do µF i mH

        modelParams.Jrext = Jr_ext;
        modelParams.Drext = Dr_ext;

        //ustawianie parametrow momentu zewnetrznego
        modelParams.Textern    = Text;
        modelParams.Textern_t1 = Text_t1;
        modelParams.Textern_t2 = Text_t2;
        //----
        flag = false;


        size = Convert.ToInt32(tmax / delta); //liczenie ilości próbek

        modelParams.PtsResults = size;
        //------------Sprawdzenie poprawności wprowadzania danych - walidacja-------------
        if (tmin >= tmax || tmax > 5 || tmin < 0 || !bVal1 || !bVal2)
        {
            validation.Visible           = true;
            labErrorMessage_time.Visible = true;
            labErrorMessage_time.Text    = "Wartości parametrów t<sub>min</sub> oraz t<sub>max</sub> zostały wprowadzone błędnie ";
            txtTmin.BackColor            = System.Drawing.Color.Red;
            txtTmax.BackColor            = System.Drawing.Color.Red;
            flag = true;
        }

        /* Sprawdzenie poprawności napięć*/

        if (!bVal4 || Ua < 0)
        {
            validation.Visible = true;
            labErrorMessage_Voltage.Visible = true;
            labErrorMessage_Voltage.Text    = "Błędnie wprowadzona wartość napięcia twornika";
            txtUa.BackColor = System.Drawing.Color.Red;
            flag            = true;
        }
        /* Sprawdzenie poprawności parametrów obwodu*/

        if (!bVal5 || Ra_ext < 0)
        {
            validation.Visible           = true;
            labErrorMessage_Reza.Visible = true;
            labErrorMessage_Reza.Text    = "Błędnie wprowadzona wartość rezystancji obwodu twornika";
            txtRa_ext.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }
        if (!bVal6 || Rf_ext < 0)
        {
            validation.Visible           = true;
            labErrorMessage_Rezf.Visible = true;
            labErrorMessage_Rezf.Text    = "Błędnie wprowadzona wartość rezystancji obwodu wzbudzenia";
            txtRf_ext.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }
        if (!bVal7 || Ma_ext < 0)
        {
            validation.Visible           = true;
            labErrorMessage_Inda.Visible = true;
            labErrorMessage_Inda.Text    = "Błędnie wprowadzona wartość indukcyjności obwodu twornika";
            txtMa_ext.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }
        if (!bVal8 || Mf_ext < 0)
        {
            validation.Visible           = true;
            labErrorMessage_Indf.Visible = true;
            labErrorMessage_Indf.Text    = "Błędnie wprowadzona wartość indukcyjności obwodu wzbudzenia";
            txtMf_ext.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }
        /********sprawdzenie  momentu bezwładności oraz współczynnika tłumienia********/
        if (!bVal9 || Jr_ext < 0 || Jr_ext > 1)
        {
            validation.Visible         = true;
            labErrorMessage_Jr.Visible = true;
            labErrorMessage_Jr.Text    = "Wprowadzono niepoprawną wartość momentu bezwładności";
            txtJr_ext.BackColor        = System.Drawing.Color.Red;
            flag = true;
        }
        if (!bVal10 || Dr_ext < 0 || Dr_ext > 1)
        {
            validation.Visible         = true;
            labErrorMessage_Dr.Visible = true;
            labErrorMessage_Dr.Text    = "Wprowadzono niepoprawną wartość współczynnika tłumienia";
            txtDr_ext.BackColor        = System.Drawing.Color.Red;
            flag = true;
        }
        /*Sprawdzenie warunku momentu*/
        if (Text_t1 > Text_t2 || Text_t2 > tmax || Text_t1 < 0 || Text_t1 < 0 || Text_t2 < 0 || !bVal12 || !bVal13 || !bVal11)
        {
            validation.Visible           = true;
            labErrorMessage_Text.Visible = true;
            labErrorMessage_Text.Text    = "Błędne wartości parametrów Text<sub>t1</sub>, Text<sub>t2</sub> oraz Text";
            txtText.BackColor            = System.Drawing.Color.Red;
            txtText_t1.BackColor         = System.Drawing.Color.Red;
            txtText_t2.BackColor         = System.Drawing.Color.Red;
            flag = true;
        }
        /*pętla*/
        if (flag == true)
        {
            return;
        }
        else
        {
            labErrorMessage.Visible = true;
            labErrorMessage.Text    = "Dane zostały wprowadzone poprawnie";
            Chart1.Visible          = true;
        }

        this.mathModel = new MathModel(modelParams, modelParams.TimeStart, modelParams.InitCondit);
        this.solver    = new Solver(modelParams, mathModel);
        //---
        solver.SolverStart(modelParams);
        double[,] wyniki = solver.Results;
        //-- pierwsza tabela danych do wykresu 1
        table1 = new DataTable();
        //--
        DataColumn column1;
        DataRow    row1;

        //--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "Torque";
        table1.Columns.Add(column1);
        //=--
        //column = new DataColumn();
        //column.DataType = Type.GetType("System.Double");
        //column.ColumnName = "Voltage";
        //table.Columns.Add(column);
        //=--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "Omega";
        table1.Columns.Add(column1);
        //=--
        //column1 = new DataColumn();
        //column1.DataType = Type.GetType("System.Double");
        //column1.ColumnName = "Uf";
        //table1.Columns.Add(column1);
        //=--
        //column1 = new DataColumn();
        //column1.DataType = Type.GetType("System.Double");
        //column1.ColumnName = "Ics";
        //table1.Columns.Add(column1);


        //----- tabela do drugiego wykresu

        //table2 = new DataTable();

        //DataColumn column2;
        //DataRow row2;
        //--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Time";
        //table2.Columns.Add(column2);

        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Uas";
        //table2.Columns.Add(column2);
        ////=--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Ubs";
        //table2.Columns.Add(column2);
        ////=--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Ucs";
        //table2.Columns.Add(column2);

        //-------tabela do trzeciego wykresu

        //table3 = new DataTable();

        //DataColumn column3;
        //DataRow row3;
        //--
        //column3 = new DataColumn();
        //column3.DataType = Type.GetType("System.Double");
        //column3.ColumnName = "Time";
        //table3.Columns.Add(column3);

        //column3 = new DataColumn();
        //column3.DataType = Type.GetType("System.Double");
        //column3.ColumnName = "Iar";
        //table3.Columns.Add(column3);
        ////=--
        //column3 = new DataColumn();
        //column3.DataType = Type.GetType("System.Double");
        //column3.ColumnName = "Ibr";
        //table3.Columns.Add(column3);
        ////=--
        //column3 = new DataColumn();
        //column3.DataType = Type.GetType("System.Double");
        //column3.ColumnName = "Icr";
        //table3.Columns.Add(column3);

        //-------tabela do czwartego wykresu

        //table2 = new DataTable();

        //DataColumn column2;
        //DataRow row2;
        //--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Time";
        //table2.Columns.Add(column2);

        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "ω";
        //table2.Columns.Add(column2);
        //=--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Text";
        //table2.Columns.Add(column2);
        //=--
        //column2 = new DataColumn();
        //column2.DataType = Type.GetType("System.Double");
        //column2.ColumnName = "Telem";
        //table2.Columns.Add(column2);


        //----------------
        int size_tmin = Convert.ToInt32(tmin / delta);

        //labErrorMessage.Text = "jest to ilosc " + (int)size;
        for (int i = 0; i <= size; i++)
        {
            row1           = table1.NewRow();
            row1["Torque"] = wyniki[i, 7];
            row1["Omega"]  = wyniki[i, 3]; //
            //row1["Uf"] = wyniki[i, 6]; //
            //row1["Ics"] = wyniki[i, 3]; //

            table1.Rows.Add(row1);

            //row2 = table2.NewRow();
            //row2["Time"] = wyniki[i, 0];
            //row2["Uas"] = wyniki[i, 9]; //
            //row2["Ubs"] = wyniki[i, 10]; //
            //row2["Ucs"] = wyniki[i, 11]; //

            //table2.Rows.Add(row2);

            //row3 = table3.NewRow();
            //row3["Time"] = wyniki[i, 0];
            //row3["Iar"] = wyniki[i, 4]; //
            //row3["Ibr"] = wyniki[i, 5]; //
            //row3["Icr"] = wyniki[i, 6]; //

            //table3.Rows.Add(row3);

            //row2 = table2.NewRow();
            //row2["Time"] = wyniki[i, 0];
            //row2["ω"] = wyniki[i, 3]; //
            //row2["Text"] = wyniki[i, 5]; //
            //row2["Telem"] = wyniki[i, 6]; //

            //table2.Rows.Add(row2);
        }
        //table1.Rows.RemoveAt(table1.Rows.Count - 1);
        dView1 = new DataView(table1);
        //--

        Chart1.Series.Clear();
        Chart1.ChartAreas.Add("Wykres01");
        //--
        Chart1.DataBindTable(dView1, "Torque");
        Chart1.Width  = 900;
        Chart1.Height = 750;

        //Chart3.Series["Voltage"].ChartType = SeriesChartType.Line;

        Chart1.Series["Omega"].ChartType   = SeriesChartType.Spline;
        Chart1.Series["Omega"].BorderWidth = 3;//grubosc wykresu



        //Chart1.Series["Uf"].ChartType = SeriesChartType.Spline;
        //Chart1.Series["Uf"].BorderWidth = 3;//grubosc wykresu
        //Chart1.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
        //Chart1.Series["Uf"].YAxisType = AxisType.Secondary;

        //if (chkIcs.Checked)
        //{
        //    Chart1.Visible = true;
        //    Chart1.Series["Ics"].ChartType = SeriesChartType.Line;
        //    Chart1.Series["Ics"].BorderWidth = 3;//grubosc wykresu
        //}
        //Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        Chart1.ChartAreas[0].AxisX.Minimum = tmin;
        //Chart1.ChartAreas[0].AxisX.Maximum = (double)table.Rows[size]["Time"];
        //Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        Chart1.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart1.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        Chart1.ChartAreas[0].AxisY2.ArrowStyle = AxisArrowStyle.Lines;
        //Chart1.ChartAreas[0].AxisY2.Minimum = 0.0;
        //Chart1.ChartAreas[0].AxisY2.Maximum = 2.4;
        Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        Chart1.ChartAreas[0].AxisX.Title             = "Moment obrotowy [Nm]";
        Chart1.ChartAreas[0].AxisY.Title             = "Omega [rad/s]";
        //Chart1.ChartAreas[0].AxisY2.Title = "Uf [V]";
        Chart1.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        Chart1.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        //Chart1.ChartAreas[0].AxisY2.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);


        //DRUGI WYKRES

        //dView2 = new DataView(table2);
        ////--

        //Chart2.Series.Clear();
        //Chart2.ChartAreas.Add("Wykres02");
        //Chart2.Series.Add("Series2");
        ////--
        //Chart2.DataBindTable(dView2, "Time");
        //Chart2.Width = 1200;
        //Chart2.Height = 800;

        ////Chart3.Series["Voltage"].ChartType = SeriesChartType.Line;
        //if (chkUas.Checked)
        //{
        //    Chart2.Visible = true;
        //    Chart2.Series["Uas"].ChartType = SeriesChartType.Line;
        //    Chart2.Series["Uas"].BorderWidth = 3;//grubosc wykresu
        //}

        //if (chkUbs.Checked)
        //{
        //    Chart2.Visible = true;
        //    Chart2.Series["Ubs"].ChartType = SeriesChartType.Line;
        //    Chart2.Series["Ubs"].BorderWidth = 3;//grubosc wykresu
        //}

        //if (chkUcs.Checked)
        //{
        //    Chart2.Visible = true;
        //    Chart2.Series["Ucs"].ChartType = SeriesChartType.Line;
        //    Chart2.Series["Ucs"].BorderWidth = 3;//grubosc wykresu
        //}

        ////Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        //Chart2.ChartAreas[0].AxisX.Minimum = tmin;
        ////Chart1.ChartAreas[0].AxisX.Maximum = (double)table.Rows[size]["Time"];
        ////Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        //Chart2.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart2.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        //Chart2.ChartAreas[0].AxisY2.Minimum = 0.0;
        //Chart2.ChartAreas[0].AxisY2.Maximum = 100.0;
        //Chart2.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        //Chart2.ChartAreas[0].AxisX.Title = "Czas [s]";
        //Chart2.ChartAreas[0].AxisY.Title = "Napięcie [U]";
        //Chart2.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Calibri", 15F, System.Drawing.FontStyle.Bold);
        //Chart2.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Calibri", 15F, System.Drawing.FontStyle.Bold);

        //Trzeci WYKRES

        //dView3 = new DataView(table3);
        ////--

        //Chart3.Series.Clear();
        //Chart3.ChartAreas.Add("Wykres03");
        ////--
        //Chart3.DataBindTable(dView3, "Time");
        //Chart3.Width = 1200;
        //Chart3.Height = 800;

        //if (chkIar.Checked)
        //{
        //    Chart3.Visible = true;
        //    Chart3.Series["Iar"].ChartType = SeriesChartType.Line;
        //    Chart3.Series["Iar"].BorderWidth = 3;//grubosc wykresu
        //}

        //if (chkIbr.Checked)
        //{
        //    Chart3.Visible = true;
        //    Chart3.Series["Ibr"].ChartType = SeriesChartType.Line;
        //    Chart3.Series["Ibr"].BorderWidth = 3;//grubosc wykresu
        //}

        //if (chkIcr.Checked)
        //{
        //    Chart3.Visible = true;
        //    Chart3.Series["Icr"].ChartType = SeriesChartType.Line;
        //    Chart3.Series["Icr"].BorderWidth = 3;//grubosc wykresu
        //}

        ////Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        //Chart3.ChartAreas[0].AxisX.Minimum = tmin;
        ////Chart1.ChartAreas[0].AxisX.Maximum = (double)table.Rows[size]["Time"];
        ////Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        //Chart3.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart3.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        //Chart3.ChartAreas[0].AxisY2.Minimum = 0.0;
        //Chart3.ChartAreas[0].AxisY2.Maximum = 100.0;
        //Chart3.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        //Chart3.ChartAreas[0].AxisX.Title = "Czas [s]";
        //Chart3.ChartAreas[0].AxisY.Title = "Prąd [A]";
        //Chart3.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Calibri", 15F, System.Drawing.FontStyle.Bold);
        //Chart3.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Calibri", 15F, System.Drawing.FontStyle.Bold);

        //Czwarty WYKRES

        //dView2 = new DataView(table2);
        //--

        //Chart2.Series.Clear();
        //Chart2.ChartAreas.Add("Wykres04");
        //--

        //Chart2.DataBindTable(dView2, "Time");
        //Chart2.Width = 900;
        //Chart2.Height = 750;



        //Chart4.Visible = true;
        //Chart4.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
        //Chart4.Series["ω"].ChartType = SeriesChartType.Line;
        //Chart4.Series["ω"].BorderWidth = 3;//grubosc wykresu
        //Chart4.Series["ω"].YAxisType = AxisType.Secondary;



        //Chart2.Series["ω"].ChartType = SeriesChartType.Line;
        //Chart2.Series["ω"].BorderWidth = 3;//grubosc wykresu
        //Chart2.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
        //Chart2.Series["ω"].YAxisType = AxisType.Secondary;



        //Chart2.Series["Text"].ChartType = SeriesChartType.Line;
        //Chart2.Series["Text"].BorderWidth = 3;//grubosc wykresu


        //Chart2.Series["Telem"].ChartType = SeriesChartType.Line;
        //Chart2.Series["Telem"].BorderWidth = 3;//grubosc wykresu



        //Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        //Chart2.ChartAreas[0].AxisX.Minimum = tmin;
        //Chart1.ChartAreas[0].AxisX.Maximum = (double)table.Rows[size]["Time"];
        //Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        //Chart2.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart2.ChartAreas[0].AxisY2.ArrowStyle = AxisArrowStyle.Lines;
        //Chart4.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        //Chart4.ChartAreas[0].AxisY2.Minimum = 0.0;
        //Chart4.ChartAreas[0].AxisY2.Maximum = 110.0;
        //Chart2.ChartAreas[0].AxisY2.Title = "prędkość kątowa [rad/s]";
        //Chart2.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        //Chart2.ChartAreas[0].AxisX.Title = "Czas [s]";
        //Chart2.ChartAreas[0].AxisY.Title = "Moment [Nm]";
        //Chart2.ChartAreas[0].AxisX.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        //Chart2.ChartAreas[0].AxisY.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        //Chart2.ChartAreas[0].AxisY2.TitleFont = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
    }
Ejemplo n.º 12
0
    //double[,] aray2;



    protected void btnOblicz_Click(object sender, EventArgs e)
    {
        //bool bVal1 = Double.TryParse(txtUfmin.Text, out tmin);
        //bool bVal2 = Double.TryParse(txtUfmax.Text, out tmax);
        bool bVal1 = Double.TryParse(txtMf_ext.Text, out Mf_ext);
        bool bVal2 = Double.TryParse(txtω.Text, out ω);

        modelParams = new ModelParams();

        //modelParams.TimeStart = tmin;
        modelParams.TimeStop = tmax;

        modelParams.Uarma = Ua;
        modelParams.Uflux = Uf;

        modelParams.Raext = Ra_ext;
        modelParams.Rfext = Rf_ext;
        modelParams.Maext = Ma_ext * 0.001;        //przeliczenie jednostek do µF i mH
        modelParams.Mfext = Mf_ext * 0.001;        //przeliczenie jednostek do µF i mH

        modelParams.Jrext = Jr_ext;
        modelParams.Drext = Dr_ext;



        //ustawianie parametrow momentu zewnetrznego
        modelParams.Textern       = Text;
        modelParams.Textern_t1    = Text_t1;
        modelParams.Textern_t2    = Text_t2;
        modelParams.InitCondit[2] = ω;
        flag = false;

        //modelParams.Textern = Text;

        //size = Convert.ToInt32(tmax / delta); //liczenie ilości próbek

        modelParams.PtsResults = size;

        if (!bVal1 || Mf_ext < 0)
        {
            validation.Visible           = true;
            labErrorMessage_Indf.Visible = true;
            labErrorMessage_Indf.Text    = "Błędnie wprowadzona wartość indukcyjności obwodu wzbudzenia";
            txtMf_ext.BackColor          = System.Drawing.Color.Red;
            flag = true;
        }
        if (ω <= 0 || !bVal2)
        {
            validation.Visible        = true;
            labErrorMessage_ω.Visible = true;
            labErrorMessage_ω.Text    = "Błędne wartości prędkości kątowej wału silnika";
            txtω.BackColor            = System.Drawing.Color.Red;
            flag = true;
        }
        /*pętla*/
        if (flag == true)
        {
            return;
        }
        else
        {
            validation.Visible      = true;
            labErrorMessage.Visible = true;
            labErrorMessage.Text    = "Wprowadzono dane poprawnie";
            Chart1.Visible          = true;
            validation.Visible      = true;
        }
        //--- tablica napięć i prądów do wykresu
        aray1 = new double[17, 3];
        //aray2 = new double[17, 2];
        aray1[0, 0]  = 20;
        aray1[1, 0]  = 30;
        aray1[2, 0]  = 50;
        aray1[3, 0]  = 80;
        aray1[4, 0]  = 100;
        aray1[5, 0]  = 120;
        aray1[6, 0]  = 140;
        aray1[7, 0]  = 160;
        aray1[8, 0]  = 180;
        aray1[9, 0]  = 210;
        aray1[10, 0] = 220;
        aray1[11, 0] = 230;
        aray1[12, 0] = 240;
        aray1[13, 0] = 260;
        aray1[14, 0] = 280;
        aray1[15, 0] = 350;
        aray1[16, 0] = 380;

        //aray1[0, 1] = -0.0018*20*20 +1.4616*20 - 2.5091;
        //aray1[1, 1] = -0.0018*30*30 +1.4616*30 - 2.5091;
        //aray1[2, 1] = -0.0018*50*50 +1.4616*50 - 2.5091;
        //aray1[3, 1] = -0.0018*80*80 +1.4616*80 - 2.5091;
        //aray1[4, 1] = -0.0018*100*100 +1.4616*100 - 2.5091;
        //aray1[5, 1] = -0.0018*120*120 +1.4616*120 - 2.5091;
        //aray1[6, 1] = -0.0018*140*140 +1.4616*140 - 2.5091;
        //aray1[7, 1] = -0.0018*160*160 +1.4616*160 - 2.5091;
        //aray1[8, 1] = -0.0018*180*180 +1.4616*180 - 2.5091;
        //aray1[9, 1] = -0.0018*210*210 +1.4616*210 - 2.5091;
        //aray1[10, 1] = -0.0018*220*220 +1.4616*220 - 2.5091;
        //aray1[11, 1] = -0.0018*230*230 +1.4616*230 - 2.5091;
        //aray1[12, 1] = -0.0018*240*240 +1.4616*240 - 2.5091;
        //aray1[13, 1] = -0.0018*260*260 +1.4616*260 - 2.5091;
        //aray1[14, 1] = -0.0018*280*280 +1.4616*280 - 2.5091;
        //aray1[15, 1] = -0.0018*350*350 +1.4616*350 - 2.5091;
        //aray1[16, 1] = -0.0018*380*380 +1.4616*380 - 2.5091;

        //aray1[0, 2] = -0.0014 * 20 * 20 + 1.3296 * 20 - 7.4899;
        //aray1[1, 2] = -0.0014 * 30 * 30 + 1.3296 * 30 - 7.4899;
        //aray1[2, 2] = -0.0014 * 50 * 50 + 1.3296 * 50 - 7.4899;
        //aray1[3, 2] = -0.0014 * 80 * 80 + 1.3296 * 80 - 7.4899;
        //aray1[4, 2] = -0.0014 * 100 * 100 + 1.3296 * 100 - 7.4899;
        //aray1[5, 2] = -0.0014 * 120 * 120 + 1.3296 * 120 - 7.4899;
        //aray1[6, 2] = -0.0014 * 140 * 140 + 1.3296 * 140 - 7.4899;
        //aray1[7, 2] = -0.0014 * 160 * 160 + 1.3296 * 160 - 7.4899;
        //aray1[8, 2] = -0.0014 * 180 * 180 + 1.3296 * 180 - 7.4899;
        //aray1[9, 2] = -0.0014 * 210 * 210 + 1.3296 * 210 - 7.4899;
        //aray1[10, 2] = -0.0014 * 220 * 220 + 1.3296 * 220 - 7.4899;
        //aray1[11, 2] = -0.0014 * 230 * 230 + 1.3296 * 230 - 7.4899;
        //aray1[12, 2] = -0.0014 * 240 * 240 + 1.3296 * 240 - 7.4899;
        //aray1[13, 2] = -0.0014 * 260 * 260 + 1.3296 * 260 - 7.4899;
        //aray1[14, 2] = -0.0014 * 280 * 280 + 1.3296 * 280 - 7.4899;
        //aray1[15, 2] = -0.0014 * 350 * 350 + 1.3296 * 350 - 7.4899;
        //aray1[16, 2] = -0.0014 * 380 * 380 + 1.3296 * 380 - 7.4899;



        for (int i = 0; i < 17; i++)
        {
            aray1[i, 1] = -0.0018 * Math.Pow(aray1[i, 0], 2) + 1.4516 * aray1[i, 0] - 2.5091;
            aray1[i, 2] = -0.0014 * Math.Pow(aray1[i, 0], 2) + 1.3296 * aray1[i, 0] - 7.4899;
        }



        this.mathModel = new MathModel(modelParams, modelParams.TimeStart, modelParams.InitCondit);
        this.solver    = new Solver(modelParams, mathModel);
        //---
        solver.SolverStart(modelParams);
        double[,] wyniki = solver.Results;
        //-- pierwsza tabela danych do wykresu 1
        table1 = new DataTable();

        DataColumn column1;
        DataRow    row1;

        //--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "If";
        table1.Columns.Add(column1);
        //=--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "Eao ↗";
        table1.Columns.Add(column1);
        //=--
        column1            = new DataColumn();
        column1.DataType   = Type.GetType("System.Double");
        column1.ColumnName = "Eao ↘";
        table1.Columns.Add(column1);
        //=--
        //----------------
        //int size_tmin = Convert.ToInt32(tmin / delta);
        //labErrorMessage.Text = "jest to ilosc " + (int)size;
        for (int i = 0; i <= 16; i++)
        {
            row1          = table1.NewRow();
            row1["If"]    = aray1[i, 0];
            row1["Eao ↗"] = aray1[i, 2]; //
            row1["Eao ↘"] = aray1[i, 1]; //
            //row1["Ics"] = wyniki[i, 3]; //

            table1.Rows.Add(row1);
        }

        dView1 = new DataView(table1);
        //--
        Chart1.Series.Clear();
        Chart1.ChartAreas.Add("Wykres01");
        //--
        Chart1.DataBindTable(dView1, "If");
        Chart1.Width  = 900;
        Chart1.Height = 750;
        //Chart3.Series["Voltage"].ChartType = SeriesChartType.Line;
        Chart1.Series["Eao ↗"].ChartType   = SeriesChartType.Spline;
        Chart1.Series["Eao ↗"].BorderWidth = 3;//grubosc wykresu

        Chart1.Series["Eao ↘"].ChartType               = SeriesChartType.Spline;
        Chart1.Series["Eao ↘"].BorderWidth             = 3;//grubosc wykresu
        Chart1.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
        Chart1.Series["Eao ↘"].YAxisType               = AxisType.Secondary;

        //if (chkIcs.Checked)
        //{
        //    Chart1.Visible = true;
        //    Chart1.Series["Ics"].ChartType = SeriesChartType.Line;
        //    Chart1.Series["Ics"].BorderWidth = 3;//grubosc wykresu
        //}
        //Chart1.ChartAreas[0].AxisX.LineWidth = 2;
        Chart1.ChartAreas[0].AxisX.Minimum = tmin;
        //Chart1.ChartAreas[0].AxisX.Maximum = (double)table1.Rows[size]["If"];
        //Chart1.ChartAreas[0].AxisY.Minimum = 0.0;
        Chart1.ChartAreas[0].AxisY.ArrowStyle = AxisArrowStyle.Lines;//strzałki wykresu
        //Chart1.ChartAreas[0].AxisX.ArrowStyle = AxisArrowStyle.Lines;
        Chart1.ChartAreas[0].AxisY2.ArrowStyle = AxisArrowStyle.Lines;
        //Chart1.ChartAreas[0].AxisY2.Minimum = 0.0;
        //Chart1.ChartAreas[0].AxisY2.Maximum = 2.4;
        Chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{#0.###}";
        Chart1.ChartAreas[0].AxisX.Title             = "If [mA]";
        Chart1.ChartAreas[0].AxisY.Title             = "Eao  [V]";
        Chart1.ChartAreas[0].AxisY2.Title            = "Eao  [V]";
        Chart1.ChartAreas[0].AxisX.TitleFont         = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        Chart1.ChartAreas[0].AxisY.TitleFont         = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
        Chart1.ChartAreas[0].AxisY2.TitleFont        = new System.Drawing.Font("Calibri", 11F, System.Drawing.FontStyle.Bold);
    }