129 lines
4.8 KiB
C#
129 lines
4.8 KiB
C#
using Aurora.Api;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using VisionCommon;
|
|
using System;
|
|
using VisionUI.Pattern;
|
|
using VisionCommonUI;
|
|
using VisionCommonUI.Resources;
|
|
using VisionSequence.Inspector;
|
|
using VisionInspector;
|
|
|
|
namespace VisionUI.Inspector {
|
|
/// <summary>
|
|
/// 어태치 검사 레시피 세팅 뷰
|
|
/// AttachInspRecipeSettingView.xaml BehindCode
|
|
/// </summary>
|
|
public partial class AttachInspRecipeSettingView : UserControl, IUpdateRecipe, IDisposable {
|
|
private Logger _Logger;
|
|
private SubSysInfo _SubSysInfo;
|
|
private SubSysRecipe _SubSysRecipe;
|
|
private IDisposable _EventDisposable;
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="subSysInfo">서브시스템 정보</param>
|
|
public AttachInspRecipeSettingView(SubSysInfo subSysInfo) {
|
|
_SubSysInfo = subSysInfo;
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(subSysInfo);
|
|
_Logger = new Logger($"AttachInspRecipeSettingView[{_SubSysRecipe.SubSysName}]");
|
|
|
|
InitializeComponent();
|
|
CreateProcPatternSettingView();
|
|
}
|
|
/// <summary>
|
|
/// Proc패턴 세팅 뷰 생성
|
|
/// </summary>
|
|
public void CreateProcPatternSettingView() {
|
|
gridProcPatternSettingView.Children.Add(new ProcPatternSettingView(_SubSysInfo, $"Inspect"));
|
|
}
|
|
|
|
private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
|
|
bool isVisible = (bool)e.NewValue;
|
|
if (isVisible == true) {
|
|
RefreshVisionRecipes();
|
|
UpdateRecipeFromFile();
|
|
}
|
|
}
|
|
|
|
public void RefreshVisionRecipes() {
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(_SubSysInfo);
|
|
(DataContext as AttachInspRecipeSettingViewModel).RefreshVisionRecipes();
|
|
}
|
|
|
|
public void UpdateRecipeFromFile() {
|
|
(DataContext as AttachInspRecipeSettingViewModel).UpdateRecipeFromFile();
|
|
}
|
|
|
|
public void UpdateRecipeFromUI() {
|
|
(DataContext as AttachInspRecipeSettingViewModel).UpdateRecipeFromUI();
|
|
}
|
|
/// <summary>
|
|
/// 명시적 이벤트 해제
|
|
/// </summary>
|
|
public void Dispose() {
|
|
_EventDisposable?.Dispose();
|
|
_EventDisposable = null;
|
|
}
|
|
|
|
private void Button_Save_Click(object sender, RoutedEventArgs e) {
|
|
UpdateRecipeFromUI();
|
|
UpdateRecipeFromUI_ProcPatternSetting();
|
|
RecipeFileManager.SaveVisionRecipe();
|
|
MessageBoxUtil.ShowMessageBoxOk(StrTokens.MSG_O_SaveCompleted);
|
|
}
|
|
|
|
private void UpdateRecipeFromUI_ProcPatternSetting() {
|
|
var procPatternSettingView = gridProcPatternSettingView.Children[0] as ProcPatternSettingView;
|
|
procPatternSettingView.UpdateRecipeFromUI();
|
|
}
|
|
|
|
private void Button_Start_Click(object sender, RoutedEventArgs e) {
|
|
try {
|
|
var myDisplayType = eDisplayType.Main_1; // 부착 검사 결과를 바인딩할 메인 화면 타입을 지정해서 사용
|
|
|
|
var attachInspRecipe = _SubSysRecipe.InspRecipe.AttachInspRecipe;
|
|
if (attachInspRecipe == null) {
|
|
_Logger.FuncE($"AttachInspRecipe of {_SubSysRecipe.SubSysName} is null.");
|
|
return;
|
|
}
|
|
|
|
object initParam = null;
|
|
switch (attachInspRecipe.AttachInspFovType) {
|
|
case eAttachInspFovType.C2_F4_MV:
|
|
initParam = new AttachInspSeqParams_C2_F4_MV(_SubSysInfo, null, myDisplayType);
|
|
break;
|
|
}
|
|
if (initParam == null) {
|
|
_Logger.FuncE($"AttachInspSeq InitParam of {_SubSysRecipe.SubSysName} is null.");
|
|
return;
|
|
}
|
|
|
|
string seqName = string.Format(VisionKeys.AttachInspSeqKey, attachInspRecipe.AttachInspFovType);
|
|
ISequence seq = VisionEnv.AuroraEnv.SequenceEntry[seqName];
|
|
|
|
if (seq.RunState == SequenceRunState.Running) {
|
|
seq.EmergencyStop();
|
|
}
|
|
seq.Start(initParam, OnAttachInspSeqCompleted);
|
|
}
|
|
catch (Exception ex) {
|
|
_Logger.FuncE(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void OnAttachInspSeqCompleted(SequenceActionResult seqResult) {
|
|
try {
|
|
if (seqResult == null) {
|
|
_Logger.FuncE("SeqResult is null.");
|
|
return;
|
|
}
|
|
var attachInspResultAll = seqResult.Param as AttachInspResultAll;
|
|
}
|
|
catch (Exception e) {
|
|
_Logger.FuncE(e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|