//从XML配置文档中读取串口配置 private void initSerialPortsConfig() { try { m_strListSerialPorts = System.IO.Ports.SerialPort.GetPortNames(); combox_serialPorts.Items.Clear(); for (int i = 0; i < m_strListSerialPorts.Length; i++) { combox_serialPorts.Items.Add(m_strListSerialPorts[i]); } string strVal = CommonFunc.Read(_NODE_SERIALPORT, _NODE_PORTNAME, "COM1", m_fileINI); if (combox_serialPorts.Items.Count > 0) { combox_serialPorts.SelectedIndex = (combox_serialPorts.Items.IndexOf(strVal) >= 0) ? combox_serialPorts.Items.IndexOf(strVal) : 0; } strVal = CommonFunc.Read(_NODE_SERIALPORT, _NODE_BOUDRATE, "115200", m_fileINI); combox_boudrate.SelectedIndex = (combox_boudrate.Items.IndexOf(strVal) >= 0) ? combox_boudrate.Items.IndexOf(strVal) : 4; strVal = CommonFunc.Read(_NODE_SERIALPORT, _NODE_DATABIT, "8", m_fileINI); combox_databit.SelectedIndex = (combox_databit.Items.IndexOf(strVal) >= 0) ? combox_databit.Items.IndexOf(strVal) : 3; strVal = CommonFunc.Read(_NODE_SERIALPORT, _NODE_PARITY, "NONE", m_fileINI); combox_parity.SelectedIndex = (combox_parity.Items.IndexOf(strVal) >= 0) ? combox_parity.Items.IndexOf(strVal) : 0; strVal = CommonFunc.Read(_NODE_SERIALPORT, _NODE_STOPBIT, "1", m_fileINI); combox_stopbit.SelectedIndex = (combox_stopbit.Items.IndexOf(strVal) >= 0) ? combox_stopbit.Items.IndexOf(strVal) : 0; } catch (System.Exception ex) { CommLogDisplay(ex.ToString(), emMsgType.EXCEPTION_TEXT); } }
public void ReadINI() { this.Invoke(new Action(() => { m_iniCCDMatchSection = this.CameraLocation.ToString() + "MATCH"; string str = CommonFunc.Read(m_iniCCDMatchSection, "minScore", "0", m_configFile); //MinScoreUpDown.Value = Convert.ToInt32(str == "" ? "0" : str); str = CommonFunc.Read(m_iniCCDMatchSection, "numMatches", "1", m_configFile); //NumMatchesUpDown.Value = Convert.ToInt32(str == "" ? "1" : str); str = CommonFunc.Read(m_iniCCDMatchSection, "greediness", "0", m_configFile); //GreedinessUpDown.Value = Convert.ToInt32(str == "" ? "0" : str); str = CommonFunc.Read(m_iniCCDMatchSection, "maxOverlap", "0", m_configFile); //MaxOverlapUpDown.Value = Convert.ToInt32(str == "" ? "0" : str); str = CommonFunc.Read(m_iniCCDMatchSection, "subpixelBox", "least_squares", m_configFile); //SubPixelBox.SelectedIndex = SubPixelBox.Items.IndexOf(str == "" ? "least_squares" : str); str = CommonFunc.Read(m_iniCCDMatchSection, "lastPyramidLevel", "1", m_configFile); //LastPyrLevUpDown.Value = Convert.ToInt32(str == "" ? "1" : str); })); }
public void ReadINI() { m_fileINI = m_pathConfig + "\\" + "Config.ini"; string str = ""; //相机曝光值-制品 str = CommonFunc.Read(m_CCDName, ini_key_ExposureP, "10000", m_fileINI); m_ExposureProduct = Convert.ToInt32(str); //相机曝光值-校准片 str = CommonFunc.Read(m_CCDName, ini_key_ExposureM, "10000", m_fileINI); m_ExposureModel = Convert.ToInt32(str); //制品Mark点面积区间 str = CommonFunc.Read(m_CCDName, ini_key_ProductArea, "100,100", m_fileINI); string[] _strPro = str.Split(','); if (_strPro.Length == 2) { AreaProduct[0] = Convert.ToInt32(_strPro[0]); AreaProduct[1] = Convert.ToInt32(_strPro[1]); } else { AreaProduct = new int[2] { 100, 100 }; } halconHelp.SetMarkArea(AreaProduct); //默认制品Mark点 //菲林片大Mark点面积区间 str = CommonFunc.Read(m_CCDName, ini_key_MarkArea, "100,100", m_fileINI); string[] _strM = str.Split(','); if (_strM.Length == 2) { AreaMark[0] = Convert.ToInt32(_strM[0]); AreaMark[1] = Convert.ToInt32(_strM[1]); } else { AreaMark = new int[2] { 100, 100 }; } //菲林片小Mark点面积区间 str = CommonFunc.Read(m_CCDName, ini_key_PointArea, "100,100", m_fileINI); string[] _strP = str.Split(','); if (_strP.Length == 2) { AreaPoint[0] = Convert.ToInt32(_strP[0]); AreaPoint[1] = Convert.ToInt32(_strP[1]); } else { AreaPoint = new int[2] { 100, 100 }; } halconHelp.SetPointArea(AreaPoint); //像素点尺寸 str = CommonFunc.Read(m_CCDName, ini_key_UmPixel, "2.224", m_fileINI); m_UmPixel = Convert.ToDouble(str); //位置 str = CommonFunc.Read(m_CCDName, ini_key_Location, "0,0", m_fileINI); Location1 = new Point(Convert.ToInt32(str.Split(',')[0]), Convert.ToInt32(str.Split(',')[1])); //AVT相机编号 AVTName = CommonFunc.Read(m_CCDName, ini_key_AVTDevice, "", m_fileINI); }