/// <summary> /// Closes the camera, vimba, and the frame grabber, and reinitializes them to default settings. Takes about a minute to complete. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReinitializeSystem_Button_Click(object sender, EventArgs e) { try { if (!restartLocked) { if (shutter.ShutterOpen) { shutter.Close(); Shutter_Label.Text = "Closed"; } if (vmb.IsAcquiring) { vmb.StartAcquisition(); } vmb.Close(); Thread.Sleep(100); int i = vmb.Initialize(); if (i < 0) { MessageBox.Show("Camera Open Failed"); Application.Exit(); } string FORMAT = ""; string FORMATFILE = ""; FORMATFILE = $"{Constants.projectPath}Resources/XCAPVideoSetup16Bit30Hz.fmt"; PXD.pxd_PIXCIclose(); Thread.Sleep(100); i = PXD.pxd_PIXCIopen("", FORMAT, FORMATFILE); Thread.Sleep(100); if (i < 0) { MessageBox.Show("PXD Open Failed"); PXD.pxd_mesgFault(1); Application.Exit(); } promptBox.Text += "System Fully Booted\n"; restartLocked = true; ReinitializeSystem_Button.BackColor = Color.DarkGray; LockReinitialize_Button.Text = "Locked"; LockReinitialize_Button.BackColor = Color.White; } } catch (VimbaException ve) { promptBox.Text += $"{ve.Message}\n"; } catch (Exception ex) { promptBox.Text += $"{ex.Message}\n"; } }
/// <summary> /// This function executes as the program loads. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, System.EventArgs e) { try { shutter.Close(); // Calls the precompiled CloseShutter.exe program pxd.IsSixteenBit = true; //Default function parameters vmb.exposureTime = 33000; vmb.highGain = true; pxd.imageName = "stillShot"; pxd.liveName = "videoFrame"; pxd.frameCount = 40; pxd.frameCountRemainder = 0; //info[1] = "TempSetPoint\tCamTemp\tExposure\tGain\tFrameRate"; /*while (File.Exists($"{Constants.infoPath}VideoInfo/info{infoFiles}.txt")) * { * infoFiles++; * }*/ pxd.Close(); // In case the DLL was run before and aborted without closing pxd.Initialize(); if (!pxd.IsOpen) // Double check that pxd opened successfully { Thread.Sleep(5000); pxd.Initialize(); } if (!pxd.IsOpen) // Abort if frame grabber fails to initialize { MessageBox.Show("Open Failed, Possible Frame Grabber Malfunction\n" + "If you get this message repeatedly, restart Windows"); PXD.pxd_mesgFault(1); Application.Exit(); } //promptBox.Text += $"{vmb.Initialize()}"; vmb.Initialize(); if (!vmb.IsOpen) { Thread.Sleep(1000); int i = vmb.Initialize(); if (i < 0) { MessageBox.Show("Camera Open Failed"); Application.Exit(); } } if (!vmb.VMBOpen) { promptBox.Text += "Could not boot Vimba\n"; promptBox.Text += "Closing PIXCI\n"; PXD.pxd_PIXCIclose(); } else if (!vmb.IsOpen) { promptBox.Text += "Could not boot Camera\n"; promptBox.Text += "Closing PIXCI\n"; PXD.pxd_PIXCIclose(); } else { promptBox.Text += "Camera booted and ready\n"; } } catch (Exception ex) { promptBox.Text += $"{ex.Message}\n"; } } //