public override void FlushToDlg(VisionSetpBase visionSetp, VisionControl visionControl, Control Farther = null)
 {
     if (visionSetp == null)
     {
         return;
     }
     //if (Farther != null)
     //    this.Location = new Point(Farther.Location.X, Farther.Location.Y);
     m_visionControl = visionControl;
     m_vision2dCode  = visionSetp as Vision2dCode;
     if (m_vision2dCode == null)
     {
         return;
     }
     m_vision2dCode = (Vision2dCode)visionSetp;
     if (m_vision2dCode == null)
     {
         MessageBox.Show("视觉类型为空 刷新失败,请选择", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (m_vision2dCode != null)
     {
         comboBox_CodeSystem.Text        = m_vision2dCode.vision2dCodeParam.Code2dSystem;
         comboBox_ContrastTolerance.Text = m_vision2dCode.vision2dCodeParam.ContrastTolerance;
     }
 }
Пример #2
0
        public override Object Read()
        {
            VisionCode2dParam tempvision2dCodeParam = null;
            string            strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".xml";

            //tempvision2dCodeParam = (VisionCode2dParam)AccessXmlSerializer.XmlToObject(strPath, vision2dCodeParam.GetType());
            strPath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + ".json";
            Vision2dCode vision2DCode = (Vision2dCode)AccessJosnSerializer.JsonToObject(strPath, this.GetType());

            if (vision2DCode == null || vision2DCode.vision2dCodeParam == null)
            {
                _logger.Warn(m_strStepName + ": 视觉处理项目加载失败,请检查");
                MessageBox.Show(m_strStepName + ": 视觉处理项目加载失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            vision2dCodeParam = tempvision2dCodeParam = vision2DCode.vision2dCodeParam;

            string Mode2dcodePath = VisionMgr.GetInstance().CurrentVisionProcessDir + "\\" + m_strStepName + "\\" + m_strStepName + "_data_code_model.dcm";;

            if (vision2dCodeParam != null && Mode2dcodePath != null && File.Exists(Mode2dcodePath))
            {
                if (Mode2dCode != null)
                {
                    HOperatorSet.ClearDataCode2dModel(Mode2dCode);
                }
                Mode2dCode = null;
                HOperatorSet.ReadDataCode2dModel(Mode2dcodePath, out Mode2dCode);
                if (Mode2dCode == null || Mode2dCode.Length <= 0)
                {
                    _logger.Warn(m_strStepName + ": 2维码模板读取失败,请检查");
                    MessageBox.Show(m_strStepName + ": 2维码模板读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                // MessageBox.Show(m_strStepName + ": 2维码模板读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (vision2dCodeParam != null && File.Exists(vision2dCodeParam.Mode2dcodeSearchPath))
            {
                if (Mode2dCodeSearch != null && Mode2dCodeSearch.IsInitialized())
                {
                    Mode2dCodeSearch.Dispose();
                }
                HOperatorSet.ReadRegion(out Mode2dCodeSearch, vision2dCodeParam.Mode2dcodeSearchPath);
                if (Mode2dCodeSearch == null || Mode2dCodeSearch.IsInitialized())
                {
                    _logger.Warn(m_strStepName + ": 2维码搜索区域读取失败,请检查");
                }
                //  MessageBox.Show(m_strStepName + ": 2维码搜索区域读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                _logger.Warn(m_strStepName + ": 2维码搜索区域读取失败,请检查");
                //  MessageBox.Show(m_strStepName + ": 2维码搜索区域读取失败,请检查", "Err", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            GC.Collect();

            return(vision2dCodeParam);
        }