/// <summary>
        /// Shows <see cref="CSVfileWriter"/> packet counts and file names in <see cref="PassiveMessageBox"/>.
        /// </summary>
        /// <param name="CSVfileWriter">
        /// <see cref="CSVfileWriter"/> object.
        /// </param>
        /// <param name="caption">
        /// Caption of <see cref="PassiveMessageBox"/>.
        /// </param>
        public static void Show(x_IMU_API.CSVfileWriter CSVfileWriter, string caption)
        {
            string dialogText = "No files were created.";

            if (CSVfileWriter.FilesCreated.Length != 0)
            {
                int maxWidth = 0;

                // Measure x_IMU_API.PacketCount property names with a non-zero value for tab spacing
                foreach (PropertyInfo propertyInfo in CSVfileWriter.PacketsWrittenCounter.GetType().GetProperties())
                {
                    if ((int)propertyInfo.GetValue(CSVfileWriter.PacketsWrittenCounter, null) > 0)
                    {
                        int width = TextRenderer.MeasureText(propertyInfo.Name + ":", Control.DefaultFont).Width;
                        maxWidth = width > maxWidth ? width : maxWidth;
                    }
                }

                // Add all property names with a non-zero to dialog text with tab spacing.
                dialogText = "";
                foreach (PropertyInfo propertyInfo in CSVfileWriter.PacketsWrittenCounter.GetType().GetProperties())
                {
                    if ((int)propertyInfo.GetValue(CSVfileWriter.PacketsWrittenCounter, null) > 0)
                    {
                        string lineText = propertyInfo.Name + ":";
                        while (TextRenderer.MeasureText(lineText, Control.DefaultFont).Width < maxWidth)
                        {
                            lineText += " ";
                        }
                        dialogText += lineText + "\t" + propertyInfo.GetValue(CSVfileWriter.PacketsWrittenCounter, null).ToString() + Environment.NewLine;
                    }
                }

                // Add list of file names to dialog text
                dialogText += Environment.NewLine + "Files created:" + Environment.NewLine;
                foreach (string fileName in CSVfileWriter.FilesCreated)
                {
                    dialogText += fileName + Environment.NewLine;
                }
                if (CSVfileWriter.FilesCreated.Length == 0)
                {
                    dialogText += "None.";
                }
            }

            // Display dialog text in PassiveMessageBox
            PassiveMessageBox.Show(dialogText, caption, MessageBoxIcon.Information);
        }
 /// <summary>
 /// Shows <see cref="CSVfileWriter"/> packet counts and file names in <see cref="PassiveMessageBox"/>.
 /// </summary>
 /// <param name="CSVfileWriter">
 /// <see cref="CSVfileWriter"/> object.
 /// </param>
 public static void Show(x_IMU_API.CSVfileWriter CSVfileWriter)
 {
     Show(CSVfileWriter, "CSVfileWriterResults");
 }
示例#3
0
 /// <summary>
 /// ToggleButton Click event toggles hard-iron calibration data logger start/stop.
 /// </summary>
 private void toggleButton_collectHardIronCalDatasetStartStopLogging_Click(object sender, EventArgs e)
 {
     if ((sender as ToggleButton).ToggleState)
     {
         try
         {
             hardIronCalCSVfileWriter = new x_IMU_API.CSVfileWriter(textBox_collectHardIronCalDatasetFilePath.Text);
             textBox_collectHardIronCalDatasetFilePath.Enabled = false;
             button_collectHardIronCalDatasetBrowse.Enabled = false;
         }
         catch
         {
             MessageBox.Show("Invalid file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         hardIronCalCSVfileWriter.CloseFiles();
         if (hardIronCalCSVfileWriter.PacketsWrittenCounter.CalInertialAndMagneticDataPackets == 0)
         {
             PassiveMessageBox.Show("No 'CalInertialAndMagneticData' packets were received." + Environment.NewLine + Environment.NewLine +
                                    "Please check the \"Data Output Settings\" registers.", "Warning", MessageBoxIcon.Warning);
         }
         else
         {
             CSVfileWriterResults.Show(hardIronCalCSVfileWriter, "Hard-Iron Dataset Collection Results");
         }
         button_collectHardIronCalDatasetBrowse.Enabled = true;
         textBox_collectHardIronCalDatasetFilePath.Enabled = true;
         hardIronCalCSVfileWriter = null;
     }
 }
示例#4
0
 /// <summary>
 /// ToggleButton Click event toggles data logging start/stop.
 /// </summary>
 private void toggleButton_dataLoggerStartStopLogging_Click(object sender, EventArgs e)
 {
     if ((sender as ToggleButton).ToggleState)
     {
         try
         {
             dataLoggerCSVfileWriter = new x_IMU_API.CSVfileWriter(textBox_dataLoggerFilePath.Text);
             textBox_dataLoggerFilePath.Enabled = false;
             button_dataLoggerBrowse.Enabled = false;
         }
         catch
         {
             MessageBox.Show("Invalid file path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         dataLoggerCSVfileWriter.CloseFiles();
         CSVfileWriterResults.Show(dataLoggerCSVfileWriter, "Data Logger Results");
         dataLoggerCSVfileWriter = null;
         button_dataLoggerBrowse.Enabled = true;
         textBox_dataLoggerFilePath.Enabled = true;
     }
 }
示例#5
0
        /// <summary>
        /// Button Click event disables form control and starts binary file conversion in new thread.
        /// </summary>
        private void button_convertBinaryFileConvert_Click(object sender, EventArgs e)
        {
            // Error if file not exist
            if (!File.Exists(textBox_convertBinaryFileFilePath.Text))
            {
                MessageBox.Show("File does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Disable SD card form controls
            textBox_convertBinaryFileFilePath.Enabled = false;
            button_convertBinaryFileBrowse.Enabled = false;
            button_convertBinaryFileConvert.Enabled = false;
            button_convertBinaryFileConvert.Text = "Converting...";

            // Create process dialog
            binaryFileConverterProgressDialog = new ProgressDialog(this.Handle);
            binaryFileConverterProgressDialog.Title = "Converting Binary File";
            binaryFileConverterProgressDialog.CancelMessage = "Cancelling...";
            binaryFileConverterProgressDialog.Line1 = "Converting to binary file to CSV files";
            binaryFileConverterProgressDialog.Line3 = "Initialising x-IMU file reader.";
            binaryFileConverterProgressDialog.ShowDialog();
            binaryFileConverterProgressDialog.Value = 0;

            // Create file converter objects
            binaryFileConverterCSVfileWriter = new x_IMU_API.CSVfileWriter(Path.GetDirectoryName(textBox_convertBinaryFileFilePath.Text) + "\\" + Path.GetFileNameWithoutExtension(textBox_convertBinaryFileFilePath.Text));
            x_IMU_API.xIMUfile xIMUfile = new x_IMU_API.xIMUfile(textBox_convertBinaryFileFilePath.Text);
            xIMUfile.xIMUdataRead += new x_IMU_API.xIMUfile.onxIMUdataRead(xIMUfile_xIMUdataRead);
            xIMUfile.AsyncReadProgressChanged += new x_IMU_API.xIMUfile.onAsyncReadProgressChanged(xIMUfile_AsyncReadProgressChanged);
            xIMUfile.AsyncReadCompleted += new x_IMU_API.xIMUfile.onAsyncReadCompleted(xIMUfile_AsyncReadCompleted);
            xIMUfile.RunAnsycRead();
        }