Ejemplo n.º 1
0
        /// <summary>
        /// Called when load file two dialog is file ok
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void file2Dialog_FileOk(object sender, CancelEventArgs e)
        {
            if (file2Dialog.FileName != null && !file2Dialog.FileName.Equals(""))
            {
                polar2 = new Polar();
                polar2.LoadData(file2Dialog.FileName);

                dw2 = new DataViewImproved(polar2.GetUnit(), polar2.GetHrData(), polar2.GetSMODE(), this.polar2, this, polar2.GetRideInfo());
                //dw1.AddRideInfo(polar.GetRideInfo());
                dw2.AddFullData();
                dw2.SetFTP(ftp);
                dw2.Dock = DockStyle.Fill;

                if (dw2.GetInterval() != dw1.GetInterval())
                {
                    MessageBox.Show("Error: Please load a file with the same recording interval", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dw2 = null;
                    return;
                }
                //singleView.Controls.Clear();
                //singleView.Controls.Add(dw2);
                //enterMaximumHeartRateToolStripMenuItem.ShowDropDown();
                // ftpMenu.ShowDropDown();

                //menuStrip3.Hide();
                file2 = new ComparrisonControl(dw2, this, "file2");
                AddComparison();
            }
        }
        /// <summary>
        /// Called to chunk the data
        /// </summary>
        /// <param name="sizeOfChunks">the size of each chunk</param>
        /// <param name="numberOfChunks">the number of requried chunk</param>
        public void ChunkData(int sizeOfChunks, int numberOfChunks)
        {
            chunks.Clear();
            Console.WriteLine("Number of chunks: " + numberOfChunks);
            bool     start = true;
            DateTime chunkEnd;

            for (int i = 1; i <= numberOfChunks; i++)
            {
                DateTime chunkStart = new DateTime(2018, 1, 1, 0, 0, 0);
                if (start)
                {
                    start = false;
                }
                else
                {
                    chunkStart = chunkStart.AddSeconds((((i - 1) * sizeOfChunks) / dv.GetInterval()));
                }

                if (i == numberOfChunks)
                {
                    chunkEnd = dv.GetEndDateTime();
                }
                else
                {
                    chunkEnd = new DateTime(2018, 1, 1, 0, 0, 0);
                    chunkEnd = chunkEnd.AddSeconds(((i * sizeOfChunks) / dv.GetInterval()));
                }



                chunks.Add(new DateTime[] { chunkStart, chunkEnd });
            }

            Console.WriteLine(chunks.Count);
        }