/// <summary> /// Form Load event initialises form objects, sets form control values and starts auto-connect process. /// </summary> private void Form_main_Load(object sender, EventArgs e) { this.Text = Assembly.GetExecutingAssembly().GetName().Name + " " + Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString(); // Create peripheral GUIs and assign to ShowHideButton batteryOscilloscope = new SimpleOscilloscope("Battery Data (V)", "Oscilloscope/batteryOscilloscope_settings.ini"); showHideButton_batteryGraph.Object = batteryOscilloscope; thermometerOscilloscope = new SimpleOscilloscope("Thermometer Data (°C)", "Oscilloscope/thermometerOscilloscope_settings.ini"); showHideButton_thermometerGraph.Object = thermometerOscilloscope; gyroscopeOscilloscope = new SimpleOscilloscope("Gyroscope Data (°/s)", "Oscilloscope/gyroscopeOscilloscope_settings.ini"); showHideButton_gyroscopeGraph.Object = gyroscopeOscilloscope; accelerometerOscilloscope = new SimpleOscilloscope("Accelerometer Data (g)", "Oscilloscope/accelerometerOscilloscope_settings.ini"); showHideButton_accelerometerGraph.Object = accelerometerOscilloscope; magnetometerOscilloscope = new SimpleOscilloscope("Magnetometer Data (Gauss)", "Oscilloscope/magnetometerOscilloscope_settings.ini"); showHideButton_magnetometerGraph.Object = magnetometerOscilloscope; eulerAnglesOscilloscope = new SimpleOscilloscope("Euler Angles Data (°)", "Oscilloscope/eulerAnglesOscilloscope_settings.ini"); showHideButton_eulerAnglesGraph.Object = eulerAnglesOscilloscope; form_3Dcuboid = new Form_3Dcuboid(); form_3Dcuboid.MinimizeInsteadOfClose = true; showHideButton_3Dcuboid.Object = form_3Dcuboid; form_digitalIOpanel = new Form_digitalIOpanel(); form_digitalIOpanel.OutputChanged += new Form_digitalIOpanel.onOutputChanged(digitalIOpanel_OutputChanged); showHideButton_digitalIOpanel.Object = form_digitalIOpanel; analogueInputAX0AX1oscilloscope = new SimpleOscilloscope("Analogue Input AX0 AX1 Data (lsb)", "Oscilloscope/analogueInputAX0AX1oscilloscope_settings.ini"); showHideButton_AX0andAX1graph.Object = analogueInputAX0AX1oscilloscope; analogueInputAX2AX3oscilloscope = new SimpleOscilloscope("Analogue Input AX2 AX3 Data (lsb)", "Oscilloscope/analogueInputAX2AX3oscilloscope_settings.ini"); showHideButton_AX2andAX3graph.Object = analogueInputAX2AX3oscilloscope; analogueInputAX4AX5oscilloscope = new SimpleOscilloscope("Analogue Input AX4 AX5 Data (lsb)", "Oscilloscope/analogueInputAX4AX5oscilloscope_settings.ini"); showHideButton_AX4andAX5graph.Object = analogueInputAX4AX5oscilloscope; analogueInputAX6AX7oscilloscope = new SimpleOscilloscope("Analogue Input AX6 AX7 Data (lsb)", "Oscilloscope/analogueInputAX6AX7oscilloscope_settings.ini"); showHideButton_AX6andAX7graph.Object = analogueInputAX6AX7oscilloscope; form_PWMoutputPanel = new Form_PWMoutputPanel(); form_PWMoutputPanel.ValuesChanged += new Form_PWMoutputPanel.onValuesChanged(PWMoutputPanel_ValuesChanged); showHideButton_PWMoutputPanel.Object = form_PWMoutputPanel; ADXL345_Aoscilloscope = new SimpleOscilloscope("ADXL234 A Data", "Oscilloscope/ADXL345Aoscilloscope_settings.ini"); showHideButton_ADXL345Agraph.Object = ADXL345_Aoscilloscope; ADXL345_Boscilloscope = new SimpleOscilloscope("ADXL234 B Data", "Oscilloscope/ADXL345Boscilloscope_settings.ini"); showHideButton_ADXL345Bgraph.Object = ADXL345_Boscilloscope; ADXL345_Coscilloscope = new SimpleOscilloscope("ADXL234 C Data", "Oscilloscope/ADXL345Coscilloscope_settings.ini"); showHideButton_ADXL345Cgraph.Object = ADXL345_Coscilloscope; ADXL345_Doscilloscope = new SimpleOscilloscope("ADXL234 D Data", "Oscilloscope/ADXL345Doscilloscope_settings.ini"); showHideButton_ADXL345Dgraph.Object = ADXL345_Doscilloscope; // Create x-IMU serial object xIMUserial = new x_IMU_API.xIMUserial(); xIMUserial.xIMUdataReceived += new x_IMU_API.xIMUserial.onxIMUdataReceived(xIMUserial_xIMUdataReceived); xIMUserial.ErrorDataReceived += new x_IMU_API.xIMUserial.onErrorDataReceived(xIMUserial_ErrorDataReceived); xIMUserial.CommandDataReceived += new x_IMU_API.xIMUserial.onCommandDataReceived(xIMUserial_CommandDataReceived); xIMUserial.RegisterDataReceived += new x_IMU_API.xIMUserial.onRegisterDataReceived(xIMUserial_RegisterDataReceived); xIMUserial.DateTimeDataReceived += new x_IMU_API.xIMUserial.onDateTimeDataReceived(xIMUserial_DateTimeDataReceived); xIMUserial.RawBatteryAndThermometerDataReceived += new x_IMU_API.xIMUserial.onRawBatteryAndThermometerDataReceived(xIMUserial_RawBatteryAndThermometerDataReceived); xIMUserial.CalBatteryAndThermometerDataReceived += new x_IMU_API.xIMUserial.onCalBatteryAndThermometerDataReceived(xIMUserial_CalBatteryAndThermometerDataReceived); xIMUserial.RawInertialAndMagneticDataReceived += new x_IMU_API.xIMUserial.onRawInertialAndMagneticDataReceived(xIMUserial_RawInertialAndMagneticDataReceived); xIMUserial.CalInertialAndMagneticDataReceived += new x_IMU_API.xIMUserial.onCalInertialAndMagneticDataReceived(xIMUserial_CalInertialAndMagneticDataReceived); xIMUserial.CalInertialAndMagneticDataReceived += new x_IMU_API.xIMUserial.onCalInertialAndMagneticDataReceived(xIMUserial_CalInertialAndMagneticDataReceivedHardIronCal); xIMUserial.QuaternionDataReceived += new x_IMU_API.xIMUserial.onQuaternionDataReceived(xIMUserial_QuaternionDataReceived); xIMUserial.DigitalIODataReceived += new x_IMU_API.xIMUserial.onDigitalIODataReceived(xIMUserial_DigitalIODataReceived); xIMUserial.RawAnalogueInputDataReceived += new x_IMU_API.xIMUserial.onRawAnalogueInputDataReceived(xIMUserial_RawAnalogueInputDataReceived); xIMUserial.CalAnalogueInputDataReceived += new x_IMU_API.xIMUserial.onCalAnalogueInputDataReceived(xIMUserial_CalAnalogueInputDataReceived); xIMUserial.PWMoutputDataReceived += new x_IMU_API.xIMUserial.onPWMoutputDataReceived(xIMUserial_PWMoutputDataReceived); xIMUserial.RawADXL345busDataReceived += new x_IMU_API.xIMUserial.onRawADXL345busDataReceived(xIMUserial_RawADXL345busDataReceived); xIMUserial.CalADXL345busDataReceived += new x_IMU_API.xIMUserial.onCalADXL345busDataReceived(xIMUserial_CalADXL345busDataReceived); // Create buffers to parse data between xIMUserial and Form_main threads dateTimeDataBuffer = null; registerDataBuffer = new x_IMU_API.RegisterData[(int)x_IMU_API.RegisterAddresses.NumRegisters]; // Create ToolTip for RegisterTreeView ToolTip toolTip = new ToolTip(); toolTip.ToolTipTitle = "Tip:"; toolTip.SetToolTip(registerTreeView, "Right-click for action menu"); // Set fixed form control values label_GUIversionNum.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); label_APIversionNum.Text = FileVersionInfo.GetVersionInfo("x-IMU API.dll").FileVersion.ToString(); label_compatibleFirmwareVersionNums.Text = ""; for (int i = 0; i < Enum.GetValues(typeof(x_IMU_API.CompatibleFirmwareVersions)).Length; i++) { label_compatibleFirmwareVersionNums.Text += ((int[])Enum.GetValues(typeof(x_IMU_API.CompatibleFirmwareVersions)))[i].ToString() + ".x"; if (i < ((int[])Enum.GetValues(typeof(x_IMU_API.CompatibleFirmwareVersions))).Length - 1) { label_compatibleFirmwareVersionNums.Text += ", "; } } // Set default variable form control values button_refreshList.PerformClick(); textBox_dataLoggerFilePath.Text = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\" + "LoggedData"; textBox_collectHardIronCalDatasetFilePath.Text = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\" + "HardIronCal"; // Create and start form update timer formUpdateTimer = new System.Windows.Forms.Timer(); formUpdateTimer.Interval = 50; formUpdateTimer.Tick += new EventHandler(formUpdateTimer_Tick); formUpdateTimer.Start(); // Auto connect on start up toggleButton_openClosePort.PerformClick(); }
/// <summary> /// xIMUserial DateTimeDataReceived event parses data to dateTimeDataBuffer. /// </summary> private void xIMUserial_DateTimeDataReceived(object sender, x_IMU_API.DateTimeData e) { dateTimeDataBuffer = e; }