Esempio n. 1
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            int selectedIndex = comboBox1.SelectedIndex + 1;

            dataGridView2.Rows.Clear();

            var a = list["data" + selectedIndex] as Dictionary <string, List <string> >;
            var b = a.ToDictionary(k => k.Key, k => k.Value as object);


            var data = new TableFiller().FillDataInSumaryTable(b, "19:12:15", null);

            dataGridView2.Rows.Add(data);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fileOneText) || string.IsNullOrEmpty(fileTwoText))
            {
                MessageBox.Show("Both file are required");
                return;
            }

            var firstTableData  = new TableFiller().FillTable(fileOneText, dataGridView1);
            var secondTableData = new TableFiller().FillTable(fileTwoText, dataGridView2);

            dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(firstTableData, firstTableData["endTime"] as string, firstTableData["params"] as Dictionary <string, string>));
            dataGridView3.Rows.Add(new TableFiller().FillDataInSumaryTable(secondTableData, secondTableData["endTime"] as string, secondTableData["params"] as Dictionary <string, string>));
        }
Esempio n. 3
0
 private TableFiller[] GetTableFillers(DataGridView[] tables)
 {
     TableFiller[] tablesFillers = new TableFiller[tables.Length];
     tablesFillers[0] = () =>
     {
         DataGridViewCell[] cells;
         for (int i = 0; i < tables[0].RowCount; i++)
         {
             cells = new DataGridViewCell[] { tables[0][1, i], tables[0][2, i] };
             if (!TryParseCells(cells, out double[] parameters) || parameters[1] <= 0)
             {
                 continue;
             }
             tables[0][3, i].Value = parameters[0] * 365 / parameters[1];
         }
Esempio n. 4
0
        private TableFiller[] GetTableFillers(DataGridView[] tables)
        {
            var tablesFillers = new TableFiller[tables.Length];

            tablesFillers[0] = () =>
            {
                for (var i = 0; i < tables[0].RowCount; i++)
                {
                    var cells = new[] { tables[0][1, i], tables[0][2, i] };
                    if (!TryParseCells(cells, out double[] parameters) || parameters[1] <= 0)
                    {
                        tables[0][3, i].Value = 0;
                        continue;
                    }
                    tables[0][3, i].Value = Math.Round(parameters[0] / parameters[1] * 366, 2);
                }
Esempio n. 5
0
        /// <summary>
        /// Open dialog box to read hrm file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string text = File.ReadAllText(openFileDialog1.FileName);
                Dictionary <string, object> hrData = new TableFiller().FillTable(text, dataGridView1);
                _hrData = hrData.ToDictionary(k => k.Key, k => k.Value as List <string>);

                var metricsCalculation = new AdvanceMetricsCalculation();

                /// <summary>
                /// Advanced Metrics Calculation
                /// </summary>

                // Calculation of Normalized Power
                double np = metricsCalculation.CalculateNormalizedPower(hrData);
                label3.Text = "Normalized power = " + Summary.RoundUp(np, 2);

                //Calculation of Training Stress Score
                double ftp = metricsCalculation.CalculateFunctionalThresholdPower(hrData);
                label4.Text = "Training Stress Score = " + Summary.RoundUp(ftp, 2);

                //Calculation of Intensity Factor
                double ifa = metricsCalculation.CalculateIntensityFactor(hrData);
                label5.Text = "Intensity Factor = " + Summary.RoundUp(ifa, 2);

                //Calculation of Power Balance
                double pb = metricsCalculation.CalculatePowerBalance(hrData);
                label2.Text = "Power balance = " + Summary.RoundUp(pb, 2);

                var param = hrData["params"] as Dictionary <string, string>;
                //header file
                labelstarttime.Text = labelstarttime.Text + "= " + param["StartTime"];
                labelinterval.Text  = labelinterval.Text + "= " + param["Interval"];
                labelmonitor.Text   = labelmonitor.Text + "= " + param["Monitor"];
                labelsmode.Text     = labelsmode.Text + "= " + param["SMode"];
                labeldate.Text      = labeldate.Text + "= " + param["Date"];
                labellength.Text    = labellength.Text + "= " + param["Length"];
                labelweight.Text    = labelweight.Text + "= " + param["Weight"];

                //smode is declared and used in the system
                var sMode = param["SMode"];
                for (int i = 0; i < sMode.Length; i++)
                {
                    smode.Add((int)Char.GetNumericValue(param["SMode"][i]));
                }
                //smode is checked from the smode given in the file.
                if (smode[0] == 0)
                {
                    dataGridView1.Columns[0].Visible = false;
                }
                else if (smode[1] == 0)
                {
                    dataGridView1.Columns[1].Visible = false;
                }
                else if (smode[2] == 0)
                {
                    dataGridView1.Columns[2].Visible = false;
                }
                else if (smode[3] == 0)
                {
                    dataGridView1.Columns[3].Visible = false;
                }
                else if (smode[4] == 0)
                {
                    dataGridView1.Columns[4].Visible = false;
                }
                dataGridView2.Rows.Clear();
                dataGridView2.Rows.Add(new TableFiller().FillDataInSumaryTable(hrData, hrData["endTime"] as string, hrData["params"] as Dictionary <string, string>));
            }
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                Cursor.Current = Cursors.WaitCursor;
                string text = File.ReadAllText(openFileDialog1.FileName);
                Dictionary <string, object> hrData = new TableFiller().FillTable(text, dataGridView1);
                _hrData = hrData.ToDictionary(k => k.Key, k => k.Value as List <string>);

                var metricsCalculation = new AdvanceMetricsCalculation();

                //advance metrics calculation
                double np = metricsCalculation.CalculateNormalizedPower(hrData);
                label3.Text = "Normalized power = " + Summary.RoundUp(np, 2);

                double ftp = metricsCalculation.CalculateFunctionalThresholdPower(hrData);
                label4.Text = "Training Stress Score = " + Summary.RoundUp(ftp, 2);

                double ifa = metricsCalculation.CalculateIntensityFactor(hrData);
                label5.Text = "Intensity Factor = " + Summary.RoundUp(ifa, 2);

                double pb = metricsCalculation.CalculatePowerBalance(hrData);
                label2.Text = "Power balance = " + Summary.RoundUp(pb, 2);

                var param = hrData["params"] as Dictionary <string, string>;

                //header file
                lblStartTime.Text = lblStartTime.Text + "= " + param["StartTime"];
                lblInterval.Text  = lblInterval.Text + "= " + param["Interval"];
                lblMonitor.Text   = lblMonitor.Text + "= " + param["Monitor"];
                lblSMode.Text     = lblSMode.Text + "= " + param["SMode"];
                lblDate.Text      = lblDate.Text + "= " + Summary.ConvertToDate(param["Date"]);
                lblLength.Text    = lblLength.Text + "= " + param["Length"];
                lblWeight.Text    = lblWeight.Text + "= " + param["Weight"];



                //smode calculation
                var sMode = param["SMode"];
                for (int i = 0; i < sMode.Length; i++)
                {
                    smode.Add((int)Char.GetNumericValue(param["SMode"][i]));
                }

                if (smode[0] == 0)
                {
                    dataGridView1.Columns[0].Visible = false;
                }
                else if (smode[1] == 0)
                {
                    dataGridView1.Columns[1].Visible = false;
                }
                else if (smode[2] == 0)
                {
                    dataGridView1.Columns[2].Visible = false;
                }
                else if (smode[3] == 0)
                {
                    dataGridView1.Columns[3].Visible = false;
                }
                else if (smode[4] == 0)
                {
                    dataGridView1.Columns[4].Visible = false;
                }

                dataGridView2.Rows.Clear();
                //adding value to datagrid
                dataGridView2.Rows.Add(new TableFiller().FillDataInSumaryTable(hrData, hrData["endTime"] as string, hrData["params"] as Dictionary <string, string>));
            }
        }