private void cbTaskName_SelectedIndexChanged(object sender, EventArgs e) { if (cbTaskName.SelectedIndex < 0) { return; } string currFovName = cbFovName.Text; string currTaskName = cbTaskName.Text; JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager; JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe; string taskVcName = recipe.VisionCfgName(currFovName, currTaskName); if (string.IsNullOrEmpty(taskVcName)) { cbTaskVc.SelectedIndex = -1; return; } cbTaskVc.Text = taskVcName; string[] allVcNames = JFHubCenter.Instance.VisionMgr.SingleVisionCfgNameByOwner(cbRecipeID.Text); if (allVcNames != null && allVcNames.Contains(taskVcName)) { cbTaskVc.BackColor = SystemColors.Control; } else { cbTaskVc.BackColor = Color.OrangeRed; } }
/// <summary> /// 取消 Task参数编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btTaskVcEditCancel_Click(object sender, EventArgs e) { _isTaskVcEditting = false; cbTaskName.Enabled = true; cbTaskVc.Enabled = false; btTaskVcEditSave.Text = "编辑"; btTaskVcEditCancel.Enabled = false; JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager; JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe; string taskVcName = recipe.VisionCfgName(cbFovName.Text, cbTaskName.Text); cbTaskVc.Text = taskVcName; }
/// <summary> /// 调整视觉配置为当前Task所选 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btFixTask_Click(object sender, EventArgs e) { string recipeID = cbRecipeID.Text; string fovName = cbFovName.Text; string taskName = cbTaskName.Text; if (string.IsNullOrEmpty(recipeID)) { MessageBox.Show("请选择RecipeID"); return; } if (string.IsNullOrEmpty(fovName)) { MessageBox.Show("请选择Fov Name"); return; } JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager; JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe; if (null == recipe) { MessageBox.Show("RecipeID:" + recipeID + " 产品配方不存在"); return; } string taskVc = recipe.VisionCfgName(fovName, taskName); if (string.IsNullOrEmpty(taskVc)) { MessageBox.Show("请先设置视觉配置"); return; } string errorInfo = ""; if (!_station.FixTaskVisionCfg(taskName, out errorInfo)) { MessageBox.Show("操作失败:" + errorInfo); return; } }
/// <summary> /// 检查参数列表(是否有未设置选项) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btChkCfg_Click(object sender, EventArgs e) { string recipeID = cbRecipeID.Text; if (string.IsNullOrEmpty(recipeID)) { MessageBox.Show("RecipeID未选择"); return; } JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager; JFDLAFProductRecipe recipe = rm.GetRecipe(CategoteProduct, cbRecipeID.Text) as JFDLAFProductRecipe; if (null == recipe) { MessageBox.Show("RecipeID = \"" + recipeID + "\"产品配方不存在"); return; } JFVisionManager vm = JFHubCenter.Instance.VisionMgr; bool isCfgOK = true; StringBuilder errorInfo = new StringBuilder(); string mark1Cfg = recipe.GetMark1LightCfg(); if (string.IsNullOrEmpty(mark1Cfg)) { isCfgOK = false; errorInfo.AppendLine("Mark1视觉配置未设置"); } else { if (!vm.ContainSingleVisionCfgByName(mark1Cfg)) { isCfgOK = false; errorInfo.AppendLine("Mark1视觉参数:\"" + mark1Cfg + "\" 在视觉配置表中不存在"); } } string mark2Cfg = recipe.GetMark2LightCfg(); if (string.IsNullOrEmpty(mark2Cfg)) { isCfgOK = false; errorInfo.AppendLine("Mark2视觉配置未设置"); } else { if (!vm.ContainSingleVisionCfgByName(mark2Cfg)) { isCfgOK = false; errorInfo.AppendLine("Mark2视觉参数:\"" + mark2Cfg + "\" 在视觉配置表中不存在"); } } string[] allFovNames = recipe.FovNames(); if (null != allFovNames) { foreach (string fovName in allFovNames) { string[] taskNames = recipe.TaskNames(fovName); if (null != taskNames) { foreach (string taskName in taskNames) { string vcName = recipe.VisionCfgName(fovName, taskName); if (string.IsNullOrEmpty(vcName)) { isCfgOK = false; errorInfo.AppendLine("Fov:\"" + fovName + "\" Task:\"" + taskName + "\" 视觉参数未设置"); } else { if (!vm.ContainSingleVisionCfgByName(vcName)) { isCfgOK = false; errorInfo.AppendLine("Fov:\"" + fovName + "\" Task:\"" + taskName + "\" 视觉参数:\"" + vcName + "\"在视觉配置中不存在"); } } } } } } if (isCfgOK) { MessageBox.Show("所有视觉参数已配置完成!"); return; } else { MessageBox.Show(errorInfo.ToString()); return; } }