public frmMVCTestTen(MvcTestMode TestMode)
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            this.Width = Screen.PrimaryScreen.Bounds.Width;
            this.Height = Screen.PrimaryScreen.Bounds.Height;

            testMode = TestMode;
            DataSample = new Classes.MvcDS(GlobalVariables.leftSerialPort);
            AssignCallbackMethods();
            dSet = new MvcDataSet();

            dSetArray[0] = new MvcDataSetTen("LLQC");
            dSetArray[1] = new MvcDataSetTen("LLQE");
            dSetArray[2] = new MvcDataSetTen("LLHC");
            dSetArray[3] = new MvcDataSetTen("LLHE");
            dSetArray[4] = new MvcDataSetTen("RLQC");
            dSetArray[5] = new MvcDataSetTen("RLQE");
            dSetArray[6] = new MvcDataSetTen("RLHC");
            dSetArray[7] = new MvcDataSetTen("RLHE");

            // Set the control style to double buffer.
            //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            //this.SetStyle(ControlStyles.SupportsTransparentBackColor, false);
            //this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }
        //Done
        #region Left Leg Quads Conc
        private void TestLeftLegQuadConc()
        {
            if (CalibrationSettings.Default.SoundEnabled == true) GlobalFunctions.PlayClickSound();
            //DisableButtons();

            dSetArray[0] = new MvcDataSetTen("LLQC");
            foreach (DataTable dTable in dSetArray[0].Tables)
            {
                dTable.Rows.Clear();
            }

            DataSample.SelectedTorque = 300;
            DataSample.SelectedSpeed = Convert.ToInt32(Math.Ceiling((15.0/360.0)*60.0))*3;
            DataSample.MaxTorqueLeftQuadConc = 0;                                                         //Reset Max Left Torque

            if (GlobalVariables.ServoController.InitiateMotor(DataSample.SelectedSpeed, DataSample.SelectedTorque, Enumerators.Direction.Forward, GlobalVariables.leftSerialPort).IsSuccess == false)
                return;
            else
            {
                GlobalVariables.leftSerialPort.DiscardInBuffer();
                GlobalVariables.leftSerialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serialPort_DataReceived_TestLeftLegQuadsConc);
            }
        }
        public void PopulateXmlfile(MvcDataSetTen[] MvcData, int TotalCycles)
        {
            DataSet DataTables = new DataSet();

            string UserId;
            if (GlobalVariables.LoggedInUser != null)
            {
                UserId = GlobalVariables.LoggedInUser.id.ToString();
            }
            else
            {
                UserId = "0";
            }

            string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\XmlData\\" + UserId;
            if (!System.IO.Directory.Exists(directory))
                System.IO.Directory.CreateDirectory(directory);

            string FileName = directory + "\\DataSetTenCycles.xml";
            if (!System.IO.File.Exists(FileName))
            {
                System.IO.FileStream fs = System.IO.File.Create(FileName);
                fs.Close();
            }
            else
            {
                System.IO.File.Delete(FileName);
                System.IO.FileStream fs = System.IO.File.Create(FileName);
                fs.Close();
            }

            for (int ii = 0; ii <= 7; ii++)
            {
                //Copy DataTables to Main DataSet
                for (int jj = 0; jj < TotalCycles; jj++)
                {
                    if (MvcData[ii].Tables[jj].Rows.Count == 0)
                    {
                        for (int kk = 0; kk < 50; kk++)
                        {
                            MvcData[ii].AddNewRow(jj, 0, 0);
                        }
                    }
                    DataTable dtCopy = MvcData[ii].Tables[jj].Copy();
                    DataTables.Tables.Add(dtCopy);
                }
                //DataTable[] dTableArray = new DataTable[4];
                //MvcData[ii].Tables.CopyTo(dTableArray, 0);
                //DataTables.Tables.AddRange(dTableArray);
                //string FileName = directory + "\\DataSet_" + ii.ToString() + ".xml";
                //if (!System.IO.File.Exists(FileName))
                //{
                //    System.IO.FileStream fs = System.IO.File.Create(FileName);
                //    fs.Close();
                //}
                //else
                //{
                //    System.IO.File.Delete(FileName);
                //    System.IO.FileStream fs = System.IO.File.Create(FileName);
                //    fs.Close();
                //}

                try
                {
                    DataTables.WriteXml(FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception caught in WriteXML: {0}", ex.ToString());
                }
            }
        }