public bool init(string vpppath, CogRecordDisplay cogRecordDisplayin = null) { if (null == vpppath) { return false; } try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath); myJob = myJobManager.Job(0); myJobIndependent = myJob.OwnedIndependent; myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); myJob.ImageQueueFlush(); myJobIndependent.RealTimeQueueFlush(); updateDisplaySource(cogRecordDisplayin); } catch { } return true; }
public bool init0(string vpppath0, CogRecordDisplay cogRecordDisplayin0 = null) { updateDisplaySource0(cogRecordDisplayin0); if (null == vpppath0) { return false; } try { myJobManager0 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath0); myJob0 = myJobManager0.Job(0); myJobIndependent0 = myJob0.OwnedIndependent; myJobManager0.UserQueueFlush(); myJobManager0.FailureQueueFlush(); myJob0.ImageQueueFlush(); myJobIndependent0.RealTimeQueueFlush(); } catch { return false; } return true; }
static void listJobs() { if (manager != null) { for (int i = 0; i < manager.JobCount; i++) { Console.WriteLine(string.Format("{0}:\t\t{1}", manager.Job(i).Name, i)); } } }
//初始化函数1 private void InitialVPP() { string path = System.Environment.CurrentDirectory; m_strVppFileName = path + "//" + m_strVppFileName; Console.WriteLine(m_strVppFileName); // 加载Vpp if (!System.IO.File.Exists(m_strVppFileName)) { MessageBox.Show("Vpp Job文件不存在\n退出软件?", "警告"); this.Close(); return; } m_JobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(m_strVppFileName); if (m_JobManager == null) { MessageBox.Show("NULL错误", "警告"); this.Close(); } int nCount = m_JobManager.JobCount; if (nCount < 3) { MessageBox.Show("Wrong CCD Model:Job count less than 3."); this.Close(); } m_Job_1 = m_JobManager.Job(0); m_Job_2 = m_JobManager.Job(1); m_Job_3 = m_JobManager.Job(2); // 注册Job完成事件 m_Job_1.Stopped += new CogJob.CogJobStoppedEventHandler(myJob1_Stopped); m_Job_2.Stopped += new CogJob.CogJobStoppedEventHandler(myJob2_Stopped); m_Job_3.Stopped += new CogJob.CogJobStoppedEventHandler(myJob3_Stopped); //Job_1_Ran += new Job_1_RanEventHandler(testJob_1); // 刷新队列 m_JobManager.UserQueueFlush(); m_JobManager.FailureQueueFlush(); }
private void buttonUpdate_Click(object sender, EventArgs e) { if (numericUpDownXadjust.Value == 0 && numericUpDownYadjust.Value == 0) { return; } // Prompt to save the adjustment bool saved = mainForm.SaveVisionParametersToQuickBuild(); if (!saved) { return; } CogToolGroup lctg; CogCalibCheckerboardTool myCalibTool; try { // Adjust the Basler cal lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; //myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalBasler"]; myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalBasler"]; myCalibTool.Calibration.CalibratedOriginX = myCalibTool.Calibration.CalibratedOriginX + (double)numericUpDownXadjust.Value; myCalibTool.Calibration.CalibratedOriginY = myCalibTool.Calibration.CalibratedOriginY + (double)numericUpDownYadjust.Value; myCalibTool.Calibration.Calibrate(); // Adjust the Flir cal //myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalFlir"]; myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalFlir"]; myCalibTool.Calibration.CalibratedOriginX = myCalibTool.Calibration.CalibratedOriginX + (double)numericUpDownXadjust.Value; myCalibTool.Calibration.CalibratedOriginY = myCalibTool.Calibration.CalibratedOriginY + (double)numericUpDownYadjust.Value; myCalibTool.Calibration.Calibrate(); // Read adjusted results and update the read-only text boxes lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; //myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalBasler"]; myCalibTool = (CogCalibCheckerboardTool)lctg.Tools["CalBasler"]; textBoxXorigin.Text = myCalibTool.Calibration.CalibratedOriginX.ToString(); textBoxYorigin.Text = myCalibTool.Calibration.CalibratedOriginY.ToString(); // Reset adjust boxes numericUpDownXadjust.Value = 0; numericUpDownYadjust.Value = 0; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static public void FlushAllQueues(CogJobManager jm) { // Flush all queues if (jm == null) { return; } jm.UserQueueFlush(); jm.FailureQueueFlush(); for (int i = 0; i < jm.JobCount; i++) { jm.Job(i).OwnedIndependent.RealTimeQueueFlush(); jm.Job(i).ImageQueueFlush(); } }
private void InitializeJobManager() { SampleTextBox.Text = "This sample demonstrates how to load a persisted QuickBuild application and access " + "the results provided in the posted items (a.k.a. as user result queue)." + System.Environment.NewLine + System.Environment.NewLine + "The sample uses mySavedQB.vpp, which consists of a single Job that executes a " + "Blob tool with default parameters using a frame grabber provided image. " + @"The provided .vpp file is configured to use ""VPRO_ROOT\images\pmSample.idb"" as the " + "source of images." + System.Environment.NewLine + System.Environment.NewLine + "To use: Click the Run button or the Run Continuous button. " + "The number of blobs will be displayed in the count text box " + "and the Blob tool input image will be displayed in the image display control."; //Depersist the QuickBuild session myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile( Environment.GetEnvironmentVariable("VPRO_ROOT") + "\\Samples\\Programming\\QuickBuild\\mySavedQB.vpp"); myJob = myJobManager.Job(0); myIndependentJob = myJob.OwnedIndependent; //flush queues myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); myJob.ImageQueueFlush(); myIndependentJob.RealTimeQueueFlush(); // setup event handlers. These are called when a result packet is available on // the User Result Queue or the Real-Time Queue, respectively. myJobManager.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(myJobManager_UserResultAvailable); }
/// <summary> /// This function is responsible for the initial setup of the app. /// It loads and prepares the saved QuickBuild app into a CogJobManager /// object, attaches event handlers to to interesting CogJobManager /// events, and sets up the CogDisplayStatusBar to reflect the status /// of the CogDisplay we are using. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { // Depersist the CogJobManager saved via QuickBuild myJobManager = CogSerializer.LoadObjectFromFile( Environment.GetEnvironmentVariable("VPRO_ROOT") + "\\Samples\\Programming\\QuickBuild\\advancedAppOne.vpp") as CogJobManager; // Initialize Variables myJob = myJobManager.Job(0); myIndependentJob = myJob.OwnedIndependent; // Flush queues myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); myJob.ImageQueueFlush(); myIndependentJob.RealTimeQueueFlush(); // Register handler for Stopped event myJobManager.Stopped += new CogJobManager.CogJobManagerStoppedEventHandler( myJobManager_Stopped); // Register handler for UserResultAvailable event myJobManager.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler( myJobManager_UserResultAvailable); // Connect the status bar this.cogDisplayStatusBar1.Display = this.cogRecordDisplay1; }
private bool GetImage(string pathin) { myToolGroup = (CogToolGroup)(myJobManager.Job(0).VisionTool); myImageFile = (CogImageFileTool)(myToolGroup.Tools["CogImageFileTool1"]); myImageFile.Operator.Open(pathin, CogImageFileModeConstants.Read); Imagein = new Bitmap(pathin); myImageFile.InputImage = new CogImage8Grey(Imagein); myImageFile.Run(); return(true); }
private bool GetImage2(string pathin) { try { myToolGroup2 = (CogToolGroup)(myJobManager2.Job(0).VisionTool); myImageFile2 = (CogImageFileTool)(myToolGroup2.Tools["CogImageFileTool1"]); myImageFile2.Operator.Open(pathin, CogImageFileModeConstants.Read); Imagein2 = new Bitmap(pathin); myImageFile2.InputImage = new CogImage8Grey(Imagein2); myImageFile2.Run(); } catch{} }
private void GetImage0(string pathin) { try { myToolGroup0 = (CogToolGroup)(myJobManager0.Job(0).VisionTool); myImageFile0 = (CogImageFileTool)(myToolGroup0.Tools["CogImageFileTool1"]); myImageFile0.Operator.Open(pathin, CogImageFileModeConstants.Read); Imagein0 = new Bitmap(pathin); myImageFile0.InputImage = new CogImage8Grey(Imagein0); myImageFile0.Run(); } catch{} }
static public int GetJobIndexFromName(CogJobManager mgr, string name) { if (mgr != null) { for (int i = 0; i < mgr.JobCount; ++i) { if (mgr.Job(i).Name == name) { return(i); } } } return(-1); }
private bool GetImage3(string pathin) { try { myToolGroup3 = (CogToolGroup)(myJobManager3.Job(0).VisionTool); myImageFile3 = (CogImageFileTool)(myToolGroup3.Tools["CogImageFileTool1"]); myImageFile3.Operator.Open(pathin, CogImageFileModeConstants.Read); Imagein3 = new Bitmap(pathin); myImageFile3.InputImage = new CogImage8Grey(Imagein3); myImageFile3.Run(); return true; } catch { return false; } }
private bool GetImage(int numOfJobs, List <string> pathin) { if (null == pathin[numOfJobs]) { return(false); } else { myToolGroup = (CogToolGroup)(myJobManager.Job(numOfJobs).VisionTool); myImageFile = (CogImageFileTool)(myToolGroup.Tools["CogImageFileTool1"]); myImageFile.Operator.Open(pathin[numOfJobs], CogImageFileModeConstants.Read); Imagein = new Bitmap(pathin[numOfJobs]); myImageFile.InputImage = new CogImage8Grey(Imagein); myImageFile.Run(); Imagein = null; } return(true); }
/// <summary> /// 获取图像 /// </summary> /// /// <param name="pathin">< 图片路径 ></param> /// /// <returns>< bool判定是否获取成功 ></returns> private bool GetImage(string pathin) { bool step1 = false; bool step2 = false; bool step3 = false; try { mTGTool = (CogToolGroup)(myJobManager.Job(0).VisionTool); step1 = true; } catch { step1 = false; } try { mIFTool = (CogImageFileTool)(mTGTool.Tools["CogImageFileTool1"]); mIFTool.Operator.Open(pathin, CogImageFileModeConstants.Read); step2 = true; } catch { step2 = false; } try { Imagein = new Bitmap(pathin); mIFTool.InputImage = new CogImage8Grey(Imagein); step3 = true; } catch { step3 = false; } if (step1 && step2 && step3) { return(true); } else { return(false); } }
public bool init(string vpppath, CogRecordDisplay cogRecordDisplayin = null) { if (null == vpppath) { return(false); } try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath); myJob = myJobManager.Job(0); myJobIndependent = myJob.OwnedIndependent; myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); myJob.ImageQueueFlush(); myJobIndependent.RealTimeQueueFlush(); updateDisplaySource(cogRecordDisplayin); } catch { } return(true); }
private void InitializeJobManager() { // Depersist the QuickBuild session // myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile( // Environment.GetEnvironmentVariable("VPRO_ROOT") + "\\Samples\\Programming\\QuickBuild\\mySavedQB.vpp"); myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(path); cogJobManagerEdit1.Subject = myJobManager; myJob0 = myJobManager.Job(0); myIndependentJob = myJob0.OwnedIndependent; // Flush queues myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); myJob0.ImageQueueFlush(); myIndependentJob.RealTimeQueueFlush(); // Start the timer. timer1.Start(); }
private void loadCognex() { try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(visionProFilePath); myJob = myJobManager.Job(0); myIndependentJob = myJob.OwnedIndependent; //flush queues //myJobManager.UserQueueFlush(); //myJobManager.FailureQueueFlush(); //myJob.ImageQueueFlush(); //myJob.ResetAllStatistics(); //myIndependentJob.RealTimeQueueFlush(); Trace.WriteLine("VisionProFile loaded."); Dispatcher.Invoke(new Action(() => { brd_Buttons.IsEnabled = true; brd_Loading.Visibility = Visibility.Collapsed; Panel.SetZIndex(brd_Loading, int.MinValue); })); } catch (Exception ex) { Trace.WriteLine("Vision-Pro not ready! Exception:" + ex.Message); } }
public bool init1(string vpppath1, CogRecordDisplay cogRecordDisplayin1 = null) { updateDisplaySource1(cogRecordDisplayin1); if (null == vpppath1) { return false; } try { myJobManager1 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath1); myJob1 = myJobManager1.Job(0); myJobIndependent1 = myJob1.OwnedIndependent; myJobManager1.UserQueueFlush(); myJobManager1.FailureQueueFlush(); myJob1.ImageQueueFlush(); myJobIndependent1.RealTimeQueueFlush(); } catch { return false; } return true; }
public bool init3(string vpppath3, CogRecordDisplay cogRecordDisplayin3 = null) { updateDisplaySource3(cogRecordDisplayin3); if (null == vpppath3) { return false; } try { myJobManager3 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath3); myJob3 = myJobManager3.Job(0); myJobIndependent3 = myJob3.OwnedIndependent; myJobManager3.UserQueueFlush(); myJobManager3.FailureQueueFlush(); myJob3.ImageQueueFlush(); myJobIndependent3.RealTimeQueueFlush(); } catch { return false; } return true; }
public bool init(string vpppath, int amountOfJobs, List <CogRecordDisplay> cogRecordDisplayin = null) { if (null == vpppath) { return(false); } try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath); for (int i = 0; i < amountOfJobs; i++) { myJob[i] = myJobManager.Job(i); myJobIndependent[i] = myJob[i].OwnedIndependent; myJob[i].ImageQueueFlush(); myJobIndependent[i].RealTimeQueueFlush(); } myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); updateAllDisplaySource(cogRecordDisplayin); } catch { } return(true); }
public bool init2(string vpppath2, CogRecordDisplay cogRecordDisplayin2 = null) { updateDisplaySource2(cogRecordDisplayin2); if (null == vpppath2) { return false; } try { myJobManager2 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath2); myJob2 = myJobManager2.Job(0); myJobIndependent2 = myJob2.OwnedIndependent; myJobManager2.UserQueueFlush(); myJobManager2.FailureQueueFlush(); myJob2.ImageQueueFlush(); myJobIndependent2.RealTimeQueueFlush(); } catch { return false; } return true; }
public bool init(string vpppath, int amountOfJobs, List<CogRecordDisplay> cogRecordDisplayin = null) { if (null == vpppath) { return false; } try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath); for (int i = 0; i < amountOfJobs; i++) { myJob[i] = myJobManager.Job(i); myJobIndependent[i] = myJob[i].OwnedIndependent; myJob[i].ImageQueueFlush(); myJobIndependent[i].RealTimeQueueFlush(); } myJobManager.UserQueueFlush(); myJobManager.FailureQueueFlush(); updateAllDisplaySource(cogRecordDisplayin); } catch { } return true; }
private void loadCognex() { try { myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(visionProFilePath); myJob = myJobManager.Job(0); myIndependentJob = myJob.OwnedIndependent; //flush queues //myJobManager.UserQueueFlush(); //myJobManager.FailureQueueFlush(); //myJob.ImageQueueFlush(); //myJob.ResetAllStatistics(); //myIndependentJob.RealTimeQueueFlush(); Trace.WriteLine("VisionProFile loaded."); Dispatcher.Invoke(new Action(() => { brd_Buttons.IsEnabled = true; brd_Loading.Visibility = Visibility.Collapsed; Panel.SetZIndex(brd_Loading, int.MinValue); })); } catch (Exception ex) { Trace.WriteLine("Vision-Pro not ready! Exception:" + ex.Message); } }
public bool init(string vpppath0,string vpppath1, string vpppath2, CogRecordDisplay cogRecordDisplayin0 = null, CogRecordDisplay cogRecordDisplayin1 = null, CogRecordDisplay cogRecordDisplayin2 = null) { bool initS1 = false; bool initS2 = false; bool initS3 = false; updateDisplaySource0(cogRecordDisplayin0); updateDisplaySource1(cogRecordDisplayin1); updateDisplaySource2(cogRecordDisplayin2); if (null == vpppath0) { return false; } try { myJobManager0 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath0); myJob0 = myJobManager0.Job(0); myJobIndependent0 = myJob0.OwnedIndependent; myJobManager0.UserQueueFlush(); myJobManager0.FailureQueueFlush(); myJob0.ImageQueueFlush(); myJobIndependent0.RealTimeQueueFlush(); // updateDisplaySource0(cogRecordDisplayin0); initS1 = true; } catch { initS1 = false; } if (null == vpppath1) { return false; } try { myJobManager1 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath1); myJob1 = myJobManager1.Job(0); myJobIndependent1 = myJob1.OwnedIndependent; myJobManager1.UserQueueFlush(); myJobManager1.FailureQueueFlush(); myJob1.ImageQueueFlush(); myJobIndependent1.RealTimeQueueFlush(); // updateDisplaySource1(cogRecordDisplayin1); initS2 = true; } catch { initS2 = false; } if (null == vpppath2) { return false; } try { myJobManager2 = (CogJobManager)CogSerializer.LoadObjectFromFile(vpppath2); myJob2 = myJobManager2.Job(0); myJobIndependent2 = myJob2.OwnedIndependent; myJobManager2.UserQueueFlush(); myJobManager2.FailureQueueFlush(); myJob2.ImageQueueFlush(); myJobIndependent2.RealTimeQueueFlush(); // updateDisplaySource2(cogRecordDisplayin2); initS3 = true; } catch { inits3 = false; } if(inits1 == true && inits2 == true && initS3 == true) { return true; } return false; }
private void RestorePatternParameters() { CogToolGroup lctg; CogPMAlignTool myPMAlignTool; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myPMAlignTool = (CogPMAlignTool)lctg.Tools["FindWrapperPatterns"]; // Restore the Zone Scale Low/High myPMAlignTool.RunParams.ZoneScale.Low = restoreParameters.VisPatRunParamsZoneScaleLow; myPMAlignTool.RunParams.ZoneScale.High = restoreParameters.VisPatRunParamsZoneScaleHigh; // Restore the Zone angle Low/High/Overlap myPMAlignTool.RunParams.ZoneAngle.Low = restoreParameters.VisPatRunParamsZoneAngleLow; myPMAlignTool.RunParams.ZoneAngle.High = restoreParameters.VisPatRunParamsZoneAngleHigh; myPMAlignTool.RunParams.ZoneAngle.Overlap = restoreParameters.VisPatRunParamsZoneAngleOverlap; // Restore Contrast threshold myPMAlignTool.RunParams.ContrastThreshold = restoreParameters.VisPatRunParamsContrastThreshold; // Restore Coarse Acceptance params myPMAlignTool.RunParams.CoarseAcceptThresholdEnabled = restoreParameters.VisPatRunParamsCoarseAcceptThresholdChecked; myPMAlignTool.RunParams.CoarseAcceptThreshold = restoreParameters.VisPatRunParamsCoarseAcceptThreshold; // Restore Elasticity myPMAlignTool.Pattern.Elasticity = restoreParameters.VisPatRunParamsElasticity; mainForm.SerializeRuntimeParameters(restoreParameters); }
private void any_numeric_ValueChanged(object sender, EventArgs e) { if (!formLoadComplete) { return; } string name = ((NumericUpDown)sender).Name; CogToolGroup lctg; CogAcqFifoTool myAcqTool; // Update object members switch (name) { case "numericUpDownGreyExposure": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyExposure; //Restore value return; } try { lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myAcqTool = (CogAcqFifoTool)lctg.Tools["BaslerAcqFiFo"]; myAcqTool.Operator.OwnedExposureParams.Exposure = (double)((NumericUpDown)sender).Value; runtimeParameters.VisGreyExposure = (double)((NumericUpDown)sender).Value; } catch (Cognex.VisionPro.Exceptions.CogAcqNoFrameGrabberException ex) { this.numericUpDownGreyExposure.ValueChanged -= new System.EventHandler(this.any_numeric_ValueChanged); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyExposure; //Restore value MessageBox.Show(ex.Message); this.numericUpDownGreyExposure.ValueChanged += new System.EventHandler(this.any_numeric_ValueChanged); return; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } break; case "numericUpDownGreyBrightness": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyBrightness; //Restore value return; } try { lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myAcqTool = (CogAcqFifoTool)lctg.Tools["BaslerAcqFifo"]; myAcqTool.Operator.OwnedBrightnessParams.Brightness = (double)((NumericUpDown)sender).Value; runtimeParameters.VisGreyBrightness = (double)((NumericUpDown)sender).Value; } catch (Cognex.VisionPro.Exceptions.CogAcqNoFrameGrabberException ex) { this.numericUpDownGreyBrightness.ValueChanged -= new System.EventHandler(this.any_numeric_ValueChanged); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyBrightness; //Restore value MessageBox.Show(ex.Message); this.numericUpDownGreyBrightness.ValueChanged += new System.EventHandler(this.any_numeric_ValueChanged); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } break; case "numericUpDownGreyContrast": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyContrast; //Restore value return; } try { lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myAcqTool = (CogAcqFifoTool)lctg.Tools["BaslerAcqFifo"]; myAcqTool.Operator.OwnedContrastParams.Contrast = (double)((NumericUpDown)sender).Value; runtimeParameters.VisGreyContrast = (double)((NumericUpDown)sender).Value; } catch (Cognex.VisionPro.Exceptions.CogAcqNoFrameGrabberException ex) { this.numericUpDownGreyContrast.ValueChanged -= new System.EventHandler(this.any_numeric_ValueChanged); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyContrast; //Restore value MessageBox.Show(ex.Message); this.numericUpDownGreyContrast.ValueChanged += new System.EventHandler(this.any_numeric_ValueChanged); return; } catch (Exception ex) { MessageBox.Show(ex.Message); } break; } }
private void any_numeric_ValueChanged(object sender, EventArgs e) { if (!formLoadComplete) { return; } string name = ((NumericUpDown)sender).Name; CogToolGroup lctg; CogBlobTool myTool; CogPMAlignTool myPMAlignTool; // Update object members switch (name) { case "numericUpDownGreyVisThreshold": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyThreshold; //Restore value return; } runtimeParameters.VisGreyThreshold = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["FindWrappersInBasler"]; myTool.RunParams.SegmentationParams.HardFixedThreshold = (int)runtimeParameters.VisGreyThreshold; break; case "numericUpDownVisGreyAreaMin": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyAreaMin; //Restore value return; } runtimeParameters.VisGreyAreaMin = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["FindWrappersInBasler"]; myTool.RunParams.RunTimeMeasures[0].FilterRangeLow = (double)runtimeParameters.VisGreyAreaMin; break; case "numericUpDownVisGreyAreaMax": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisGreyAreaMax; //Restore value return; } runtimeParameters.VisGreyAreaMax = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["FindWrappersInBasler"]; myTool.RunParams.RunTimeMeasures[0].FilterRangeHigh = (double)runtimeParameters.VisGreyAreaMax; break; case "numericUpDownVisThermAreaMin": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisThermAreaMin; //Restore value return; } runtimeParameters.VisThermAreaMin = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["PopsicleBlobFinder"]; myTool.RunParams.RunTimeMeasures[0].FilterRangeLow = (double)runtimeParameters.VisThermAreaMin; break; case "numericUpDownVisThermAreaMax": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisThermAreaMax; //Restore value return; } runtimeParameters.VisThermAreaMax = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["PopsicleBlobFinder"]; myTool.RunParams.RunTimeMeasures[0].FilterRangeHigh = (double)runtimeParameters.VisThermAreaMax; break; case "numericUpDownThermVisThreshold": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisThermThreshold; //Restore value return; } runtimeParameters.VisThermThreshold = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myTool = (CogBlobTool)lctg.Tools["PopsicleBlobFinder"]; myTool.RunParams.SegmentationParams.HardFixedThreshold = (int)runtimeParameters.VisThermThreshold; break; case "numericUpDownPatternAcceptThreshold": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisPatMatchAcceptThreshold * 100; //Restore value return; } runtimeParameters.VisPatMatchAcceptThreshold = (double)((NumericUpDown)sender).Value / 100; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; myPMAlignTool = (CogPMAlignTool)lctg.Tools["FindWrapperPatterns"]; myPMAlignTool.RunParams.AcceptThreshold = (double)runtimeParameters.VisPatMatchAcceptThreshold; break; case "numericUpDownMinHistCount": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisThermMinHistCount; //Restore value return; } runtimeParameters.VisThermMinHistCount = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; lctg.SetScriptTerminalData("MinPopsicleHistCount", (double)numericUpDownMinHistCount.Value); break; case "numericUpDownVisEvenSortAngle": runtimeParameters.VisEvenSortAngle = (double)((NumericUpDown)sender).Value; break; case "numericUpDownVisOddSortAngle": runtimeParameters.VisOddSortAngle = (double)((NumericUpDown)sender).Value; break; case "numericUpDownVisSideXLength": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisSideXLength; //Restore value return; } runtimeParameters.VisSideXLength = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; lctg.SetScriptTerminalData("VisSideXLength", (double)numericUpDownVisSideXLength.Value); break; case "numericUpDownVisSideYLength": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisSideYLength; //Restore value return; } runtimeParameters.VisSideYLength = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; lctg.SetScriptTerminalData("VisSideYLength", (double)numericUpDownVisSideYLength.Value); break; case "numericUpDownFlirRegionXadj": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisFlirRegionXadj; //Restore value return; } runtimeParameters.VisFlirRegionXadj = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; lctg.SetScriptTerminalData("VisFlirRegionXadj", (double)numericUpDownFlirRegionXadj.Value); break; case "numericUpDownFlirRegionYadj": if (mcjmAcq == null) { MessageBox.Show("Unable to read value from Vision System @any_numeric_ValueChanged", "Warning"); ((NumericUpDown)sender).Value = (decimal)runtimeParameters.VisFlirRegionYadj; //Restore value return; } runtimeParameters.VisFlirRegionYadj = (double)((NumericUpDown)sender).Value; lctg = (CogToolGroup)mcjmAcq.Job(mainForm.CogJobName).VisionTool; lctg.SetScriptTerminalData("VisFlirRegionYadj", (double)numericUpDownFlirRegionYadj.Value); break; } }