Esempio n. 1
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. 2
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>));
            }
        }